compiler/libec: (#1058) Fixed issues preventing PrintLn([1, 2, 3]); and PrintLn(...
authorJerome St-Louis <jerome@ecere.com>
Tue, 4 Feb 2014 17:15:49 +0000 (00:15 +0700)
committerJerome St-Louis <jerome@ecere.com>
Tue, 4 Feb 2014 17:20:05 +0000 (00:20 +0700)
compiler/bootstrap/libec/bootstrap/copy.c
compiler/bootstrap/libec/bootstrap/pass15.c
compiler/bootstrap/libec/bootstrap/pass2.c
compiler/bootstrap/libec/bootstrap/pass3.c
compiler/libec/src/copy.ec
compiler/libec/src/pass15.ec
compiler/libec/src/pass2.ec
compiler/libec/src/pass3.ec

index 4eb6664..aa804b8 100644 (file)
@@ -1038,6 +1038,8 @@ extern struct Expression * MkExpExtensionCompound(struct Statement * compound);
 
 static struct Statement * CopyStatement(struct Statement * stmt);
 
+extern struct Expression * MkExpExtensionInitializer(struct TypeName * typeName, struct Initializer * initializer);
+
 struct Expression * CopyExpression(struct Expression * exp)
 {
 struct Expression * result = (((void *)0));
@@ -1129,6 +1131,9 @@ break;
 case 25:
 result = MkExpExtensionCompound(CopyStatement(exp->compound));
 break;
+case 35:
+result = MkExpExtensionInitializer(CopyTypeName(exp->initializer.typeName), CopyInitializer(exp->initializer.initializer));
+break;
 }
 if(result)
 {
index 36fc1d2..b1db599 100644 (file)
@@ -12704,7 +12704,7 @@ struct Type * __ecereInstance2 = __ecereNameSpace__ecere__com__eInstance_New(__e
 __ecereInstance2->refCount = 1, __ecereInstance2->kind = 13, __ecereInstance2->type = __extension__ ({
 struct Type * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Type);
 
-__ecereInstance1->refCount = 1, __ecereInstance1->kind = 1, __ecereInstance1->constant = 0x1, __ecereInstance1;
+__ecereInstance1->refCount = 1, __ecereInstance1->kind = 1, __ecereInstance1->constant = 0x1, __ecereInstance1->isSigned = 0x1, __ecereInstance1;
 }), __ecereInstance2;
 });
 break;
index 367683a..6aa5555 100644 (file)
@@ -3027,11 +3027,18 @@ if(_class->type == 0 && destType->byReference == 0x0 && strcmp(_class->dataTypeS
 struct Expression * c;
 struct Context * context = PushContext();
 
+if(_class->templateClass && !strcmp(_class->templateClass->name, "Container") && e->list && (*e->list).first && ((struct Expression *)(*e->list).first)->type == 11 && ((struct Expression *)(*e->list).first)->cast.exp && ((struct Expression *)(*e->list).first)->cast.exp->type == 4 && ((struct Expression *)(*e->list).first)->cast.exp->op.op == '&' && ((struct Expression *)(*e->list).first)->cast.exp->op.exp2 && ((struct Expression *)(*e->list).first)->cast.exp->op.exp2->type == 35)
+{
+__ecereMethod___ecereNameSpace__ecere__sys__OldList_Insert((&*exp->call.arguments), e->prev, MkExpIdentifier(MkIdentifier(className)));
+}
+else
+{
 c = MkExpExtensionCompound(MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifierName("Instance")), MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal_ClassInst")), MkInitializerAssignment(CopyExpression(e)))))), MkListOne(MkExpressionStmt(MkListOne(MkExpCondition(MkExpIdentifier(MkIdentifier("__internal_ClassInst")), MkListOne(MkExpPointer(MkExpIdentifier(MkIdentifier("__internal_ClassInst")), MkIdentifier("_class"))), MkExpIdentifier(MkIdentifier(className))))))));
 c->compound->compound.context = context;
 PopContext(context);
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Insert((&*exp->call.arguments), e->prev, c);
 }
+}
 else
 __ecereMethod___ecereNameSpace__ecere__sys__OldList_Insert((&*exp->call.arguments), e->prev, MkExpIdentifier(MkIdentifier(className)));
 }
