bool outputLineNumbers = true;
public void SetOutputLineNumbers(bool value) { outputLineNumbers = value; }
+public void FixModuleName(char *moduleName)
+{
+ ChangeCh(moduleName, '.', '_');
+ ChangeCh(moduleName, ' ', '_');
+ ChangeCh(moduleName, '-', '_');
+ ChangeCh(moduleName, '&', '_');
+}
+
+// todo support %var% variables for windows and $var for linux?
+public char * PassArg(char * output, const char * input)
+{
+#ifdef __WIN32__
+//define windowsFileNameCharsNeedEscaping = " !%&'()+,;=[]^`{}~"; // "#$-.@_" are ok
+ const char * escChars = " !\"%&'()+,;=[]^`{}~"; // windowsFileNameCharsNeedEscaping;
+ const char * escCharsQuoted = "\"";
+#else
+//define linuxFileNameCharsNeedEscaping = " !\"$&'()*:;<=>?[\\`{|"; // "#%+,-.@]^_}~" are ok
+ const char * escChars = " !\"$&'()*:;<=>?[\\`{|"; // linuxFileNameCharsNeedEscaping;
+ const char * escCharsQuoted = "\"()$";
+#endif
+ bool quoting = false;
+ char *o = output, *i = input, *l = input;
+#ifdef __WIN32__
+ while(*l && !strchr(escChars, *l)) l++;
+ if(*l) quoting = true;
+#else
+ if(*i == '-')
+ {
+ l++;
+ while(*l && !strchr(escChars, *l)) l++;
+ if(*l) quoting = true;
+ *o++ = *i++;
+ }
+#endif
+ if(quoting)
+ *o++ = '\"';
+ while(*i)
+ {
+ if(strchr(quoting ? escCharsQuoted : escChars, *i))
+ *o++ = '\\';
+ *o++ = *i++;
+ }
+ if(quoting)
+ *o++ = '\"';
+ *o = '\0';
+ return o;
+}
/*public Module GetPrivateModule()
{
return privateModule;
{
public:
int line, charPos, pos;
- bool included;
+ int included;
void AdjustDelete(BufferLocation start, BufferLocation end)
{
noDebuggerErrorExp, debugStateErrorExp,
extensionCompoundExp, classExp, classDataExp, new0Exp, renew0Exp,
dbopenExp, dbfieldExp, dbtableExp, dbindexExp, extensionExpressionExp, extensionInitializerExp,
- vaArgExp, arrayExp
+ vaArgExp, arrayExp, typeAlignExp
};
public enum MemberType
int specifier;
struct
{
+ ExtDecl extDecl;
char * name;
Symbol symbol;
OldList * templateArgs;
OldList * definitions;
bool addNameSpace;
Context ctx;
+ ExtDecl extDeclStruct;
};
Expression expression;
Specifier _class;
};
};
+public class Attribute : struct
+{
+public:
+ Attribute prev, next;
+ Location loc;
+ String attr;
+ Expression exp;
+}
+
+public class Attrib : struct
+{
+public:
+ Location loc;
+ int type;
+ OldList * attribs;
+}
+
+public class ExtDecl : struct
+{
+public:
+ Location loc;
+ ExtDeclType type;
+ union
+ {
+ String s;
+ Attrib attr;
+ };
+}
+
+public enum ExtDeclType
+{
+ extDeclString, extDeclAttrib
+};
+
public class Expression : struct
{
public:
DataValue val;
- uint address;
+ uint64 address;
bool hasAddress;
// *** COMPILING DATA ***
{
Expression exp;
Expression posExp;
- char * attrib;
+ Attrib attrib;
} structDecl;
struct
{
} pointer;
struct
{
- char * extended;
+ ExtDecl extended;
} extended;
};
};
voidType, charType, shortType, intType, int64Type, longType, floatType,
doubleType, classType, structType, unionType, functionType, arrayType, pointerType,
ellipsisType, enumType, methodType, vaListType, /*typedObjectType, anyObjectType, classPointerType, */ dummyType,
- subClassType, templateType, thisClassType
+ subClassType, templateType, thisClassType, intPtrType, intSizeType
};
public class Type : struct
struct
{
Method method;
- Class methodClass;
+ Class methodClass; // Clarify what this is!
Class usedClass;
};
Type type;
TemplateParameter templateParameter;
};
- bool isSigned;
TypeKind kind;
- bool constant;
uint size;
char * name;
char * typeName;
- bool count;
- bool truth;
ClassObjectType classObjectType;
- bool byReference;
-
- bool extraParam;
int alignment;
- bool directClassAccess;
- bool computing;
- bool dllExport;
uint offset;
- bool keepCast;
- bool passAsTemplate;
int bitFieldCount;
+ int count;
+
+ bool isSigned:1;
+ bool constant:1;
+ bool truth:1;
+ bool byReference:1;
+ bool extraParam:1; // Clarify this... One thing it is used for is adaptive method with their own type explicitly specified
+ bool directClassAccess:1; // Need to clarify this if this had the same intended purpose as declaredWithStruct
+ bool computing:1;
+ bool keepCast:1;
+ bool passAsTemplate:1;
+ bool dllExport:1;
+ bool attrStdcall:1;
+ bool declaredWithStruct:1;
+ bool typedByReference:1; // Originally typed by reference, regardless of class type
char * OnGetString(char * tempString, void * fieldData, bool * needClass)
{
unsigned int ui;
float f;
double d;
- unsigned char * p;
+ // unsigned char * p; // Now always storing addresses in ui64
int64 i64;
uint64 ui64;
+ // intptr iptr;
+ // uintptr uiptr;
};
OpTable ops;
};
bool (* Cond)(Expression, Operand, Operand, Operand);
};
-define MAX_INCLUDE_DEPTH = 10;
+define MAX_INCLUDE_DEPTH = 30;
#include <stdarg.h>
printf($":%d:%d: error: ", yylloc.start.line, yylloc.start.charPos);
//printf(":%d: error: ", yylloc.start.line);
va_start(args, format);
- vsprintf(string,format,args);
+ vsnprintf(string, sizeof(string), format, args);
+ string[sizeof(string)-1] = 0;
va_end(args);
fputs(string, stdout);
__thisModule.application.exitCode = 1;
printf($":%d:%d: warning: ", yylloc.start.line, yylloc.start.charPos);
//printf(":%d: warning: ", yylloc.start.line);
va_start(args, format);
- vsprintf(string,format,args);
+ vsnprintf(string, sizeof(string), format, args);
+ string[sizeof(string)-1] = 0;
va_end(args);
fputs(string, stdout);
numWarnings++;
Platform targetPlatform;
+public int GetHostBits()
+{
+ // Default to runtime platform in case we fail to determine host
+ int hostBits = (sizeof(uintptr) == 8) ? 64 : 32;
+ String hostType = getenv("HOSTTYPE");
+ char host[256];
+ if(!hostType)
+ {
+ DualPipe f = DualPipeOpen({ output = true }, "uname -m");
+ if(f)
+ {
+ if(f.GetLine(host, sizeof(host)))
+ hostType = host;
+ delete f;
+ }
+ }
+ if(hostType)
+ {
+ if(!strcmp(hostType, "x86_64"))
+ hostBits = 64;
+ else if(!strcmp(hostType, "i386") || !strcmp(hostType, "i686"))
+ hostBits = 32;
+ }
+ return hostBits;
+}
+
public void SetTargetPlatform(Platform platform) { targetPlatform = platform; };
+
+int targetBits;
+
+public void SetTargetBits(int bits) { targetBits = bits; };
+public int GetTargetBits() { return targetBits; };