compiler/libec Improvements to conversion from AST->Type class, and to outputting...
[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 extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__sys__FileOpen(char *  fileName, int mode);
505
506 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_MethodImport;
507
508 struct MethodImport
509 {
510 struct MethodImport * prev;
511 struct MethodImport * next;
512 char *  name;
513 unsigned int isVirtual;
514 } __attribute__ ((gcc_struct));
515
516 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_PropertyImport;
517
518 struct PropertyImport
519 {
520 struct PropertyImport * prev;
521 struct PropertyImport * next;
522 char *  name;
523 unsigned int isVirtual;
524 unsigned int hasSet;
525 unsigned int hasGet;
526 } __attribute__ ((gcc_struct));
527
528 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_FunctionImport;
529
530 struct FunctionImport
531 {
532 struct FunctionImport * prev;
533 struct FunctionImport * next;
534 char *  name;
535 } __attribute__ ((gcc_struct));
536
537 int __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(struct __ecereNameSpace__ecere__com__Instance * this, char *  format, ...);
538
539 extern void __ecereNameSpace__ecere__com__eInstance_DecRef(struct __ecereNameSpace__ecere__com__Instance * instance);
540
541 static void OutputImports(char * fileName)
542 {
543 struct __ecereNameSpace__ecere__com__Instance * f = __ecereNameSpace__ecere__sys__FileOpen(fileName, 2);
544
545 if(f)
546 {
547 if(imports.first)
548 {
549 struct ModuleImport * module;
550
551 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "[Imported Modules]\n");
552 for(module = imports.first; module; module = module->next)
553 {
554 struct ClassImport * _class;
555 struct FunctionImport * function;
556
557 if(module->name)
558 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "   %s\n", module->name);
559 else
560 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "   [This]\n");
561 if(module->importType == 1)
562 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "      [Static]\n");
563 else if(module->importType == 2)
564 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "      [Remote]\n");
565 if(module->importAccess == 2)
566 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "      [Private]\n");
567 else
568 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "      [Public]\n");
569 if(module->classes.first)
570 {
571 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "      [Imported Classes]\n");
572 for(_class = module->classes.first; _class; _class = _class->next)
573 {
574 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "         %s\n", _class->name);
575 if(_class->itself)
576 {
577 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "            [Instantiated]\n");
578 }
579 if(_class->isRemote)
580 {
581 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "            [Remote]\n");
582 }
583 if(_class->methods.first)
584 {
585 struct MethodImport * method;
586
587 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "            [Imported Methods]\n");
588 for(method = _class->methods.first; method; method = method->next)
589 {
590 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "               %s\n", method->name);
591 if(method->isVirtual)
592 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "                  [Virtual]\n");
593 }
594 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "               .\n");
595 }
596 if(_class->properties.first)
597 {
598 struct PropertyImport * prop;
599
600 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "            [Imported Properties]\n");
601 for(prop = _class->properties.first; prop; prop = prop->next)
602 {
603 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "               %s\n", prop->name);
604 if(prop->isVirtual)
605 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "                  [Virtual]\n");
606 if(prop->hasSet)
607 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "                  [Set]\n");
608 if(prop->hasGet)
609 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "                  [Get]\n");
610 }
611 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "               .\n");
612 }
613 }
614 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "        .\n");
615 }
616 if(module->functions.first)
617 {
618 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "      [Imported Functions]\n");
619 for(function = module->functions.first; function; function = function->next)
620 {
621 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "         %s\n", function->name);
622 }
623 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "        .\n");
624 }
625 }
626 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "   .\n");
627 }
628 }
629 (__ecereNameSpace__ecere__com__eInstance_DecRef(f), f = 0);
630 }
631
632 static struct __ecereNameSpace__ecere__com__Class * __ecereClass_CompilerApp;
633
634 extern int __ecereNameSpace__ecere__com__GetRuntimePlatform(void);
635
636 extern int GetHostBits(void);
637
638 extern void SetSymbolsDir(char *  s);
639
640 extern int strcmp(const char * , const char * );
641
642 extern size_t strlen(const char * );
643
644 extern char *  strcpy(char * , const char * );
645
646 extern void SetBuildingEcereCom(unsigned int b);
647
648 extern void SetBuildingEcereComModule(unsigned int b);
649
650 extern char *  __ecereNameSpace__ecere__sys__CopyString(char *  string);
651
652 extern char *  GetOutputFile(void);
653
654 extern void SetOutputFile(char *  s);
655
656 extern char *  GetSourceFile(void);
657
658 extern void SetSourceFile(char *  s);
659
660 extern void SetMemoryGuard(unsigned int b);
661
662 extern void SetDefaultNameSpace(char *  s);
663
664 extern void SetStrictNameSpaces(unsigned int b);
665
666 extern void SetOutputLineNumbers(unsigned int value);
667
668 extern char *  __ecereNameSpace__ecere__sys__PathCat(char *  string, char *  addedPath);
669
670 extern char *  __ecereNameSpace__ecere__sys__ChangeExtension(char *  string, char *  ext, char *  output);
671
672 extern int printf(char * , ...);
673
674 extern char *  __ecereNameSpace__ecere__GetTranslatedString(struct __ecereNameSpace__ecere__com__Instance * module, char *  string, char *  stringAndContext);
675
676 extern struct __ecereNameSpace__ecere__com__Instance * __thisModule;
677
678 extern void SetGlobalData(struct __ecereNameSpace__ecere__com__NameSpace *  nameSpace);
679
680 extern void SetExcludedSymbols(struct __ecereNameSpace__ecere__sys__OldList *  list);
681
682 extern void SetGlobalContext(struct Context * context);
683
684 extern void SetCurrentContext(struct Context * context);
685
686 extern void SetTopContext(struct Context * context);
687
688 extern void SetDefines(struct __ecereNameSpace__ecere__sys__OldList *  list);
689
690 extern void SetImports(struct __ecereNameSpace__ecere__sys__OldList *  list);
691
692 extern void SetInCompiler(unsigned int b);
693
694 extern void SetTargetPlatform(int platform);
695
696 extern void SetTargetBits(int bits);
697
698 extern void SetEchoOn(unsigned int b);
699
700 extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__com____ecere_COM_Initialize(unsigned int guiApp, int argc, char *  argv[]);
701
702 extern void SetPrivateModule(struct __ecereNameSpace__ecere__com__Instance * module);
703
704 extern struct Type * ProcessTypeString(char *  string, unsigned int staticMethod);
705
706 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_GlobalData;
707
708 struct GlobalData
709 {
710 uintptr_t key;
711 struct __ecereNameSpace__ecere__sys__BTNode * parent;
712 struct __ecereNameSpace__ecere__sys__BTNode * left;
713 struct __ecereNameSpace__ecere__sys__BTNode * right;
714 int depth;
715 struct __ecereNameSpace__ecere__com__Instance * module;
716 char *  dataTypeString;
717 struct Type * dataType;
718 void *  symbol;
719 char *  fullName;
720 } __attribute__ ((gcc_struct));
721
722 extern int snprintf(char * , size_t, char * , ...);
723
724 extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__sys__DualPipeOpen(unsigned int mode, char *  commandLine);
725
726 extern void SetFileInput(struct __ecereNameSpace__ecere__com__Instance * file);
727
728 extern void SetMainModule(struct ModuleImport * moduleImport);
729
730 extern char *  __ecereNameSpace__ecere__sys__GetLastDirectory(char *  string, char *  output);
731
732 extern unsigned int __ecereNameSpace__ecere__sys__StripExtension(char *  string);
733
734 extern void resetScanner(void);
735
736 extern char *  GetSymbolsDir(void);
737
738 extern unsigned int LoadSymbols(char *  fileName, int importType, unsigned int loadDllOnly);
739
740 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ImportedModule;
741
742 struct ImportedModule
743 {
744 struct ImportedModule * prev;
745 struct ImportedModule * next;
746 char *  name;
747 int type;
748 int importType;
749 unsigned int globalInstance;
750 unsigned int dllOnly;
751 int importAccess;
752 } __attribute__ ((gcc_struct));
753
754 extern int strcasecmp(const char * , const char * );
755
756 extern unsigned int GetEcereImported(void);
757
758 extern unsigned int GetBuildingEcereCom(void);
759
760 extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__com__eModule_LoadStrict(struct __ecereNameSpace__ecere__com__Instance * fromModule, char *  name, int importAccess);
761
762 extern void ParseEc(void);
763
764 extern void CheckDataRedefinitions(void);
765
766 extern void SetYydebug(unsigned int b);
767
768 extern void SetCurrentNameSpace(char *  s);
769
770 extern void SetDeclMode(int accessMode);
771
772 extern struct __ecereNameSpace__ecere__sys__OldList *  GetAST(void);
773
774 extern void ProcessDBTableDefinitions(void);
775
776 extern void PrePreProcessClassDefinitions(void);
777
778 extern void ComputeModuleClasses(struct __ecereNameSpace__ecere__com__Instance * module);
779
780 extern void PreProcessClassDefinitions(void);
781
782 extern void ProcessClassDefinitions(void);
783
784 extern void ComputeDataTypes(void);
785
786 extern void ProcessInstantiations(void);
787
788 extern void ProcessMemberAccess(void);
789
790 extern void ProcessInstanceDeclarations(void);
791
792 extern void OutputTree(struct __ecereNameSpace__ecere__sys__OldList * ast, struct __ecereNameSpace__ecere__com__Instance * f);
793
794 extern void FreeASTTree(struct __ecereNameSpace__ecere__sys__OldList * ast);
795
796 extern void FreeContext(struct Context * context);
797
798 extern void FreeExcludedSymbols(struct __ecereNameSpace__ecere__sys__OldList * excludedSymbols);
799
800 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Definition;
801
802 struct Definition;
803
804 extern void FreeModuleDefine(struct Definition * def);
805
806 extern void FreeModuleImport(struct ModuleImport * imp);
807
808 extern void FreeTypeData(struct __ecereNameSpace__ecere__com__Instance * privateModule);
809
810 extern void FreeIncludeFiles(void);
811
812 extern void FreeGlobalData(struct __ecereNameSpace__ecere__com__NameSpace * globalDataList);
813
814 extern void OutputIntlStrings(void);
815
816 extern void *  __ecereNameSpace__ecere__com__eInstance_New(struct __ecereNameSpace__ecere__com__Class * _class);
817
818 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__TempFile;
819
820 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Application;
821
822 struct __ecereNameSpace__ecere__com__Application
823 {
824 int argc;
825 char * *  argv;
826 int exitCode;
827 unsigned int isGUIApp;
828 struct __ecereNameSpace__ecere__sys__OldList allModules;
829 char *  parsedCommand;
830 struct __ecereNameSpace__ecere__com__NameSpace systemNameSpace;
831 } __attribute__ ((gcc_struct));
832
833 char *  __ecereProp___ecereNameSpace__ecere__com__Platform_Get_char__PTR_(int this);
834
835 int __ecereProp___ecereNameSpace__ecere__com__Platform_Set_char__PTR_(char *  value);
836
837 extern struct __ecereNameSpace__ecere__com__Property ** __ecereProp___ecereNameSpace__ecere__com__Platform_char__PTR_;
838
839 unsigned int __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(struct __ecereNameSpace__ecere__sys__BinaryTree * this, struct __ecereNameSpace__ecere__sys__BTNode * node);
840
841 void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(struct __ecereNameSpace__ecere__sys__OldList * this, void *  item);
842
843 unsigned int __ecereMethod___ecereNameSpace__ecere__sys__OldList_AddName(struct __ecereNameSpace__ecere__sys__OldList * this, void *  item);
844
845 int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Eof;
846
847 int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Read;
848
849 int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Write;
850
851 int __ecereMethod___ecereNameSpace__ecere__sys__DualPipe_GetExitCode();
852
853 int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek;
854
855 void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Delete(struct __ecereNameSpace__ecere__sys__OldList * this, void *  item);
856
857 void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Free(struct __ecereNameSpace__ecere__sys__OldList * this, void (*  freeFn)(void * ));
858
859 void __ecereMethod_CompilerApp_Main(struct __ecereNameSpace__ecere__com__Instance * this)
860 {
861 char * cppCommand = (((void *)0));
862 char * cppOptions = (((void *)0));
863 int cppOptionsLen = 0;
864 int c;
865 unsigned int valid = 0x1;
866 char defaultOutputFile[797];
867 unsigned int buildingBootStrap = 0x0;
868 int targetPlatform = __ecereNameSpace__ecere__com__GetRuntimePlatform();
869 int targetBits = GetHostBits();
870
871 SetSymbolsDir("");
872 for(c = 1; c < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc; c++)
873 {
874 char * arg = ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c];
875
876 if(arg[0] == '-')
877 {
878 if(!strcmp(arg + 1, "m32") || !strcmp(arg + 1, "m64"))
879 {
880 int argLen = strlen(arg);
881 int newLen = cppOptionsLen + 1 + argLen;
882
883 cppOptions = __ecereNameSpace__ecere__com__eSystem_Renew(cppOptions, sizeof(char) * (newLen + 1));
884 cppOptions[cppOptionsLen] = ' ';
885 strcpy(cppOptions + cppOptionsLen + 1, arg);
886 cppOptionsLen = newLen;
887 targetBits = !strcmp(arg + 1, "m32") ? 32 : 64;
888 }
889 else if(arg[1] == 'D')
890 {
891 int argLen = strlen(arg);
892 int newLen = cppOptionsLen + 1 + argLen;
893
894 cppOptions = __ecereNameSpace__ecere__com__eSystem_Renew(cppOptions, sizeof(char) * (newLen + 1));
895 cppOptions[cppOptionsLen] = ' ';
896 strcpy(cppOptions + cppOptionsLen + 1, arg);
897 cppOptionsLen = newLen;
898 if(!strcmp(arg, "-DBUILDING_ECERE_COM"))
899 SetBuildingEcereCom(0x1);
900 else if(!strcmp(arg, "-DECERE_COM_MODULE"))
901 SetBuildingEcereComModule(0x1);
902 else if(!strcmp(arg, "-DECERE_BOOTSTRAP"))
903 buildingBootStrap = 0x1;
904 }
905 else if(arg[1] == 'I')
906 {
907 int argLen = strlen(arg);
908 int newLen = cppOptionsLen + argLen + 3;
909
910 cppOptions = __ecereNameSpace__ecere__com__eSystem_Renew(cppOptions, sizeof(char) * (newLen + 1));
911 cppOptions[cppOptionsLen] = ' ';
912 cppOptions[cppOptionsLen + 1] = '-';
913 cppOptions[cppOptionsLen + 2] = 'I';
914 cppOptions[cppOptionsLen + 3] = '"';
915 strcpy(cppOptions + cppOptionsLen + 4, arg + 2);
916 cppOptions[newLen - 1] = '\"';
917 cppOptions[newLen] = '\0';
918 cppOptionsLen = newLen;
919 }
920 else if(!strcmp(arg + 1, "t"))
921 {
922 if(++c < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
923 targetPlatform = __ecereProp___ecereNameSpace__ecere__com__Platform_Set_char__PTR_(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c]);
924 else
925 valid = 0x0;
926 }
927 else if(!strcmp(arg + 1, "cpp"))
928 {
929 if(++c < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
930 cppCommand = __ecereNameSpace__ecere__sys__CopyString(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c]);
931 else
932 valid = 0x0;
933 }
934 else if(!strcmp(arg + 1, "o"))
935 {
936 if(!GetOutputFile() && c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
937 {
938 SetOutputFile(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c + 1]);
939 c++;
940 }
941 else
942 valid = 0x0;
943 }
944 else if(!strcmp(arg + 1, "c"))
945 {
946 if(!GetSourceFile() && c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
947 {
948 SetSourceFile(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c + 1]);
949 c++;
950 }
951 else
952 valid = 0x0;
953 }
954 else if(!strcmp(arg + 1, "isystem") || !strcmp(arg + 1, "isysroot"))
955 {
956 if(c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
957 {
958 int argLen = strlen(arg);
959 int arg1Len = strlen(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c + 1]);
960 int newLen = cppOptionsLen + argLen + arg1Len + 4;
961
962 cppOptions = __ecereNameSpace__ecere__com__eSystem_Renew(cppOptions, sizeof(char) * (newLen + 1));
963 cppOptions[cppOptionsLen] = ' ';
964 strcpy(cppOptions + cppOptionsLen + 1, arg);
965 cppOptions[cppOptionsLen + argLen + 1] = ' ';
966 cppOptions[cppOptionsLen + argLen + 2] = '"';
967 arg = ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[++c];
968 strcpy(cppOptions + cppOptionsLen + argLen + 3, arg);
969 cppOptions[newLen - 1] = '\"';
970 cppOptions[newLen] = '\0';
971 cppOptionsLen = newLen;
972 }
973 else
974 valid = 0x0;
975 }
976 else if(!strcmp(arg + 1, "symbols"))
977 {
978 if(c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
979 {
980 SetSymbolsDir(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c + 1]);
981 c++;
982 }
983 else
984 valid = 0x0;
985 }
986 else if(!strcmp(arg + 1, "memguard"))
987 {
988 SetMemoryGuard(0x1);
989 }
990 else if(!strcmp(arg + 1, "defaultns"))
991 {
992 if(c + 1 < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
993 {
994 SetDefaultNameSpace(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c + 1]);
995 c++;
996 }
997 else
998 valid = 0x0;
999 }
1000 else if(!strcmp(arg + 1, "strictns"))
1001 {
1002 SetStrictNameSpaces(0x1);
1003 }
1004 else if(!strcmp(arg + 1, "nolinenumbers"))
1005 {
1006 SetOutputLineNumbers(0x0);
1007 }
1008 }
1009 else
1010 valid = 0x0;
1011 }
1012 if(valid)
1013 {
1014 if(!cppCommand)
1015 cppCommand = __ecereNameSpace__ecere__sys__CopyString("gcc");
1016 if(!GetSourceFile())
1017 valid = 0x0;
1018 else if(!GetOutputFile())
1019 {
1020 strcpy(defaultOutputFile, "");
1021 __ecereNameSpace__ecere__sys__PathCat(defaultOutputFile, GetSourceFile());
1022 __ecereNameSpace__ecere__sys__ChangeExtension(defaultOutputFile, "c", defaultOutputFile);
1023 SetOutputFile(defaultOutputFile);
1024 }
1025 }
1026 if(!valid)
1027 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))));
1028 else
1029 {
1030 struct __ecereNameSpace__ecere__com__Instance * cppOutput;
1031 char command[3075LL];
1032
1033 SetGlobalData(&globalData);
1034 SetExcludedSymbols(&_excludedSymbols);
1035 SetGlobalContext(globalContext);
1036 SetCurrentContext(globalContext);
1037 SetTopContext(globalContext);
1038 SetDefines(&defines);
1039 SetImports(&imports);
1040 SetInCompiler(0x1);
1041 SetTargetPlatform(targetPlatform);
1042 SetTargetBits(targetBits);
1043 SetEchoOn(0x0);
1044 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)));
1045 SetPrivateModule(privateModule);
1046 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
1047 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
1048
1049 __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint"), __ecereInstance1->type = ProcessTypeString("unsigned int", 0x0), __ecereInstance1;
1050 }));
1051 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
1052 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
1053
1054 __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint64"), __ecereInstance1->type = ProcessTypeString("unsigned int64", 0x0), __ecereInstance1;
1055 }));
1056 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
1057 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
1058
1059 __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint32"), __ecereInstance1->type = ProcessTypeString("unsigned int", 0x0), __ecereInstance1;
1060 }));
1061 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
1062 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
1063
1064 __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint16"), __ecereInstance1->type = ProcessTypeString("unsigned short", 0x0), __ecereInstance1;
1065 }));
1066 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
1067 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
1068
1069 __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("byte"), __ecereInstance1->type = ProcessTypeString("unsigned char", 0x0), __ecereInstance1;
1070 }));
1071 if(buildingBootStrap)
1072 {
1073 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
1074 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
1075
1076 __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("intptr_t"), __ecereInstance1->type = ProcessTypeString("intptr", 0x0), __ecereInstance1;
1077 }));
1078 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
1079 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
1080
1081 __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uintptr_t"), __ecereInstance1->type = ProcessTypeString("uintptr", 0x0), __ecereInstance1;
1082 }));
1083 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
1084 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
1085
1086 __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("ssize_t"), __ecereInstance1->type = ProcessTypeString("intsize", 0x0), __ecereInstance1;
1087 }));
1088 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
1089 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
1090
1091 __ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("size_t"), __ecereInstance1->type = ProcessTypeString("uintsize", 0x0), __ecereInstance1;
1092 }));
1093 }
1094 {
1095 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);
1096
1097 data->key = (uintptr_t)data->fullName;
1098 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalData.functions, (struct __ecereNameSpace__ecere__sys__BTNode *)data);
1099 }
1100 snprintf(command, sizeof command, "%s%s -x c -E %s\"%s\"", cppCommand, cppOptions ? cppOptions : "", buildingBootStrap ? "" : "-include stdint.h -include sys/types.h ", GetSourceFile());
1101 command[sizeof command - 1] = (char)0;
1102 if((cppOutput = __ecereNameSpace__ecere__sys__DualPipeOpen((((unsigned int)(0x1))), command)))
1103 {
1104 char impFile[797];
1105 struct ImportedModule * module;
1106 char mainModuleName[274];
1107 int exitCode;
1108 struct __ecereNameSpace__ecere__sys__OldList * ast;
1109 struct __ecereNameSpace__ecere__com__Instance * fileInput = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass___ecereNameSpace__ecere__sys__TempFile);
1110
1111 SetFileInput(fileInput);
1112 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&imports, (mainModule = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_ModuleImport)));
1113 SetMainModule(mainModule);
1114 __ecereNameSpace__ecere__sys__GetLastDirectory(GetSourceFile(), mainModuleName);
1115 __ecereNameSpace__ecere__sys__StripExtension(mainModuleName);
1116 module = __extension__ ({
1117 struct ImportedModule * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_ImportedModule);
1118
1119 __ecereInstance1->name = __ecereNameSpace__ecere__sys__CopyString(mainModuleName), __ecereInstance1->type = 0, __ecereInstance1;
1120 });
1121 __ecereMethod___ecereNameSpace__ecere__sys__OldList_AddName(&defines, module);
1122 resetScanner();
1123 while(!((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *))cppOutput->_vTbl[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Eof])(cppOutput))
1124 {
1125 char junk[4096];
1126 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);
1127
1128 ((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);
1129 }
1130 exitCode = __ecereMethod___ecereNameSpace__ecere__sys__DualPipe_GetExitCode(cppOutput);
1131 (__ecereNameSpace__ecere__com__eInstance_DecRef(cppOutput), cppOutput = 0);
1132 ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, int pos, int mode))fileInput->_vTbl[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek])(fileInput, 0, 0);
1133 {
1134 char symFile[274];
1135 char symLocation[797];
1136 struct ImportedModule * module, * next;
1137
1138 __ecereNameSpace__ecere__sys__GetLastDirectory(GetSourceFile(), symFile);
1139 __ecereNameSpace__ecere__sys__ChangeExtension(symFile, "sym", symFile);
1140 strcpy(symLocation, GetSymbolsDir());
1141 __ecereNameSpace__ecere__sys__PathCat(symLocation, symFile);
1142 LoadSymbols(symLocation, 3, 0x0);
1143 for(module = defines.first; module; module = next)
1144 {
1145 next = module->next;
1146 if(module->type == 0 && (strcasecmp)(module->name, mainModuleName))
1147 {
1148 (__ecereNameSpace__ecere__com__eSystem_Delete(module->name), module->name = 0);
1149 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Delete(&defines, module);
1150 }
1151 }
1152 if(!GetEcereImported() && !GetBuildingEcereCom())
1153 __ecereNameSpace__ecere__com__eModule_LoadStrict(privateModule, "ecereCOM", 1);
1154 }
1155 ParseEc();
1156 CheckDataRedefinitions();
1157 SetYydebug(0x0);
1158 SetCurrentNameSpace((((void *)0)));
1159 SetDefaultNameSpace((((void *)0)));
1160 SetDeclMode(2);
1161 (__ecereNameSpace__ecere__com__eInstance_DecRef(fileInput), fileInput = 0);
1162 SetFileInput((((void *)0)));
1163 ast = GetAST();
1164 if(!exitCode)
1165 {
1166 ProcessDBTableDefinitions();
1167 PrePreProcessClassDefinitions();
1168 ComputeModuleClasses(privateModule);
1169 PreProcessClassDefinitions();
1170 ComputeModuleClasses(privateModule);
1171 ProcessClassDefinitions();
1172 ComputeDataTypes();
1173 ProcessInstantiations();
1174 ProcessMemberAccess();
1175 ProcessInstanceDeclarations();
1176 strcpy(impFile, GetSymbolsDir());
1177 {
1178 char fileName[274];
1179
1180 __ecereNameSpace__ecere__sys__GetLastDirectory(GetSourceFile(), fileName);
1181 __ecereNameSpace__ecere__sys__PathCat(impFile, fileName);
1182 __ecereNameSpace__ecere__sys__ChangeExtension(impFile, "imp", impFile);
1183 }
1184 if(imports.first)
1185 OutputImports(impFile);
1186 if(!((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->exitCode)
1187 {
1188 struct __ecereNameSpace__ecere__com__Instance * output = __ecereNameSpace__ecere__sys__FileOpen(GetOutputFile(), 2);
1189
1190 if(output)
1191 {
1192 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#if defined(__GNUC__)\n");
1193 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef long long int64;\n");
1194 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef unsigned long long uint64;\n");
1195 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#ifndef _WIN32\n");
1196 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __declspec(x)\n");
1197 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#endif\n");
1198 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#elif defined(__TINYC__)\n");
1199 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#include <stdarg.h>\n");
1200 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __builtin_va_list va_list\n");
1201 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __builtin_va_start va_start\n");
1202 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __builtin_va_end va_end\n");
1203 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#ifdef _WIN32\n");
1204 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define strcasecmp stricmp\n");
1205 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define strncasecmp strnicmp\n");
1206 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __declspec(x) __attribute__((x))\n");
1207 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#else\n");
1208 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __declspec(x)\n");
1209 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#endif\n");
1210 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef long long int64;\n");
1211 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef unsigned long long uint64;\n");
1212 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#else\n");
1213 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef __int64 int64;\n");
1214 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef unsigned __int64 uint64;\n");
1215 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#endif\n");
1216 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#ifdef __BIG_ENDIAN__\n");
1217 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __ENDIAN_PAD(x) (8 - (x))\n");
1218 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#else\n");
1219 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __ENDIAN_PAD(x) 0\n");
1220 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#endif\n");
1221 if(buildingBootStrap)
1222 {
1223 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#include <stdint.h>\n");
1224 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#include <sys/types.h>\n");
1225 }
1226 if(ast)
1227 OutputTree(ast, output);
1228 (__ecereNameSpace__ecere__com__eInstance_DecRef(output), output = 0);
1229 }
1230 }
1231 }
1232 else
1233 ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->exitCode = exitCode;
1234 if(ast)
1235 {
1236 FreeASTTree(ast);
1237 }
1238 }
1239 FreeContext(globalContext);
1240 FreeExcludedSymbols(&_excludedSymbols);
1241 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Free(&defines, FreeModuleDefine);
1242 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Free(&imports, FreeModuleImport);
1243 FreeTypeData(privateModule);
1244 FreeIncludeFiles();
1245 FreeGlobalData(&globalData);
1246 (__ecereNameSpace__ecere__com__eInstance_DecRef(privateModule), privateModule = 0);
1247 }
1248 (__ecereNameSpace__ecere__com__eSystem_Delete(cppCommand), cppCommand = 0);
1249 (__ecereNameSpace__ecere__com__eSystem_Delete(cppOptions), cppOptions = 0);
1250 SetSymbolsDir((((void *)0)));
1251 OutputIntlStrings();
1252 }
1253
1254 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);
1255
1256 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Module;
1257
1258 struct __ecereNameSpace__ecere__com__Module
1259 {
1260 struct __ecereNameSpace__ecere__com__Instance * application;
1261 struct __ecereNameSpace__ecere__sys__OldList classes;
1262 struct __ecereNameSpace__ecere__sys__OldList defines;
1263 struct __ecereNameSpace__ecere__sys__OldList functions;
1264 struct __ecereNameSpace__ecere__sys__OldList modules;
1265 struct __ecereNameSpace__ecere__com__Instance * prev;
1266 struct __ecereNameSpace__ecere__com__Instance * next;
1267 char *  name;
1268 void *  library;
1269 void *  Unload;
1270 int importType;
1271 int origImportType;
1272 struct __ecereNameSpace__ecere__com__NameSpace privateNameSpace;
1273 struct __ecereNameSpace__ecere__com__NameSpace publicNameSpace;
1274 } __attribute__ ((gcc_struct));
1275
1276 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);
1277
1278 void __ecereRegisterModule_ecc(struct __ecereNameSpace__ecere__com__Instance * module)
1279 {
1280 struct __ecereNameSpace__ecere__com__Class * class;
1281
1282 class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(0, "CompilerApp", "ecere::com::Application", 0, 0, 0, 0, module, 2, 1);
1283 if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application && class)
1284 __ecereClass_CompilerApp = class;
1285 __ecereNameSpace__ecere__com__eClass_AddMethod(class, "Main", 0, __ecereMethod_CompilerApp_Main, 1);
1286 }
1287
1288 void __ecereUnregisterModule_ecc(struct __ecereNameSpace__ecere__com__Instance * module)
1289 {
1290
1291 }
1292
1293 int __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_CompareString(struct __ecereNameSpace__ecere__sys__BinaryTree * this, char *  a, char *  b);
1294
1295 void __ecereCreateModuleInstances_ecc()
1296 {
1297 globalContext = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Context);
1298 (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);
1299 }
1300
1301 void __ecereDestroyModuleInstances_ecc()
1302 {
1303 ((globalContext ? (__ecereClass_Context->Destructor ? __ecereClass_Context->Destructor(globalContext) : 0, __ecereNameSpace__ecere__com__eSystem_Delete(globalContext)) : 0), globalContext = 0);
1304 }
1305