2 public import static "ecere"
24 #define yylloc _yylloc
30 identifier = IDENTIFIER,
32 stringLiteral = STRING_LITERAL,
45 mulAssign = MUL_ASSIGN,
46 divAssign = DIV_ASSIGN,
47 modAssign = MOD_ASSIGN,
48 addAssign = ADD_ASSIGN,
49 subAssign = SUB_ASSIGN,
50 leftAssign = LEFT_ASSIGN,
51 rightAssign = RIGHT_ASSIGN,
52 andAssign = AND_ASSIGN,
53 xorAssign = XOR_ASSIGN,
93 thisClass = THISCLASS,
94 className = CLASS_NAME,
102 _extStorage = EXT_STORAGE,
109 typedObject = TYPED_OBJECT,
110 anyObject = ANY_OBJECT,
112 extension = EXTENSION,
116 stopWatching = STOPWATCHING,
117 fireWatchers = FIREWATCHERS,
118 _watchable = WATCHABLE,
119 classDesigner = CLASS_DESIGNER,
120 classNoExpansion = CLASS_NO_EXPANSION,
121 classFixed = CLASS_FIXED,
122 isPropSet = ISPROPSET,
123 classDefaultProperty = CLASS_DEFAULT_PROPERTY,
124 propertyCategory = PROPERTY_CATEGORY,
125 classData = CLASS_DATA,
126 classProperty = CLASS_PROPERTY,
128 nameSpace = NAMESPACE,
135 databaseOpen = DATABASE_OPEN,
137 attribDep = ATTRIB_DEP,
142 imaginary = _IMAGINARY,
143 _restrict = RESTRICT,
147 enum Order { ascending, descending };
149 public class DBTableDef : struct
154 OldList * definitions;
158 enum DBTableEntryType { fieldEntry, indexEntry };
160 class DBTableEntry : struct
162 DBTableEntry prev, next;
163 DBTableEntryType type;
176 class DBIndexItem : struct
178 DBIndexItem prev, next;
183 bool inCompiler = false;
184 public void SetInCompiler(bool b) { inCompiler = b; }
186 bool inDebugger = false;
187 public void SetInDebugger(bool b) { inDebugger = b; }
190 Context globalContext;
191 OldList * excludedSymbols;
196 Module privateModule;
197 public void SetPrivateModule(Module module) { privateModule = module; }public Module GetPrivateModule() { return privateModule; }
198 ModuleImport mainModule;
199 public void SetMainModule(ModuleImport moduleImport) { mainModule = moduleImport; } public ModuleImport GetMainModule() { return mainModule; }
201 public void SetFileInput(File file) { fileInput = file; }
202 char * symbolsDir = null;
203 public void SetSymbolsDir(const char * s) {
205 symbolsDir = CopyString(s);
206 } public const char * GetSymbolsDir() { return symbolsDir ? symbolsDir : ""; }
207 const char * outputFile;
208 public void SetOutputFile(const char * s) { outputFile = s; } public const char * GetOutputFile() { return outputFile; }
209 const char * sourceFile;
210 public void SetSourceFile(const char * s) { sourceFile = s; } public const char * GetSourceFile() { return sourceFile; }
211 const char * i18nModuleName;
212 public void SetI18nModuleName(const char * s) { i18nModuleName = s; } public const char * GetI18nModuleName() { return i18nModuleName; }
214 public void SetGlobalContext(Context context) { globalContext = context; } public Context GetGlobalContext() { return globalContext; }
215 public void SetTopContext(Context context) { topContext = context; } public Context GetTopContext() { return topContext; }
216 public void SetCurrentContext(Context context) { curContext = context; } public Context GetCurrentContext() { return curContext; }
217 public void SetExcludedSymbols(OldList * list) { excludedSymbols = list; }
218 public void SetImports(OldList * list) { imports = list; }
219 public void SetDefines(OldList * list) { defines = list; }
221 bool outputLineNumbers = true;
222 public void SetOutputLineNumbers(bool value) { outputLineNumbers = value; }
224 public void FixModuleName(char *moduleName)
226 ChangeCh(moduleName, '.', '_');
227 ChangeCh(moduleName, ' ', '_');
228 ChangeCh(moduleName, '-', '_');
229 ChangeCh(moduleName, '&', '_');
232 // todo support %var% variables for windows and $var for linux?
233 public char * PassArg(char * output, const char * input)
236 //define windowsFileNameCharsNeedEscaping = " !%&'()+,;=[]^`{}~"; // "#$-.@_" are ok
237 const char * escChars = " !\"%&'()+,;=[]^`{}~"; // windowsFileNameCharsNeedEscaping;
238 const char * escCharsQuoted = "\"";
240 //define linuxFileNameCharsNeedEscaping = " !\"$&'()*:;<=>?[\\`{|"; // "#%+,-.@]^_}~" are ok
241 const char * escChars = " !\"$&'()*:;<=>?[\\`{|"; // linuxFileNameCharsNeedEscaping;
242 const char * escCharsQuoted = "\"()$";
244 bool quoting = false;
246 const char *i = input, *l = input;
248 while(*l && !strchr(escChars, *l)) l++;
249 if(*l) quoting = true;
254 while(*l && !strchr(escChars, *l)) l++;
255 if(*l) quoting = true;
263 if(strchr(quoting ? escCharsQuoted : escChars, *i))
272 /*public Module GetPrivateModule()
274 return privateModule;
277 public class GlobalData : BTNode
281 char * dataTypeString;
287 public class TemplatedType : BTNode
290 TemplateParameter param;
293 class DataRedefinition : struct
295 DataRedefinition prev, next;
297 char type1[1024], type2[1024];
300 public struct CodePosition
303 int line, charPos, pos;
306 void AdjustDelete(BufferLocation start, BufferLocation end)
308 // Location is before, nothing to do
309 if(line - 1 < start.y || (line - 1 == start.y && charPos - 1 < start.x))
311 // Location is inside deleted bytes, point to the start
312 if((line - 1 >= start.y && (line - 1 > start.y || charPos - 1 >= start.x)) &&
313 (line - 1 >= end.y && (line - 1 > end.y || charPos - 1 >= end.x)))
316 if(line - 1 >= end.y)
318 // Location is on another line
320 line -= end.y - start.y;
321 // Location is the last touched line
324 if(charPos - 1 >= end.x)
327 //if(start.line == end.line)
328 charPos -= end.x - start.x;
336 charPos = start.x + 1;
340 // Assuming no carriage return before first character ???? fixed?
341 void AdjustAdd(BufferLocation start, BufferLocation end)
343 int numLines = end.y - start.y;
344 if(line - 1 >= start.y)
346 if(line - 1 > start.y)
350 if(charPos - 1 > start.x || (charPos - 1 == start.x /*&& (numLines ? true : false)*/))
353 //charPos - 1 += numLines ? end.x : (end.x - start.x);
354 charPos += end.x - start.x;
361 public struct Location
364 CodePosition start, end;
366 bool Inside(int line, int charPos)
368 return (start.line < line || (start.line == line && start.charPos <= charPos)) &&
369 (end.line > line || (end.line == line && end.charPos >= charPos));
373 public enum DefinitionType { moduleDefinition, classDefinition, defineDefinition, functionDefinition, dataDefinition };
375 public class Definition : struct
378 Definition prev, next;
383 public class ImportedModule : struct
386 ImportedModule prev, next;
389 ImportType importType;
392 AccessMode importAccess;
395 public class Identifier : struct
398 Identifier prev, next;
400 // TODO: NameSpace * nameSpace;
407 public enum ExpressionType
409 identifierExp, instanceExp, constantExp, stringExp, opExp,
410 bracketsExp, indexExp, callExp, memberExp, pointerExp, typeSizeExp,
411 castExp, conditionExp, newExp, renewExp, classSizeExp,
412 dummyExp, dereferenceErrorExp, symbolErrorExp,
413 memberSymbolErrorExp, memoryErrorExp, unknownErrorExp,
415 extensionCompoundExp, classExp, classDataExp, new0Exp, renew0Exp,
416 dbopenExp, dbfieldExp, dbtableExp, dbindexExp, extensionExpressionExp, extensionInitializerExp,
417 vaArgExp, arrayExp, typeAlignExp,
418 memberPropertyErrorExp, functionCallErrorExp, divideBy0ErrorExp
421 public enum MemberType
423 unresolvedMember, propertyMember, methodMember, dataMember, reverseConversionMember, classPropertyMember
426 public class ExpUsage
429 bool usageGet:1, usageSet:1, usageArg:1, usageCall:1, usageMember:1, usageDeepGet:1, usageRef:1, usageDelete:1;
432 public class TemplateParameter : struct
435 TemplateParameter prev, next;
438 TemplateParameterType type;
439 Identifier identifier;
442 TemplateDatatype dataType; // For both base datatype (type) and data type (expression)
443 TemplateMemberType memberType; // For identifier
445 TemplateArgument defaultArgument;
447 // For type parameters
448 const char * dataTypeString;
452 public class TemplateDatatype : struct
455 OldList * specifiers;
459 public class TemplateArgument : struct
462 TemplateArgument prev, next;
466 TemplateParameterType type;
469 Expression expression;
470 Identifier identifier;
471 TemplateDatatype templateDatatype;
475 public enum SpecifierType
477 baseSpecifier, nameSpecifier, enumSpecifier, structSpecifier, unionSpecifier, /*classSpecifier,*/
478 extendedSpecifier, typeOfSpecifier, subClassSpecifier, templateTypeSpecifier
481 public class Specifier : struct
484 Specifier prev, next;
495 OldList/*<TemplateArgument>*/ * templateArgs;
501 OldList/*<Enumerator>*/ * list;
502 OldList/*<Specifier>*/ * baseSpecs;
503 OldList/*<ClassDef>*/ * definitions;
506 ExtDecl extDeclStruct;
508 Expression expression;
510 TemplateParameter templateParameter;
514 public class Attribute : struct
517 Attribute prev, next;
523 public class Attrib : struct
531 public class ExtDecl : struct
543 public enum ExtDeclType
545 extDeclString, extDeclAttrib
548 public class Expression : struct
551 Expression prev, next;
559 Identifier identifier;
562 Instantiation instance;
572 OldList * specifiers;
595 MemberType memberType;
601 Expression exp1, exp2;
640 Initializer initializer;
656 // *** COMPILING DATA ***
668 uint needTemplateCast;
688 needTemplateCast = 0;
692 public class Enumerator : struct
695 Enumerator prev, next;
701 class Pointer : struct
705 OldList * qualifiers;
709 public enum DeclaratorType
711 structDeclarator, identifierDeclarator, bracketsDeclarator, arrayDeclarator,
712 functionDeclarator, pointerDeclarator, extendedDeclarator, extendedDeclaratorEnd
715 public class Declarator : struct
718 Declarator prev, next;
721 Symbol symbol;//, propSymbol;
722 Declarator declarator;
725 Identifier identifier;
739 OldList * parameters;
752 public enum InitializerType { expInitializer, listInitializer };
754 public class Initializer : struct
757 Initializer prev, next;
759 InitializerType type;
769 public class InitDeclarator : struct
772 InitDeclarator prev, next;
774 Declarator declarator;
775 Initializer initializer;
778 public enum ClassObjectType
786 public class TypeName : struct
791 OldList * qualifiers;
792 Declarator declarator;
793 //bool /*typedObject, */byReference;
795 ClassObjectType classObjectType;
799 class AsmField : struct
804 Expression expression;
808 public enum StmtType { labeledStmt, caseStmt, compoundStmt,
809 expressionStmt, ifStmt, switchStmt, whileStmt, doWhileStmt,
810 forStmt, gotoStmt, continueStmt, breakStmt, returnStmt, asmStmt, badDeclarationStmt,
811 fireWatchersStmt, stopWatchingStmt, watchStmt, forEachStmt
814 public class Statement : struct
817 Statement prev, next;
822 OldList * expressions;
835 OldList * declarations;
836 OldList * statements;
876 OldList * inputFields;
877 OldList * outputFields;
878 OldList * clobberedFields;
882 Expression watcher, object;
883 OldList * watches; // OldList of PropertyWatch for a StmtWatch, list of property identifiers for firewatches, stopwatching
896 public enum DeclarationType { structDeclaration, initDeclaration, instDeclaration, defineDeclaration };
898 public class Declaration : struct
901 Declaration prev, next;
903 DeclarationType type;
908 OldList * specifiers;
909 OldList * declarators;
918 Specifier extStorage;
923 public class Instantiation : struct
926 Instantiation prev, next;
935 Location nameLoc, insideLoc;
939 public enum MembersInitType { dataMembersInit, methodMembersInit };
941 public class FunctionDefinition : struct
944 FunctionDefinition prev, next;
946 OldList * specifiers;
947 Declarator declarator;
948 OldList * declarations;
951 OldList attached; // For IDE
958 bool propertyNoThis; // Not used yet; might use to support both this = and return syntax for conversion properties
961 public class ClassFunction : struct
964 ClassFunction prev, next;
966 OldList * specifiers;
967 Declarator declarator;
968 OldList * declarations;
971 OldList attached; // For IDE
979 bool isConstructor, isDestructor;
984 public class MembersInit : struct
987 MembersInit prev, next;
989 MembersInitType type;
992 OldList * dataMembers;
993 ClassFunction function;
998 public class MemberInit : struct
1001 MemberInit prev, next;
1004 OldList * identifiers;
1006 Initializer initializer;
1014 public class ClassDefinition : struct
1017 ClassDefinition prev, next;
1021 OldList * baseSpecs;
1022 OldList * definitions;
1024 Location blockStart;
1026 AccessMode declMode;
1027 bool deleteWatchable;
1030 public class PropertyWatch : struct
1033 PropertyWatch prev, next;
1036 OldList * properties;
1040 public enum ClassDefType
1042 functionClassDef, defaultPropertiesClassDef, declarationClassDef, propertyClassDef,
1043 propertyWatchClassDef, classDesignerClassDef, classNoExpansionClassDef, classFixedClassDef,
1044 designerDefaultPropertyClassDef, classDataClassDef, classPropertyClassDef, classPropertyValueClassDef,
1045 memberAccessClassDef, accessOverrideClassDef
1048 public class PropertyDef : struct
1051 PropertyDef prev, next;
1053 OldList * specifiers;
1054 Declarator declarator;
1058 Statement issetStmt;
1060 Expression category;
1069 public class ClassDef : struct
1072 ClassDef prev, next;
1078 ClassFunction function;
1079 OldList * defProperties;
1080 PropertyDef propertyDef;
1081 PropertyWatch propertyWatch;
1083 Identifier defaultProperty;
1087 Initializer initializer;
1090 AccessMode memberAccess;
1096 // An 'edge from' is a 'dependency on'
1097 class TopoEdge : struct
1099 public LinkElement<TopoEdge> in, out;
1104 public enum ExternalType { functionExternal, declarationExternal, classExternal, importExternal, nameSpaceExternal, dbtableExternal };
1106 public class External : struct
1109 External prev, next;
1115 FunctionDefinition function;
1116 ClassDefinition _class;
1117 Declaration declaration;
1118 char * importString;
1122 ImportType importType;
1126 LinkList<TopoEdge, link = out> outgoing { };
1127 LinkList<TopoEdge, link = in> incoming { };
1128 int nonBreakableIncoming;
1130 void CreateUniqueEdge(External from, bool soft)
1132 for(i : from.outgoing; i.to == this)
1134 if(i.breakable && !soft)
1138 PrintLn("bug: self-dependency");
1140 i.breakable = false;
1141 nonBreakableIncoming++;
1145 CreateEdge(from, soft);
1148 void CreateEdge(External from, bool soft)
1150 TopoEdge e { from = from, to = this, breakable = soft };
1153 if(from == this && !soft)
1154 PrintLn("bug: self-dependency");
1156 /*for(i : from.outgoing)
1159 PrintLn("Warning: adding a duplicate edge");
1163 from.outgoing.Add(e);
1166 nonBreakableIncoming++;
1169 External ForwardDeclare()
1172 Context tmpContext = curContext;
1176 case declarationExternal:
1178 if(declaration.type == initDeclaration)
1180 OldList * specs = declaration.specifiers;
1184 for(s = specs->first; s; s = s.next)
1186 if(s.type == structSpecifier || s.type == unionSpecifier)
1192 f = MkExternalDeclaration(MkDeclaration(MkListOne(MkStructOrUnion(s.type, CopyIdentifier(s.id), null)), null));
1193 curContext = tmpContext;
1199 case functionExternal:
1202 f = MkExternalDeclaration(MkDeclaration(CopyList(function.specifiers, CopySpecifier), MkListOne(MkInitDeclarator(CopyDeclarator(function.declarator), null))));
1203 curContext = tmpContext;
1206 DeclareTypeForwardDeclare(f, symbol.type, false, false);
1212 for(i : m.protoDepsExternal)
1214 // If the edge is already added, don't bother
1215 if(i.incoming.count)
1216 CreateEdge(f, i.fwdDecl ? i.fwdDecl : i, i.fwdDecl ? false : true);
1223 PrintLn("warning: unhandled forward declaration requested");
1228 public class Context : struct
1232 BinaryTree types { CompareKey = (void *)BinaryTree::CompareString };
1233 BinaryTree classes { CompareKey = (void *)BinaryTree::CompareString };
1234 BinaryTree symbols { CompareKey = (void *)BinaryTree::CompareString };
1235 BinaryTree structSymbols { CompareKey = (void *)BinaryTree::CompareString };
1238 BinaryTree templateTypes { CompareKey = (void *)BinaryTree::CompareString };
1239 ClassDefinition classDef;
1240 bool templateTypesOnly;
1244 /*************** Compiling passes symbols ***************/
1246 public class Symbol : struct
1250 Symbol parent, left, right; // Reusing left, right as prev, next when in excludedSymbols
1260 bool notYetDeclared;
1265 External pointerExternal; // external declaration for the pointer to the Class: e.g. __ecereClass___ecereNameSpace__ecere__com__Class
1266 External structExternal; // external declaration for the actual class members structure: e.g. __ecereNameSpace__ecere__com__Class
1270 External externalGet;
1271 External externalSet;
1272 External externalPtr; // Property pointer for watchers
1273 External externalIsSet;
1277 External methodExternal;
1278 External methodCodeExternal;
1281 bool imported, declaredStructSym;
1282 Class _class; // for properties only...
1284 // Only used for classes right now...
1285 bool declaredStruct;
1286 bool needConstructor, needDestructor;
1287 char * constructorName, * structName, * className, * destructorName;
1289 ModuleImport module;
1290 ClassImport _import;
1295 bool fireWatchersDone;
1300 OldList * templateParams; // Review the necessity for this
1301 OldList templatedClasses;
1304 Expression propCategory;
1305 bool mustRegister; // Must register the class within the RegisterClass (also used to check whether this class is declared in this module)
1308 // For the .imp file:
1309 public class ClassImport : struct
1312 ClassImport prev, next;
1320 public class FunctionImport : struct
1323 FunctionImport prev, next;
1327 public class ModuleImport : struct
1330 ModuleImport prev, next;
1334 ImportType importType;
1335 AccessMode importAccess;
1338 public class PropertyImport : struct
1341 PropertyImport prev, next;
1344 bool hasSet, hasGet;
1347 public class MethodImport : struct
1350 MethodImport prev, next;
1355 // For the .sym file:
1356 public enum TypeKind
1358 voidType, charType, shortType, intType, int64Type, longType, floatType,
1359 doubleType, classType, structType, unionType, functionType, arrayType, pointerType,
1360 ellipsisType, enumType, methodType, vaListType, /*typedObjectType, anyObjectType, classPointerType, */ dummyType,
1361 subClassType, templateType, thisClassType, intPtrType, intSizeType, _BoolType
1364 public class Type : struct
1384 TemplateParameter thisClassTemplate;
1390 Class methodClass; // Clarify what this is!
1399 Expression arraySizeExp;
1405 TemplateParameter templateParameter;
1411 Class thisClassFrom;
1413 ClassObjectType classObjectType;
1417 int count; // This is used to avoid outputting warnings when non-zero
1423 bool extraParam:1; // Clarify this... One thing it is used for is adaptive method with their own type explicitly specified
1424 bool directClassAccess:1; // Need to clarify this if this had the same intended purpose as declaredWithStruct
1427 bool passAsTemplate:1;
1430 bool declaredWithStruct:1;
1431 bool typedByReference:1; // Originally typed by reference, regardless of class type
1433 bool pointerAlignment:1; // true if the alignment is the pointer size
1434 bool isLong:1; // true if this is truly a long set as a int/int64 (need to improve long support)
1435 // bool wasThisClass:1;
1436 // TODO: Add _Complex & _Imaginary support
1437 // bool complex:1, imaginary:1;
1439 const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
1441 Type type = (Type)this;
1442 tempString[0] = '\0';
1444 PrintType(type, tempString, false, true);
1453 property bool specConst
1458 while((t.kind == pointerType || t.kind == arrayType) && t.type) t = t.type;
1463 // Used for generating calls to eClass_AddDataMember (differs slightly from 'isPointerType' below), meant to return true where ComputeTypeSize returns targetBits / 8
1464 property bool isPointerTypeSize
1468 bool result = false;
1475 Class _class = this._class ? this._class.registered : null;
1476 if(!_class || (_class.type != structClass && _class.type != unitClass && _class.type != enumClass && _class.type != bitClass))
1489 TemplateParameter param = templateParameter;
1490 Type baseType = ProcessTemplateParameterType(param);
1492 result = baseType.isPointerTypeSize;
1501 property bool isPointerType
1507 if(kind == pointerType || kind == methodType || kind == functionType || kind == arrayType || kind == subClassType)
1509 else if(kind == classType)
1511 if(_class && _class.registered)
1513 Class c = _class.registered;
1514 if(c.type == bitClass || c.type == unitClass || c.type == enumClass || c.type == systemClass)
1516 else if(c.type == structClass && !byReference)
1521 else if(kind == templateType)
1523 if(passAsTemplate) return false;
1524 if(templateParameter)
1526 if(templateParameter.dataType)
1528 Specifier spec = templateParameter.dataType.specifiers ? templateParameter.dataType.specifiers->first : null;
1529 if(templateParameter.dataType.decl && templateParameter.dataType.decl.type == pointerDeclarator)
1531 if(spec && spec.type == nameSpecifier && strcmp(spec.name, "uint64"))
1534 if(templateParameter.dataTypeString)
1546 public struct Operand
1551 unsigned int ptrSize;
1552 union // Promote to using data value
1562 // unsigned char * p; // Now always storing addresses in ui64
1571 public struct OpTable
1574 // binary arithmetic
1575 bool (* Add)(Expression, Operand, Operand);
1576 bool (* Sub)(Expression, Operand, Operand);
1577 bool (* Mul)(Expression, Operand, Operand);
1578 bool (* Div)(Expression, Operand, Operand);
1579 bool (* Mod)(Expression, Operand, Operand);
1582 bool (* Neg)(Expression, Operand);
1584 // unary arithmetic increment and decrement
1585 bool (* Inc)(Expression, Operand);
1586 bool (* Dec)(Expression, Operand);
1588 // binary arithmetic assignment
1589 bool (* Asign)(Expression, Operand, Operand);
1590 bool (* AddAsign)(Expression, Operand, Operand);
1591 bool (* SubAsign)(Expression, Operand, Operand);
1592 bool (* MulAsign)(Expression, Operand, Operand);
1593 bool (* DivAsign)(Expression, Operand, Operand);
1594 bool (* ModAsign)(Expression, Operand, Operand);
1597 bool (* BitAnd)(Expression, Operand, Operand);
1598 bool (* BitOr)(Expression, Operand, Operand);
1599 bool (* BitXor)(Expression, Operand, Operand);
1600 bool (* LShift)(Expression, Operand, Operand);
1601 bool (* RShift)(Expression, Operand, Operand);
1602 bool (* BitNot)(Expression, Operand);
1604 // binary bitwise assignment
1605 bool (* AndAsign)(Expression, Operand, Operand);
1606 bool (* OrAsign)(Expression, Operand, Operand);
1607 bool (* XorAsign)(Expression, Operand, Operand);
1608 bool (* LShiftAsign)(Expression, Operand, Operand);
1609 bool (* RShiftAsign)(Expression, Operand, Operand);
1611 // unary logical negation
1612 bool (* Not)(Expression, Operand);
1614 // binary logical equality
1615 bool (* Equ)(Expression, Operand, Operand);
1616 bool (* Nqu)(Expression, Operand, Operand);
1619 bool (* And)(Expression, Operand, Operand);
1620 bool (* Or)(Expression, Operand, Operand);
1622 // binary logical relational
1623 bool (* Grt)(Expression, Operand, Operand);
1624 bool (* Sma)(Expression, Operand, Operand);
1625 bool (* GrtEqu)(Expression, Operand, Operand);
1626 bool (* SmaEqu)(Expression, Operand, Operand);
1628 bool (* Cond)(Expression, Operand, Operand, Operand);
1631 define MAX_INCLUDE_DEPTH = 30;
1635 void Compiler_Error(const char * format, ...)
1644 if(yylloc.start.included)
1646 GetWorkingDir(string, sizeof(string));
1647 PathCat(string, GetIncludeFileFromID(yylloc.start.included));
1651 GetWorkingDir(string, sizeof(string));
1652 PathCat(string, sourceFile);
1654 printf("%s", string);
1657 yylloc.start.col = yylloc.end.col = 1;
1658 yylloc.start.line = yylloc.end.line = 1;
1659 yylloc.start.pos = yylloc.end.pos = 0;
1662 if(!yylloc.start.line)
1666 //printf("(%d, %d) : error: ", yylloc.start.line, yylloc.start.charPos);
1667 printf($":%d:%d: error: ", yylloc.start.line, yylloc.start.charPos);
1668 //printf(":%d: error: ", yylloc.start.line);
1669 va_start(args, format);
1670 vsnprintf(string, sizeof(string), format, args);
1671 string[sizeof(string)-1] = 0;
1673 fputs(string, stdout);
1675 __thisModule.application.exitCode = 1;
1679 // Error parsing type
1680 parseTypeError = true;
1686 public int GetNumWarnings() { return numWarnings; }
1688 void Compiler_Warning(const char * format, ...)
1694 char fileName[MAX_FILENAME];
1696 if(yylloc.start.included)
1698 String include = GetIncludeFileFromID(yylloc.start.included);
1699 GetWorkingDir(string, sizeof(string));
1700 PathCat(string, include);
1704 GetWorkingDir(string, sizeof(string));
1705 PathCat(string, sourceFile);
1708 // Skip these warnings from MinGW-w64 GCC 4.8 in intrin-impl.h
1709 GetLastDirectory(string, fileName);
1710 if(!strcmp(fileName, "intrin-impl.h")) return;
1712 printf("%s", string);
1714 //printf("(%d, %d) : warning: ", yylloc.start.line, yylloc.start.charPos);
1715 printf($":%d:%d: warning: ", yylloc.start.line, yylloc.start.charPos);
1716 //printf(":%d: warning: ", yylloc.start.line);
1717 va_start(args, format);
1718 vsnprintf(string, sizeof(string), format, args);
1719 string[sizeof(string)-1] = 0;
1721 fputs(string, stdout);
1734 //printf("\n%*s\n%*s\n", column, "^", column, s);
1736 Compiler_Error($"syntax error\n");
1741 Platform targetPlatform;
1743 public int GetHostBits()
1745 // Default to runtime platform in case we fail to determine host
1746 int hostBits = (sizeof(uintptr) == 8) ? 64 : 32;
1747 String hostType = getenv("HOSTTYPE");
1751 DualPipe f = DualPipeOpen({ output = true }, "uname -m");
1754 if(f.GetLine(host, sizeof(host)))
1761 if(!strcmp(hostType, "x86_64"))
1763 else if(!strcmp(hostType, "i386") || !strcmp(hostType, "i686"))
1769 public void SetTargetPlatform(Platform platform) { targetPlatform = platform; };
1773 public void SetTargetBits(int bits) { targetBits = bits; };
1774 public int GetTargetBits() { return targetBits; };