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)
235 const char * escChars, * escCharsQuoted;
236 bool quoting = false;
238 const char *i = input, *l = input;
239 if(__runtimePlatform == win32)
241 //define windowsFileNameCharsNeedEscaping = " !%&'()+,;=[]^`{}~"; // "#$-.@_" are ok
242 escChars = " !\"%&'()+,;=[]^`{}~"; // windowsFileNameCharsNeedEscaping;
243 escCharsQuoted = "\"";
244 while(*l && !strchr(escChars, *l)) l++;
245 if(*l) quoting = true;
247 //define linuxFileNameCharsNeedEscaping = " !\"$&'()*:;<=>?[\\`{|"; // "#%+,-.@]^_}~" are ok
250 escChars = " !\"$&'()*:;<=>?[\\`{|"; // linuxFileNameCharsNeedEscaping;
251 escCharsQuoted = "\"()$";
255 while(*l && !strchr(escChars, *l)) l++;
256 if(*l) quoting = true;
264 if(strchr(quoting ? escCharsQuoted : escChars, *i))
273 /*public Module GetPrivateModule()
275 return privateModule;
278 public class GlobalData : BTNode
282 char * dataTypeString;
288 public class TemplatedType : BTNode
291 TemplateParameter param;
294 class DataRedefinition : struct
296 DataRedefinition prev, next;
298 char type1[1024], type2[1024];
301 public struct CodePosition
304 int line, charPos, pos;
307 void AdjustDelete(BufferLocation start, BufferLocation end)
309 // Location is before, nothing to do
310 if(line - 1 < start.y || (line - 1 == start.y && charPos - 1 < start.x))
312 // Location is inside deleted bytes, point to the start
313 if((line - 1 >= start.y && (line - 1 > start.y || charPos - 1 >= start.x)) &&
314 (line - 1 >= end.y && (line - 1 > end.y || charPos - 1 >= end.x)))
317 if(line - 1 >= end.y)
319 // Location is on another line
321 line -= end.y - start.y;
322 // Location is the last touched line
325 if(charPos - 1 >= end.x)
328 //if(start.line == end.line)
329 charPos -= end.x - start.x;
337 charPos = start.x + 1;
341 // Assuming no carriage return before first character ???? fixed?
342 void AdjustAdd(BufferLocation start, BufferLocation end)
344 int numLines = end.y - start.y;
345 if(line - 1 >= start.y)
347 if(line - 1 > start.y)
351 if(charPos - 1 > start.x || (charPos - 1 == start.x /*&& (numLines ? true : false)*/))
354 //charPos - 1 += numLines ? end.x : (end.x - start.x);
355 charPos += end.x - start.x;
362 public struct Location
365 CodePosition start, end;
367 bool Inside(int line, int charPos)
369 return (start.line < line || (start.line == line && start.charPos <= charPos)) &&
370 (end.line > line || (end.line == line && end.charPos >= charPos));
374 public enum DefinitionType { moduleDefinition, classDefinition, defineDefinition, functionDefinition, dataDefinition };
376 public class Definition : struct
379 Definition prev, next;
384 public class ImportedModule : struct
387 ImportedModule prev, next;
390 ImportType importType;
393 AccessMode importAccess;
396 public class Identifier : struct
399 Identifier prev, next;
401 // TODO: NameSpace * nameSpace;
408 public enum ExpressionType
410 identifierExp, instanceExp, constantExp, stringExp, opExp,
411 bracketsExp, indexExp, callExp, memberExp, pointerExp, typeSizeExp,
412 castExp, conditionExp, newExp, renewExp, classSizeExp,
413 dummyExp, dereferenceErrorExp, symbolErrorExp,
414 memberSymbolErrorExp, memoryErrorExp, unknownErrorExp,
416 extensionCompoundExp, classExp, classDataExp, new0Exp, renew0Exp,
417 dbopenExp, dbfieldExp, dbtableExp, dbindexExp, extensionExpressionExp, extensionInitializerExp,
418 vaArgExp, arrayExp, typeAlignExp,
419 memberPropertyErrorExp, functionCallErrorExp, divideBy0ErrorExp,
423 public enum MemberType
425 unresolvedMember, propertyMember, methodMember, dataMember, reverseConversionMember, classPropertyMember
428 public class ExpUsage
431 bool usageGet:1, usageSet:1, usageArg:1, usageCall:1, usageMember:1, usageDeepGet:1, usageRef:1, usageDelete:1;
434 public class TemplateParameter : struct
437 TemplateParameter prev, next;
440 TemplateParameterType type;
441 Identifier identifier;
444 TemplateDatatype dataType; // For both base datatype (type) and data type (expression)
445 TemplateMemberType memberType; // For identifier
447 TemplateArgument defaultArgument;
449 // For type parameters
450 const char * dataTypeString;
454 public class TemplateDatatype : struct
457 OldList * specifiers;
461 public class TemplateArgument : struct
464 TemplateArgument prev, next;
468 TemplateParameterType type;
471 Expression expression;
472 Identifier identifier;
473 TemplateDatatype templateDatatype;
477 public enum SpecifierType
479 baseSpecifier, nameSpecifier, enumSpecifier, structSpecifier, unionSpecifier, /*classSpecifier,*/
480 extendedSpecifier, typeOfSpecifier, subClassSpecifier, templateTypeSpecifier
483 public class Specifier : struct
486 Specifier prev, next;
497 OldList/*<TemplateArgument>*/ * templateArgs;
503 OldList/*<Enumerator>*/ * list;
504 OldList/*<Specifier>*/ * baseSpecs;
505 OldList/*<ClassDef>*/ * definitions;
508 ExtDecl extDeclStruct;
510 Expression expression;
512 TemplateParameter templateParameter;
516 public class Attribute : struct
519 Attribute prev, next;
525 public class Attrib : struct
533 public class ExtDecl : struct
545 public enum ExtDeclType
547 extDeclString, extDeclAttrib
550 public class Expression : struct
553 Expression prev, next;
561 Identifier identifier;
564 Instantiation instance;
574 OldList * specifiers;
597 MemberType memberType;
603 Expression exp1, exp2;
642 Initializer initializer;
663 // *** COMPILING DATA ***
675 bool usedInComparison;
677 bool parentOpDestType;
678 uint needTemplateCast;
698 parentOpDestType = false;
699 usedInComparison = false;
700 needTemplateCast = 0;
704 public class Enumerator : struct
707 Enumerator prev, next;
713 class Pointer : struct
717 OldList * qualifiers;
721 public enum DeclaratorType
723 structDeclarator, identifierDeclarator, bracketsDeclarator, arrayDeclarator,
724 functionDeclarator, pointerDeclarator, extendedDeclarator, extendedDeclaratorEnd
727 public class Declarator : struct
730 Declarator prev, next;
733 Symbol symbol;//, propSymbol;
734 Declarator declarator;
737 Identifier identifier;
751 OldList * parameters;
764 public enum InitializerType { expInitializer, listInitializer };
766 public class Initializer : struct
769 Initializer prev, next;
771 InitializerType type;
781 public class InitDeclarator : struct
784 InitDeclarator prev, next;
786 Declarator declarator;
787 Initializer initializer;
790 public enum ClassObjectType
798 public class TypeName : struct
803 OldList * qualifiers;
804 Declarator declarator;
805 //bool /*typedObject, */byReference;
807 ClassObjectType classObjectType;
811 class AsmField : struct
816 Expression expression;
820 public enum StmtType { labeledStmt, caseStmt, compoundStmt,
821 expressionStmt, ifStmt, switchStmt, whileStmt, doWhileStmt,
822 forStmt, gotoStmt, continueStmt, breakStmt, returnStmt, asmStmt, badDeclarationStmt,
823 fireWatchersStmt, stopWatchingStmt, watchStmt, forEachStmt
826 public class Statement : struct
829 Statement prev, next;
834 OldList * expressions;
847 OldList * declarations;
848 OldList * statements;
888 OldList * inputFields;
889 OldList * outputFields;
890 OldList * clobberedFields;
894 Expression watcher, object;
895 OldList * watches; // OldList of PropertyWatch for a StmtWatch, list of property identifiers for firewatches, stopwatching
908 public enum DeclarationType { structDeclaration, initDeclaration, instDeclaration, defineDeclaration };
910 public class Declaration : struct
913 Declaration prev, next;
915 DeclarationType type;
920 OldList * specifiers;
921 OldList * declarators;
930 Specifier extStorage;
935 public class Instantiation : struct
938 Instantiation prev, next;
947 Location nameLoc, insideLoc;
951 public enum MembersInitType { dataMembersInit, methodMembersInit };
953 public class FunctionDefinition : struct
956 FunctionDefinition prev, next;
958 OldList * specifiers;
959 Declarator declarator;
960 OldList * declarations;
963 OldList attached; // For IDE
970 bool propertyNoThis; // Not used yet; might use to support both this = and return syntax for conversion properties
973 public class ClassFunction : struct
976 ClassFunction prev, next;
978 OldList * specifiers;
979 Declarator declarator;
980 OldList * declarations;
983 OldList attached; // For IDE
991 bool isConstructor, isDestructor;
996 public class MembersInit : struct
999 MembersInit prev, next;
1001 MembersInitType type;
1004 OldList * dataMembers;
1005 ClassFunction function;
1010 public class MemberInit : struct
1013 MemberInit prev, next;
1016 OldList * identifiers;
1018 Initializer initializer;
1026 public class ClassDefinition : struct
1029 ClassDefinition prev, next;
1033 OldList * baseSpecs;
1034 OldList * definitions;
1036 Location blockStart;
1038 AccessMode declMode;
1039 bool deleteWatchable;
1042 public class PropertyWatch : struct
1045 PropertyWatch prev, next;
1048 OldList * properties;
1052 public enum ClassDefType
1054 functionClassDef, defaultPropertiesClassDef, declarationClassDef, propertyClassDef,
1055 propertyWatchClassDef, classDesignerClassDef, classNoExpansionClassDef, classFixedClassDef,
1056 designerDefaultPropertyClassDef, classDataClassDef, classPropertyClassDef, classPropertyValueClassDef,
1057 memberAccessClassDef, accessOverrideClassDef
1060 public class PropertyDef : struct
1063 PropertyDef prev, next;
1065 OldList * specifiers;
1066 Declarator declarator;
1070 Statement issetStmt;
1072 Expression category;
1081 public class ClassDef : struct
1084 ClassDef prev, next;
1090 ClassFunction function;
1091 OldList * defProperties;
1092 PropertyDef propertyDef;
1093 PropertyWatch propertyWatch;
1095 Identifier defaultProperty;
1099 Initializer initializer;
1102 AccessMode memberAccess;
1108 // An 'edge from' is a 'dependency on'
1109 class TopoEdge : struct
1111 public LinkElement<TopoEdge> in, out;
1116 public enum ExternalType { functionExternal, declarationExternal, classExternal, importExternal, nameSpaceExternal, dbtableExternal };
1118 public class External : struct
1121 External prev, next;
1127 FunctionDefinition function;
1128 ClassDefinition _class;
1129 Declaration declaration;
1130 char * importString;
1134 ImportType importType;
1138 LinkList<TopoEdge, link = out> outgoing { };
1139 LinkList<TopoEdge, link = in> incoming { };
1140 int nonBreakableIncoming;
1142 void CreateUniqueEdge(External from, bool soft)
1144 for(i : from.outgoing; i.to == this)
1146 if(i.breakable && !soft)
1150 PrintLn("bug: self-dependency");
1152 i.breakable = false;
1153 nonBreakableIncoming++;
1157 CreateEdge(from, soft);
1160 void CreateEdge(External from, bool soft)
1162 TopoEdge e { from = from, to = this, breakable = soft };
1165 if(from == this && !soft)
1166 PrintLn("bug: self-dependency");
1168 /*for(i : from.outgoing)
1171 PrintLn("Warning: adding a duplicate edge");
1175 from.outgoing.Add(e);
1178 nonBreakableIncoming++;
1181 External ForwardDeclare()
1184 Context tmpContext = curContext;
1188 case declarationExternal:
1190 if(declaration.type == initDeclaration)
1192 OldList * specs = declaration.specifiers;
1196 for(s = specs->first; s; s = s.next)
1198 if(s.type == structSpecifier || s.type == unionSpecifier)
1204 f = MkExternalDeclaration(MkDeclaration(MkListOne(MkStructOrUnion(s.type, CopyIdentifier(s.id), null)), null));
1205 curContext = tmpContext;
1211 case functionExternal:
1214 f = MkExternalDeclaration(MkDeclaration(CopyList(function.specifiers, CopySpecifier), MkListOne(MkInitDeclarator(CopyDeclarator(function.declarator), null))));
1215 curContext = tmpContext;
1218 DeclareTypeForwardDeclare(f, symbol.type, false, false);
1224 for(i : m.protoDepsExternal)
1226 // If the edge is already added, don't bother
1227 if(i.incoming.count)
1228 CreateEdge(f, i.fwdDecl ? i.fwdDecl : i, i.fwdDecl ? false : true);
1235 PrintLn("warning: unhandled forward declaration requested");
1240 public class Context : struct
1244 BinaryTree types { CompareKey = (void *)BinaryTree::CompareString };
1245 BinaryTree classes { CompareKey = (void *)BinaryTree::CompareString };
1246 BinaryTree symbols { CompareKey = (void *)BinaryTree::CompareString };
1247 BinaryTree structSymbols { CompareKey = (void *)BinaryTree::CompareString };
1250 BinaryTree templateTypes { CompareKey = (void *)BinaryTree::CompareString };
1251 ClassDefinition classDef;
1252 bool templateTypesOnly;
1256 /*************** Compiling passes symbols ***************/
1258 public class Symbol : struct
1262 Symbol parent, left, right; // Reusing left, right as prev, next when in excludedSymbols
1272 bool notYetDeclared;
1277 External pointerExternal; // external declaration for the pointer to the Class: e.g. __ecereClass___ecereNameSpace__ecere__com__Class
1278 External structExternal; // external declaration for the actual class members structure: e.g. __ecereNameSpace__ecere__com__Class
1282 External externalGet;
1283 External externalSet;
1284 External externalPtr; // Property pointer for watchers
1285 External externalIsSet;
1289 External methodExternal;
1290 External methodCodeExternal;
1293 bool imported, declaredStructSym;
1294 Class _class; // for properties only...
1296 // Only used for classes right now...
1297 bool declaredStruct;
1298 bool needConstructor, needDestructor;
1299 char * constructorName, * structName, * className, * destructorName;
1301 ModuleImport module;
1302 ClassImport _import;
1307 bool fireWatchersDone;
1312 OldList * templateParams; // Review the necessity for this
1313 OldList templatedClasses;
1316 Expression propCategory;
1317 bool mustRegister; // Must register the class within the RegisterClass (also used to check whether this class is declared in this module)
1320 // For the .imp file:
1321 public class ClassImport : struct
1324 ClassImport prev, next;
1332 public class FunctionImport : struct
1335 FunctionImport prev, next;
1339 public class ModuleImport : struct
1342 ModuleImport prev, next;
1346 ImportType importType;
1347 AccessMode importAccess;
1350 public class PropertyImport : struct
1353 PropertyImport prev, next;
1356 bool hasSet, hasGet;
1359 public class MethodImport : struct
1362 MethodImport prev, next;
1367 // For the .sym file:
1368 public enum TypeKind
1370 voidType, charType, shortType, intType, int64Type, longType, floatType,
1371 doubleType, classType, structType, unionType, functionType, arrayType, pointerType,
1372 ellipsisType, enumType, methodType, vaListType, /*typedObjectType, anyObjectType, classPointerType, */ dummyType,
1373 subClassType, templateType, thisClassType, intPtrType, intSizeType, _BoolType
1376 public class Type : struct
1396 TemplateParameter thisClassTemplate;
1402 Class methodClass; // Clarify what this is!
1411 Expression arraySizeExp;
1417 TemplateParameter templateParameter;
1423 Class thisClassFrom;
1424 TypeKind promotedFrom;
1426 ClassObjectType classObjectType;
1430 int count; // This is used to avoid outputting warnings when non-zero
1437 bool extraParam:1; // Clarify this... One thing it is used for is adaptive method with their own type explicitly specified
1438 bool directClassAccess:1; // Need to clarify this if this had the same intended purpose as declaredWithStruct
1441 bool passAsTemplate:1;
1444 bool declaredWithStruct:1;
1445 bool typedByReference:1; // Originally typed by reference, regardless of class type
1447 bool pointerAlignment:1; // true if the alignment is the pointer size
1448 bool isLong:1; // true if this is truly a long set as a int/int64 (need to improve long support)
1449 bool signedBeforePromotion:1;
1450 // bool wasThisClass:1;
1451 // TODO: Add _Complex & _Imaginary support
1452 // bool complex:1, imaginary:1;
1454 const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
1456 Type type = (Type)this;
1457 tempString[0] = '\0';
1459 PrintType(type, tempString, false, true);
1468 property bool specConst
1473 while((t.kind == pointerType || t.kind == arrayType) && t.type) t = t.type;
1478 // Used for generating calls to eClass_AddDataMember (differs slightly from 'isPointerType' below), meant to return true where ComputeTypeSize returns targetBits / 8
1479 property bool isPointerTypeSize
1483 bool result = false;
1490 Class _class = this._class ? this._class.registered : null;
1491 if(!_class || (_class.type != structClass && _class.type != unitClass && _class.type != enumClass && _class.type != bitClass))
1504 TemplateParameter param = templateParameter;
1505 Type baseType = ProcessTemplateParameterType(param);
1507 result = baseType.isPointerTypeSize;
1516 property bool isPointerType
1522 if(kind == pointerType || kind == methodType || kind == functionType || kind == arrayType || kind == subClassType)
1524 else if(kind == classType)
1526 if(_class && _class.registered)
1528 Class c = _class.registered;
1529 if(c.type == bitClass || c.type == unitClass || c.type == enumClass || c.type == systemClass)
1531 else if(c.type == structClass && !byReference)
1536 else if(kind == templateType)
1538 if(passAsTemplate) return false;
1539 if(templateParameter)
1541 if(templateParameter.dataType)
1543 Specifier spec = templateParameter.dataType.specifiers ? templateParameter.dataType.specifiers->first : null;
1544 if(templateParameter.dataType.decl && templateParameter.dataType.decl.type == pointerDeclarator)
1546 if(spec && spec.type == nameSpecifier && strcmp(spec.name, "uint64"))
1549 if(templateParameter.dataTypeString)
1561 public struct Operand
1566 unsigned int ptrSize;
1567 union // Promote to using data value
1577 // unsigned char * p; // Now always storing addresses in ui64
1586 public struct OpTable
1589 // binary arithmetic
1590 bool (* Add)(Expression, Operand, Operand);
1591 bool (* Sub)(Expression, Operand, Operand);
1592 bool (* Mul)(Expression, Operand, Operand);
1593 bool (* Div)(Expression, Operand, Operand);
1594 bool (* Mod)(Expression, Operand, Operand);
1597 bool (* Neg)(Expression, Operand);
1599 // unary arithmetic increment and decrement
1600 bool (* Inc)(Expression, Operand);
1601 bool (* Dec)(Expression, Operand);
1603 // binary arithmetic assignment
1604 bool (* Asign)(Expression, Operand, Operand);
1605 bool (* AddAsign)(Expression, Operand, Operand);
1606 bool (* SubAsign)(Expression, Operand, Operand);
1607 bool (* MulAsign)(Expression, Operand, Operand);
1608 bool (* DivAsign)(Expression, Operand, Operand);
1609 bool (* ModAsign)(Expression, Operand, Operand);
1612 bool (* BitAnd)(Expression, Operand, Operand);
1613 bool (* BitOr)(Expression, Operand, Operand);
1614 bool (* BitXor)(Expression, Operand, Operand);
1615 bool (* LShift)(Expression, Operand, Operand);
1616 bool (* RShift)(Expression, Operand, Operand);
1617 bool (* BitNot)(Expression, Operand);
1619 // binary bitwise assignment
1620 bool (* AndAsign)(Expression, Operand, Operand);
1621 bool (* OrAsign)(Expression, Operand, Operand);
1622 bool (* XorAsign)(Expression, Operand, Operand);
1623 bool (* LShiftAsign)(Expression, Operand, Operand);
1624 bool (* RShiftAsign)(Expression, Operand, Operand);
1626 // unary logical negation
1627 bool (* Not)(Expression, Operand);
1629 // binary logical equality
1630 bool (* Equ)(Expression, Operand, Operand);
1631 bool (* Nqu)(Expression, Operand, Operand);
1634 bool (* And)(Expression, Operand, Operand);
1635 bool (* Or)(Expression, Operand, Operand);
1637 // binary logical relational
1638 bool (* Grt)(Expression, Operand, Operand);
1639 bool (* Sma)(Expression, Operand, Operand);
1640 bool (* GrtEqu)(Expression, Operand, Operand);
1641 bool (* SmaEqu)(Expression, Operand, Operand);
1643 bool (* Cond)(Expression, Operand, Operand, Operand);
1646 define MAX_INCLUDE_DEPTH = 30;
1650 void Compiler_Error(const char * format, ...)
1659 if(yylloc.start.included)
1661 GetWorkingDir(string, sizeof(string));
1662 PathCat(string, GetIncludeFileFromID(yylloc.start.included));
1666 GetWorkingDir(string, sizeof(string));
1667 PathCat(string, sourceFile);
1669 printf("%s", string);
1672 yylloc.start.col = yylloc.end.col = 1;
1673 yylloc.start.line = yylloc.end.line = 1;
1674 yylloc.start.pos = yylloc.end.pos = 0;
1677 if(!yylloc.start.line)
1681 //printf("(%d, %d) : error: ", yylloc.start.line, yylloc.start.charPos);
1682 printf($":%d:%d: error: ", yylloc.start.line, yylloc.start.charPos);
1683 //printf(":%d: error: ", yylloc.start.line);
1684 va_start(args, format);
1685 vsnprintf(string, sizeof(string), format, args);
1686 string[sizeof(string)-1] = 0;
1688 fputs(string, stdout);
1690 __thisModule.application.exitCode = 1;
1694 // Error parsing type
1695 parseTypeError = true;
1701 public int GetNumWarnings() { return numWarnings; }
1703 void Compiler_Warning(const char * format, ...)
1709 char fileName[MAX_FILENAME];
1711 if(yylloc.start.included)
1713 String include = GetIncludeFileFromID(yylloc.start.included);
1714 GetWorkingDir(string, sizeof(string));
1715 PathCat(string, include);
1719 GetWorkingDir(string, sizeof(string));
1720 PathCat(string, sourceFile);
1723 // Skip these warnings from MinGW-w64 GCC 4.8 in intrin-impl.h
1724 GetLastDirectory(string, fileName);
1725 if(!strcmp(fileName, "intrin-impl.h")) return;
1727 printf("%s", string);
1729 //printf("(%d, %d) : warning: ", yylloc.start.line, yylloc.start.charPos);
1730 printf($":%d:%d: warning: ", yylloc.start.line, yylloc.start.charPos);
1731 //printf(":%d: warning: ", yylloc.start.line);
1732 va_start(args, format);
1733 vsnprintf(string, sizeof(string), format, args);
1734 string[sizeof(string)-1] = 0;
1736 fputs(string, stdout);
1749 //printf("\n%*s\n%*s\n", column, "^", column, s);
1751 Compiler_Error($"syntax error\n");
1756 Platform targetPlatform;
1758 public int GetHostBits()
1760 // Default to runtime platform in case we fail to determine host
1761 int hostBits = (sizeof(uintptr) == 8) ? 64 : 32;
1762 String hostType = getenv("HOSTTYPE");
1766 DualPipe f = DualPipeOpen({ output = true }, "uname -m");
1769 if(f.GetLine(host, sizeof(host)))
1776 if(!strcmp(hostType, "x86_64"))
1778 else if(!strcmp(hostType, "i386") || !strcmp(hostType, "i686"))
1784 public void SetTargetPlatform(Platform platform) { targetPlatform = platform; };
1788 public void SetTargetBits(int bits) { targetBits = bits; };
1789 public int GetTargetBits() { return targetBits; };