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;
500 OldList/*<Enumerator>*/ * list;
501 OldList/*<Specifier>*/ * baseSpecs;
502 OldList/*<ClassDef>*/ * definitions;
505 ExtDecl extDeclStruct;
507 Expression expression;
509 TemplateParameter templateParameter;
513 public class Attribute : struct
516 Attribute prev, next;
522 public class Attrib : struct
530 public class ExtDecl : struct
542 public enum ExtDeclType
544 extDeclString, extDeclAttrib
547 public class Expression : struct
550 Expression prev, next;
558 Identifier identifier;
561 Instantiation instance;
571 OldList * specifiers;
594 MemberType memberType;
600 Expression exp1, exp2;
639 Initializer initializer;
655 // *** COMPILING DATA ***
667 uint needTemplateCast;
687 needTemplateCast = 0;
691 public class Enumerator : struct
694 Enumerator prev, next;
700 class Pointer : struct
704 OldList * qualifiers;
708 public enum DeclaratorType
710 structDeclarator, identifierDeclarator, bracketsDeclarator, arrayDeclarator,
711 functionDeclarator, pointerDeclarator, extendedDeclarator, extendedDeclaratorEnd
714 public class Declarator : struct
717 Declarator prev, next;
720 Symbol symbol;//, propSymbol;
721 Declarator declarator;
724 Identifier identifier;
738 OldList * parameters;
751 public enum InitializerType { expInitializer, listInitializer };
753 public class Initializer : struct
756 Initializer prev, next;
758 InitializerType type;
768 public class InitDeclarator : struct
771 InitDeclarator prev, next;
773 Declarator declarator;
774 Initializer initializer;
777 public enum ClassObjectType
785 public class TypeName : struct
790 OldList * qualifiers;
791 Declarator declarator;
792 //bool /*typedObject, */byReference;
794 ClassObjectType classObjectType;
798 class AsmField : struct
803 Expression expression;
807 public enum StmtType { labeledStmt, caseStmt, compoundStmt,
808 expressionStmt, ifStmt, switchStmt, whileStmt, doWhileStmt,
809 forStmt, gotoStmt, continueStmt, breakStmt, returnStmt, asmStmt, badDeclarationStmt,
810 fireWatchersStmt, stopWatchingStmt, watchStmt, forEachStmt
813 public class Statement : struct
816 Statement prev, next;
821 OldList * expressions;
834 OldList * declarations;
835 OldList * statements;
875 OldList * inputFields;
876 OldList * outputFields;
877 OldList * clobberedFields;
881 Expression watcher, object;
882 OldList * watches; // OldList of PropertyWatch for a StmtWatch, list of property identifiers for firewatches, stopwatching
895 public enum DeclarationType { structDeclaration, initDeclaration, instDeclaration, defineDeclaration };
897 public class Declaration : struct
900 Declaration prev, next;
902 DeclarationType type;
907 OldList * specifiers;
908 OldList * declarators;
917 Specifier extStorage;
922 public class Instantiation : struct
925 Instantiation prev, next;
934 Location nameLoc, insideLoc;
938 public enum MembersInitType { dataMembersInit, methodMembersInit };
940 public class FunctionDefinition : struct
943 FunctionDefinition prev, next;
945 OldList * specifiers;
946 Declarator declarator;
947 OldList * declarations;
950 OldList attached; // For IDE
957 bool propertyNoThis; // Not used yet; might use to support both this = and return syntax for conversion properties
960 public class ClassFunction : struct
963 ClassFunction prev, next;
965 OldList * specifiers;
966 Declarator declarator;
967 OldList * declarations;
970 OldList attached; // For IDE
978 bool isConstructor, isDestructor;
983 public class MembersInit : struct
986 MembersInit prev, next;
988 MembersInitType type;
991 OldList * dataMembers;
992 ClassFunction function;
997 public class MemberInit : struct
1000 MemberInit prev, next;
1003 OldList * identifiers;
1005 Initializer initializer;
1013 public class ClassDefinition : struct
1016 ClassDefinition prev, next;
1020 OldList * baseSpecs;
1021 OldList * definitions;
1023 Location blockStart;
1025 AccessMode declMode;
1026 bool deleteWatchable;
1029 public class PropertyWatch : struct
1032 PropertyWatch prev, next;
1035 OldList * properties;
1039 public enum ClassDefType
1041 functionClassDef, defaultPropertiesClassDef, declarationClassDef, propertyClassDef,
1042 propertyWatchClassDef, classDesignerClassDef, classNoExpansionClassDef, classFixedClassDef,
1043 designerDefaultPropertyClassDef, classDataClassDef, classPropertyClassDef, classPropertyValueClassDef,
1044 memberAccessClassDef, accessOverrideClassDef
1047 public class PropertyDef : struct
1050 PropertyDef prev, next;
1052 OldList * specifiers;
1053 Declarator declarator;
1057 Statement issetStmt;
1059 Expression category;
1068 public class ClassDef : struct
1071 ClassDef prev, next;
1077 ClassFunction function;
1078 OldList * defProperties;
1079 PropertyDef propertyDef;
1080 PropertyWatch propertyWatch;
1082 Identifier defaultProperty;
1086 Initializer initializer;
1089 AccessMode memberAccess;
1095 // An 'edge from' is a 'dependency on'
1096 class TopoEdge : struct
1098 public LinkElement<TopoEdge> in, out;
1103 public enum ExternalType { functionExternal, declarationExternal, classExternal, importExternal, nameSpaceExternal, dbtableExternal };
1105 public class External : struct
1108 External prev, next;
1114 FunctionDefinition function;
1115 ClassDefinition _class;
1116 Declaration declaration;
1117 char * importString;
1121 ImportType importType;
1125 LinkList<TopoEdge, link = out> outgoing { };
1126 LinkList<TopoEdge, link = in> incoming { };
1127 int nonBreakableIncoming;
1129 void CreateUniqueEdge(External from, bool soft)
1131 for(i : from.outgoing; i.to == this)
1133 if(i.breakable && !soft)
1137 PrintLn("bug: self-dependency");
1139 i.breakable = false;
1140 nonBreakableIncoming++;
1144 CreateEdge(from, soft);
1147 void CreateEdge(External from, bool soft)
1149 TopoEdge e { from = from, to = this, breakable = soft };
1152 if(from == this && !soft)
1153 PrintLn("bug: self-dependency");
1155 /*for(i : from.outgoing)
1158 PrintLn("Warning: adding a duplicate edge");
1162 from.outgoing.Add(e);
1165 nonBreakableIncoming++;
1168 External ForwardDeclare()
1171 Context tmpContext = curContext;
1175 case declarationExternal:
1177 if(declaration.type == initDeclaration)
1179 OldList * specs = declaration.specifiers;
1183 for(s = specs->first; s; s = s.next)
1185 if(s.type == structSpecifier || s.type == unionSpecifier)
1191 f = MkExternalDeclaration(MkDeclaration(MkListOne(MkStructOrUnion(s.type, CopyIdentifier(s.id), null)), null));
1192 curContext = tmpContext;
1198 case functionExternal:
1201 f = MkExternalDeclaration(MkDeclaration(CopyList(function.specifiers, CopySpecifier), MkListOne(MkInitDeclarator(CopyDeclarator(function.declarator), null))));
1202 curContext = tmpContext;
1205 DeclareTypeForwardDeclare(f, symbol.type, false, false);
1211 for(i : m.protoDepsExternal)
1213 // If the edge is already added, don't bother
1214 if(i.incoming.count)
1215 CreateEdge(f, i.fwdDecl ? i.fwdDecl : i, i.fwdDecl ? false : true);
1222 PrintLn("warning: unhandled forward declaration requested");
1227 public class Context : struct
1231 BinaryTree types { CompareKey = (void *)BinaryTree::CompareString };
1232 BinaryTree classes { CompareKey = (void *)BinaryTree::CompareString };
1233 BinaryTree symbols { CompareKey = (void *)BinaryTree::CompareString };
1234 BinaryTree structSymbols { CompareKey = (void *)BinaryTree::CompareString };
1237 BinaryTree templateTypes { CompareKey = (void *)BinaryTree::CompareString };
1238 ClassDefinition classDef;
1239 bool templateTypesOnly;
1243 /*************** Compiling passes symbols ***************/
1245 public class Symbol : struct
1249 Symbol parent, left, right; // Reusing left, right as prev, next when in excludedSymbols
1259 bool notYetDeclared;
1264 External pointerExternal; // external declaration for the pointer to the Class: e.g. __ecereClass___ecereNameSpace__ecere__com__Class
1265 External structExternal; // external declaration for the actual class members structure: e.g. __ecereNameSpace__ecere__com__Class
1269 External externalGet;
1270 External externalSet;
1271 External externalPtr; // Property pointer for watchers
1272 External externalIsSet;
1276 External methodExternal;
1277 External methodCodeExternal;
1280 bool imported, declaredStructSym;
1281 Class _class; // for properties only...
1283 // Only used for classes right now...
1284 bool declaredStruct;
1285 bool needConstructor, needDestructor;
1286 char * constructorName, * structName, * className, * destructorName;
1288 ModuleImport module;
1289 ClassImport _import;
1294 bool fireWatchersDone;
1299 OldList * templateParams; // Review the necessity for this
1300 OldList templatedClasses;
1303 Expression propCategory;
1306 // For the .imp file:
1307 public class ClassImport : struct
1310 ClassImport prev, next;
1318 public class FunctionImport : struct
1321 FunctionImport prev, next;
1325 public class ModuleImport : struct
1328 ModuleImport prev, next;
1332 ImportType importType;
1333 AccessMode importAccess;
1336 public class PropertyImport : struct
1339 PropertyImport prev, next;
1342 bool hasSet, hasGet;
1345 public class MethodImport : struct
1348 MethodImport prev, next;
1353 // For the .sym file:
1354 public enum TypeKind
1356 voidType, charType, shortType, intType, int64Type, longType, floatType,
1357 doubleType, classType, structType, unionType, functionType, arrayType, pointerType,
1358 ellipsisType, enumType, methodType, vaListType, /*typedObjectType, anyObjectType, classPointerType, */ dummyType,
1359 subClassType, templateType, thisClassType, intPtrType, intSizeType, _BoolType
1362 public class Type : struct
1382 TemplateParameter thisClassTemplate;
1388 Class methodClass; // Clarify what this is!
1397 Expression arraySizeExp;
1403 TemplateParameter templateParameter;
1409 Class thisClassFrom;
1411 ClassObjectType classObjectType;
1415 int count; // This is used to avoid outputting warnings when non-zero
1421 bool extraParam:1; // Clarify this... One thing it is used for is adaptive method with their own type explicitly specified
1422 bool directClassAccess:1; // Need to clarify this if this had the same intended purpose as declaredWithStruct
1425 bool passAsTemplate:1;
1428 bool declaredWithStruct:1;
1429 bool typedByReference:1; // Originally typed by reference, regardless of class type
1431 bool pointerAlignment:1; // true if the alignment is the pointer size
1432 // bool wasThisClass:1;
1433 // TODO: Add _Complex & _Imaginary support
1434 // bool complex:1, imaginary:1;
1436 const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
1438 Type type = (Type)this;
1439 tempString[0] = '\0';
1441 PrintType(type, tempString, false, true);
1450 property bool specConst
1455 while((t.kind == pointerType || t.kind == arrayType) && t.type) t = t.type;
1460 // Used for generating calls to eClass_AddDataMember (differs slightly from 'isPointerType' below), meant to return true where ComputeTypeSize returns targetBits / 8
1461 property bool isPointerTypeSize
1465 bool result = false;
1472 Class _class = this._class ? this._class.registered : null;
1473 if(!_class || (_class.type != structClass && _class.type != unitClass && _class.type != enumClass && _class.type != bitClass))
1486 TemplateParameter param = templateParameter;
1487 Type baseType = ProcessTemplateParameterType(param);
1489 result = baseType.isPointerTypeSize;
1498 property bool isPointerType
1504 if(kind == pointerType || kind == methodType || kind == functionType || kind == arrayType || kind == subClassType)
1506 else if(kind == classType)
1508 if(_class && _class.registered)
1510 Class c = _class.registered;
1511 if(c.type == bitClass || c.type == unitClass || c.type == enumClass || c.type == systemClass)
1513 else if(c.type == structClass && !byReference)
1518 else if(kind == templateType)
1520 if(passAsTemplate) return false;
1521 if(templateParameter)
1523 if(templateParameter.dataType)
1525 Specifier spec = templateParameter.dataType.specifiers ? templateParameter.dataType.specifiers->first : null;
1526 if(templateParameter.dataType.decl && templateParameter.dataType.decl.type == pointerDeclarator)
1528 if(spec && spec.type == nameSpecifier && strcmp(spec.name, "uint64"))
1531 if(templateParameter.dataTypeString)
1543 public struct Operand
1548 unsigned int ptrSize;
1549 union // Promote to using data value
1559 // unsigned char * p; // Now always storing addresses in ui64
1568 public struct OpTable
1571 // binary arithmetic
1572 bool (* Add)(Expression, Operand, Operand);
1573 bool (* Sub)(Expression, Operand, Operand);
1574 bool (* Mul)(Expression, Operand, Operand);
1575 bool (* Div)(Expression, Operand, Operand);
1576 bool (* Mod)(Expression, Operand, Operand);
1579 bool (* Neg)(Expression, Operand);
1581 // unary arithmetic increment and decrement
1582 bool (* Inc)(Expression, Operand);
1583 bool (* Dec)(Expression, Operand);
1585 // binary arithmetic assignment
1586 bool (* Asign)(Expression, Operand, Operand);
1587 bool (* AddAsign)(Expression, Operand, Operand);
1588 bool (* SubAsign)(Expression, Operand, Operand);
1589 bool (* MulAsign)(Expression, Operand, Operand);
1590 bool (* DivAsign)(Expression, Operand, Operand);
1591 bool (* ModAsign)(Expression, Operand, Operand);
1594 bool (* BitAnd)(Expression, Operand, Operand);
1595 bool (* BitOr)(Expression, Operand, Operand);
1596 bool (* BitXor)(Expression, Operand, Operand);
1597 bool (* LShift)(Expression, Operand, Operand);
1598 bool (* RShift)(Expression, Operand, Operand);
1599 bool (* BitNot)(Expression, Operand);
1601 // binary bitwise assignment
1602 bool (* AndAsign)(Expression, Operand, Operand);
1603 bool (* OrAsign)(Expression, Operand, Operand);
1604 bool (* XorAsign)(Expression, Operand, Operand);
1605 bool (* LShiftAsign)(Expression, Operand, Operand);
1606 bool (* RShiftAsign)(Expression, Operand, Operand);
1608 // unary logical negation
1609 bool (* Not)(Expression, Operand);
1611 // binary logical equality
1612 bool (* Equ)(Expression, Operand, Operand);
1613 bool (* Nqu)(Expression, Operand, Operand);
1616 bool (* And)(Expression, Operand, Operand);
1617 bool (* Or)(Expression, Operand, Operand);
1619 // binary logical relational
1620 bool (* Grt)(Expression, Operand, Operand);
1621 bool (* Sma)(Expression, Operand, Operand);
1622 bool (* GrtEqu)(Expression, Operand, Operand);
1623 bool (* SmaEqu)(Expression, Operand, Operand);
1625 bool (* Cond)(Expression, Operand, Operand, Operand);
1628 define MAX_INCLUDE_DEPTH = 30;
1632 void Compiler_Error(const char * format, ...)
1641 if(yylloc.start.included)
1643 GetWorkingDir(string, sizeof(string));
1644 PathCat(string, GetIncludeFileFromID(yylloc.start.included));
1648 GetWorkingDir(string, sizeof(string));
1649 PathCat(string, sourceFile);
1651 printf("%s", string);
1654 yylloc.start.col = yylloc.end.col = 1;
1655 yylloc.start.line = yylloc.end.line = 1;
1656 yylloc.start.pos = yylloc.end.pos = 0;
1659 if(!yylloc.start.line)
1663 //printf("(%d, %d) : error: ", yylloc.start.line, yylloc.start.charPos);
1664 printf($":%d:%d: error: ", yylloc.start.line, yylloc.start.charPos);
1665 //printf(":%d: error: ", yylloc.start.line);
1666 va_start(args, format);
1667 vsnprintf(string, sizeof(string), format, args);
1668 string[sizeof(string)-1] = 0;
1670 fputs(string, stdout);
1672 __thisModule.application.exitCode = 1;
1676 // Error parsing type
1677 parseTypeError = true;
1683 public int GetNumWarnings() { return numWarnings; }
1685 void Compiler_Warning(const char * format, ...)
1691 char fileName[MAX_FILENAME];
1693 if(yylloc.start.included)
1695 String include = GetIncludeFileFromID(yylloc.start.included);
1696 GetWorkingDir(string, sizeof(string));
1697 PathCat(string, include);
1701 GetWorkingDir(string, sizeof(string));
1702 PathCat(string, sourceFile);
1705 // Skip these warnings from MinGW-w64 GCC 4.8 in intrin-impl.h
1706 GetLastDirectory(string, fileName);
1707 if(!strcmp(fileName, "intrin-impl.h")) return;
1709 printf("%s", string);
1711 //printf("(%d, %d) : warning: ", yylloc.start.line, yylloc.start.charPos);
1712 printf($":%d:%d: warning: ", yylloc.start.line, yylloc.start.charPos);
1713 //printf(":%d: warning: ", yylloc.start.line);
1714 va_start(args, format);
1715 vsnprintf(string, sizeof(string), format, args);
1716 string[sizeof(string)-1] = 0;
1718 fputs(string, stdout);
1731 //printf("\n%*s\n%*s\n", column, "^", column, s);
1733 Compiler_Error($"syntax error\n");
1738 Platform targetPlatform;
1740 public int GetHostBits()
1742 // Default to runtime platform in case we fail to determine host
1743 int hostBits = (sizeof(uintptr) == 8) ? 64 : 32;
1744 String hostType = getenv("HOSTTYPE");
1748 DualPipe f = DualPipeOpen({ output = true }, "uname -m");
1751 if(f.GetLine(host, sizeof(host)))
1758 if(!strcmp(hostType, "x86_64"))
1760 else if(!strcmp(hostType, "i386") || !strcmp(hostType, "i686"))
1766 public void SetTargetPlatform(Platform platform) { targetPlatform = platform; };
1770 public void SetTargetBits(int bits) { targetBits = bits; };
1771 public int GetTargetBits() { return targetBits; };