compiler/libec: (#341, #351, #644, #771) Improved enum type matching and type handlin...
[sdk] / compiler / bootstrap / libec / bootstrap / dbpass.c
index f4b8f4e..0799e55 100644 (file)
@@ -1,3 +1,4 @@
+/* Code generated from eC source file: dbpass.ec */
 #if defined(__GNUC__)
 typedef long long int64;
 typedef unsigned long long uint64;
@@ -37,6 +38,8 @@ extern void *  __ecereNameSpace__ecere__com__eSystem_Renew(void *  memory, unsig
 
 extern void *  __ecereNameSpace__ecere__com__eSystem_Renew0(void *  memory, unsigned int size);
 
+extern void __ecereNameSpace__ecere__com__eSystem_Delete(void *  memory);
+
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__BTNode;
 
 struct __ecereNameSpace__ecere__sys__BTNode;
@@ -367,7 +370,11 @@ struct Identifier * identifier;
 } __attribute__ ((gcc_struct));
 struct Statement * compound;
 struct Instantiation * instance;
+struct
+{
 char *  string;
+unsigned int intlString;
+} __attribute__ ((gcc_struct));
 struct __ecereNameSpace__ecere__sys__OldList *  list;
 struct
 {
@@ -460,6 +467,7 @@ unsigned int isConstant;
 unsigned int addedThis;
 unsigned int needCast;
 unsigned int thisPtr;
+unsigned int opDestType;
 } __attribute__ ((gcc_struct));
 
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateDatatype;
@@ -714,6 +722,8 @@ 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;
@@ -755,7 +765,7 @@ unsigned int noExpansion;
 char *  defaultProperty;
 unsigned int comRedefinition;
 int count;
-unsigned int isRemote;
+int isRemote;
 unsigned int internalDecl;
 void *  data;
 unsigned int computeSize;
@@ -773,10 +783,13 @@ 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 void __ecereNameSpace__ecere__com__eInstance_FireSelfWatchers(struct __ecereNameSpace__ecere__com__Instance * instance, struct __ecereNameSpace__ecere__com__Property * _property);
+
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Instance;
 
 struct __ecereNameSpace__ecere__com__Instance
@@ -846,7 +859,7 @@ struct __ecereNameSpace__ecere__com__Method * method;
 
 enum yytokentype
 {
-IDENTIFIER = 258, CONSTANT = 259, STRING_LITERAL = 260, SIZEOF = 261, PTR_OP = 262, INC_OP = 263, DEC_OP = 264, LEFT_OP = 265, RIGHT_OP = 266, LE_OP = 267, GE_OP = 268, EQ_OP = 269, NE_OP = 270, AND_OP = 271, OR_OP = 272, MUL_ASSIGN = 273, DIV_ASSIGN = 274, MOD_ASSIGN = 275, ADD_ASSIGN = 276, SUB_ASSIGN = 277, LEFT_ASSIGN = 278, RIGHT_ASSIGN = 279, AND_ASSIGN = 280, XOR_ASSIGN = 281, OR_ASSIGN = 282, TYPE_NAME = 283, TYPEDEF = 284, EXTERN = 285, STATIC = 286, AUTO = 287, REGISTER = 288, CHAR = 289, SHORT = 290, INT = 291, UINT = 292, INT64 = 293, LONG = 294, SIGNED = 295, UNSIGNED = 296, FLOAT = 297, DOUBLE = 298, CONST = 299, VOLATILE = 300, VOID = 301, VALIST = 302, STRUCT = 303, UNION = 304, ENUM = 305, ELLIPSIS = 306, CASE = 307, DEFAULT = 308, IF = 309, SWITCH = 310, WHILE = 311, DO = 312, FOR = 313, GOTO = 314, CONTINUE = 315, BREAK = 316, RETURN = 317, IFX = 318, ELSE = 319, CLASS = 320, THISCLASS = 321, CLASS_NAME = 322, PROPERTY = 323, SETPROP = 324, GETPROP = 325, NEWOP = 326, RENEW = 327, DELETE = 328, EXT_DECL = 329, EXT_STORAGE = 330, IMPORT = 331, DEFINE = 332, VIRTUAL = 333, ATTRIB = 334, PUBLIC = 335, PRIVATE = 336, TYPED_OBJECT = 337, ANY_OBJECT = 338, _INCREF = 339, EXTENSION = 340, ASM = 341, TYPEOF = 342, WATCH = 343, STOPWATCHING = 344, FIREWATCHERS = 345, WATCHABLE = 346, CLASS_DESIGNER = 347, CLASS_NO_EXPANSION = 348, CLASS_FIXED = 349, ISPROPSET = 350, CLASS_DEFAULT_PROPERTY = 351, PROPERTY_CATEGORY = 352, CLASS_DATA = 353, CLASS_PROPERTY = 354, SUBCLASS = 355, NAMESPACE = 356, NEW0OP = 357, RENEW0 = 358, VAARG = 359, DBTABLE = 360, DBFIELD = 361, DBINDEX = 362, DATABASE_OPEN = 363, ALIGNOF = 364, ATTRIB_DEP = 365, __ATTRIB = 366
+IDENTIFIER = 258, CONSTANT = 259, STRING_LITERAL = 260, SIZEOF = 261, PTR_OP = 262, INC_OP = 263, DEC_OP = 264, LEFT_OP = 265, RIGHT_OP = 266, LE_OP = 267, GE_OP = 268, EQ_OP = 269, NE_OP = 270, AND_OP = 271, OR_OP = 272, MUL_ASSIGN = 273, DIV_ASSIGN = 274, MOD_ASSIGN = 275, ADD_ASSIGN = 276, SUB_ASSIGN = 277, LEFT_ASSIGN = 278, RIGHT_ASSIGN = 279, AND_ASSIGN = 280, XOR_ASSIGN = 281, OR_ASSIGN = 282, TYPE_NAME = 283, TYPEDEF = 284, EXTERN = 285, STATIC = 286, AUTO = 287, REGISTER = 288, CHAR = 289, SHORT = 290, INT = 291, UINT = 292, INT64 = 293, LONG = 294, SIGNED = 295, UNSIGNED = 296, FLOAT = 297, DOUBLE = 298, CONST = 299, VOLATILE = 300, VOID = 301, VALIST = 302, STRUCT = 303, UNION = 304, ENUM = 305, ELLIPSIS = 306, CASE = 307, DEFAULT = 308, IF = 309, SWITCH = 310, WHILE = 311, DO = 312, FOR = 313, GOTO = 314, CONTINUE = 315, BREAK = 316, RETURN = 317, IFX = 318, ELSE = 319, CLASS = 320, THISCLASS = 321, CLASS_NAME = 322, PROPERTY = 323, SETPROP = 324, GETPROP = 325, NEWOP = 326, RENEW = 327, DELETE = 328, EXT_DECL = 329, EXT_STORAGE = 330, IMPORT = 331, DEFINE = 332, VIRTUAL = 333, ATTRIB = 334, PUBLIC = 335, PRIVATE = 336, TYPED_OBJECT = 337, ANY_OBJECT = 338, _INCREF = 339, EXTENSION = 340, ASM = 341, TYPEOF = 342, WATCH = 343, STOPWATCHING = 344, FIREWATCHERS = 345, WATCHABLE = 346, CLASS_DESIGNER = 347, CLASS_NO_EXPANSION = 348, CLASS_FIXED = 349, ISPROPSET = 350, CLASS_DEFAULT_PROPERTY = 351, PROPERTY_CATEGORY = 352, CLASS_DATA = 353, CLASS_PROPERTY = 354, SUBCLASS = 355, NAMESPACE = 356, NEW0OP = 357, RENEW0 = 358, VAARG = 359, DBTABLE = 360, DBFIELD = 361, DBINDEX = 362, DATABASE_OPEN = 363, ALIGNOF = 364, ATTRIB_DEP = 365, __ATTRIB = 366, BOOL = 367, _BOOL = 368, _COMPLEX = 369, _IMAGINARY = 370, RESTRICT = 371, THREAD = 372
 };
 
 typedef union YYSTYPE
@@ -982,9 +995,13 @@ struct Statement * getStmt;
 struct Statement * setStmt;
 struct Statement * issetStmt;
 struct Symbol * symbol;
-unsigned int conversion;
-unsigned int isWatchable;
 struct Expression * category;
+struct
+{
+unsigned int conversion : 1;
+unsigned int isWatchable : 1;
+unsigned int isDBProp : 1;
+} __attribute__ ((gcc_struct));
 } __attribute__ ((gcc_struct));
 
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_PropertyWatch;
@@ -1077,6 +1094,8 @@ static void ProcessProperty(struct PropertyDef * def);
 
 static void ProcessStatement(struct Statement * stmt);
 
