diff gen/toir.cpp @ 295:895e1b50cf2a trunk

[svn r316] Fixed array slice assignments like: int[] arr = ...; arr[] = 42; There was problems with most non basic types... Added an option to premake so we can do: premake --target gnu --no-boehm to disable the Boehm GC.
author lindquist
date Mon, 23 Jun 2008 14:48:42 +0200
parents 068cb3c60afb
children 6b62e8cdf970
line wrap: on
line diff
--- a/gen/toir.cpp	Sun Jun 22 21:36:07 2008 +0200
+++ b/gen/toir.cpp	Mon Jun 23 14:48:42 2008 +0200
@@ -2702,18 +2702,20 @@
     LLValue* mem = 0;
     bool isinplace = true;
 
+    // already has memory (r-value of assignment)
+    IRExp* topexp = p->topexp();
+    if (topexp && topexp->e2 == this && !topexp->v->isSlice())
+    {
+        assert(topexp->e2 == this);
+        sptr = topexp->v->getLVal();
+    }
     // temporary struct literal
-    if (!p->topexp() || p->topexp()->e2 != this)
+    else
     {
         sptr = new llvm::AllocaInst(llt,"tmpstructliteral",p->topallocapoint());
         isinplace = false;
     }
-    // already has memory
-    else
-    {
-        assert(p->topexp()->e2 == this);
-        sptr = p->topexp()->v->getLVal();
-    }
+
 
     // num elements in literal
     unsigned n = elements->dim;