wip II
[sdk] / compiler / bootstrap / libec / bootstrap / pass0.c
index 1e3486c..05b99cc 100644 (file)
@@ -1,6 +1,10 @@
+/* Code generated from eC source file: pass0.ec */
 #if defined(__GNUC__)
 typedef long long int64;
 typedef unsigned long long uint64;
+#ifndef _WIN32
+#define __declspec(x)
+#endif
 #elif defined(__TINYC__)
 #include <stdarg.h>
 #define __builtin_va_list va_list
@@ -24,17 +28,19 @@ typedef unsigned __int64 uint64;
 #else
 #define __ENDIAN_PAD(x) 0
 #endif
-#ifdef __MINGW32__
-#ifdef _WIN64
-typedef unsigned long long int uintptr_t;
-typedef long long int intptr_t;
-#else
-typedef unsigned int uintptr_t;
-typedef int intptr_t;
-#endif
-#else
 #include <stdint.h>
+#include <sys/types.h>
+
+#if /*defined(_W64) || */(defined(__WORDSIZE) && __WORDSIZE == 8) || defined(__x86_64__)
+#define _64BIT 1
+#else
+#define _64BIT 0
 #endif
+
+#define arch_PointerSize                  sizeof(void *)
+#define structSize_Instance               (_64BIT ? 24 : 12)
+#define structSize_Module                 (_64BIT ? 560 : 300)
+
 extern void *  __ecereNameSpace__ecere__com__eSystem_New(unsigned int size);
 
 extern void *  __ecereNameSpace__ecere__com__eSystem_New0(unsigned int size);
@@ -101,9 +107,9 @@ struct __ecereNameSpace__ecere__com__Class * _class;
 char *  dataTypeString;
 struct __ecereNameSpace__ecere__com__Class * dataTypeClass;
 struct Type * dataType;
-void (*  Set)();
-int (*  Get)();
-unsigned int (*  IsSet)();
+void (*  Set)(void * , int);
+int (*  Get)(void * );
+unsigned int (*  IsSet)(void * );
 void *  data;
 void *  symbol;
 int vid;
@@ -122,7 +128,7 @@ struct CodePosition
 int line;
 int charPos;
 int pos;
-unsigned int included;
+int included;
 } __attribute__ ((gcc_struct));
 
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Location;
@@ -455,7 +461,7 @@ struct TypeName * typeName;
 } __attribute__ ((gcc_struct));
 unsigned int debugValue;
 struct __ecereNameSpace__ecere__com__DataValue val;
-unsigned int address;
+uint64 address;
 unsigned int hasAddress;
 struct Type * expType;
 struct Type * destType;
@@ -506,6 +512,7 @@ struct __ecereNameSpace__ecere__sys__OldList *  baseSpecs;
 struct __ecereNameSpace__ecere__sys__OldList *  definitions;
 unsigned int addNameSpace;
 struct Context * ctx;
+struct ExtDecl * extDeclStruct;
 } __attribute__ ((gcc_struct));
 struct Expression * expression;
 struct Specifier * _class;
@@ -728,25 +735,28 @@ struct Symbol * enumClass;
 struct Type * type;
 struct TemplateParameter * templateParameter;
 } __attribute__ ((gcc_struct));
-unsigned int isSigned;
 int kind;
-unsigned int constant;
 unsigned int size;
 char *  name;
 char *  typeName;
-unsigned int count;
-unsigned int truth;
 int classObjectType;
-unsigned int byReference;
-unsigned int extraParam;
 int alignment;
-unsigned int directClassAccess;
-unsigned int computing;
-unsigned int dllExport;
 unsigned int offset;
-unsigned int keepCast;
-unsigned int passAsTemplate;
 int bitFieldCount;
+int count;
+unsigned int isSigned : 1;
+unsigned int constant : 1;
+unsigned int truth : 1;
+unsigned int byReference : 1;
+unsigned int extraParam : 1;
+unsigned int directClassAccess : 1;
+unsigned int computing : 1;
+unsigned int keepCast : 1;
+unsigned int passAsTemplate : 1;
+unsigned int dllExport : 1;
+unsigned int attrStdcall : 1;
+unsigned int declaredWithStruct : 1;
+unsigned int typedByReference : 1;
 } __attribute__ ((gcc_struct));
 
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Class;
@@ -805,8 +815,12 @@ struct __ecereNameSpace__ecere__com__ClassTemplateArgument *  templateArgs;
 struct __ecereNameSpace__ecere__com__Class * templateClass;
 struct __ecereNameSpace__ecere__sys__OldList templatized;
 int numParams;