+static void ProcessInitializer(struct Initializer * initializer);
+
 static void ProcessSpecifier(struct Specifier * spec)
 {
 switch(spec->type)
@@ -1123,6 +1142,10 @@ if(def->propertyWatch && def->propertyWatch->compound)
 ProcessStatement(def->propertyWatch->compound);
 }
 break;
+case 11:
+if(def->initializer)
+ProcessInitializer(def->initializer);
+break;
 }
 }
 }
@@ -1175,6 +1198,8 @@ extern struct Statement * MkIfStmt(struct __ecereNameSpace__ecere__sys__OldList
 
 extern struct Statement * MkReturnStmt(struct __ecereNameSpace__ecere__sys__OldList * exp);
 
+extern struct Expression * MkExpConstant(char *  string);
+
 extern struct Statement * MkExpressionStmt(struct __ecereNameSpace__ecere__sys__OldList * expressions);
 
 extern struct Expression * MkExpOp(struct Expression * exp1, int op, struct Expression * exp2);
@@ -1187,15 +1212,11 @@ extern struct Expression * MkExpMember(struct Expression * expression, struct Id
 
 extern struct Declarator * MkDeclaratorArray(struct Declarator * declarator, struct Expression * exp);
 
-extern struct Expression * MkExpConstant(char *  string);
-
 extern struct Initializer * MkInitializerList(struct __ecereNameSpace__ecere__sys__OldList * list);
 
 extern void Compiler_Error(char *  format, ...);
 
-extern char *  __ecereNameSpace__ecere__GetTranslatedString(struct __ecereNameSpace__ecere__com__Instance * module, char *  string, char *  stringAndContext);
-
-extern struct __ecereNameSpace__ecere__com__Instance * __thisModule;
+extern char *  __ecereNameSpace__ecere__GetTranslatedString(char * name, char *  string, char *  stringAndContext);
 
 extern void *  __ecereNameSpace__ecere__com__eInstance_New(struct __ecereNameSpace__ecere__com__Class * _class);
 
@@ -1292,7 +1313,7 @@ ProcessExpression(exp->cond.elseExp);
 break;
 case 16:
 break;
-case 31:
+case 29:
 {
 char tableName[1024];
 char name[1024];
@@ -1307,7 +1328,7 @@ exp->type = 0;
 exp->identifier = MkIdentifier(name);
 break;
 }
-case 32:
+case 30:
 {
 char tableName[1024];
 char name[1024];
@@ -1322,7 +1343,7 @@ exp->type = 0;
 exp->identifier = MkIdentifier(name);
 break;
 }
-case 33:
+case 31:
 {
 char tableName[1024];
 char name[1024];
@@ -1337,7 +1358,7 @@ exp->type = 0;
 exp->identifier = MkIdentifier(name);
 break;
 }
-case 30:
+case 28:
 {
 if(tableStatements)
 {
@@ -1358,7 +1379,7 @@ args = MkList();
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*args), MkSpecifier(STATIC));
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*args), MkSpecifierName("bool"));
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*databaseOpenStmt->compound.declarations), MkDeclaration(args, MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("initialized")), MkInitializerAssignment(MkExpIdentifier(MkIdentifier("false")))))));
-__ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*databaseOpenStmt->compound.statements), MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("initialized"))), MkReturnStmt(MkListOne(MkExpIdentifier(MkIdentifier("null")))), (((void *)0))));
+__ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*databaseOpenStmt->compound.statements), MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("initialized"))), MkReturnStmt(MkListOne(MkExpConstant("0"))), (((void *)0))));
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*databaseOpenStmt->compound.statements), MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("initialized")), '=', MkExpIdentifier(MkIdentifier("true"))))));
 args = MkList();
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*args), CopyExpression(exp->dbopen.name));
@@ -1385,6 +1406,7 @@ __ecereInstance1->parent = databaseOpenStmt->compound.context, __ecereInstance1;
 });
 sprintf(numIndexesString, "%d", numIndexes);
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*ifDBStmt->compound.declarations), MkDeclaration(MkListOne(MkSpecifierName("FieldIndex")), MkListOne(MkInitDeclarator(MkDeclaratorArray(MkDeclaratorIdentifier(MkIdentifier("indexes")), MkExpConstant(numIndexesString)), MkInitializerList(MkListOne(MkInitializerList(MkListOne(MkInitializerAssignment(MkExpIdentifier(MkIdentifier("null")))))))))));
+__ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*ifDBStmt->compound.statements), MkExpressionStmt(MkListOne(MkExpCall(MkExpMember(MkExpIdentifier(MkIdentifier("db")), MkIdentifier("Begin")), MkList()))));
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*ifDBStmt->compound.statements), compound = MkCompoundStmt((((void *)0)), tableStatements));
 compound->compound.context = __extension__ ({
 struct Context * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Context);
@@ -1402,7 +1424,8 @@ struct Context * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(
 
 __ecereInstance1->parent = ifDBStmt->compound.context, __ecereInstance1;
 });
