compiler/libec: Fixed setting class properties on static classes
authorJerome St-Louis <jerome@ecere.com>
Wed, 6 Aug 2014 21:01:06 +0000 (17:01 -0400)
committerJerome St-Louis <jerome@ecere.com>
Wed, 6 Aug 2014 21:34:08 +0000 (17:34 -0400)
compiler/bootstrap/libec/bootstrap/pass1.c
compiler/libec/src/pass1.ec

index 8d26356..e3420d9 100644 (file)
@@ -627,6 +627,7 @@ extern struct Identifier * GetDeclId(struct Declarator * decl);
 struct ClassPropertyValue
 {
 struct __ecereNameSpace__ecere__com__Class * regClass;
+unsigned int staticClass;
 struct Identifier * id;
 struct Expression * exp;
 } ecere_gcc_struct;
@@ -2981,7 +2982,7 @@ __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpa
 })[__ecereVMethodID___ecereNameSpace__ecere__com__Container_Add])(classPropValues, (uint64)(uintptr_t)(__extension__ ({
 struct __ecereNameSpace__ecere__com__Instance * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_ClassPropertyValue);
 
-((struct ClassPropertyValue *)(((char *)__ecereInstance1 + __ecereClass_ClassPropertyValue->offset)))->regClass = regClass, ((struct ClassPropertyValue *)(((char *)__ecereInstance1 + __ecereClass_ClassPropertyValue->offset)))->id = def->__anon1.__anon1.id, ((struct ClassPropertyValue *)(((char *)__ecereInstance1 + __ecereClass_ClassPropertyValue->offset)))->exp = def->__anon1.__anon1.initializer->__anon1.exp, __ecereInstance1;
+((struct ClassPropertyValue *)(((char *)__ecereInstance1 + __ecereClass_ClassPropertyValue->offset)))->regClass = regClass, ((struct ClassPropertyValue *)(((char *)__ecereInstance1 + __ecereClass_ClassPropertyValue->offset)))->staticClass = (declMode == 3), ((struct ClassPropertyValue *)(((char *)__ecereInstance1 + __ecereClass_ClassPropertyValue->offset)))->id = def->__anon1.__anon1.id, ((struct ClassPropertyValue *)(((char *)__ecereInstance1 + __ecereClass_ClassPropertyValue->offset)))->exp = def->__anon1.__anon1.initializer->__anon1.exp, __ecereInstance1;
 })));
 def->__anon1.__anon1.id = (((void *)0));
 def->__anon1.__anon1.initializer->__anon1.exp = (((void *)0));
@@ -3197,11 +3198,30 @@ char * __ecTemp1 = (char *)(((struct __ecereNameSpace__ecere__com__Instance *)(u
 ((struct ClassPropertyValue *)(__ecTemp1 + __ecereClass_ClassPropertyValue->offset));
 })->exp->loc;
 ListAdd(findClassArgs, MkExpIdentifier(MkIdentifier("module")));
-s = QMkString(__extension__ ({
+{
+char nameSpace[1024] = "";
+char className[1024] = "";
+struct __ecereNameSpace__ecere__com__Class * regClass = __extension__ ({
+char * __ecTemp1 = (char *)(((struct __ecereNameSpace__ecere__com__Instance *)(uintptr_t)__ecereProp___ecereNameSpace__ecere__com__Iterator_Get_data(&v)));
+
+((struct ClassPropertyValue *)(__ecTemp1 + __ecereClass_ClassPropertyValue->offset));
+})->regClass;
+
+GetNameSpaceString(regClass->nameSpace, nameSpace);
+if(__extension__ ({
 char * __ecTemp1 = (char *)(((struct __ecereNameSpace__ecere__com__Instance *)(uintptr_t)__ecereProp___ecereNameSpace__ecere__com__Iterator_Get_data(&v)));
 
 ((struct ClassPropertyValue *)(__ecTemp1 + __ecereClass_ClassPropertyValue->offset));
-})->regClass->name);
+})->staticClass)
+{
+__ecereNameSpace__ecere__sys__GetLastDirectory(sourceFile, className);
+__ecereNameSpace__ecere__sys__ChangeCh(className, '.', '_');
+strcat(className, "}");
+}
+strcat(className, nameSpace);
+strcat(className, regClass->name);
+s = QMkString(className);
+}
 ListAdd(findClassArgs, MkExpString(s));
 (__ecereNameSpace__ecere__com__eSystem_Delete(s), s = 0);
 ListAdd(args, MkExpIdentifier(MkIdentifier("_class")));
index c72f75d..0370d4a 100644 (file)
@@ -1709,7 +1709,7 @@ static void ProcessClass(ClassType classType, OldList definitions, Symbol symbol
                }
                else if(def.type == classPropertyValueClassDef)
                {
-                  classPropValues.Add(ClassPropertyValue { regClass = regClass, id = def.id, exp = def.initializer.exp });
+                  classPropValues.Add(ClassPropertyValue { regClass = regClass, staticClass = (declMode == staticAccess), id = def.id, exp = def.initializer.exp });
                   def.id = null;
                   def.initializer.exp = null;
                }
@@ -1722,6 +1722,7 @@ static void ProcessClass(ClassType classType, OldList definitions, Symbol symbol
 class ClassPropertyValue
 {
    Class regClass;
+   bool staticClass;
    Identifier id;
    Expression exp;
 
@@ -1955,7 +1956,21 @@ public void ProcessClassDefinitions()
             yylloc = v.exp.loc;
 
          ListAdd(findClassArgs, MkExpIdentifier(MkIdentifier("module")));
-         s = QMkString(v.regClass.name);
+         {
+            char nameSpace[1024] = "";
+            char className[1024] = "";
+            Class regClass = v.regClass;
+            GetNameSpaceString(regClass.nameSpace, nameSpace);
+            if(v.staticClass)
+            {
+               GetLastDirectory(sourceFile, className);
+               ChangeCh(className, '.', '_');
+               strcat(className, "}");
+            }
+            strcat(className, nameSpace);
+            strcat(className, regClass.name);
+            s = QMkString(className);
+         }
          ListAdd(findClassArgs, MkExpString(s));
          delete s;