+unsigned int isInstanceClass;
+unsigned int byValueSystemClass;
 } __attribute__ ((gcc_struct));
 
+extern long long __ecereNameSpace__ecere__com__eClass_GetProperty(struct __ecereNameSpace__ecere__com__Class * _class, char *  name);
+
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Instance;
 
 struct __ecereNameSpace__ecere__com__Instance
@@ -1105,7 +1119,7 @@ output[d] = (char)0;
 
 extern char *  strcat(char * , const char * );
 
-extern int strlen(const char * );
+extern size_t strlen(const char * );
 
 void FullClassNameCat(char * output, char * className, unsigned int includeTemplateParams)
 {
@@ -1168,12 +1182,12 @@ output[len++] = ch;
 output[len++] = (char)0;
 }
 
-extern int AddMembers(struct __ecereNameSpace__ecere__sys__OldList *  declarations, struct __ecereNameSpace__ecere__com__Class * _class, unsigned int isMember, unsigned int *  retSize, struct __ecereNameSpace__ecere__com__Class * topClass);
+extern int AddMembers(struct __ecereNameSpace__ecere__sys__OldList *  declarations, struct __ecereNameSpace__ecere__com__Class * _class, unsigned int isMember, unsigned int *  retSize, struct __ecereNameSpace__ecere__com__Class * topClass, unsigned int *  addedPadding);
 
 static void AddSimpleBaseMembers(struct __ecereNameSpace__ecere__sys__OldList * list, struct __ecereNameSpace__ecere__com__Class * _class, struct __ecereNameSpace__ecere__com__Class * topClass)
 {
 if(_class->type != 1000)
-AddMembers(list, _class, 0x0, (((void *)0)), topClass);
+AddMembers(list, _class, 0x0, (((void *)0)), topClass, (((void *)0)));
 }
 
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__NameSpace;
@@ -1259,9 +1273,9 @@ Compiler_Error(__ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Non-s
 }
 else if(access == 1)
 {
-if(!NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + 12)))->application + 300)))->systemNameSpace))
+if(!NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + structSize_Instance)))->application + structSize_Module)))->systemNameSpace))
 {
-if(NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + 12)))->privateNameSpace) || !ModuleAccess(privateModule, regClass->module))
+if(NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + structSize_Instance)))->privateNameSpace) || !ModuleAccess(privateModule, regClass->module))
 Compiler_Error(__ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Public %s making use of a private class\n", (((void *)0))), word);
 }
 }
@@ -1597,7 +1611,7 @@ extern struct Expression * QMkExpId(char *  id);
 
 extern void FreeDeclarator(struct Declarator * decl);
 
-extern void FreeList(struct __ecereNameSpace__ecere__sys__OldList * list, void (* )(void * ));
+extern void FreeList(struct __ecereNameSpace__ecere__sys__OldList * list, void (*  FreeFunction)(void * ));
 
 extern void FreeSpecifier(struct Specifier * spec);
 
@@ -1617,7 +1631,7 @@ extern void FreeExternal(struct External * external);
 
 extern int declMode;
 
-extern char *  strstr(char * , const char * );
+extern char *  strstr(const char * , const char * );
 
 extern char *  sourceFile;
 
