compiler: Added (u)intsize to map to size_t; Updated C prototypes to use it; Fixed...
[sdk] / compiler / bootstrap / ecc / bootstrap / ecc.c
1 #if defined(__GNUC__)
2 typedef long long int64;
3 typedef unsigned long long uint64;
4 #ifndef _WIN32
5 #define __declspec(x)
6 #endif
7 #elif defined(__TINYC__)
8 #include <stdarg.h>
9 #define __builtin_va_list va_list
10 #define __builtin_va_start va_start
11 #define __builtin_va_end va_end
12 #ifdef _WIN32
13 #define strcasecmp stricmp
14 #define strncasecmp strnicmp
15 #define __declspec(x) __attribute__((x))
16 #else
17 #define __declspec(x)
18 #endif
19 typedef long long int64;
20 typedef unsigned long long uint64;
21 #else
22 typedef __int64 int64;
23 typedef unsigned __int64 uint64;
24 #endif
25 #ifdef __BIG_ENDIAN__
26 #define __ENDIAN_PAD(x) (8 - (x))
27 #else
28 #define __ENDIAN_PAD(x) 0
29 #endif
30 #include <stdint.h>
31 #include <sys/types.h>
32
33 #if defined(_W64) || (defined(__WORDSIZE) && __WORDSIZE == 8) || defined(__x86_64__)
34 #define _64BIT 1
35 #else
36 #define _64BIT 0
37 #endif
38
39 #define arch_PointerSize                  sizeof(void *)
40 #define structSize_Instance               (_64BIT ? 24 : 12)
41 #define structSize_Module                 (_64BIT ? 560 : 300)
42
43 extern void *  __ecereNameSpace__ecere__com__eSystem_New(unsigned int size);
44
45 extern void *  __ecereNameSpace__ecere__com__eSystem_New0(unsigned int size);
46
47 extern void *  __ecereNameSpace__ecere__com__eSystem_Renew(void *  memory, unsigned int size);
48
49 extern void *  __ecereNameSpace__ecere__com__eSystem_Renew0(void *  memory, unsigned int size);
50
51 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__BTNode;
52
53 struct __ecereNameSpace__ecere__sys__BTNode;
54
55 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__BinaryTree;
56
57 struct __ecereNameSpace__ecere__sys__BinaryTree
58 {
59 struct __ecereNameSpace__ecere__sys__BTNode * root;
60 int count;
61 int (*  CompareKey)(struct __ecereNameSpace__ecere__sys__BinaryTree * tree, uintptr_t a, uintptr_t b);
62 void (*  FreeKey)(void *  key);
63 } __attribute__ ((gcc_struct));
64
65 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__OldList;
66
67 struct __ecereNameSpace__ecere__sys__OldList
68 {
69 void *  first;
70 void *  last;
71 int count;
72 unsigned int offset;
73 unsigned int circ;
74 } __attribute__ ((gcc_struct));
75
76 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Method;
77
78 struct __ecereNameSpace__ecere__com__Method
79 {
80 char *  name;
81 struct __ecereNameSpace__ecere__com__Method * parent;
82 struct __ecereNameSpace__ecere__com__Method * left;
83 struct __ecereNameSpace__ecere__com__Method * right;
84 int depth;
85 int (*  function)();
86 int vid;
87 int type;
88 struct __ecereNameSpace__ecere__com__Class * _class;
89 void *  symbol;
90 char *  dataTypeString;
91 struct Type * dataType;
92 int memberAccess;
93 } __attribute__ ((gcc_struct));
94
95 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Property;
96
97 struct __ecereNameSpace__ecere__com__Property
98 {
99 struct __ecereNameSpace__ecere__com__Property * prev;
100 struct __ecereNameSpace__ecere__com__Property * next;
101 char *  name;
102 unsigned int isProperty;
103 int memberAccess;
104 int id;
105 struct __ecereNameSpace__ecere__com__Class * _class;
106 char *  dataTypeString;
107 struct __ecereNameSpace__ecere__com__Class * dataTypeClass;
108 struct Type * dataType;
109 void (*  Set)(void * , int);
110 int (*  Get)(void * );
111 unsigned int (*  IsSet)(void * );
112 void *  data;
113 void *  symbol;
114 int vid;
115 unsigned int conversion;
116 unsigned int watcherOffset;
117 char *  category;
118 unsigned int compiled;
119 unsigned int selfWatchable;
120 unsigned int isWatchable;
121 } __attribute__ ((gcc_struct));
122
123 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_CodePosition;
124
125 struct CodePosition
126 {
127 int line;
128 int charPos;
129 int pos;
130 unsigned int included;
131 } __attribute__ ((gcc_struct));
132
133 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Location;
134
135 struct Location
136 {
137 struct CodePosition start;
138 struct CodePosition end;
139 } __attribute__ ((gcc_struct));
140
141 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Attrib;
142
143 struct Attrib;
144
145 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ExtDecl;
146
147 struct ExtDecl;
148
149 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ClassDefinition;
150
151 struct ClassDefinition;
152
153 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Context;
154
155 struct Context
156 {
157 struct Context * parent;
158 struct __ecereNameSpace__ecere__sys__BinaryTree types;
159 struct __ecereNameSpace__ecere__sys__BinaryTree classes;
160 struct __ecereNameSpace__ecere__sys__BinaryTree symbols;
161 struct __ecereNameSpace__ecere__sys__BinaryTree structSymbols;
162 int nextID;
163 int simpleID;
164 struct __ecereNameSpace__ecere__sys__BinaryTree templateTypes;
165 struct ClassDefinition * classDef;
166 unsigned int templateTypesOnly;
167 unsigned int hasNameSpace;
168 } __attribute__ ((gcc_struct));
169
170 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Instantiation;
171
172 struct Instantiation;
173
174 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Declaration;
175
176 struct Declaration;
177
178 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Statement;
179
180 struct Statement;
181
182 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TypeName;
183
184 struct TypeName;
185
186 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Initializer;
187
188 struct Initializer;
189
190 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__DataValue;
191
192 struct __ecereNameSpace__ecere__com__DataValue
193 {
194 union
195 {
196 char c;
197 unsigned char uc;
198 short s;
199 unsigned short us;
200 int i;
201 unsigned int ui;
202 void *  p;
203 float f;
204 double d;
205 long long i64;
206 uint64 ui64;
207 } __attribute__ ((gcc_struct));
208 } __attribute__ ((gcc_struct));
209
210 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Expression;
211
212 struct Expression;
213
214 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateDatatype;
215
216 struct TemplateDatatype;
217
218 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateArgument;
219
220 struct TemplateArgument;
221
222 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateParameter;
223
224 struct TemplateParameter;
225
226 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Specifier;
227
228 struct Specifier;
229
230 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Identifier;
231
232 struct Identifier;
233
234 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Declarator;
235
236 struct Declarator;
237
238 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_FunctionDefinition;
239
240 struct FunctionDefinition;
241
242 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_DBTableDef;
243
244 struct DBTableDef;
245
246 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_External;
247
248 struct External;
249
250 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ModuleImport;
251
252 struct ModuleImport
253 {
254 struct ModuleImport * prev;
255 struct ModuleImport * next;
256 char *  name;
257 struct __ecereNameSpace__ecere__sys__OldList classes;
258 struct __ecereNameSpace__ecere__sys__OldList functions;
259 int importType;
260 int importAccess;
261 } __attribute__ ((gcc_struct));
262
263 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ClassImport;
264
265 struct ClassImport
266 {
267 struct ClassImport * prev;
268 struct ClassImport * next;
269 char *  name;
270 struct __ecereNameSpace__ecere__sys__OldList methods;
271 struct __ecereNameSpace__ecere__sys__OldList properties;
272 unsigned int itself;
273 unsigned int isRemote;
274 } __attribute__ ((gcc_struct));
275
276 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Symbol;
277
278 struct Symbol
279 {
280 char *  string;
281 struct Symbol * parent;
282 struct Symbol * left;
283 struct Symbol * right;
284 int depth;
285 struct Type * type;
286 union
287 {
288 struct __ecereNameSpace__ecere__com__Method * method;
289 struct __ecereNameSpace__ecere__com__Property * _property;
290 struct __ecereNameSpace__ecere__com__Class * registered;
291 } __attribute__ ((gcc_struct));
292 int id;
293 int idCode;
294 union
295 {
296 struct
297 {
298 struct External * pointerExternal;
299 struct External * structExternal;
300 } __attribute__ ((gcc_struct));
301 struct
302 {
303 struct External * externalGet;
304 struct External * externalSet;
305 struct External * externalPtr;
306 struct External * externalIsSet;
307 } __attribute__ ((gcc_struct));
308 struct
309 {
310 struct External * methodExternal;
311 struct External * methodCodeExternal;
312 } __attribute__ ((gcc_struct));
313 } __attribute__ ((gcc_struct));
314 unsigned int imported;
315 unsigned int declaredStructSym;
316 struct __ecereNameSpace__ecere__com__Class * _class;
317 unsigned int declaredStruct;
318 unsigned int needConstructor;
319 unsigned int needDestructor;
320 char *  constructorName;
321 char *  structName;
322 char *  className;
323 char *  destructorName;
324 struct ModuleImport * module;
325 struct ClassImport * _import;
326 struct Location nameLoc;
327 unsigned int isParam;
328 unsigned int isRemote;
329 unsigned int isStruct;
330 unsigned int fireWatchersDone;
331 int declaring;
332 unsigned int classData;
333 unsigned int isStatic;
334 char *  shortName;
335 struct __ecereNameSpace__ecere__sys__OldList *  templateParams;
336 struct __ecereNameSpace__ecere__sys__OldList templatedClasses;
337 struct Context * ctx;
338 int isIterator;
339 struct Expression * propCategory;
340 } __attribute__ ((gcc_struct));
341
342 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Type;
343
344 struct Type;
345
346 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Class;
347
348 struct __ecereNameSpace__ecere__com__Class
349 {
350 struct __ecereNameSpace__ecere__com__Class * prev;
351 struct __ecereNameSpace__ecere__com__Class * next;
352 char *  name;
353 int offset;
354 int structSize;
355 int (* *  _vTbl)();
356 int vTblSize;
357 int (*  Constructor)(struct __ecereNameSpace__ecere__com__Instance *);
358 void (*  Destructor)(struct __ecereNameSpace__ecere__com__Instance *);
359 int offsetClass;
360 int sizeClass;
361 struct __ecereNameSpace__ecere__com__Class * base;
362 struct __ecereNameSpace__ecere__sys__BinaryTree methods;
363 struct __ecereNameSpace__ecere__sys__BinaryTree members;
364 struct __ecereNameSpace__ecere__sys__BinaryTree prop;
365 struct __ecereNameSpace__ecere__sys__OldList membersAndProperties;
366 struct __ecereNameSpace__ecere__sys__BinaryTree classProperties;
367 struct __ecereNameSpace__ecere__sys__OldList derivatives;
368 int memberID;
369 int startMemberID;
370 int type;
371 struct __ecereNameSpace__ecere__com__Instance * module;
372 struct __ecereNameSpace__ecere__com__NameSpace *  nameSpace;
373 char *  dataTypeString;
374 struct Type * dataType;
375 int typeSize;
376 int defaultAlignment;
377 void (*  Initialize)();
378 int memberOffset;
379 struct __ecereNameSpace__ecere__sys__OldList selfWatchers;
380 char *  designerClass;
381 unsigned int noExpansion;
382 char *  defaultProperty;
383 unsigned int comRedefinition;
384 int count;
385 unsigned int isRemote;
386 unsigned int internalDecl;
387 void *  data;
388 unsigned int computeSize;
389 int structAlignment;
390 int destructionWatchOffset;
391 unsigned int fixed;
392 struct __ecereNameSpace__ecere__sys__OldList delayedCPValues;
393 int inheritanceAccess;
394 char *  fullName;
395 void *  symbol;
396 struct __ecereNameSpace__ecere__sys__OldList conversions;
397 struct __ecereNameSpace__ecere__sys__OldList templateParams;
398 struct __ecereNameSpace__ecere__com__ClassTemplateArgument *  templateArgs;
399 struct __ecereNameSpace__ecere__com__Class * templateClass;
400 struct __ecereNameSpace__ecere__sys__OldList templatized;
401 int numParams;
402 } __attribute__ ((gcc_struct));
403
404 extern long long __ecereNameSpace__ecere__com__eClass_GetProperty(struct __ecereNameSpace__ecere__com__Class * _class, char *  name);
405
406 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Instance;
407
408 struct __ecereNameSpace__ecere__com__Instance
409 {
410 int (* *  _vTbl)();
411 struct __ecereNameSpace__ecere__com__Class * _class;
412 int _refCount;
413 } __attribute__ ((gcc_struct));
414
415 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__DataMember;
416
417 struct __ecereNameSpace__ecere__com__DataMember
418 {
419 struct __ecereNameSpace__ecere__com__DataMember * prev;
420 struct __ecereNameSpace__ecere__com__DataMember * next;
421 char *  name;
422 unsigned int isProperty;
423 int memberAccess;
424 int id;
425 struct __ecereNameSpace__ecere__com__Class * _class;
426 char *  dataTypeString;
427 struct __ecereNameSpace__ecere__com__Class * dataTypeClass;
428 struct Type * dataType;
429 int type;
430 int offset;
431 int memberID;
432 struct __ecereNameSpace__ecere__sys__OldList members;
433 struct __ecereNameSpace__ecere__sys__BinaryTree membersAlpha;
434 int memberOffset;
435 int structAlignment;
436 } __attribute__ ((gcc_struct));
437
438 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__SerialBuffer;
439
440 struct __ecereNameSpace__ecere__com__SerialBuffer
441 {
442 unsigned char *  _buffer;
443 unsigned int count;
444 unsigned int _size;
445 unsigned int pos;
446 } __attribute__ ((gcc_struct));
447
448 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__ClassTemplateArgument;
449
450 struct __ecereNameSpace__ecere__com__ClassTemplateArgument
451 {
452 union
453 {
454 struct
455 {
456 char *  dataTypeString;
457 struct __ecereNameSpace__ecere__com__Class * dataTypeClass;
458 } __attribute__ ((gcc_struct));
459 struct __ecereNameSpace__ecere__com__DataValue expression;
460 struct
461 {
462 char *  memberString;
463 union
464 {
465 struct __ecereNameSpace__ecere__com__DataMember * member;
466 struct __ecereNameSpace__ecere__com__Property * prop;
467 struct __ecereNameSpace__ecere__com__Method * method;
468 } __attribute__ ((gcc_struct));
469 } __attribute__ ((gcc_struct));
470 } __attribute__ ((gcc_struct));
471 } __attribute__ ((gcc_struct));
472
473 static struct Context * globalContext;
474
475 static struct __ecereNameSpace__ecere__com__Instance * privateModule;
476
477 static struct ModuleImport * mainModule;
478
479 struct __ecereNameSpace__ecere__sys__OldList _excludedSymbols = 
480 {
481 0, 0, 0, (unsigned int)&((struct Symbol *)(void *)0)->left, 0
482 };
483
484 static struct __ecereNameSpace__ecere__sys__OldList defines, imports;
485
486 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__NameSpace;
487
488 struct __ecereNameSpace__ecere__com__NameSpace
489 {
490 char *  name;
491 struct __ecereNameSpace__ecere__com__NameSpace *  btParent;
492 struct __ecereNameSpace__ecere__com__NameSpace *  left;
493 struct __ecereNameSpace__ecere__com__NameSpace *  right;
494 int depth;
495 struct __ecereNameSpace__ecere__com__NameSpace *  parent;
496 struct __ecereNameSpace__ecere__sys__BinaryTree nameSpaces;
497 struct __ecereNameSpace__ecere__sys__BinaryTree classes;
498 struct __ecereNameSpace__ecere__sys__BinaryTree defines;
499 struct __ecereNameSpace__ecere__sys__BinaryTree functions;
500 } __attribute__ ((gcc_struct));
501
502 static struct __ecereNameSpace__ecere__com__NameSpace globalData;
503
504 static struct __ecereNameSpace__ecere__sys__OldList _precompDefines;
505
506 extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__sys__FileOpen(char *  fileName, int mode);
507
508 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_MethodImport;
509
510 struct MethodImport
511 {
512 struct MethodImport * prev;
513 struct MethodImport * next;
514 char *  name;
515 unsigned int isVirtual;
516 } __attribute__ ((gcc_struct));
517
518 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_PropertyImport;
519
520 struct PropertyImport
521 {
522 struct PropertyImport * prev;
523 struct PropertyImport * next;
524 char *  name;
525 unsigned int isVirtual;
526 unsigned int hasSet;
527 unsigned int hasGet;
528 } __attribute__ ((gcc_struct));
529
530 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_FunctionImport;
531
532 struct FunctionImport
533 {
534 struct FunctionImport * prev;
535 struct FunctionImport * next;
536 char *  name;
537 } __attribute__ ((gcc_struct));
538
539 int __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(struct __ecereNameSpace__ecere__com__Instance * this, char *  format, ...);
540
541 extern void __ecereNameSpace__ecere__com__eInstance_DecRef(struct __ecereNameSpace__ecere__com__Instance * instance);
542
543 static void OutputImports(char * fileName)
544 {
545 struct __ecereNameSpace__ecere__com__Instance * f = __ecereNameSpace__ecere__sys__FileOpen(fileName, 2);
546
547 if(f)
548 {
549 if(imports.first)
550 {
551 struct ModuleImport * module;
552
553 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "[Imported Modules]\n");
554 for(module = imports.first; module; module = module->next)
555 {
556 struct ClassImport * _class;
557 struct FunctionImport * function;
558
559 if(module->name)
560 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "   %s\n", module->name);
561 else
562 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "   [This]\n");
563 if(module->importType == 1)
564 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "      [Static]\n");
565 else if(module->importType == 2)
566 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "      [Remote]\n");
567 if(module->importAccess == 2)
568 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "      [Private]\n");
569 else
570 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "      [Public]\n");
571 if(module->classes.first)
572 {
573 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "      [Imported Classes]\n");
574 for(_class = module->classes.first; _class; _class = _class->next)
575 {
576 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "         %s\n", _class->name);
577 if(_class->itself)
578 {
579 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "            [Instantiated]\n");
580 }
581 if(_class->isRemote)
582 {
583 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "            [Remote]\n");
584 }
585 if(_class->methods.first)
586 {
587 struct MethodImport * method;
588
589 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "            [Imported Methods]\n");
590 for(method = _class->methods.first; method; method = method->next)
591 {
592 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "               %s\n", method->name);
593 if(method->isVirtual)
594 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "                  [Virtual]\n");
595 }
596 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "               .\n");
597 }
598 if(_class->properties.first)
599 {
600 struct PropertyImport * prop;
601
602 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "            [Imported Properties]\n");
603 for(prop = _class->properties.first; prop; prop = prop->next)
604 {
605 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "               %s\n", prop->name);
606 if(prop->isVirtual)
607 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "                  [Virtual]\n");
608 if(prop->hasSet)
609 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "                  [Set]\n");
610 if(prop->hasGet)
611 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "                  [Get]\n");
612 }
613 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "               .\n");
614 }
615 }
616 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "        .\n");
617 }
618 if(module->functions.first)
619 {
620 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "      [Imported Functions]\n");
621 for(function = module->functions.first; function; function = function->next)
622 {
623 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "         %s\n", function->name);
624 }
625 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "        .\n");
626 }
627 }
628 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "   .\n");
629 }
630 }
631 (__ecereNameSpace__ecere__com__eInstance_DecRef(f), f = 0);
632 }
633
634 static struct __ecereNameSpace__ecere__com__Class * __ecereClass_CompilerApp;
635
636 extern int __ecereNameSpace__ecere__com__GetRuntimePlatform(void);
637
638 extern int GetHostBits(void);
639
640 extern void SetSymbolsDir(char *  s);
641
642 extern int strcmp(const char * , const char * );
643
644 extern size_t strlen(const char * );
645
646 extern char *  strcpy(char * , const char * );
647
648 extern void SetBuildingEcereCom(unsigned int b);
649
650 extern void SetBuildingEcereComModule(unsigned int b);
651
652 extern char *  __ecereNameSpace__ecere__sys__CopyString(char *  string);
653
654 extern char *  GetOutputFile(void);
655
656 extern void SetOutputFile(char *  s);
657
658 extern char *  GetSourceFile(void);
659
660 extern void SetSourceFile(char *  s);
661
662 extern void SetMemoryGuard(unsigned int b);
663
664 extern void SetDefaultNameSpace(char *  s);
665
666 extern void SetStrictNameSpaces(unsigned int b);
667
668 extern void SetOutputLineNumbers(unsigned int value);
669
670 extern char *  __ecereNameSpace__ecere__sys__PathCat(char *  string, char *  addedPath);
671
672 extern char *  __ecereNameSpace__ecere__sys__ChangeExtension(char *  string, char *  ext, char *  output);
673
674 extern int printf(char * , ...);
675
676 extern char *  __ecereNameSpace__ecere__GetTranslatedString(struct __ecereNameSpace__ecere__com__Instance * module, char *  string, char *  stringAndContext);
677
678 extern struct __ecereNameSpace__ecere__com__Instance * __thisModule;
679
680 extern void SetGlobalData(struct __ecereNameSpace__ecere__com__NameSpace *  nameSpace);
681
682 extern void SetExcludedSymbols(struct __ecereNameSpace__ecere__sys__OldList *  list);
683
684 extern void SetGlobalContext(struct Context * context);
685
686 extern void SetCurrentContext(struct Context * context);
687
688 extern void SetTopContext(struct Context * context);
689
690 extern void SetDefines(struct __ecereNameSpace__ecere__sys__OldList *  list);
691
692 extern void SetImports(struct __ecereNameSpace__ecere__sys__OldList *  list);
693
694 extern void SetInCompiler(unsigned int b);
695
696 extern void SetTargetPlatform(int platform);
697
698 extern void SetTargetBits(int bits);
699
700 extern void SetEchoOn(unsigned int b);
701
702 extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__com____ecere_COM_Initialize(unsigned int guiApp, int argc, char *  argv[]);
703
704 extern void SetPrivateModule(struct __ecereNameSpace__ecere__com__Instance * module);
705
706 extern struct Type * ProcessTypeString(char *  string, unsigned int staticMethod);
707
708 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_GlobalData;
709
710 struct GlobalData
711 {
712 uintptr_t key;
713 struct __ecereNameSpace__ecere__sys__BTNode * parent;
714 struct __ecereNameSpace__ecere__sys__BTNode * left;
715 struct __ecereNameSpace__ecere__sys__BTNode * right;
716 int depth;
717 struct __ecereNameSpace__ecere__com__Instance * module;
718 char *  dataTypeString;
719 struct Type * dataType;
720 void *  symbol;
721 char *  fullName;
722 } __attribute__ ((gcc_struct));
723
724 extern int snprintf(char * , size_t, char * , ...);
725
726 extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__sys__DualPipeOpen(unsigned int mode, char *  commandLine);
727
728 extern void SetFileInput(struct __ecereNameSpace__ecere__com__Instance * file);
729
730 extern void SetMainModule(struct ModuleImport * moduleImport);
731
732 extern char *  __ecereNameSpace__ecere__sys__GetLastDirectory(char *  string, char *  output);
733
734 extern unsigned int __ecereNameSpace__ecere__sys__StripExtension(char *  string);
735
736 extern void resetScanner(void);
737
738 extern char *  GetSymbolsDir(void);
739
740 extern unsigned int LoadSymbols(char *  fileName, int importType, unsigned int loadDllOnly);
741
742 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ImportedModule;
743
744 struct ImportedModule
745 {
746 struct ImportedModule * prev;
747 struct ImportedModule * next;
748 char *  name;
749 int type;
750 int importType;
751 unsigned int globalInstance;
752 unsigned int dllOnly;
753 int importAccess;
754 } __attribute__ ((gcc_struct));
755
756 extern int strcasecmp(const char * , const char * );
757
758 extern unsigned int GetEcereImported(void);
759
760 extern unsigned int GetBuildingEcereCom(void);
761
762 extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__com__eModule_LoadStrict(struct __ecereNameSpace__ecere__com__Instance * fromModule, char *  name, int importAccess);
763
764 extern void ParseEc(void);
765
766 extern void CheckDataRedefinitions(void);
767
768 extern void SetYydebug(unsigned int b);
769
770 extern void SetCurrentNameSpace(char *  s);
771
772 extern void SetDeclMode(int accessMode);
773
774 extern struct __ecereNameSpace__ecere__sys__OldList *  GetAST(void);
775
776 extern void ProcessDBTableDefinitions(void);
777
778 extern void PrePreProcessClassDefinitions(void);
779
780 extern void ComputeModuleClasses(struct __ecereNameSpace__ecere__com__Instance * module);
781
782 extern void PreProcessClassDefinitions(void);
783
784 extern void ProcessClassDefinitions(void);
785
786 extern void ComputeDataTypes(void);
787
788 extern void ProcessInstantiations(void);
789
790 extern void ProcessMemberAccess(void);
791
792 extern void ProcessInstanceDeclarations(void);
793
794 extern void OutputTree(struct __ecereNameSpace__ecere__sys__OldList * ast, struct __ecereNameSpace__ecere__com__Instance * f);
795
796 extern void FreeASTTree(struct __ecereNameSpace__ecere__sys__OldList * ast);
797
798 extern void FreeContext(struct Context * context);
799
800 extern void FreeExcludedSymbols(struct __ecereNameSpace__ecere__sys__OldList * excludedSymbols);
801
802 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Definition;
803
804 struct Definition;
805
806 extern void FreeModuleDefine(struct Definition * def);
807
808 extern void FreeModuleImport(struct ModuleImport * imp);
809
810 extern void FreeTypeData(struct __ecereNameSpace__ecere__com__Instance * privateModule);
811
812 extern void FreeIncludeFiles(void);
813
814 extern void FreeGlobalData(struct __ecereNameSpace__ecere__com__NameSpace * globalDataList);
815
816 extern void OutputIntlStrings(void);
817
818 extern void *  __ecereNameSpace__ecere__com__eInstance_New(struct __ecereNameSpace__ecere__com__Class * _class);
819
820 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__TempFile;
821
822 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Application;
823
824 struct __ecereNameSpace__ecere__com__Application
825 {
826 int argc;
827 char * *  argv;
828 int exitCode;
829 unsigned int isGUIApp;
830 struct __ecereNameSpace__ecere__sys__OldList allModules;
831 char *  parsedCommand;
832 struct __ecereNameSpace__ecere__com__NameSpace systemNameSpace;
833 } __attribute__ ((gcc_struct));
834
835 char *  __ecereProp___ecereNameSpace__ecere__com__Platform_Get_char__PTR_(int this);
836
837 int __ecereProp___ecereNameSpace__ecere__com__Platform_Set_char__PTR_(char *  value);
838
839 extern struct __ecereNameSpace__ecere__com__Property ** __ecereProp___ecereNameSpace__ecere__com__Platform_char__PTR_;
840
841 unsigned int __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(struct __ecereNameSpace__ecere__sys__BinaryTree * this, struct __ecereNameSpace__ecere__sys__BTNode * node);
842
843 void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(struct __ecereNameSpace__ecere__sys__OldList * this, void *  item);
844
845 unsigned int __ecereMethod___ecereNameSpace__ecere__sys__OldList_AddName(struct __ecereNameSpace__ecere__sys__OldList * this, void *  item);
846
847 int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Eof;
848
849 int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Read;
850
851 int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Write;
852
853 int __ecereMethod___ecereNameSpace__ecere__sys__DualPipe_GetExitCode();
854
855 int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek;
856
857 void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Delete(struct __ecereNameSpace__ecere__sys__OldList * this, void *  item);
858
859 void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Free(struct __ecereNameSpace__ecere__sys__OldList * this, void (*  freeFn)(void * ));
860
861 void __ecereMethod_CompilerApp_Main(struct __ecereNameSpace__ecere__com__Instance * this)
862 {
863 void * __ecereTemp1;
864 char * cppCommand = (((void *)0));
865 char * cppOptions = (((void *)0));
866 int cppOptionsLen = 0;
867 int c;
868 unsigned int valid = 0x1;
869 char defaultOutputFile[797];
870 unsigned int buildingBootStrap = 0x0;
871 int targetPlatform = __ecereNameSpace__ecere__com__GetRuntimePlatform();
872 int targetBits = GetHostBits();
873
874 SetSymbolsDir("");
875 for(c = 1; c < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc; c++)
876 {
877 char * arg = ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c];
878
879 if(arg[0] == '-')
880 {
881 if(!strcmp(arg + 1, "m32") || !strcmp(arg + 1, "m64"))
882 {
883 int argLen = strlen(arg);
884 int newLen = cppOptionsLen + 1 + argLen;
885
886 cppOptions = __ecereNameSpace__ecere__com__eSystem_Renew(cppOptions, sizeof(char) * (newLen + 1));
887 cppOptions[cppOptionsLen] = ' ';
888 strcpy(cppOptions + cppOptionsLen + 1, arg);
889 cppOptionsLen = newLen;
890 targetBits = !strcmp(arg + 1, "m32") ? 32 : 64;
891 }
892 else if(arg[1] == 'D')
893 {
894 int argLen = strlen(arg);
895 int newLen = cppOptionsLen + 1 + argLen;
896
897 cppOptions = __ecereNameSpace__ecere__com__eSystem_Renew(cppOptions, sizeof(char) * (newLen + 1));
898 cppOptions[cppOptionsLen] = ' ';
899 strcpy(cppOptions + cppOptionsLen + 1, arg);
900 cppOptionsLen = newLen;
901 if(!strcmp(arg, "-DBUILDING_ECERE_COM"))
902 SetBuildingEcereCom(0x1);
903 else if(!strcmp(arg, "-DECERE_COM_MODULE"))
904 SetBuildingEcereComModule(0x1);
905 else if(!strcmp(arg, "-DECERE_BOOTSTRAP"))
906 buildingBootStrap = 0x1;
907 }
908 else if(arg[1] == 'I')
909 {
910 int argLen = strlen(arg);
911 int newLen = cppOptionsLen + argLen + 3;
912
913 cppOptions = __ecereNameSpace__ecere__com__eSystem_Renew(cppOptions, sizeof(char) * (newLen + 1));
914 cppOptions[cppOptionsLen] = ' ';
915 cppOptions[cppOptionsLen + 1] = '-';
916 cppOptions[cppOptionsLen + 2] = 'I';
917 cppOptions[cppOptionsLen + 3] = '"';
918 strcpy(cppOptions + cppOptionsLen + 4, arg + 2);
919 cppOptions[newLen - 1] = '\"';
920 cppOptions[newLen] = '\0';
921 cppOptionsLen = newLen;
922 }
923 else if(!strcmp(arg + 1, "t"))
924 {
925 if(++c < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
926 targetPlatform = __ecereProp___ecereNameSpace__ecere__com__Platform_Set_char__PTR_(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c]);
927 else
928 valid = 0x0;
929 }
930 else if(!strcmp(arg + 1, "cpp"))
931 {
932 if(++c < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
933 cppCommand = __ecereNameSpace__ecere__sys__CopyString(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c]);
934 else
935 valid = 0x0;
936 }
937 else if(!strcmp(arg + 1, "o"))
938 {
939 if(!GetOutputFile() && c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
940 {
941 SetOutputFile(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c + 1]);
942 c++;
943 }
944 else
945 valid = 0x0;
946 }
947 else if(!strcmp(arg + 1, "c"))
948 {
949 if(!GetSourceFile() && c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
950 {
951 SetSourceFile(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c + 1]);
952 c++;
953 }
954 else
955 valid = 0x0;
956 }
957 else if(!strcmp(arg + 1, "isystem") || !strcmp(arg + 1, "isysroot"))
958 {
959 if(c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
960 {
961 int argLen = strlen(arg);
962 int arg1Len = strlen(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c + 1]);
963 int newLen = cppOptionsLen + argLen + arg1Len + 4;
964
965 cppOptions = __ecereNameSpace__ecere__com__eSystem_Renew(cppOptions, sizeof(char) * (newLen + 1));
966 cppOptions[cppOptionsLen] = ' ';
967 strcpy(cppOptions + cppOptionsLen + 1, arg);
968 cppOptions[cppOptionsLen + argLen + 1] = ' ';
969 cppOptions[cppOptionsLen + argLen + 2] = '"';
970 arg = ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[++c];
971 strcpy(cppOptions + cppOptionsLen + argLen + 3, arg);
972 cppOptions[newLen - 1] = '\"';
973 cppOptions[newLen] = '\0';
974 cppOptionsLen = newLen;
975 }
976 else
977 valid = 0x0;
978 }
979 else if(!strcmp(arg + 1, "symbols"))
980 {
981 if(c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
982 {
983 SetSymbolsDir(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c + 1]);
984 c++;
985 }
986 else
987 valid = 0x0;
988 }
989 else if(!strcmp(arg + 1, "memguard"))
990 {
991 SetMemoryGuard(0x1);
992 }
993 else if(!strcmp(arg + 1, "defaultns"))
994 {
995 if(c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
996 {
997 SetDefaultNameSpace(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c + 1]);
998 c++;
999 }
1000 else
1001 valid = 0x0;
1002 }
1003 else if(!strcmp(arg + 1, "strictns"))
1004 {
1005 SetStrictNameSpaces(0x1);
1006 }
1007 else if(!strcmp(arg + 1, "nolinenumbers"))
1008 {
1009 SetOutputLineNumbers(0x0);
1010 }
1011 }
1012 else
1013 valid = 0x0;
1014 }
1015 if(valid)
1016 {
1017 if(!cppCommand)
1018 cppCommand = __ecereNameSpace__ecere__sys__CopyString("gcc");
1019 if(!GetSourceFile())
1020 valid = 0x0;
1021 else if(!GetOutputFile())
1022 {
1023 strcpy(defaultOutputFile, "");
1024 __ecereNameSpace__ecere__sys__PathCat(defaultOutputFile, GetSourceFile());
1025 __ecereNameSpace__ecere__sys__ChangeExtension(defaultOutputFile, "c", defaultOutputFile);
1026 SetOutputFile(defaultOutputFile);
1027 }
1028 }
1029 if(!valid)
1030 printf(__ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Syntax:\n   ecc [-t <target platform>] [-cpp <c preprocessor>] [-o <output>] [-symbols <outputdir>] [-I<includedir>]* [-isystem <sysincludedir>]* [-D<definition>]* -c <input>\n", (((void *)0))));
1031 else
1032 {
1033 struct __ecereNameSpace__ecere__com__Instance * cppOutput;
1034 char command[3075LL];
1035
1036 SetGlobalData(&globalData);
1037 SetExcludedSymbols(&_excludedSymbols);
1038 SetGlobalContext(globalContext);
1039 SetCurrentContext(globalContext);
1040 SetTopContext(globalContext);
1041 SetDefines(&defines);
1042 SetImports(&imports);
1043 SetInCompiler(0x1);
1044 SetTargetPlatform(targetPlatform);
1045 SetTargetBits(targetBits);
1046 SetEchoOn(0x0);
1047 privateModule = (struct __ecereNameSpace__ecere__com__Instance *)__ecereNameSpace__ecere__com____ecere_COM_Initialize(0x1 | (targetBits == sizeof(uintptr_t) * 8 ? (unsigned int)0 : targetBits == 64 ? (unsigned int)2 : targetBits == 32 ? (unsigned int)4 : (unsigned int)0) | (unsigned int)8, 1, (((void *)0)));
1048 SetPrivateModule(privateModule);
1049 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)(__ecereTemp1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol), ((struct Symbol *)__ecereTemp1)->string = __ecereNameSpace__ecere__sys__CopyString("uint"), ((struct Symbol *)__ecereTemp1)->type = ProcessTypeString("unsigned int", 0x0), ((struct Symbol *)__ecereTemp1)));
1050 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)(__ecereTemp1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol), ((struct Symbol *)__ecereTemp1)->string = __ecereNameSpace__ecere__sys__CopyString("uint64"), ((struct Symbol *)__ecereTemp1)->type = ProcessTypeString("unsigned int64", 0x0), ((struct Symbol *)__ecereTemp1)));
1051 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)(__ecereTemp1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol), ((struct Symbol *)__ecereTemp1)->string = __ecereNameSpace__ecere__sys__CopyString("uint32"), ((struct Symbol *)__ecereTemp1)->type = ProcessTypeString("unsigned int", 0x0), ((struct Symbol *)__ecereTemp1)));
1052 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)(__ecereTemp1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol), ((struct Symbol *)__ecereTemp1)->string = __ecereNameSpace__ecere__sys__CopyString("uint16"), ((struct Symbol *)__ecereTemp1)->type = ProcessTypeString("unsigned short", 0x0), ((struct Symbol *)__ecereTemp1)));
1053 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)(__ecereTemp1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol), ((struct Symbol *)__ecereTemp1)->string = __ecereNameSpace__ecere__sys__CopyString("byte"), ((struct Symbol *)__ecereTemp1)->type = ProcessTypeString("unsigned char", 0x0), ((struct Symbol *)__ecereTemp1)));
1054 if(buildingBootStrap)
1055 {
1056 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)(__ecereTemp1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol), ((struct Symbol *)__ecereTemp1)->string = __ecereNameSpace__ecere__sys__CopyString("intptr_t"), ((struct Symbol *)__ecereTemp1)->type = ProcessTypeString("intptr", 0x0), ((struct Symbol *)__ecereTemp1)));
1057 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)(__ecereTemp1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol), ((struct Symbol *)__ecereTemp1)->string = __ecereNameSpace__ecere__sys__CopyString("uintptr_t"), ((struct Symbol *)__ecereTemp1)->type = ProcessTypeString("uintptr", 0x0), ((struct Symbol *)__ecereTemp1)));
1058 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)(__ecereTemp1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol), ((struct Symbol *)__ecereTemp1)->string = __ecereNameSpace__ecere__sys__CopyString("ssize_t"), ((struct Symbol *)__ecereTemp1)->type = ProcessTypeString("intsize", 0x0), ((struct Symbol *)__ecereTemp1)));
1059 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)(__ecereTemp1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol), ((struct Symbol *)__ecereTemp1)->string = __ecereNameSpace__ecere__sys__CopyString("size_t"), ((struct Symbol *)__ecereTemp1)->type = ProcessTypeString("uintsize", 0x0), ((struct Symbol *)__ecereTemp1)));
1060 }
1061 {
1062 struct GlobalData * data = (data = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_GlobalData), data->fullName = __ecereNameSpace__ecere__sys__CopyString("__thisModule"), data->dataTypeString = __ecereNameSpace__ecere__sys__CopyString("Module"), data->module = privateModule, data);
1063
1064 data->key = (uintptr_t)data->fullName;
1065 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalData.functions, (struct __ecereNameSpace__ecere__sys__BTNode *)data);
1066 }
1067 snprintf(command, sizeof command, "%s%s -x c -E %s\"%s\"", cppCommand, cppOptions ? cppOptions : "", buildingBootStrap ? "" : "-include stdint.h -include sys/types.h ", GetSourceFile());
1068 command[sizeof command - 1] = (char)0;
1069 if((cppOutput = __ecereNameSpace__ecere__sys__DualPipeOpen((((unsigned int)(0x1))), command)))
1070 {
1071 char impFile[797];
1072 struct ImportedModule * module;
1073 char mainModuleName[274];
1074 int exitCode;
1075 struct __ecereNameSpace__ecere__sys__OldList * ast;
1076 struct __ecereNameSpace__ecere__com__Instance * fileInput = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass___ecereNameSpace__ecere__sys__TempFile);
1077
1078 SetFileInput(fileInput);
1079 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&imports, (mainModule = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_ModuleImport)));
1080 SetMainModule(mainModule);
1081 __ecereNameSpace__ecere__sys__GetLastDirectory(GetSourceFile(), mainModuleName);
1082 __ecereNameSpace__ecere__sys__StripExtension(mainModuleName);
1083 module = (__ecereTemp1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_ImportedModule), ((struct ImportedModule *)__ecereTemp1)->name = __ecereNameSpace__ecere__sys__CopyString(mainModuleName), ((struct ImportedModule *)__ecereTemp1)->type = 0, ((struct ImportedModule *)__ecereTemp1));
1084 __ecereMethod___ecereNameSpace__ecere__sys__OldList_AddName(&defines, module);
1085 resetScanner();
1086 while(!((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *))cppOutput->_vTbl[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Eof])(cppOutput))
1087 {
1088 char junk[4096];
1089 int count = ((int (*)(struct __ecereNameSpace__ecere__com__Instance *, void *  buffer, unsigned int size, unsigned int count))cppOutput->_vTbl[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Read])(cppOutput, junk, 1, 4096);
1090
1091 ((int (*)(struct __ecereNameSpace__ecere__com__Instance *, void *  buffer, unsigned int size, unsigned int count))fileInput->_vTbl[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Write])(fileInput, junk, 1, count);
1092 }
1093 exitCode = __ecereMethod___ecereNameSpace__ecere__sys__DualPipe_GetExitCode(cppOutput);
1094 (__ecereNameSpace__ecere__com__eInstance_DecRef(cppOutput), cppOutput = 0);
1095 ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, int pos, int mode))fileInput->_vTbl[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek])(fileInput, 0, 0);
1096 {
1097 char symFile[274];
1098 char symLocation[797];
1099 struct ImportedModule * module, * next;
1100
1101 __ecereNameSpace__ecere__sys__GetLastDirectory(GetSourceFile(), symFile);
1102 __ecereNameSpace__ecere__sys__ChangeExtension(symFile, "sym", symFile);
1103 strcpy(symLocation, GetSymbolsDir());
1104 __ecereNameSpace__ecere__sys__PathCat(symLocation, symFile);
1105 LoadSymbols(symLocation, 3, 0x0);
1106 for(module = defines.first; module; module = next)
1107 {
1108 next = module->next;
1109 if(module->type == 0 && (strcasecmp)(module->name, mainModuleName))
1110 {
1111 (__ecereNameSpace__ecere__com__eSystem_Delete(module->name), module->name = 0);
1112 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Delete(&defines, module);
1113 }
1114 }
1115 if(!GetEcereImported() && !GetBuildingEcereCom())
1116 __ecereNameSpace__ecere__com__eModule_LoadStrict(privateModule, "ecereCOM", 1);
1117 }
1118 ParseEc();
1119 CheckDataRedefinitions();
1120 SetYydebug(0x0);
1121 SetCurrentNameSpace((((void *)0)));
1122 SetDefaultNameSpace((((void *)0)));
1123 SetDeclMode(2);
1124 (__ecereNameSpace__ecere__com__eInstance_DecRef(fileInput), fileInput = 0);
1125 SetFileInput((((void *)0)));
1126 ast = GetAST();
1127 if(!exitCode)
1128 {
1129 ProcessDBTableDefinitions();
1130 PrePreProcessClassDefinitions();
1131 ComputeModuleClasses(privateModule);
1132 PreProcessClassDefinitions();
1133 ComputeModuleClasses(privateModule);
1134 ProcessClassDefinitions();
1135 ComputeDataTypes();
1136 ProcessInstantiations();
1137 ProcessMemberAccess();
1138 ProcessInstanceDeclarations();
1139 strcpy(impFile, GetSymbolsDir());
1140 {
1141 char fileName[274];
1142
1143 __ecereNameSpace__ecere__sys__GetLastDirectory(GetSourceFile(), fileName);
1144 __ecereNameSpace__ecere__sys__PathCat(impFile, fileName);
1145 __ecereNameSpace__ecere__sys__ChangeExtension(impFile, "imp", impFile);
1146 }
1147 if(imports.first)
1148 OutputImports(impFile);
1149 if(!((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->exitCode)
1150 {
1151 struct __ecereNameSpace__ecere__com__Instance * output = __ecereNameSpace__ecere__sys__FileOpen(GetOutputFile(), 2);
1152
1153 if(output)
1154 {
1155 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#if defined(__GNUC__)\n");
1156 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef long long int64;\n");
1157 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef unsigned long long uint64;\n");
1158 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#ifndef _WIN32\n");
1159 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __declspec(x)\n");
1160 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#endif\n");
1161 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#elif defined(__TINYC__)\n");
1162 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#include <stdarg.h>\n");
1163 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __builtin_va_list va_list\n");
1164 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __builtin_va_start va_start\n");
1165 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __builtin_va_end va_end\n");
1166 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#ifdef _WIN32\n");
1167 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define strcasecmp stricmp\n");
1168 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define strncasecmp strnicmp\n");
1169 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __declspec(x) __attribute__((x))\n");
1170 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#else\n");
1171 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __declspec(x)\n");
1172 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#endif\n");
1173 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef long long int64;\n");
1174 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef unsigned long long uint64;\n");
1175 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#else\n");
1176 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef __int64 int64;\n");
1177 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef unsigned __int64 uint64;\n");
1178 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#endif\n");
1179 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#ifdef __BIG_ENDIAN__\n");
1180 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __ENDIAN_PAD(x) (8 - (x))\n");
1181 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#else\n");
1182 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __ENDIAN_PAD(x) 0\n");
1183 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#endif\n");
1184 if(buildingBootStrap)
1185 {
1186 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#include <stdint.h>\n");
1187 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#include <sys/types.h>\n");
1188 }
1189 if(ast)
1190 OutputTree(ast, output);
1191 (__ecereNameSpace__ecere__com__eInstance_DecRef(output), output = 0);
1192 }
1193 }
1194 }
1195 else
1196 ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->exitCode = exitCode;
1197 if(ast)
1198 {
1199 FreeASTTree(ast);
1200 }
1201 }
1202 FreeContext(globalContext);
1203 FreeExcludedSymbols(&_excludedSymbols);
1204 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Free(&defines, FreeModuleDefine);
1205 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Free(&imports, FreeModuleImport);
1206 FreeTypeData(privateModule);
1207 FreeIncludeFiles();
1208 FreeGlobalData(&globalData);
1209 (__ecereNameSpace__ecere__com__eInstance_DecRef(privateModule), privateModule = 0);
1210 }
1211 (__ecereNameSpace__ecere__com__eSystem_Delete(cppCommand), cppCommand = 0);
1212 (__ecereNameSpace__ecere__com__eSystem_Delete(cppOptions), cppOptions = 0);
1213 SetSymbolsDir((((void *)0)));
1214 OutputIntlStrings();
1215 }
1216
1217 extern struct __ecereNameSpace__ecere__com__Class * __ecereNameSpace__ecere__com__eSystem_RegisterClass(int type, char *  name, char *  baseName, int size, int sizeClass, unsigned int (* )(void * ), void (* )(void * ), struct __ecereNameSpace__ecere__com__Instance * module, int declMode, int inheritanceAccess);
1218
1219 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Module;
1220
1221 struct __ecereNameSpace__ecere__com__Module
1222 {
1223 struct __ecereNameSpace__ecere__com__Instance * application;
1224 struct __ecereNameSpace__ecere__sys__OldList classes;
1225 struct __ecereNameSpace__ecere__sys__OldList defines;
1226 struct __ecereNameSpace__ecere__sys__OldList functions;
1227 struct __ecereNameSpace__ecere__sys__OldList modules;
1228 struct __ecereNameSpace__ecere__com__Instance * prev;
1229 struct __ecereNameSpace__ecere__com__Instance * next;
1230 char *  name;
1231 void *  library;
1232 void *  Unload;
1233 int importType;
1234 int origImportType;
1235 struct __ecereNameSpace__ecere__com__NameSpace privateNameSpace;
1236 struct __ecereNameSpace__ecere__com__NameSpace publicNameSpace;
1237 } __attribute__ ((gcc_struct));
1238
1239 extern struct __ecereNameSpace__ecere__com__Method * __ecereNameSpace__ecere__com__eClass_AddMethod(struct __ecereNameSpace__ecere__com__Class * _class, char *  name, char *  type, void *  function, int declMode);
1240
1241 void __ecereRegisterModule_ecc(struct __ecereNameSpace__ecere__com__Instance * module)
1242 {
1243 struct __ecereNameSpace__ecere__com__Class * class;
1244
1245 class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(0, "CompilerApp", "ecere::com::Application", 0, 0, 0, 0, module, 2, 1);
1246 if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application && class)
1247 __ecereClass_CompilerApp = class;
1248 __ecereNameSpace__ecere__com__eClass_AddMethod(class, "Main", 0, __ecereMethod_CompilerApp_Main, 1);
1249 }
1250
1251 void __ecereUnregisterModule_ecc(struct __ecereNameSpace__ecere__com__Instance * module)
1252 {
1253
1254 }
1255
1256 int __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_CompareString(struct __ecereNameSpace__ecere__sys__BinaryTree * this, char *  a, char *  b);
1257
1258 void __ecereCreateModuleInstances_ecc()
1259 {
1260 globalContext = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Context);
1261 (globalData.classes.CompareKey = (void *)__ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_CompareString, globalData.defines.CompareKey = (void *)__ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_CompareString, globalData.functions.CompareKey = (void *)__ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_CompareString, globalData.nameSpaces.CompareKey = (void *)__ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_CompareString);
1262 }
1263
1264 void __ecereDestroyModuleInstances_ecc()
1265 {
1266 ((globalContext ? (__ecereClass_Context->Destructor ? __ecereClass_Context->Destructor(globalContext) : 0, __ecereNameSpace__ecere__com__eSystem_Delete(globalContext)) : 0), globalContext = 0);
1267 }
1268