compiler/libec: Fixed deletion of class:struct where value being deleted is modified...
[sdk] / compiler / bootstrap / ecs / bootstrap / ecs.c
index 87d0b52..c9a38dd 100644 (file)
@@ -35,6 +35,18 @@ typedef unsigned __int64 uint64;
 #else
 #define __ENDIAN_PAD(x) 0
 #endif
+#if defined(_WIN32)
+#   if defined(__GNUC__) || defined(__TINYC__)
+#      define ecere_stdcall __attribute__((__stdcall__))
+#      define ecere_gcc_struct __attribute__((gcc_struct))
+#   else
+#      define ecere_stdcall __stdcall
+#      define ecere_gcc_struct
+#   endif
+#else
+#   define ecere_stdcall
+#   define ecere_gcc_struct
+#endif
 #include <stdint.h>
 #include <sys/types.h>
 
@@ -79,7 +91,7 @@ void *  last;
 int count;
 unsigned int offset;
 unsigned int circ;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__com__DataValue
 {
@@ -96,8 +108,8 @@ float f;
 double d;
 long long i64;
 uint64 ui64;
-} __attribute__ ((gcc_struct)) __anon1;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct __anon1;
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__com__SerialBuffer
 {
@@ -105,7 +117,7 @@ unsigned char *  _buffer;
 unsigned int count;
 unsigned int _size;
 unsigned int pos;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 extern void *  __ecereNameSpace__ecere__com__eSystem_New(unsigned int size);
 
@@ -125,7 +137,7 @@ int line;
 int charPos;
 int pos;
 int included;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct Context;
 
@@ -195,13 +207,13 @@ struct ContextStringPair
 {
 char * string;
 char * context;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__com__CustomAVLTree
 {
 struct __ecereNameSpace__ecere__com__AVLNode * root;
 int count;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 extern char *  __ecereNameSpace__ecere__sys__PathCat(char *  string, const char *  addedPath);
 
@@ -247,7 +259,7 @@ struct Location
 {
 struct CodePosition start;
 struct CodePosition end;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 extern void FinishTemplatesContext(struct Context * context);
 
@@ -286,7 +298,7 @@ struct __ecereNameSpace__ecere__sys__OldList classes;
 struct __ecereNameSpace__ecere__sys__OldList functions;
 int importType;
 int importAccess;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 extern void FreeModuleImport(struct ModuleImport * imp);
 
@@ -297,7 +309,7 @@ struct __ecereNameSpace__ecere__com__Instance
 void * *  _vTbl;
 struct __ecereNameSpace__ecere__com__Class * _class;
 int _refCount;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 extern long long __ecereNameSpace__ecere__com__eClass_GetProperty(struct __ecereNameSpace__ecere__com__Class * _class, const char *  name);
 
@@ -325,13 +337,13 @@ struct __ecereNameSpace__ecere__com__MapIterator
 {
 struct __ecereNameSpace__ecere__com__Instance * container;
 struct __ecereNameSpace__ecere__com__IteratorPointer * pointer;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__com__Iterator
 {
 struct __ecereNameSpace__ecere__com__Instance * container;
 struct __ecereNameSpace__ecere__com__IteratorPointer * pointer;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 unsigned int __ecereMethod___ecereNameSpace__ecere__sys__File_GetLine(struct __ecereNameSpace__ecere__com__Instance * this, char *  s, int max);
 
@@ -376,7 +388,7 @@ struct ModuleInfo
 struct ModuleInfo * prev, * next;
 char * name;
 unsigned int globalInstance;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__sys__BTNode;
 
@@ -387,7 +399,7 @@ struct __ecereNameSpace__ecere__sys__BTNode * parent;
 struct __ecereNameSpace__ecere__sys__BTNode * left;
 struct __ecereNameSpace__ecere__sys__BTNode * right;
 int depth;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__sys__BTNode * __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_next(struct __ecereNameSpace__ecere__sys__BTNode * this);
 
@@ -408,7 +420,7 @@ struct FunctionImport
 struct FunctionImport * prev;
 struct FunctionImport * next;
 char *  name;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct MethodImport;
 
@@ -418,7 +430,7 @@ struct MethodImport * prev;
 struct MethodImport * next;
 char *  name;
 unsigned int isVirtual;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct PropertyImport;
 
@@ -430,7 +442,7 @@ char *  name;
 unsigned int isVirtual;
 unsigned int hasSet;
 unsigned int hasGet;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct ImportedModule;
 
@@ -444,7 +456,7 @@ int importType;
 unsigned int globalInstance;
 unsigned int dllOnly;
 int importAccess;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct Type;
 
@@ -472,7 +484,7 @@ const char *  category;
 unsigned int compiled;
 unsigned int selfWatchable;
 unsigned int isWatchable;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 extern struct Type * ProcessTypeString(const char *  string, unsigned int staticMethod);
 
@@ -490,7 +502,7 @@ struct __ecereNameSpace__ecere__com__BTNamedLink * left;
 struct __ecereNameSpace__ecere__com__BTNamedLink * right;
 int depth;
 void *  data;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__sys__OldLink;
 
@@ -499,7 +511,7 @@ struct __ecereNameSpace__ecere__sys__OldLink
 struct __ecereNameSpace__ecere__sys__OldLink * prev;
 struct __ecereNameSpace__ecere__sys__OldLink * next;
 void *  data;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct Symbol;
 
@@ -522,7 +534,7 @@ struct __ecereNameSpace__ecere__sys__OldList methods;
 struct __ecereNameSpace__ecere__sys__OldList properties;
 unsigned int itself;
 int isRemote;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__com__Method;
 
@@ -541,7 +553,7 @@ void *  symbol;
 const char *  dataTypeString;
 struct Type * dataType;
 int memberAccess;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct Symbol
 {
@@ -556,7 +568,7 @@ union
 struct __ecereNameSpace__ecere__com__Method * method;
 struct __ecereNameSpace__ecere__com__Property * _property;
 struct __ecereNameSpace__ecere__com__Class * registered;
-} __attribute__ ((gcc_struct)) __anon1;
+} ecere_gcc_struct __anon1;
 unsigned int notYetDeclared;
 union
 {
@@ -564,20 +576,20 @@ struct
 {
 struct External * pointerExternal;
 struct External * structExternal;
-} __attribute__ ((gcc_struct)) __anon1;
+} ecere_gcc_struct __anon1;
 struct
 {
 struct External * externalGet;
 struct External * externalSet;
 struct External * externalPtr;
 struct External * externalIsSet;
-} __attribute__ ((gcc_struct)) __anon2;
+} ecere_gcc_struct __anon2;
 struct
 {
 struct External * methodExternal;
 struct External * methodCodeExternal;
-} __attribute__ ((gcc_struct)) __anon3;
-} __attribute__ ((gcc_struct)) __anon2;
+} ecere_gcc_struct __anon3;
+} ecere_gcc_struct __anon2;
 unsigned int imported;
 unsigned int declaredStructSym;
 struct __ecereNameSpace__ecere__com__Class * _class;
@@ -605,7 +617,7 @@ struct Context * ctx;
 int isIterator;
 struct Expression * propCategory;
 unsigned int mustRegister;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct Type
 {
@@ -619,7 +631,7 @@ struct
 {
 struct __ecereNameSpace__ecere__sys__OldList members;
 char *  enumName;
-} __attribute__ ((gcc_struct)) __anon1;
+} ecere_gcc_struct __anon1;
 struct
 {
 struct Type * returnType;
@@ -627,13 +639,13 @@ struct __ecereNameSpace__ecere__sys__OldList params;
 struct Symbol * thisClass;
 unsigned int staticMethod;
 struct TemplateParameter * thisClassTemplate;
-} __attribute__ ((gcc_struct)) __anon2;
+} ecere_gcc_struct __anon2;
 struct
 {
 struct __ecereNameSpace__ecere__com__Method * method;
 struct __ecereNameSpace__ecere__com__Class * methodClass;
 struct __ecereNameSpace__ecere__com__Class * usedClass;
-} __attribute__ ((gcc_struct)) __anon3;
+} ecere_gcc_struct __anon3;
 struct
 {
 struct Type * arrayType;
@@ -641,20 +653,22 @@ int arraySize;
 struct Expression * arraySizeExp;
 unsigned int freeExp;
 struct Symbol * enumClass;
-} __attribute__ ((gcc_struct)) __anon4;
+} ecere_gcc_struct __anon4;
 struct Type * type;
 struct TemplateParameter * templateParameter;