-exp->type = 25;
+__ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*ifDBStmt->compound.statements), MkExpressionStmt(MkListOne(MkExpCall(MkExpMember(MkExpIdentifier(MkIdentifier("db")), MkIdentifier("Commit")), MkList()))));
+exp->type = 23;
 exp->compound = databaseOpenStmt;
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*databaseOpenStmt->compound.statements), MkExpressionStmt(MkListOne(MkExpIdentifier(MkIdentifier("db")))));
 tableStatements = (((void *)0));
@@ -1410,7 +1433,7 @@ tableStatements = (((void *)0));
 else
 {
 FreeExpContents(exp);
-Compiler_Error(__ecereNameSpace__ecere__GetTranslatedString(__thisModule, "No database table defined in this module or database_open already used.\n", (((void *)0))));
+Compiler_Error(__ecereNameSpace__ecere__GetTranslatedString("ec", "No database table defined in this module or database_open already used.\n", (((void *)0))));
 exp->type = 16;
 }
 break;
@@ -1774,6 +1797,10 @@ ProcessMemberInit(init);
 }
 break;
 }
+case 11:
+if(def->initializer)
+ProcessInitializer(def->initializer);
+break;
 case 0:
 ProcessClassFunction(def->function);
 break;
@@ -1805,6 +1832,8 @@ ProcessClassDef(def);
 }
 }
 