@@ -1667,7 +1681,7 @@ extern struct Statement * MkReturnStmt(struct __ecereNameSpace__ecere__sys__OldL
 
 extern struct TypeName * MkTypeName(struct __ecereNameSpace__ecere__sys__OldList * qualifiers, struct Declarator * declarator);
 
-extern struct __ecereNameSpace__ecere__sys__OldList *  CopyList(struct __ecereNameSpace__ecere__sys__OldList *  source, void *  (* )(void * ));
+extern struct __ecereNameSpace__ecere__sys__OldList *  CopyList(struct __ecereNameSpace__ecere__sys__OldList *  source, void *  (*  CopyFunction)(void * ));
 
 extern struct Declarator * PlugDeclarator(struct Declarator * decl, struct Declarator * baseDecl);
 
@@ -1675,6 +1689,18 @@ extern struct __ecereNameSpace__ecere__sys__OldList *  ast;
 
 extern int sprintf(char * , char * , ...);
 
+extern struct Type * ProcessType(struct __ecereNameSpace__ecere__sys__OldList * specs, struct Declarator * decl);
+
+extern struct Context * curContext;
+
+extern struct Initializer * MkInitializerAssignment(struct Expression * exp);
+
+extern struct Expression * MkExpCast(struct TypeName * typeName, struct Expression * expression);
+
+extern struct Declarator * CopyDeclarator(struct Declarator * declarator);
+
+extern void FreeType(struct Type * type);
+
 extern struct Declarator * GetFuncDecl(struct Declarator * decl);
 
 extern void ProcessMethodType(struct __ecereNameSpace__ecere__com__Method * method);
@@ -1693,9 +1719,8 @@ void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(struct __ecereNameS
 
 void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Clear(struct __ecereNameSpace__ecere__sys__OldList * this);
 
-static void ProcessClass(int classType, struct __ecereNameSpace__ecere__sys__OldList * definitions, struct Symbol * symbol, struct __ecereNameSpace__ecere__sys__OldList * baseSpecs, struct __ecereNameSpace__ecere__sys__OldList * enumValues, struct Location * loc, struct __ecereNameSpace__ecere__sys__OldList * defs, void * after, struct __ecereNameSpace__ecere__sys__OldList * initDeclarators)
+static void ProcessClass(int classType, struct __ecereNameSpace__ecere__sys__OldList * definitions, struct Symbol * symbol, struct __ecereNameSpace__ecere__sys__OldList * baseSpecs, struct __ecereNameSpace__ecere__sys__OldList * enumValues, struct Location * loc, struct __ecereNameSpace__ecere__sys__OldList * defs, void * after, struct __ecereNameSpace__ecere__sys__OldList * initDeclarators, struct ExtDecl * extDecl)
 {
-void * __ecereTemp1;
 char structName[1024];
 char className[1024];
 char constructorName[1024];
@@ -1721,7 +1746,7 @@ classType = regClass->type;
 if(inCompiler)
 {
 yylloc = *loc;
-if(!NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + 12)))->privateNameSpace) && regClass->inheritanceAccess == 1)
+if(!NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + structSize_Instance)))->privateNameSpace) && regClass->inheritanceAccess == 1)
 {
 if(!regClass->base->symbol)
 regClass->base->symbol = FindClass(regClass->base->fullName);
@@ -1779,7 +1804,7 @@ if(definitions != (((void *)0)))
 {
 if(inCompiler)
 {
-if(!NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + 12)))->privateNameSpace))
+if(!NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + structSize_Instance)))->privateNameSpace))
 CheckMembersDefinitions(regClass, (((void *)0)), definitions, 1);
 else if(!symbol->isStatic)
 CheckMembersDefinitions(regClass, (((void *)0)), definitions, 2);
@@ -1915,7 +1940,12 @@ struct __ecereNameSpace__ecere__sys__OldList * specs = MkList(), * declarators =
 initDeclarators = (((void *)0));
 strcpy(structName, symbol->string);
 symbol->structName = __ecereNameSpace__ecere__sys__CopyString(structName);
-ListAdd(specs, MkStructOrUnion(3, MkIdentifier(structName), isUnion ? MkListOne(MkClassDefDeclaration(MkStructDeclaration(MkListOne(MkStructOrUnion(4, (((void *)0)), list)), (((void *)0)), (((void *)0))))) : list));
+{
+struct Specifier * spec = MkStructOrUnion(3, MkIdentifier(structName), isUnion ? MkListOne(MkClassDefDeclaration(MkStructDeclaration(MkListOne(MkStructOrUnion(4, (((void *)0)), list)), (((void *)0)), (((void *)0))))) : list);
+
+spec->extDeclStruct = extDecl;
+ListAdd(specs, spec);
+}
 external->symbol = symbol;
 symbol->structExternal = external;
 external->declaration = MkDeclaration(specs, declarators);
@@ -2013,7 +2043,11 @@ body = MkCompoundStmt(declarations, statements);
 PopContext(context);
 body->compound.context = context;
 decl = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(destructorName)), (((void *)0)));
