diff gen/toir.cpp @ 468:45a67b6f1310

Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially in this regard. Code for accessing nested variables and contexts rewritten. Probably more. Fairly well tested.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 04 Aug 2008 02:59:34 +0200
parents 261b05cf4d1c
children d0dad1fe0f45
line wrap: on
line diff
--- a/gen/toir.cpp	Sun Aug 03 16:59:28 2008 +0200
+++ b/gen/toir.cpp	Mon Aug 04 02:59:34 2008 +0200
@@ -106,7 +106,7 @@
         // nested variable
         else if (vd->nestedref) {
             Logger::println("nested variable");
-            return new DVarValue(type, vd, DtoNestedVariable(vd), true);
+            return DtoNestedVariable(type, vd);
         }
         // function parameter
         else if (vd->isParameter()) {
@@ -114,7 +114,7 @@
             FuncDeclaration* fd = vd->toParent2()->isFuncDeclaration();
             if (fd && fd != p->func()->decl) {
                 Logger::println("nested parameter");
-                return new DVarValue(type, vd, DtoNestedVariable(vd), true);
+                return DtoNestedVariable(type, vd);
             }
             else if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(vd->ir.getIrValue())) {
                 return new DVarValue(type, vd, vd->ir.getIrValue(), true);
@@ -472,16 +472,7 @@
     if (l->isSlice() || l->isComplex())
         return l;
 
-    if (type->toBasetype()->ty == Tstruct && e2->type->isintegral())
-    {
-        // handle struct = 0;
-        return l;
-    }
-    else
-    {
-        assert(type->equals(e2->type));
-        return r;
-    }
+    return r;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -986,25 +977,20 @@
     {
         LLValue* v = p->func()->thisVar;
         assert(v);
-        return new DImValue(type, v);
+        return new DVarValue(type, v, true);
     }
     // regular this expr
     else if (VarDeclaration* vd = var->isVarDeclaration()) {
         LLValue* v;
         if (vd->toParent2() != p->func()->decl) {
             Logger::println("nested this exp");
-            v = DtoLoad(DtoNestedVariable(vd));
+            return DtoNestedVariable(type, vd);
         }
         else {
             Logger::println("normal this exp");
             v = p->func()->decl->ir.irFunc->thisVar;
-            if (llvm::isa<llvm::AllocaInst>(v))
-                v = DtoLoad(v);
         }
-        const LLType* t = DtoType(type);
-        if (v->getType() != t)
-            v = DtoBitCast(v, t);
-        return new DThisValue(type, vd, v);
+        return new DVarValue(type, vd, v, true);
     }
 
     // anything we're not yet handling ?
@@ -1497,7 +1483,7 @@
             LLValue* rval = dval->getRVal();
             DtoDeleteClass(rval);
         }
-        if (!dval->isThis() && dval->isVar() && dval->isVar()->lval) {
+        if (dval->isVar() && dval->isVar()->lval) {
             LLValue* lval = dval->getLVal();
             DtoStore(llvm::Constant::getNullValue(lval->getType()->getContainedType(0)), lval);
         }