compiler/libec: Fixed improper usage of GCC compound statement expressions that would...
authorJerome St-Louis <jerome@ecere.com>
Mon, 13 Aug 2012 04:32:13 +0000 (00:32 -0400)
committerJerome St-Louis <jerome@ecere.com>
Mon, 13 Aug 2012 04:32:13 +0000 (00:32 -0400)
1. In builtin containers for [ ] syntax
2. Passing by address template types templated to doubles
3. Also fixed converting double template type to/from generic uint64 (which still worked but were similarly improper)

compiler/bootstrap/ecere/bootstrap/System.c
compiler/bootstrap/libec/bootstrap/pass15.c
compiler/bootstrap/libec/bootstrap/pass16.c
compiler/bootstrap/libec/bootstrap/pass2.c
compiler/bootstrap/libec/bootstrap/pass3.c
compiler/libec/locale/ec.pot
compiler/libec/src/pass15.ec
compiler/libec/src/pass16.ec
compiler/libec/src/pass2.ec
compiler/libec/src/pass3.ec
eda/libeda/locale/EDA.pot

index e5650af..d410daa 100644 (file)
@@ -750,18 +750,13 @@ extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_String;
 
 void __ecereCreateModuleInstances_System()
 {
-(__ecereNameSpace__ecere__sys__errorMessages = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass___ecereNameSpace__ecere__com__Array_TPL_String_), __ecereProp___ecereNameSpace__ecere__com__Container_Set_copySrc(__ecereNameSpace__ecere__sys__errorMessages, ((struct __ecereNameSpace__ecere__com__Instance *)__extension__ ({
-char * __internalList[] = 
+(__ecereNameSpace__ecere__sys__errorMessages = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass___ecereNameSpace__ecere__com__Array_TPL_String_), __ecereProp___ecereNameSpace__ecere__com__Container_Set_copySrc(__ecereNameSpace__ecere__sys__errorMessages, ((struct __ecereNameSpace__ecere__com__Instance *)&__extension__ (struct __ecereNameSpace__ecere__com__BuiltInContainer)
 {
-__ecereNameSpace__ecere__GetTranslatedString(__thisModule, "No error", (((void *)0))), __ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Memory allocation failed", (((void *)0))), __ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Inexistant string identifier specified", (((void *)0))), __ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Identic string identifier already exists", (((void *)0))), __ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Shared library loading failed", (((void *)0))), __ecereNameSpace__ecere__GetTranslatedString(__thisModule, "File not found", (((void *)0))), __ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Couldn't write to file", (((void *)0)))
-};
-struct __ecereNameSpace__ecere__com__BuiltInContainer __internalContainer = 
+__ecereClass___ecereNameSpace__ecere__com__BuiltInContainer->_vTbl, __ecereClass___ecereNameSpace__ecere__com__BuiltInContainer, 0, __extension__ (char * [])
 {
-__ecereClass___ecereNameSpace__ecere__com__BuiltInContainer->_vTbl, __ecereClass___ecereNameSpace__ecere__com__BuiltInContainer, 0, __internalList, 7, __ecereClass_String
-};
-
-&__internalContainer;
-}))));
+__ecereNameSpace__ecere__GetTranslatedString(__thisModule, "No error", (((void *)0))), __ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Memory allocation failed", (((void *)0))), __ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Inexistant string identifier specified", (((void *)0))), __ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Identic string identifier already exists", (((void *)0))), __ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Shared library loading failed", (((void *)0))), __ecereNameSpace__ecere__GetTranslatedString(__thisModule, "File not found", (((void *)0))), __ecereNameSpace__ecere__GetTranslatedString(__thisModule, "Couldn't write to file", (((void *)0)))
+}, 7, __ecereClass_String
+})));
 __ecereNameSpace__ecere__com__eInstance_IncRef(__ecereNameSpace__ecere__sys__errorMessages);
 }
 
index d8d3786..8a7168d 100644 (file)
@@ -10728,12 +10728,12 @@ result = 0x1;
 return result;
 }
 
-extern struct Expression * MkExpExtensionCompound(struct Statement * compound);
-
 extern struct Statement * MkCompoundStmt(struct __ecereNameSpace__ecere__sys__OldList * declarations, struct __ecereNameSpace__ecere__sys__OldList * statements);
 
 extern struct Statement * MkExpressionStmt(struct __ecereNameSpace__ecere__sys__OldList * expressions);
 
