diff gen/arrays.cpp @ 127:facc562f5674 trunk

[svn r131] Fixed #11 All associative array properties now work as they should. Fixed problems with some cases of array.length and array.ptr. Fixed some problems with array properties. Fixed 'in' contracts.
author lindquist
date Fri, 30 Nov 2007 12:56:52 +0100
parents d580b95cce2b
children 1700239cab2e
line wrap: on
line diff
--- a/gen/arrays.cpp	Wed Nov 28 05:04:38 2007 +0100
+++ b/gen/arrays.cpp	Fri Nov 30 12:56:52 2007 +0100
@@ -808,8 +808,10 @@
                 return s->len;
             }
             const llvm::ArrayType* arrTy = isaArray(s->ptr->getType()->getContainedType(0));
-            assert(arrTy);
-            return DtoConstSize_t(arrTy->getNumElements());
+            if (arrTy)
+                return DtoConstSize_t(arrTy->getNumElements());
+            else
+                return DtoLoad(DtoGEPi(s->ptr, 0,0, "tmp"));
         }
         return DtoLoad(DtoGEPi(v->getRVal(), 0,0, "tmp"));
     }
@@ -831,9 +833,13 @@
     if (t->ty == Tarray) {
         if (DSliceValue* s = v->isSlice()) {
             if (s->len) return s->ptr;
+            const llvm::Type* t = s->ptr->getType()->getContainedType(0);
+            Logger::cout() << "ptr of full slice: " << *s->ptr << '\n';
             const llvm::ArrayType* arrTy = isaArray(s->ptr->getType()->getContainedType(0));
-            assert(arrTy);
-            return DtoGEPi(s->ptr, 0,0, "tmp");
+            if (arrTy)
+                return DtoGEPi(s->ptr, 0,0, "tmp");
+            else
+                return DtoLoad(DtoGEPi(s->ptr, 0,1, "tmp"));
         }
         return DtoLoad(DtoGEPi(v->getRVal(), 0,1, "tmp"));
     }