diff gen/arrays.cpp @ 287:00eb2c967c3a trunk

[svn r308] Really fixed multidimensional new expressions. the first length was bad in the resulting slice.
author lindquist
date Sat, 21 Jun 2008 05:03:42 +0200
parents a3b7c19c866c
children 068cb3c60afb
line wrap: on
line diff
--- a/gen/arrays.cpp	Sat Jun 21 04:47:14 2008 +0200
+++ b/gen/arrays.cpp	Sat Jun 21 05:03:42 2008 +0200
@@ -492,15 +492,16 @@
 
     // build dims
     LLValue* dimsArg = new llvm::AllocaInst(DtoSize_t(), DtoConstUint(ndims), ".newdims", gIR->topallocapoint());
+    LLValue* firstDim = NULL; 
     for (size_t i=0; i<ndims; ++i)
     {
         LLValue* dim = dims[i]->getRVal();
+        if (!firstDim) firstDim = dim;
         DtoStore(dim, DtoGEPi1(dimsArg, i));
     }
 
     // call allocator
-    LLConstant* arrayLen = DtoConstSize_t(ndims);
-    LLValue* newptr = gIR->ir->CreateCall3(fn, arrayTypeInfo, arrayLen, dimsArg, ".gc_mem");
+    LLValue* newptr = gIR->ir->CreateCall3(fn, arrayTypeInfo, DtoConstSize_t(ndims), dimsArg, ".gc_mem");
 
     // cast to wanted type
     const LLType* dstType = DtoType(arrayType)->getContainedType(1);
@@ -516,7 +517,8 @@
     }
 #endif
 
-    return new DSliceValue(arrayType, arrayLen, newptr);
+    assert(firstDim);
+    return new DSliceValue(arrayType, firstDim, newptr);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////