+extern struct Expression * MkExpMember(struct Expression * expression, struct Identifier * member);
+
 void CheckTemplateTypes(struct Expression * exp)
 {
 if(exp->destType && exp->destType->passAsTemplate && exp->expType && exp->expType->kind != 20 && !exp->expType->passAsTemplate)
@@ -10752,13 +10752,31 @@ newExp->next = (((void *)0));
 switch(exp->expType->kind)
 {
 case 7:
-exp->type = 4;
-exp->op.exp1 = (((void *)0));
+if(exp->destType->classObjectType)
+{
+if(exp->destType)
+exp->destType->refCount--;
+if(exp->expType)
+exp->expType->refCount--;
+((newExp ? (__ecereClass_Expression->Destructor ? __ecereClass_Expression->Destructor(newExp) : 0, __ecereNameSpace__ecere__com__eSystem_Delete(newExp)) : 0), newExp = 0);
+}
+else
+{
+struct __ecereNameSpace__ecere__sys__OldList * specs;
+struct __ecereNameSpace__ecere__sys__OldList * unionDefs = MkList();
+struct __ecereNameSpace__ecere__sys__OldList * statements = MkList();
+
 context = PushContext();
-exp->op.exp2 = MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uint64")), MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), (((void *)0)))), MkExpExtensionCompound(compound = MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifier(DOUBLE)), MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal")), MkInitializerAssignment(newExp))))), MkListOne(MkExpressionStmt(MkListOne(MkExpOp((((void *)0)), '&', MkExpIdentifier(MkIdentifier("__internal")))))))));
-compound->compound.context = context;
+ListAdd(unionDefs, MkClassDefDeclaration(MkStructDeclaration(MkListOne(MkSpecifier(DOUBLE)), MkListOne(MkDeclaratorIdentifier(MkIdentifier("d"))), (((void *)0)))));
+ListAdd(unionDefs, MkClassDefDeclaration(MkStructDeclaration(MkListOne(MkSpecifierName("uint64")), MkListOne(MkDeclaratorIdentifier(MkIdentifier("i"))), (((void *)0)))));
+specs = MkListOne(MkStructOrUnion(4, (((void *)0)), unionDefs));
+exp->type = 25;
+exp->compound = MkCompoundStmt(MkListOne(MkDeclaration(specs, MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal_union")), (((void *)0)))))), statements);
+ListAdd(statements, MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("__internal_union")), MkIdentifier("d")), '=', newExp))));
+ListAdd(statements, MkExpressionStmt(MkListOne(MkExpMember(MkExpIdentifier(MkIdentifier("__internal_union")), MkIdentifier("i")))));
+exp->compound->compound.context = context;
 PopContext(context);
-exp->op.op = '*';
+}
 break;
 default:
 exp->type = 11;
@@ -10783,14 +10801,31 @@ newExp->next = (((void *)0));
 switch(exp->expType->kind)
 {
 case 7:
-exp->type = 4;
-exp->op.exp1 = (((void *)0));
+if(exp->destType->classObjectType)
+{
+if(exp->destType)
+exp->destType->refCount--;
+if(exp->expType)
+exp->expType->refCount--;
+((newExp ? (__ecereClass_Expression->Destructor ? __ecereClass_Expression->Destructor(newExp) : 0, __ecereNameSpace__ecere__com__eSystem_Delete(newExp)) : 0), newExp = 0);
+}
+else
+{
+struct __ecereNameSpace__ecere__sys__OldList * specs;
+struct __ecereNameSpace__ecere__sys__OldList * unionDefs = MkList();
+struct __ecereNameSpace__ecere__sys__OldList * statements = MkList();
+
 context = PushContext();
-exp->op.exp2 = MkExpCast(MkTypeName(MkListOne(MkSpecifier(DOUBLE)), MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), (((void *)0)))), MkExpExtensionCompound(compound = MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifierName("uint64")), MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal")), MkInitializerAssignment(newExp))))), MkListOne(MkExpressionStmt(MkListOne(MkExpOp((((void *)0)), '&', MkExpIdentifier(MkIdentifier("__internal")))))))));
-compound->compound.context = context;
+ListAdd(unionDefs, MkClassDefDeclaration(MkStructDeclaration(MkListOne(MkSpecifier(DOUBLE)), MkListOne(MkDeclaratorIdentifier(MkIdentifier("d"))), (((void *)0)))));
+ListAdd(unionDefs, MkClassDefDeclaration(MkStructDeclaration(MkListOne(MkSpecifierName("uint64")), MkListOne(MkDeclaratorIdentifier(MkIdentifier("i"))), (((void *)0)))));
+specs = MkListOne(MkStructOrUnion(4, (((void *)0)), unionDefs));
+exp->type = 25;
+exp->compound = MkCompoundStmt(MkListOne(MkDeclaration(specs, MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal_union")), (((void *)0)))))), statements);
+ListAdd(statements, MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("__internal_union")), MkIdentifier("i")), '=', newExp))));
+ListAdd(statements, MkExpressionStmt(MkListOne(MkExpMember(MkExpIdentifier(MkIdentifier("__internal_union")), MkIdentifier("d")))));
+exp->compound->compound.context = context;
 PopContext(context);
