compiler/libec: Fixed reference issue with conversion properties
authorJerome St-Louis <jerome@ecere.com>
Wed, 9 Jul 2014 02:59:57 +0000 (22:59 -0400)
committerJerome St-Louis <jerome@ecere.com>
Wed, 9 Jul 2014 03:27:32 +0000 (23:27 -0400)
- This fixed an extra referencing level with: Class c; const char * s = c;

compiler/bootstrap/libec/bootstrap/pass15.c
compiler/libec/src/pass15.ec

index cbc7edd..940b311 100644 (file)
@@ -18715,6 +18715,10 @@ __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&exp->expType->__anon1._
 }
 }
 }
+if(!notByReference && exp->expType && exp->expType->kind == 8 && exp->expType->__anon1._class && exp->expType->__anon1._class->__anon1.registered && exp->expType->__anon1._class->__anon1.registered->type == 5 && (!exp->destType || (exp->destType->kind != 3 && exp->destType->kind != 4 && exp->destType->kind != 22 && exp->destType->kind != 23 && exp->destType->kind != 5 && exp->destType->kind != 2 && exp->destType->kind != 1 && exp->destType->kind != 24)))
+{
+exp->byReference = 1;
+}
 yylloc = exp->loc;
 if(exp->destType && (exp->destType->kind == 18))
 ;
index 697d078..8e95be0 100644 (file)
@@ -11154,6 +11154,16 @@ void ProcessExpressionType(Expression exp)
       }
    }
 
+   // Trying to do this here before conversion properties kick in and this becomes a new expression... (Fixing Class c; const char * a = c;)
+   // Mark nohead classes as by reference, unless we're casting them to an integral type
+   if(!notByReference && exp.expType && exp.expType.kind == classType && exp.expType._class && exp.expType._class.registered &&
+      exp.expType._class.registered.type == noHeadClass && (!exp.destType ||
+         (exp.destType.kind != intType && exp.destType.kind != int64Type && exp.destType.kind != intPtrType && exp.destType.kind != intSizeType &&
+          exp.destType.kind != longType && exp.destType.kind != shortType && exp.destType.kind != charType && exp.destType.kind != _BoolType)))
+   {
+      exp.byReference = true;
+   }
+
    yylloc = exp.loc;
    if(exp.destType && (/*exp.destType.kind == voidType || */exp.destType.kind == dummyType) );
    else if(exp.destType && !exp.destType.keepCast)