index 20d0fb0..ff74d5b 100644 (file)
@@ -1606,6 +1606,7 @@ static void InstDeclPassInitializer(struct Initializer * init)
 switch(init->type)
 {
 case 0:
+if(init->exp)
 InstDeclPassExpression(init->exp);
 break;
 case 1:
index 8a5d1c7..122eac3 100644 (file)
@@ -192,6 +192,9 @@ static Instantiation CopyInstantiation(Instantiation inst)
          case extensionCompoundExp:
             result = MkExpExtensionCompound(CopyStatement(exp.compound));
             break;
+         case extensionInitializerExp:
+            result = MkExpExtensionInitializer(CopyTypeName(exp.initializer.typeName), CopyInitializer(exp.initializer.initializer));
+            break;
       }
    if(result)
    {
index 5a605ca..c9e718c 100644 (file)
@@ -7614,6 +7614,7 @@ void ProcessExpressionType(Expression exp)
                refCount = 1;
                kind = charType;
                constant = true;
+               isSigned = true;
             }
          };
          break;
index 5e0d6ce..5e2277a 100644 (file)
@@ -2240,19 +2240,36 @@ static void ProcessExpression(Expression exp)
                            // ({ Instance __internal_ClassInst = e; __internal_ClassInst ? __internal_ClassInst._class : __ecereClass_...; })
                            Expression c;
                            Context context = PushContext();
-                           c = MkExpExtensionCompound(MkCompoundStmt(
-                                 MkListOne(MkDeclaration(
-                                    MkListOne(MkSpecifierName("Instance")),
-                                    MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal_ClassInst")),
-                                       MkInitializerAssignment(CopyExpression(e)))))),
-                                 MkListOne(MkExpressionStmt(MkListOne(MkExpCondition(
-                                    MkExpIdentifier(MkIdentifier("__internal_ClassInst")),
-                                    MkListOne(MkExpPointer(MkExpIdentifier(MkIdentifier("__internal_ClassInst")), MkIdentifier("_class"))),
-                                    MkExpIdentifier(MkIdentifier(className))))))));
-                           c.compound.compound.context = context;
-                           PopContext(context);
-
-                           exp.call.arguments->Insert(e.prev, c);
+
+                           // Work around to avoid repeating the BuiltInContainer just to get the type
+                           // (a bit messy since we already transformed our expression to an extensionInitializerExp in earlier pass)
+                           if(_class.templateClass && !strcmp(_class.templateClass.name, "Container") &&
+                              e.list && e.list->first &&
+                              ((Expression)e.list->first).type == castExp &&
+                              ((Expression)e.list->first).cast.exp &&
+                              ((Expression)e.list->first).cast.exp.type == opExp &&
+                              ((Expression)e.list->first).cast.exp.op.op == '&' &&
+                              ((Expression)e.list->first).cast.exp.op.exp2 &&
+                              ((Expression)e.list->first).cast.exp.op.exp2.type == extensionInitializerExp)
+                           {
+                              exp.call.arguments->Insert(e.prev, MkExpIdentifier(MkIdentifier(className)));
+                           }
+                           else
+                           {
+                              c = MkExpExtensionCompound(MkCompoundStmt(
+                                    MkListOne(MkDeclaration(
+                                       MkListOne(MkSpecifierName("Instance")),
+                                       MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal_ClassInst")),
+                                          MkInitializerAssignment(CopyExpression(e)))))),
+                                    MkListOne(MkExpressionStmt(MkListOne(MkExpCondition(
+                                       MkExpIdentifier(MkIdentifier("__internal_ClassInst")),
+                                       MkListOne(MkExpPointer(MkExpIdentifier(MkIdentifier("__internal_ClassInst")), MkIdentifier("_class"))),
+                                       MkExpIdentifier(MkIdentifier(className))))))));
+                              c.compound.compound.context = context;
+                              PopContext(context);
+
+                              exp.call.arguments->Insert(e.prev, c);
+                           }
                         }
                         else
                            exp.call.arguments->Insert(e.prev, MkExpIdentifier(MkIdentifier(className)));
index a5b56b6..bbcb715 100644 (file)
@@ -557,7 +557,8 @@ static void InstDeclPassInitializer(Initializer init)
    switch(init.type)
    {
       case expInitializer:
-         InstDeclPassExpression(init.exp);
+         if(init.exp)
+            InstDeclPassExpression(init.exp);
          break;
       case listInitializer:
       {