-exp->op.op = '*';
-ProcessExpressionType(exp->op.exp2);
+}
 break;
 case 8:
 {
@@ -11739,8 +11774,6 @@ extern unsigned int __ecereNameSpace__ecere__sys__UTF8GetChar(char *  string, in
 
 extern struct Expression * GetTemplateArgExp(struct TemplateParameter * param, struct __ecereNameSpace__ecere__com__Class * curClass, unsigned int pointer);
 
-extern struct Expression * MkExpMember(struct Expression * expression, struct Identifier * member);
-
 extern struct Expression * MkExpCondition(struct Expression * cond, struct __ecereNameSpace__ecere__sys__OldList * expressions, struct Expression * elseExp);
 
 extern struct Expression * CopyExpression(struct Expression * exp);
@@ -11751,11 +11784,11 @@ extern struct Expression * MkExpClass(struct __ecereNameSpace__ecere__sys__OldLi
 
 static void ProcessStatement(struct Statement * stmt);
 
-extern struct Initializer * MkInitializerList(struct __ecereNameSpace__ecere__sys__OldList * list);
+extern struct Expression * MkExpExtensionInitializer(struct TypeName * typeName, struct Initializer * initializer);
 
-extern struct Declaration * MkDeclarationInst(struct Instantiation * inst);
+extern struct Initializer * MkInitializerList(struct __ecereNameSpace__ecere__sys__OldList * list);
 
-extern struct Instantiation * MkInstantiationNamed(struct __ecereNameSpace__ecere__sys__OldList * specs, struct Expression * exp, struct __ecereNameSpace__ecere__sys__OldList * members);
+extern char *  __ecereNameSpace__ecere__com__PrintString(struct __ecereNameSpace__ecere__com__Class * class, void * object, ...);
 
 void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Clear(struct __ecereNameSpace__ecere__sys__OldList * this);
 
@@ -14192,25 +14225,17 @@ type = (((void *)0));
 if(typeString)
 {
 char templateString[1024];
-struct __ecereNameSpace__ecere__sys__OldList * declarations = MkList();
-struct __ecereNameSpace__ecere__sys__OldList * instMembers = MkList();
-struct __ecereNameSpace__ecere__sys__OldList * specs = MkList();
 struct __ecereNameSpace__ecere__sys__OldList * initializers = MkList();
-char count[128];
-struct Expression * e;
+struct __ecereNameSpace__ecere__sys__OldList * structInitializers = MkList();
+struct __ecereNameSpace__ecere__sys__OldList * specs = MkList();
 struct Expression * expExt;
 struct Declarator * decl = SpecDeclFromString(typeString, specs, (((void *)0)));
-struct Context * context = PushContext();
 
 sprintf(templateString, "Container<%s>", typeString);
-ListAdd(instMembers, MkMemberInit(MkListOne(MkIdentifier("data")), MkInitializerAssignment(MkExpIdentifier(MkIdentifier("__internalList")))));
-sprintf(count, "%d", (*exp->list).count);
-ListAdd(instMembers, MkMemberInit(MkListOne(MkIdentifier("count")), MkInitializerAssignment(MkExpConstant(count))));
-ListAdd(instMembers, MkMemberInit(MkListOne(MkIdentifier("type")), MkInitializerAssignment(MkExpClass(CopyList(specs, CopySpecifier), CopyDeclarator(decl)))));
-ListAdd(instMembers, MkMemberInit(MkListOne(MkIdentifier("_vTbl")), MkInitializerAssignment(MkExpMember(MkExpClass(MkListOne(MkSpecifierName("BuiltInContainer")), (((void *)0))), MkIdentifier("_vTbl")))));
-ListAdd(instMembers, MkMemberInit(MkListOne(MkIdentifier("_class")), MkInitializerAssignment(MkExpClass(MkListOne(MkSpecifierName("BuiltInContainer")), (((void *)0))))));
 if(exp->list)
 {
+struct Expression * e;
+
 type = ProcessTypeString(typeString, 0x0);
 while(e = (*exp->list).first)
 {
@@ -14223,13 +14248,22 @@ ListAdd(initializers, MkInitializerAssignment(e));
 FreeType(type);
 (__ecereNameSpace__ecere__com__eSystem_Delete(exp->list), exp->list = 0);
 }
-ListAdd(declarations, MkDeclaration(specs, MkListOne(MkInitDeclarator(MkDeclaratorArray(PlugDeclarator(decl, MkDeclaratorIdentifier(MkIdentifier("__internalList"))), (((void *)0))), MkInitializerList(initializers)))));
-ListAdd(declarations, MkDeclarationInst(MkInstantiationNamed(MkListOne(MkSpecifierName("BuiltInContainer")), MkExpIdentifier(MkIdentifier("__internalContainer")), MkListOne(MkMembersInitList(instMembers)))));
+DeclareStruct("ecere::com::BuiltInContainer", 0x0);
+ListAdd(structInitializers, MkInitializerAssignment(MkExpMember(MkExpClass(MkListOne(MkSpecifierName("BuiltInContainer")), (((void *)0))), MkIdentifier("_vTbl"))));
+ProcessExpressionType(((struct Initializer *)(*structInitializers).last)->exp);
+ListAdd(structInitializers, MkInitializerAssignment(MkExpClass(MkListOne(MkSpecifierName("BuiltInContainer")), (((void *)0)))));
+ProcessExpressionType(((struct Initializer *)(*structInitializers).last)->exp);
+ListAdd(structInitializers, MkInitializerAssignment(MkExpConstant("0")));
+ProcessExpressionType(((struct Initializer *)(*structInitializers).last)->exp);
+ListAdd(structInitializers, MkInitializerAssignment(MkExpExtensionInitializer(MkTypeName(specs, MkDeclaratorArray(decl, (((void *)0)))), MkInitializerList(initializers))));
+ProcessExpressionType(((struct Initializer *)(*structInitializers).last)->exp);
+ListAdd(structInitializers, MkInitializerAssignment((__ecereTemp1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Expression), ((struct Expression *)__ecereTemp1)->type = 2, ((struct Expression *)__ecereTemp1)->constant = __ecereNameSpace__ecere__com__PrintString(__ecereClass_int, &(*initializers).count, 0), ((struct Expression *)__ecereTemp1))));
+ProcessExpressionType(((struct Initializer *)(*structInitializers).last)->exp);
+ListAdd(structInitializers, MkInitializerAssignment(MkExpClass(CopyList(specs, CopySpecifier), CopyDeclarator(decl))));
+ProcessExpressionType(((struct Initializer *)(*structInitializers).last)->exp);
 exp->expType = ProcessTypeString(templateString, 0x0);
 exp->type = 5;
-exp->list = MkListOne(MkExpCast(MkTypeName(MkListOne(MkSpecifierName(templateString)), (((void *)0))), (expExt = MkExpExtensionCompound(MkCompoundStmt(declarations, MkListOne(MkExpressionStmt(MkListOne(MkExpOp((((void *)0)), '&', MkExpIdentifier(MkIdentifier("__internalContainer")))))))))));
-expExt->compound->compound.context = context;
-PopContext(context);
+exp->list = MkListOne(MkExpCast(MkTypeName(MkListOne(MkSpecifierName(templateString)), (((void *)0))), MkExpOp((((void *)0)), '&', expExt = MkExpExtensionInitializer(MkTypeName(MkListOne(MkSpecifierName("BuiltInContainer")), (((void *)0))), MkInitializerList(structInitializers)))));
 ProcessExpressionType(expExt);
 }
 else
@@ -14863,6 +14897,10 @@ if(curFunction->propSet && !strcmp(curFunction->propSet->string, prop->name) &&
 curFunction->propSet->fireWatchersDone = 0x1;
 }
 
+extern struct Declaration * MkDeclarationInst(struct Instantiation * inst);
+
+extern struct Instantiation * MkInstantiationNamed(struct __ecereNameSpace__ecere__sys__OldList * specs, struct Expression * exp, struct __ecereNameSpace__ecere__sys__OldList * members);
+
 extern struct Statement * MkIfStmt(struct __ecereNameSpace__ecere__sys__OldList * exp, struct Statement * statement, struct Statement * elseStmt);
 
 extern struct Statement * MkForStmt(struct Statement * init, struct Statement * check, struct __ecereNameSpace__ecere__sys__OldList * inc, struct Statement * statement);
index 9195042..b13be69 100644 (file)
@@ -2491,6 +2491,11 @@ case 36:
 ProcessExpression(exp->vaArg.exp);
 break;
 }
+case 35:
+{
+ProcessInitializer(exp->initializer.initializer);
+break;
+}
 }
 CheckTemplateTypes(exp);
 }