+static int curSymbolID = 0;
+
 extern struct External * MkExternalDeclaration(struct Declaration * declaration);
 
 extern struct __ecereNameSpace__ecere__sys__OldList *  ast;
@@ -1878,7 +1907,7 @@ char tableID[1024];
 char nameField[1024];
 struct __ecereNameSpace__ecere__sys__OldList * args;
 struct __ecereNameSpace__ecere__sys__OldList * members;
-int symbolID = 0;
+int symbolID = curSymbolID;
 
 if(table->symbol)
 idClassDefs = MkList();
@@ -1973,6 +2002,7 @@ __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*args), MkExpIdentifie
 curContext = globalContext;
 def = MkClassDefProperty(MkProperty(CopyList(entry->dataType->qualifiers, CopySpecifier), CopyDeclarator(entry->dataType->declarator), MkIdentifier(name), rowSet, (((void *)0))));
 def->propertyDef->symbol->id = def->propertyDef->symbol->idCode = symbolID;
+def->propertyDef->isDBProp = 0x1;
 def->memberAccess = 1;
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*rowClassDefs), def);
 }
@@ -2022,6 +2052,7 @@ __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*args), MkExpIdentifie
 curContext = globalContext;
 def = MkClassDefProperty(MkProperty(CopyList(entry->dataType->qualifiers, CopySpecifier), entry->dataType->declarator, CopyIdentifier(entry->id), rowSet, rowGet));
 def->propertyDef->symbol->id = def->propertyDef->symbol->idCode = symbolID;
+def->propertyDef->isDBProp = 0x1;
 def->memberAccess = 1;
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*rowClassDefs), def);
 }
@@ -2142,6 +2173,7 @@ __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*idSet->compound.state
 curContext = globalContext;
 def = MkClassDefProperty(MkProperty(CopyList(entry->dataType->qualifiers, CopySpecifier), CopyDeclarator(entry->dataType->declarator), CopyIdentifier(entry->id), idSet, idGet));
 def->propertyDef->symbol->id = def->propertyDef->symbol->idCode = symbolID;
+def->propertyDef->isDBProp = 0x1;
 def->memberAccess = 1;
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*idClassDefs), def);
 }
@@ -2171,7 +2203,7 @@ external->declaration->declMode = table->declMode;
 needTable = 0x1;
 }
 else
-Compiler_Error(__ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Multiple field index requires a name\n", (((void *)0))));
+Compiler_Error(__ecereNameSpace__ecere__GetTranslatedString("ec", "Multiple field index requires a name\n", (((void *)0))));
 }
 else
 {
@@ -2234,6 +2266,9 @@ if(ast != (((void *)0)))
 for(external = (*ast).first; external; external = external->next)
 {
 curExternal = external;
+if(external->symbol)
+curSymbolID = external->symbol->idCode;
+addAfter = external->prev;
 switch(external->type)
 {
 case 5:
@@ -2244,6 +2279,9 @@ break;
 for(external = (*ast).first; external; external = external->next)
 {
 curExternal = external;
+if(external->symbol)
+curSymbolID = external->symbol->idCode;
+addAfter = external->prev;
 switch(external->type)
 {
 case 0: