diff gen/toir.cpp @ 107:3efbcc81ba45 trunk

[svn r111] Fixed most problems with complex number support and added typeinfo for them. Added typeinfo ti_C. Did some changes to the way expressions that have both lvalue and rvalue LLVM values are handled.
author lindquist
date Tue, 20 Nov 2007 00:02:35 +0100
parents 4d1e9eb001e0
children 288fe1029e1f
line wrap: on
line diff
--- a/gen/toir.cpp	Mon Nov 19 06:01:48 2007 +0100
+++ b/gen/toir.cpp	Tue Nov 20 00:02:35 2007 +0100
@@ -562,7 +562,7 @@
         res = new DImValue(type, gep);
     }
     else if (t->iscomplex()) {
-        res = DtoComplexAdd(type, l, r);
+        res = DtoComplexAdd(e1->type, l, r);
     }
     else {
         res = DtoBinAdd(l,r);
@@ -1056,17 +1056,17 @@
     DValue* u = e1->toElem(p);
     DValue* v = DtoCast(u, to);
 
-    if (v->isSlice())
+    if (v->isSlice()) {
+        assert(!gIR->topexp() || gIR->topexp()->e1 != this);
         return v;
-    else if (u->isLValueCast() || (u->isVar() && u->isVar()->lval))
-        return new DLValueCast(to, u->getLVal(), v->getRVal());
-    else if (gIR->topexp() && gIR->topexp()->e1 == this) {
-        llvm::Value* lval = u->getLVal();
-        llvm::Value* rval = v->getRVal();
-        Logger::cout() << "lval: " << *lval << "rval: " << *rval << '\n';
-        return new DLValueCast(to, lval, rval);
     }
 
+    else if (u->isLRValue() || (u->isVar() && u->isVar()->lval))
+        return new DLRValue(e1->type, u->getLVal(), to, v->getRVal());
+
+    else if (gIR->topexp() && gIR->topexp()->e1 == this)
+        return new DLRValue(e1->type, u->getLVal(), to, v->getRVal());
+
     return v;
 }
 
@@ -1193,7 +1193,7 @@
     llvm::Value* v = lv;
     if (DtoCanLoad(v))
         v = DtoLoad(v);
-    return new DLValueCast(type, lv, v);
+    return new DLRValue(e1->type, lv, type, v);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////