index 17aac21..1562ac8 100644 (file)
@@ -1430,6 +1430,8 @@ extern void FreeDeclarator(struct Declarator * decl);
 
 extern char *  StringFromSpecDecl(struct __ecereNameSpace__ecere__sys__OldList * specs, struct Declarator * decl);
 
+static void ProcessInitializer(struct Initializer * init);
+
 unsigned int __ecereMethod___ecereNameSpace__ecere__sys__OldList_Insert(struct __ecereNameSpace__ecere__sys__OldList * this, void *  prevItem, void *  item);
 
 unsigned int __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(struct __ecereNameSpace__ecere__sys__BinaryTree * this, struct __ecereNameSpace__ecere__sys__BTNode * node);
@@ -3445,6 +3447,11 @@ case 36:
 ProcessExpression(exp->vaArg.exp);
 break;
 }
+case 35:
+{
+ProcessInitializer(exp->initializer.initializer);
+break;
+}
 }
 FixRefExp(exp);
 yylloc = oldyylloc;
index ba51e09..209a183 100644 (file)
@@ -1407,6 +1407,8 @@ extern void FreeType(struct Type * type);
 
 static void InstDeclPassStatement(struct Statement * stmt);
 
+static void InstDeclPassInitializer(struct Initializer * init);
+
 static void InstDeclPassExpression(struct Expression * exp)
 {
 switch(exp->type)
@@ -1517,6 +1519,12 @@ case 36:
 InstDeclPassExpression(exp->vaArg.exp);
 break;
 }
+case 35:
+{
+InstDeclPassTypeName(exp->initializer.typeName, 0x0);
+InstDeclPassInitializer(exp->initializer.initializer);
+break;
+}
 }
 }
 
index 04e1559..9859cea 100644 (file)
@@ -15,7 +15,7 @@ msgstr ""
 msgid "%s expected to be derived from method class\n"
 msgstr "%s expected to be derived from method class\n"
 
-#: ./src/pass15.ec:8806
+#: ./src/pass15.ec:8833
 msgid "%s undefined; assuming extern returning int\n"
 msgstr "%s undefined; assuming extern returning int\n"
 
@@ -31,12 +31,12 @@ msgstr ":%d:%d: warning: "
 msgid "Array size not constant int (%s)\n"
 msgstr "Array size not constant int (%s)\n"
 
-#: ./src/pass15.ec:10322
+#: ./src/pass15.ec:10338
 msgid "Assigning list initializer to non list\n"
 msgstr "Assigning list initializer to non list\n"
 
-#: ./src/pass15.ec:9988
-#: ./src/pass15.ec:11033
+#: ./src/pass15.ec:10004
+#: ./src/pass15.ec:11049
 msgid "Couldn't determine type of array elements\n"
 msgstr "Couldn't determine type of array elements\n"
 
@@ -52,7 +52,7 @@ msgstr "Couldn't open %s\n"
 msgid "Expecting class specifier\n"
 msgstr "Expecting class specifier\n"
 
-#: ./src/pass15.ec:11191
+#: ./src/pass15.ec:11207
 msgid "Expression is not a container\n"
 msgstr "Expression is not a container\n"
 
@@ -64,12 +64,12 @@ msgstr "Includes nested too deeply"
 msgid "Incompatible virtual function %s\n"
 msgstr "Incompatible virtual function %s\n"
 
-#: ./src/pass15.ec:11465
-#: ./src/pass15.ec:11540
+#: ./src/pass15.ec:11481
+#: ./src/pass15.ec:11556
 msgid "Invalid object specified and not inside a class\n"
 msgstr "Invalid object specified and not inside a class\n"
 
-#: ./src/pass15.ec:11373
+#: ./src/pass15.ec:11389
 msgid "Invalid watched object\n"
 msgstr "Invalid watched object\n"
 
@@ -94,16 +94,16 @@ msgstr "Multiple field index requires a name\n"
 msgid "No database table defined in this module or database_open already used.\n"
 msgstr "No database table defined in this module or database_open already used.\n"
 
-#: ./src/pass15.ec:11386
+#: ./src/pass15.ec:11402
 msgid "No observer specified and not inside a _class\n"
 msgstr "No observer specified and not inside a _class\n"
 
-#: ./src/pass15.ec:11543
+#: ./src/pass15.ec:11559
 msgid "No observer specified and not inside a class\n"
 msgstr "No observer specified and not inside a class\n"
 