-} __attribute__ ((gcc_struct)) __anon1;
+} ecere_gcc_struct __anon1;
 int kind;
 unsigned int size;
 char *  name;
 char *  typeName;
 struct __ecereNameSpace__ecere__com__Class * thisClassFrom;
+int promotedFrom;
 int classObjectType;
 int alignment;
 unsigned int offset;
 int bitFieldCount;
 int count;
+int bitMemberSize;
 unsigned int isSigned : 1;
 unsigned int constant : 1;
 unsigned int truth : 1;
@@ -671,7 +685,8 @@ unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
 unsigned int isLong : 1;
-} __attribute__ ((gcc_struct));
+unsigned int signedBeforePromotion : 1;
+} ecere_gcc_struct;
 
 extern void DeclareMethod(struct External * neededFor, struct __ecereNameSpace__ecere__com__Method * method, const char *  name);
 
@@ -712,7 +727,7 @@ struct __ecereNameSpace__ecere__sys__BTNode * root;
 int count;
 int (*  CompareKey)(struct __ecereNameSpace__ecere__sys__BinaryTree * tree, uintptr_t a, uintptr_t b);
 void (*  FreeKey)(void *  key);
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__com__NameSpace
 {
@@ -726,7 +741,7 @@ struct __ecereNameSpace__ecere__sys__BinaryTree nameSpaces;
 struct __ecereNameSpace__ecere__sys__BinaryTree classes;
 struct __ecereNameSpace__ecere__sys__BinaryTree defines;
 struct __ecereNameSpace__ecere__sys__BinaryTree functions;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__sys__BTNode * __ecereProp___ecereNameSpace__ecere__sys__BinaryTree_Get_first(struct __ecereNameSpace__ecere__sys__BinaryTree * this);
 
@@ -741,7 +756,7 @@ unsigned int isGUIApp;
 struct __ecereNameSpace__ecere__sys__OldList allModules;
 char *  parsedCommand;
 struct __ecereNameSpace__ecere__com__NameSpace systemNameSpace;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__com__Module
 {
@@ -759,7 +774,7 @@ int importType;
 int origImportType;
 struct __ecereNameSpace__ecere__com__NameSpace privateNameSpace;
 struct __ecereNameSpace__ecere__com__NameSpace publicNameSpace;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 static struct __ecereNameSpace__ecere__com__NameSpace globalData;
 
@@ -780,7 +795,7 @@ struct
 {
 const char *  dataTypeString;
 struct __ecereNameSpace__ecere__com__Class * dataTypeClass;
-} __attribute__ ((gcc_struct)) __anon1;
+} ecere_gcc_struct __anon1;
 struct __ecereNameSpace__ecere__com__DataValue expression;
 struct
 {
@@ -790,10 +805,10 @@ union
 struct __ecereNameSpace__ecere__com__DataMember * member;
 struct __ecereNameSpace__ecere__com__Property * prop;
 struct __ecereNameSpace__ecere__com__Method * method;
-} __attribute__ ((gcc_struct)) __anon1;
-} __attribute__ ((gcc_struct)) __anon2;
-} __attribute__ ((gcc_struct)) __anon1;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct __anon1;
+} ecere_gcc_struct __anon2;
+} ecere_gcc_struct __anon1;
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__com__DataMember
 {
@@ -815,7 +830,7 @@ struct __ecereNameSpace__ecere__sys__BinaryTree membersAlpha;
 int memberOffset;
 short structAlignment;
 short pointerAlignment;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 struct __ecereNameSpace__ecere__com__Class
 {
@@ -874,7 +889,7 @@ struct __ecereNameSpace__ecere__sys__OldList templatized;
 int numParams;
 unsigned int isInstanceClass;
 unsigned int byValueSystemClass;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 static struct __ecereNameSpace__ecere__com__Class * __ecereClass_ModuleInfo;
 
@@ -1163,7 +1178,11 @@ theGlobalContext = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Cont
 
 void __ecereDestroyModuleInstances_ecs()
 {
-((theGlobalContext ? (__ecereClass_Context->Destructor ? __ecereClass_Context->Destructor((void *)theGlobalContext) : 0, __ecereNameSpace__ecere__com__eSystem_Delete(theGlobalContext)) : 0), theGlobalContext = 0);
+((theGlobalContext ? __extension__ ({
+void * __ecerePtrToDelete = (theGlobalContext);
+
+__ecereClass_Context->Destructor ? __ecereClass_Context->Destructor((void *)__ecerePtrToDelete) : 0, __ecereNameSpace__ecere__com__eSystem_Delete(__ecerePtrToDelete);
+}) : 0), theGlobalContext = 0);
 }
 
 static void BindDCOMClient()
@@ -1231,7 +1250,7 @@ else
 {
 PrintTypeNoConst(method->dataType->__anon1.__anon2.returnType, type, 0, 1);
 classSym = FindClass(type);
-type[0] = (char)0;
+type[0] = 0;
 }
 strcpy(className, "__ecereClass_");
 FullClassNameCat(className, classSym->string, 1);
@@ -1266,7 +1285,7 @@ else
 {
 PrintTypeNoConst(param, type, 0, 1);
 classSym = FindClass(type);
-type[0] = (char)0;
+type[0] = 0;
 }
 strcpy(className, "__ecereClass_");
 FullClassNameCat(className, classSym->string, 1);
@@ -1401,7 +1420,7 @@ else
 {
 PrintTypeNoConst(method->dataType->__anon1.__anon2.returnType, type, 0, 1);
 classSym = FindClass(type);
-type[0] = (char)0;
+type[0] = 0;
 }
 strcpy(className, "__ecereClass_");
 FullClassNameCat(className, classSym->string, 1);
@@ -1432,7 +1451,7 @@ else
 {
 PrintTypeNoConst(param, type, 0, 1);
 classSym = FindClass(type);
-type[0] = (char)0;
+type[0] = 0;
 }
 strcpy(className, "__ecereClass_");
 FullClassNameCat(className, classSym->string, 1);
@@ -1565,7 +1584,7 @@ else
 {
 PrintTypeNoConst(method->dataType->__anon1.__anon2.returnType, type, 0, 1);
 classSym = FindClass(type);
-type[0] = (char)0;
+type[0] = 0;
 }
 strcpy(className, "__ecereClass_");
 FullClassNameCat(className, classSym->string, 1);
@@ -1600,7 +1619,7 @@ else
 {
 PrintTypeNoConst(param, type, 0, 1);
 classSym = FindClass(type);
-type[0] = (char)0;
+type[0] = 0;
 }
 strcpy(className, "__ecereClass_");
 FullClassNameCat(className, classSym->string, 1);
@@ -1718,7 +1737,7 @@ else
 {
 PrintTypeNoConst(method->dataType->__anon1.__anon2.returnType, type, 0, 1);
 classSym = FindClass(type);
-type[0] = (char)0;
+type[0] = 0;
 }
 strcpy(className, "__ecereClass_");
 FullClassNameCat(className, classSym->string, 1);
@@ -1750,7 +1769,7 @@ else
 {
 PrintTypeNoConst(param, type, 0, 1);
 classSym = FindClass(type);
-type[0] = (char)0;
+type[0] = 0;
 }
 strcpy(className, "__ecereClass_");
 FullClassNameCat(className, classSym->string, 1);
@@ -1847,7 +1866,7 @@ struct __ecereNameSpace__ecere__com__NameSpace *  nameSpace;
 const char *  dataTypeString;
 struct Type * dataType;
 void *  symbol;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 static void WriteMain(const char * fileName)
 {
@@ -1959,7 +1978,7 @@ for(prop = _class->properties.first; prop; prop = prop->next)
 {
 char propName[1024];
 
-propName[0] = (char)0;
+propName[0] = 0;
 FullClassNameCat(propName, prop->name, 1);
 if((!strcmp(_class->name, "float") || !strcmp(_class->name, "double") || module->name) && module->importType != 1)
 {
@@ -1983,7 +2002,7 @@ if(module->name && module->importType != 1 && (!func || !func->dataType || !func
 {
 char functionName[1024];
 
-functionName[0] = (char)0;
+functionName[0] = 0;
 FullClassNameCat(functionName, function->name, 0);
 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "void * __ecereFunction_%s;\n", functionName);
 anyFunction = 1;
@@ -2255,7 +2274,7 @@ for(prop = _class->properties.first; prop; prop = prop->next)
 {
 char propName[1024];
 
-propName[0] = (char)0;
+propName[0] = 0;
 FullClassNameCat(propName, prop->name, 1);
 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "   __ecereProp_%s_%s = _property = eClass_FindProperty(%s, \"%s\", module);\n", className, propName, classID, prop->name);
 if((!strcmp(_class->name, "float") || !strcmp(_class->name, "double") || module->name) && module->importType != 1)
@@ -2280,7 +2299,7 @@ if(module->name && module->importType != 1 && (!func || !func->dataType || !func
 {
 char functionName[1024];
 
-functionName[0] = (char)0;
+functionName[0] = 0;
 FullClassNameCat(functionName, function->name, 0);
 if(isDynamicLibrary && !isStaticLibrary)
 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "   function = eSystem_FindFunction(__currentModule, \"%s\");\n", function->name);
@@ -2508,7 +2527,7 @@ struct __ecereNameSpace__ecere__com__SubModule * prev;
 struct __ecereNameSpace__ecere__com__SubModule * next;
 struct __ecereNameSpace__ecere__com__Instance * module;
 int importMode;
-} __attribute__ ((gcc_struct));
+} ecere_gcc_struct;
 
 static struct __ecereNameSpace__ecere__com__Class * SearchAppClass_Module(struct __ecereNameSpace__ecere__com__Instance * module)
 {
@@ -2797,7 +2816,7 @@ else if(strstr(line, "msgid \"") == line)
 msgid = __ecereNameSpace__ecere__sys__CopyString(line + 7);
 len = strlen(msgid);
 if(len)
-msgid[len - 1] = (unsigned char)0;
+msgid[len - 1] = 0;
 }
 else if(strstr(line, "msgctxt \"") == line)
 {
@@ -2805,7 +2824,7 @@ else if(strstr(line, "msgctxt \"") == line)
 msgctxt = __ecereNameSpace__ecere__sys__CopyString(line + 9);
 len = strlen(msgctxt);
 if(len)
-msgctxt[len - 1] = (unsigned char)0;
+msgctxt[len - 1] = 0;
 }
 else if(strstr(line, "msgstr \"") == line)
 {
@@ -2813,7 +2832,7 @@ else if(strstr(line, "msgstr \"") == line)
 msgstr = __ecereNameSpace__ecere__sys__CopyString(line + 8);
 len = strlen(msgstr);
 if(len)
-msgstr[len - 1] = (unsigned char)0;
+msgstr[len - 1] = 0;
 }
 if(msgid && msgstr)
 {