diff gen/statements.cpp @ 747:46d0755451a4

Added DtoRawVarDeclaration routine to handle special variables in some statements.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sat, 01 Nov 2008 18:25:10 +0100
parents 5761d7e6f628
children f04dde6e882c
line wrap: on
line diff
--- a/gen/statements.cpp	Sat Nov 01 17:56:25 2008 +0100
+++ b/gen/statements.cpp	Sat Nov 01 18:25:10 2008 +0100
@@ -154,7 +154,7 @@
         DtoDwarfStopPoint(loc.linnum);
 
     if (match)
-        DtoDeclarationExp(match);
+        DtoRawVarDeclaration(match);
 
     DValue* cond_e = condition->toElem(p);
     LLValue* cond_val = cond_e->getRVal();
@@ -926,17 +926,14 @@
     const LLType* keytype = key ? DtoType(key->type) : DtoSize_t();
     LLValue* keyvar;
     if (key)
-    {
-        DtoDeclarationExp(key);
-        keyvar = key->ir.irLocal->value;
-    }
+        keyvar = DtoRawVarDeclaration(key);
     else
         keyvar = DtoAlloca(keytype, "foreachkey");
     LLValue* zerokey = llvm::ConstantInt::get(keytype,0,false);
 
     // value
     Logger::println("value = %s", value->toPrettyChars());
-    DtoDeclarationExp(value);
+    DtoRawVarDeclaration(value);
     const LLType* valtype = DtoType(value->type);
     LLValue* valvar = NULL;
     if (!value->isRef() && !value->isOut())
@@ -1149,30 +1146,8 @@
     assert(body);
 
     DValue* e = exp->toElem(p);
-
-    // DtoDeclarationExp(wthis); or preferably equivalent without initialization...
-    if (wthis->ir.isSet())
-    {
-        assert(wthis->nestedref);
-        assert(wthis->ir.irLocal);
-        assert(!wthis->ir.irLocal->value);
-        wthis->ir.irLocal->value = DtoAlloca(DtoType(wthis->type), wthis->toChars());
-
-        // store the address into the nested vars array
-        assert(wthis->ir.irLocal->nestedIndex >= 0);
-        LLValue* gep = DtoGEPi(gIR->func()->decl->ir.irFunc->nestedVar, 0, wthis->ir.irLocal->nestedIndex);
-        assert(isaPointer(wthis->ir.irLocal->value));
-        LLValue* val = DtoBitCast(wthis->ir.irLocal->value, getVoidPtrType());
-        DtoStore(val, gep);
-    }
-    else
-    {
-        assert(!wthis->nestedref);
-        wthis->ir.irLocal = new IrLocal(wthis);
-        wthis->ir.irLocal->value = DtoAlloca(DtoType(wthis->type), wthis->toChars());
-    }
-
-    DtoStore(e->getRVal(), wthis->ir.irLocal->value);
+    LLValue* mem = DtoRawVarDeclaration(wthis);
+    DtoStore(e->getRVal(), mem);
 
     body->toIR(p);
 }