-#: ./src/pass16.ec:1905
-#: ./src/pass16.ec:1976
+#: ./src/pass16.ec:1910
+#: ./src/pass16.ec:1981
 msgid "No set defined for property %s\n"
 msgstr "No set defined for property %s\n"
 
@@ -112,9 +112,9 @@ msgid "Non-static %s making use of a static class\n"
 msgstr "Non-static %s making use of a static class\n"
 
 #: ./src/pass1.ec:1035
-#: ./src/pass15.ec:11368
-#: ./src/pass15.ec:11440
-#: ./src/pass15.ec:11529
+#: ./src/pass15.ec:11384
+#: ./src/pass15.ec:11456
+#: ./src/pass15.ec:11545
 msgid "Property %s not found in class %s\n"
 msgstr "Property %s not found in class %s\n"
 
@@ -122,7 +122,7 @@ msgstr "Property %s not found in class %s\n"
 msgid "Public %s making use of a private class\n"
 msgstr "Public %s making use of a private class\n"
 
-#: ./src/pass15.ec:7258
+#: ./src/pass15.ec:7285
 msgid "Recursion in defined expression %s\n"
 msgstr "Recursion in defined expression %s\n"
 
@@ -143,21 +143,21 @@ msgstr "Redefinition of method %s in class %s\n"
 msgid "Unhandled type populating instance\n"
 msgstr "Unhandled type populating instance\n"
 
-#: ./src/pass15.ec:6994
+#: ./src/pass15.ec:7021
 msgid "Unspecified type\n"
 msgstr "Unspecified type\n"
 
-#: ./src/pass15.ec:8821
+#: ./src/pass15.ec:8848
 msgid "callable object undefined; extern assuming returning int\n"
 msgstr "callable object undefined; extern assuming returning int\n"
 
-#: ./src/pass15.ec:8631
+#: ./src/pass15.ec:8658
 msgid "called object %s is not a function\n"
 msgstr "called object %s is not a function\n"
 
-#: ./src/pass15.ec:7720
-#: ./src/pass15.ec:7726
-#: ./src/pass15.ec:7890
+#: ./src/pass15.ec:7747
+#: ./src/pass15.ec:7753
+#: ./src/pass15.ec:7917
 msgid "cannot add two pointers\n"
 msgstr "cannot add two pointers\n"
 
@@ -183,19 +183,19 @@ msgstr "class data member"
 msgid "class member instance"
 msgstr "class member instance"
 
-#: ./src/pass15.ec:10063
+#: ./src/pass15.ec:10079
 msgid "couldn't determine type of %s; expected %s\n"
 msgstr "couldn't determine type of %s; expected %s\n"
 
-#: ./src/pass15.ec:8267
-#: ./src/pass15.ec:8279
-#: ./src/pass15.ec:10075
-#: ./src/pass15.ec:10149
+#: ./src/pass15.ec:8294
+#: ./src/pass15.ec:8306
+#: ./src/pass15.ec:10091
+#: ./src/pass15.ec:10165
 msgid "couldn't determine type of %s\n"
 msgstr "couldn't determine type of %s\n"
 
 #: ./src/pass15.ec:1941
-#: ./src/pass15.ec:9286
+#: ./src/pass15.ec:9313
 msgid "couldn't find member %s in class %s\n"
 msgstr "couldn't find member %s in class %s\n"
 
@@ -204,17 +204,17 @@ msgstr "couldn't find member %s in class %s\n"
 msgid "couldn't find virtual method %s in class %s\n"
 msgstr "couldn't find virtual method %s in class %s\n"
 
-#: ./src/pass15.ec:7882
+#: ./src/pass15.ec:7909
 msgid "different levels of indirection\n"
 msgstr "different levels of indirection\n"
 
-#: ./src/pass15.ec:7738
-#: ./src/pass15.ec:10104
+#: ./src/pass15.ec:7765
+#: ./src/pass15.ec:10120
 msgid "incompatible expression %s (%s); expected %s\n"
 msgstr "incompatible expression %s (%s); expected %s\n"
 
-#: ./src/pass15.ec:7999
-#: ./src/pass15.ec:8159
+#: ./src/pass15.ec:8026
+#: ./src/pass15.ec:8186
 msgid "incompatible expressions %s (%s) and %s (%s)\n"
 msgstr "incompatible expressions %s (%s) and %s (%s)\n"
 
@@ -230,11 +230,11 @@ msgstr "incompatible parameter %s (expected %s)\n"
 msgid "incompatible return type for function\n"
 msgstr "incompatible return type for function\n"
 
-#: ./src/pass15.ec:9100
+#: ./src/pass15.ec:9127
 msgid "invalid class specifier %s for object of class %s\n"
 msgstr "invalid class specifier %s for object of class %s\n"
 
-#: ./src/pass15.ec:9570
+#: ./src/pass15.ec:9597
 msgid "member operator on non-structure type expression %s\n"
 msgstr "member operator on non-structure type expression %s\n"
 
@@ -257,11 +257,11 @@ msgstr "no get defined for property %s of class %s\n"
 msgid "no set defined for property %s of class %s\n"
 msgstr "no set defined for property %s of class %s\n"
 
-#: ./src/pass15.ec:8780
+#: ./src/pass15.ec:8807
 msgid "not enough arguments for function %s (%d given, expected %d)\n"
 msgstr "not enough arguments for function %s (%d given, expected %d)\n"
 
-#: ./src/pass15.ec:8776
+#: ./src/pass15.ec:8803
 msgid "not enough arguments for method %s::%s (%d given, expected %d)\n"
 msgstr "not enough arguments for method %s::%s (%d given, expected %d)\n"
 
@@ -269,11 +269,11 @@ msgstr "not enough arguments for method %s::%s (%d given, expected %d)\n"
 msgid "not enough parameters\n"
 msgstr "not enough parameters\n"
 
-#: ./src/pass15.ec:7825
+#: ./src/pass15.ec:7852
 msgid "operating on %s and %s with an untyped result, assuming %s\n"
 msgstr "operating on %s and %s with an untyped result, assuming %s\n"
 
-#: ./src/pass15.ec:7650
+#: ./src/pass15.ec:7677
 msgid "operator %s illegal on pointer\n"
 msgstr "operator %s illegal on pointer\n"
 
@@ -299,21 +299,21 @@ msgid "redefinition of destructor for class %s\n"
 msgstr "redefinition of destructor for class %s\n"
 
 #: ./src/ecdefs.ec:1282
-#: .\src\grammar.ec:3084
-#: .\src\grammar.ec:3085
-#: .\src\grammar.ec:3086
-#: .\src\grammar.ec:3087
-#: .\src\grammar.ec:3088
-#: .\src\grammar.ec:3089
-#: .\src\grammar.ec:3090
+#: ./src/grammar.ec:3084
+#: ./src/grammar.ec:3085
+#: ./src/grammar.ec:3086
+#: ./src/grammar.ec:3087
+#: ./src/grammar.ec:3088
+#: ./src/grammar.ec:3089
+#: ./src/grammar.ec:3090
 msgid "syntax error\n"
 msgstr "syntax error\n"
 
-#: ./src/pass15.ec:8699
+#: ./src/pass15.ec:8726
 msgid "too many arguments for function %s (%d given, expected %d)\n"
 msgstr "too many arguments for function %s (%d given, expected %d)\n"
 
-#: ./src/pass15.ec:8695
+#: ./src/pass15.ec:8722
 msgid "too many arguments for method %s::%s (%d given, expected %d)\n"
 msgstr "too many arguments for method %s::%s (%d given, expected %d)\n"
 
@@ -325,20 +325,20 @@ msgstr "too many initializers for instantiation of class %s\n"
 msgid "too many parameters\n"
 msgstr "too many parameters\n"
 
-#: ./src/pass15.ec:9553
+#: ./src/pass15.ec:9580
 msgid "undefined class %s\n"
 msgstr "undefined class %s\n"
 
-#: ./src/pass15.ec:10140
+#: ./src/pass15.ec:10156
 msgid "unresolved identifier %s::%s\n"
 msgstr "unresolved identifier %s::%s\n"
 
-#: ./src/pass15.ec:10061
+#: ./src/pass15.ec:10077
 msgid "unresolved identifier %s; expected %s\n"
 msgstr "unresolved identifier %s; expected %s\n"
 
-#: ./src/pass15.ec:10073
-#: ./src/pass15.ec:10142
+#: ./src/pass15.ec:10089
+#: ./src/pass15.ec:10158
 msgid "unresolved identifier %s\n"
 msgstr "unresolved identifier %s\n"
 
@@ -346,9 +346,9 @@ msgstr "unresolved identifier %s\n"
 msgid "unresolved symbol used as an instance method %s\n"
 msgstr "unresolved symbol used as an instance method %s\n"
 
-#: ./src/pass15.ec:7711
-#: ./src/pass15.ec:7868
-#: ./src/pass15.ec:7875
+#: ./src/pass15.ec:7738
+#: ./src/pass15.ec:7895
+#: ./src/pass15.ec:7902
 msgid "void *: unknown size\n"
 msgstr "void *: unknown size\n"
 
index 719cc8c..f6dad92 100644 (file)
@@ -5943,17 +5943,31 @@ void CheckTemplateTypes(Expression exp)
       switch(exp.expType.kind)
       {
          case doubleType:
-            exp.type = opExp;
-            exp.op.exp1 = null;
-            context = PushContext();               
-            exp.op.exp2 = MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uint64")), MkDeclaratorPointer(MkPointer(null, null), null)), 
-               MkExpExtensionCompound(compound = MkCompoundStmt(
-                  MkListOne(MkDeclaration(MkListOne(MkSpecifier(DOUBLE)), 
-                     MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal")), MkInitializerAssignment(newExp))))),
-                  MkListOne(MkExpressionStmt(MkListOne(MkExpOp(null, '&', MkExpIdentifier(MkIdentifier("__internal")))))))));
-            compound.compound.context = context;
-            PopContext(context);
-            exp.op.op = '*';
+            if(exp.destType.classObjectType)
+            {
+               // We need to pass the address, just pass it along (Undo what was done above)
+               if(exp.destType) exp.destType.refCount--;
+               if(exp.expType)  exp.expType.refCount--;
+               delete newExp;
+            }
+            else
+            {
+               // If we're looking for value:
+               // ({ union { double d; uint64 i; } u; u.i = [newExp]; u.d; })
+               OldList * specs;
+               OldList * unionDefs = MkList();
+               OldList * statements = MkList();
+               context = PushContext();
+               ListAdd(unionDefs, MkClassDefDeclaration(MkStructDeclaration(MkListOne(MkSpecifier(DOUBLE)), MkListOne(MkDeclaratorIdentifier(MkIdentifier("d"))), null))); 
+               ListAdd(unionDefs, MkClassDefDeclaration(MkStructDeclaration(MkListOne(MkSpecifierName("uint64")), MkListOne(MkDeclaratorIdentifier(MkIdentifier("i"))), null)));
+               specs = MkListOne(MkStructOrUnion(unionSpecifier, null, unionDefs ));
+               exp.type = extensionCompoundExp;
+               exp.compound = MkCompoundStmt(MkListOne(MkDeclaration(specs, MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal_union")), null)))),statements);
+               ListAdd(statements, MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("__internal_union")), MkIdentifier("d")), '=', newExp))));
+               ListAdd(statements, MkExpressionStmt(MkListOne(MkExpMember(MkExpIdentifier(MkIdentifier("__internal_union")), MkIdentifier("i")))));
+               exp.compound.compound.context = context;
+               PopContext(context);
+            }
             break;
          default:
             exp.type = castExp;