-decl->symbol = (__ecereTemp1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol), ((struct Symbol *)__ecereTemp1)->id = symbol->id, ((struct Symbol *)__ecereTemp1)->idCode = symbol->idCode, ((struct Symbol *)__ecereTemp1));
+decl->symbol = __extension__ ({
+struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
+
+__ecereInstance1->id = symbol->id, __ecereInstance1->idCode = symbol->idCode, __ecereInstance1;
+});
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*excludedSymbols), decl->symbol);
 function = MkClassFunction(specs, (((void *)0)), decl, (((void *)0)));
 ProcessClassFunctionBody(function, body);
@@ -2147,7 +2181,7 @@ struct ClassDef * newDef;
 if(inCompiler)
 {
 yylloc = propertyDef->loc;
-if(!NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + 12)))->privateNameSpace) && def->memberAccess == 1)
+if(!NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + structSize_Instance)))->privateNameSpace) && def->memberAccess == 1)
 CheckPublicDataType(propertyDef->symbol->type, 1, "class property");
 else if(!symbol->isStatic)
 CheckPublicDataType(propertyDef->symbol->type, 2, "class property");
@@ -2297,7 +2331,7 @@ struct ClassDef * newDef;
 if(inCompiler)
 {
 yylloc = propertyDef->loc;
-if(!NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + 12)))->privateNameSpace))
+if(!NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + structSize_Instance)))->privateNameSpace))
 CheckPublicDataType(propertyDef->symbol->type, 1, "classwide property");
 else if(!symbol->isStatic)
 CheckPublicDataType(propertyDef->symbol->type, 2, "classwide property");
@@ -2319,16 +2353,9 @@ strcat(name, propertyDef->id->string);
 MangleClassName(name);
 params = MkList();
 declId = MkDeclaratorIdentifier(MkIdentifier(name));
-if(propertyDef->symbol->type && propertyDef->symbol->type->kind == 8 && propertyDef->symbol->type->_class && propertyDef->symbol->type->_class->registered && propertyDef->symbol->type->_class->registered->type == 1)
 {
-ListAdd(params, MkTypeName(CopyList(propertyDef->specifiers, CopySpecifier), MkDeclaratorIdentifier(MkIdentifier("value"))));
-decl = PlugDeclarator(propertyDef->declarator, MkDeclaratorFunction(declId, params));
-func = MkClassFunction(MkListOne(MkSpecifier(VOID)), (((void *)0)), decl, (((void *)0)));
-}
-else
-{
-decl = PlugDeclarator(propertyDef->declarator, MkDeclaratorFunction(declId, params));
-func = MkClassFunction(CopyList(propertyDef->specifiers, CopySpecifier), (((void *)0)), decl, (((void *)0)));
+decl = MkDeclaratorFunction(declId, params);
+func = MkClassFunction(MkListOne(MkSpecifierName("uint64")), (((void *)0)), decl, (((void *)0)));
 }
 ProcessClassFunctionBody(func, propertyDef->getStmt);
 func->declarator->symbol = propertyDef->symbol;
@@ -2337,6 +2364,9 @@ func->dontMangle = 0x1;
 newDef = MkClassDefFunction(func);
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Insert(definitions, after, newDef);
 after = newDef;
+func->type = ProcessType(propertyDef->specifiers, MkDeclaratorFunction(propertyDef->declarator, (((void *)0))));
+if(func->type->returnType->kind == 8 && func->type->returnType->_class && func->type->returnType->_class->registered && func->type->returnType->_class->registered->type == 1)
+func->type->returnType->byReference = 0x1;
 if(inCompiler)
 propertyDef->getStmt = (((void *)0));
 else
@@ -2344,7 +2374,10 @@ func->body = (((void *)0));
 }
 if(propertyDef->setStmt && propertyDef->id)
 {
+struct Context * prevCurContext;
 struct __ecereNameSpace__ecere__sys__OldList * specifiers = MkList();
+struct Statement * body = propertyDef->setStmt;
+struct Declarator * ptrDecl;
 
 strcpy(name, "class::__ecereClassProp_");
 FullClassNameCat(name, symbol->string, 0x0);
@@ -2352,8 +2385,25 @@ strcat(name, "_Set_");
 strcat(name, propertyDef->id->string);
 MangleClassName(name);
 params = MkList();
-ListAdd(params, MkTypeName(CopyList(propertyDef->specifiers, CopySpecifier), PlugDeclarator(propertyDef->declarator, MkDeclaratorIdentifier(MkIdentifier("value")))));
+prevCurContext = curContext;
+curContext = body->compound.context;
+ListAdd(params, MkTypeName(MkListOne(MkSpecifierName("uint64")), MkDeclaratorIdentifier(MkIdentifier("_value"))));
 decl = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(name)), params);