@@ -5976,18 +5990,31 @@ void CheckTemplateTypes(Expression exp)
       switch(exp.expType.kind)
       {
          case doubleType:
-            exp.type = opExp;
-            exp.op.exp1 = null;
-            context = PushContext();               
-            exp.op.exp2 = MkExpCast(MkTypeName(MkListOne(MkSpecifier(DOUBLE)), MkDeclaratorPointer(MkPointer(null, null), null)), 
-               MkExpExtensionCompound(compound = MkCompoundStmt(
-                  MkListOne(MkDeclaration(MkListOne(MkSpecifierName("uint64")), 
-                     MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal")), MkInitializerAssignment(newExp))))),
-                  MkListOne(MkExpressionStmt(MkListOne(MkExpOp(null, '&', MkExpIdentifier(MkIdentifier("__internal")))))))));
-            compound.compound.context = context;
-            PopContext(context);
-            exp.op.op = '*';
-            ProcessExpressionType(exp.op.exp2);
+            if(exp.destType.classObjectType)
+            {
+               // We need to pass the address, just pass it along (Undo what was done above)
+               if(exp.destType) exp.destType.refCount--;
+               if(exp.expType)  exp.expType.refCount--;
+               delete newExp;
+            }
+            else
+            {
+               // If we're looking for value:
+               // ({ union { double d; uint64 i; } u; u.i = [newExp]; u.d; })
+               OldList * specs;
+               OldList * unionDefs = MkList();
+               OldList * statements = MkList();
+               context = PushContext();
+               ListAdd(unionDefs, MkClassDefDeclaration(MkStructDeclaration(MkListOne(MkSpecifier(DOUBLE)), MkListOne(MkDeclaratorIdentifier(MkIdentifier("d"))), null))); 
+               ListAdd(unionDefs, MkClassDefDeclaration(MkStructDeclaration(MkListOne(MkSpecifierName("uint64")), MkListOne(MkDeclaratorIdentifier(MkIdentifier("i"))), null)));
+               specs = MkListOne(MkStructOrUnion(unionSpecifier, null, unionDefs ));
+               exp.type = extensionCompoundExp;
+               exp.compound = MkCompoundStmt(MkListOne(MkDeclaration(specs, MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal_union")), null)))),statements);
+               ListAdd(statements, MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("__internal_union")), MkIdentifier("i")), '=', newExp))));
+               ListAdd(statements, MkExpressionStmt(MkListOne(MkExpMember(MkExpIdentifier(MkIdentifier("__internal_union")), MkIdentifier("d")))));
+               exp.compound.compound.context = context;
+               PopContext(context);
+            }
             break;
          case classType:
          {
@@ -9725,6 +9752,8 @@ void ProcessExpressionType(Expression exp)
       {
          Type type = ProcessType(exp.initializer.typeName.qualifiers, exp.initializer.typeName.declarator);
          type.refCount++;
+
+         // We have yet to support this... ( { } initializers are currently processed inside ProcessDeclaration()'s initDeclaration case statement
          // ProcessInitializer(exp.initializer.initializer, type);
          exp.expType = type;
          break;
@@ -9911,49 +9940,27 @@ void ProcessExpressionType(Expression exp)
          if(typeString)
          {
             /*
-            (Container)(__extension__( { 
-               int __arrayMembers[] = { 1, 7, 3, 4, 5 };
-               BuiltInContainer __baseContainer
-               {
-                  data = __arrayMembers,
-                  count = 5,
-                  type = class(int),
-                  _vTbl = class(BuiltInContainer)._vTbl,
-                  _class = class(BuiltInContainer) };
-               &__baseContainer;
-             }))
+            (Container)& (struct BuiltInContainer)
+            {
+               ._vTbl = class(BuiltInContainer)._vTbl,
+               ._class = class(BuiltInContainer),
+               .refCount = 0,
+               .data = (int[]){ 1, 7, 3, 4, 5 },
+               .count = 5,
+               .type = class(int),
+            }
             */
-            
             char templateString[1024];
-            OldList * declarations = MkList();
-            OldList * instMembers = MkList();
-            OldList * specs = MkList();
             OldList * initializers = MkList();
-            char count[128];
-            Expression e;
+            OldList * structInitializers = MkList();
+            OldList * specs = MkList();
             Expression expExt;
             Declarator decl = SpecDeclFromString(typeString, specs, null);
-            Context context = PushContext();
-
-            // sprintf(templateString, "Container<%s >", typeString);
             sprintf(templateString, "Container<%s>", typeString);
-   
-            ListAdd(instMembers, MkMemberInit(MkListOne(MkIdentifier("data")), MkInitializerAssignment(MkExpIdentifier(MkIdentifier("__internalList")))));
-
-            sprintf(count, "%d", exp.list->count);
-            ListAdd(instMembers, MkMemberInit(MkListOne(MkIdentifier("count")), MkInitializerAssignment(MkExpConstant(count))));
-
-            ListAdd(instMembers, MkMemberInit(MkListOne(MkIdentifier("type")), MkInitializerAssignment(MkExpClass(CopyList(specs, CopySpecifier), 
-               CopyDeclarator(decl)))));
-
-            ListAdd(instMembers, MkMemberInit(MkListOne(MkIdentifier("_vTbl")), MkInitializerAssignment(MkExpMember(
-               MkExpClass(MkListOne(MkSpecifierName("BuiltInContainer")), null), MkIdentifier("_vTbl")))));
-
-            ListAdd(instMembers, MkMemberInit(MkListOne(MkIdentifier("_class")), MkInitializerAssignment(
-               MkExpClass(MkListOne(MkSpecifierName("BuiltInContainer")), null))));
 
             if(exp.list)
             {
+               Expression e;
                type = ProcessTypeString(typeString, false);
                while(e = exp.list->first)
                {
@@ -9967,19 +9974,28 @@ void ProcessExpressionType(Expression exp)
                delete exp.list;
             }
             
-            ListAdd(declarations, MkDeclaration(specs, MkListOne(MkInitDeclarator(MkDeclaratorArray(PlugDeclarator(decl, 
-               MkDeclaratorIdentifier(MkIdentifier("__internalList"))), null),
-               MkInitializerList(initializers)))));
-            ListAdd(declarations, MkDeclarationInst(MkInstantiationNamed(MkListOne(MkSpecifierName("BuiltInContainer")),
-               MkExpIdentifier(MkIdentifier("__internalContainer")), MkListOne(MkMembersInitList(instMembers)))));
-
+            DeclareStruct("ecere::com::BuiltInContainer", false);
+
+            ListAdd(structInitializers, /*MkIdentifier("_vTbl")*/    MkInitializerAssignment(MkExpMember(MkExpClass(MkListOne(MkSpecifierName("BuiltInContainer")), null), MkIdentifier("_vTbl"))));
+               ProcessExpressionType(((Initializer)structInitializers->last).exp);
+            ListAdd(structInitializers, /*MkIdentifier("_class")*/   MkInitializerAssignment(MkExpClass(MkListOne(MkSpecifierName("BuiltInContainer")), null)));
+               ProcessExpressionType(((Initializer)structInitializers->last).exp);
+            ListAdd(structInitializers, /*MkIdentifier("_refCount")*/MkInitializerAssignment(MkExpConstant("0")));
+               ProcessExpressionType(((Initializer)structInitializers->last).exp);
+            ListAdd(structInitializers, /*MkIdentifier("data")*/     MkInitializerAssignment(MkExpExtensionInitializer(
+               MkTypeName(specs, MkDeclaratorArray(decl, null)),
+               MkInitializerList(initializers))));
+               ProcessExpressionType(((Initializer)structInitializers->last).exp);
+            ListAdd(structInitializers, /*MkIdentifier("count")*/    MkInitializerAssignment({ type = constantExp, constant = PrintString(initializers->count) }));
+               ProcessExpressionType(((Initializer)structInitializers->last).exp);
+            ListAdd(structInitializers, /*MkIdentifier("type")*/     MkInitializerAssignment(MkExpClass(CopyList(specs, CopySpecifier), CopyDeclarator(decl))));
+               ProcessExpressionType(((Initializer)structInitializers->last).exp);
             exp.expType = ProcessTypeString(templateString, false);
             exp.type = bracketsExp;
             exp.list = MkListOne(MkExpCast(MkTypeName(MkListOne(MkSpecifierName(templateString)), null),
-               (expExt = MkExpExtensionCompound(MkCompoundStmt(
-                  declarations, MkListOne(MkExpressionStmt(MkListOne(MkExpOp(null, '&', MkExpIdentifier(MkIdentifier("__internalContainer")))))))))));
-            expExt.compound.compound.context = context;
-            PopContext(context);
+               MkExpOp(null, '&',
+               expExt = MkExpExtensionInitializer(MkTypeName(MkListOne(MkSpecifierName("BuiltInContainer")), null),
+                  MkInitializerList(structInitializers)))));
             ProcessExpressionType(expExt);
          }
          else
index 1cc4d0f..0f7969f 100644 (file)
@@ -1530,6 +1530,11 @@ static void ProcessExpression(Expression exp)
          ProcessExpression(exp.vaArg.exp);
          break;
       }
+      case extensionInitializerExp:
+      {
+         ProcessInitializer(exp.initializer.initializer);
+         break;
+      }
    }
    CheckTemplateTypes(exp);
 }
index 0a8275f..d0c1eef 100644 (file)
@@ -2804,6 +2804,11 @@ static void ProcessExpression(Expression exp)
          ProcessExpression(exp.vaArg.exp);
          break;
       }
+      case extensionInitializerExp:
+      {
+         ProcessInitializer(exp.initializer.initializer);
+         break;
+      }
    }
    FixRefExp(exp);
    yylloc = oldyylloc;
index 55b197e..81fe896 100644 (file)
@@ -532,6 +532,12 @@ static void InstDeclPassExpression(Expression exp)
          InstDeclPassExpression(exp.vaArg.exp);
          break;
       }
+      case extensionInitializerExp:
+      {
+         InstDeclPassTypeName(exp.initializer.typeName, false);
+         InstDeclPassInitializer(exp.initializer.initializer);
+         break;
+      }
    }
 }
 
index b9f22fb..311660a 100644 (file)
@@ -103,8 +103,8 @@ msgstr "Table Editor"
 msgid "Unable to detect if table exists!\n"
 msgstr "Unable to detect if table exists!\n"
 
-#: ./src/gui/TableEditor.ec:873
-#: ./src/gui/TableEditor.ec:892
+#: ./src/gui/TableEditor.ec:886
+#: ./src/gui/TableEditor.ec:905
 msgid "WordList match cannot be found in database."
 msgstr "WordList match cannot be found in database."