+if(!body->compound.declarations)
+body->compound.declarations = MkList();
+if(propertyDef->symbol->type && propertyDef->symbol->type->kind == 8 && propertyDef->symbol->type->_class && propertyDef->symbol->type->_class->registered && propertyDef->symbol->type->_class->registered->type == 1)
+ptrDecl = MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), PlugDeclarator(propertyDef->declarator, MkDeclaratorIdentifier(MkIdentifier("value"))));
+else
+ptrDecl = PlugDeclarator(propertyDef->declarator, MkDeclaratorIdentifier(MkIdentifier("value")));
+ListAdd(body->compound.declarations, MkDeclaration(CopyList(propertyDef->specifiers, CopySpecifier), MkListOne(MkInitDeclarator(ptrDecl, MkInitializerAssignment(MkExpCast(MkTypeName(CopyList(propertyDef->specifiers, CopySpecifier), CopyDeclarator(propertyDef->declarator)), MkExpIdentifier(MkIdentifier("_value"))))))));
+curContext = prevCurContext;
+{
+struct Symbol * sym = ptrDecl->symbol;
+
+sym->isParam = 0x1;
+FreeType(sym->type);
+sym->type = ProcessType(propertyDef->specifiers, propertyDef->declarator);
+}
 ListAdd(specifiers, MkSpecifier(VOID));
 func = MkClassFunction(specifiers, (((void *)0)), decl, (((void *)0)));
 ProcessClassFunctionBody(func, propertyDef->setStmt);
@@ -2398,7 +2448,7 @@ char * newId = __ecereNameSpace__ecere__com__eSystem_New(sizeof(char) * (strlen(
 newId[0] = '\0';
 ProcessMethodType(method);
 yylloc = def->loc;
-if(!NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + 12)))->privateNameSpace) && method->memberAccess == 1)
+if(!NameSpaceContained(regClass->nameSpace, &((struct __ecereNameSpace__ecere__com__Module *)(((char *)regClass->module + structSize_Instance)))->privateNameSpace) && method->memberAccess == 1)
 CheckPublicDataType(method->dataType, 1, "class method");
 strcpy(newId, "__ecereMethod_");
 FullClassNameCat(newId, symbol->string, 0x0);
@@ -2423,8 +2473,6 @@ if(initDeclarators != (((void *)0)))
 FreeList(initDeclarators, FreeInitDeclarator);
 }
 
-extern struct Type * ProcessType(struct __ecereNameSpace__ecere__sys__OldList * specs, struct Declarator * decl);
-
 void PreProcessClassDefinitions()
 {
 struct External * external, * next;
@@ -2442,7 +2490,7 @@ struct ClassDefinition * _class = external->_class;
 
 if(_class->definitions)
 {
-ProcessClass(0, _class->definitions, _class->symbol, _class->baseSpecs, (((void *)0)), &_class->loc, ast, external->prev, (((void *)0)));
+ProcessClass(0, _class->definitions, _class->symbol, _class->baseSpecs, (((void *)0)), &_class->loc, ast, external->prev, (((void *)0)), (((void *)0)));
 }
 }
 else if(external->type == 1)
@@ -2464,13 +2512,15 @@ struct Symbol * symbol = FindClass(specifier->id->string);
 if(symbol)
 {
 struct __ecereNameSpace__ecere__sys__OldList * initDeclarators = (((void *)0));
+struct ExtDecl * extDecl = specifier->extDeclStruct;
 
+specifier->extDeclStruct = (((void *)0));
 if(inCompiler)
 {
 initDeclarators = declaration->declarators;
 declaration->declarators = (((void *)0));
 }
-ProcessClass((specifier->type == 4) ? 6 : 0, specifier->definitions, symbol, specifier->baseSpecs, specifier->list, &specifier->loc, ast, external->prev, initDeclarators);
+ProcessClass((specifier->type == 4) ? 6 : 0, specifier->definitions, symbol, specifier->baseSpecs, specifier->list, &specifier->loc, ast, external->prev, initDeclarators, extDecl);
 }
 }
 }