comparison 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
comparison
equal deleted inserted replaced
126:a2c2c3c1a73d 127:facc562f5674
806 if (DSliceValue* s = v->isSlice()) { 806 if (DSliceValue* s = v->isSlice()) {
807 if (s->len) { 807 if (s->len) {
808 return s->len; 808 return s->len;
809 } 809 }
810 const llvm::ArrayType* arrTy = isaArray(s->ptr->getType()->getContainedType(0)); 810 const llvm::ArrayType* arrTy = isaArray(s->ptr->getType()->getContainedType(0));
811 assert(arrTy); 811 if (arrTy)
812 return DtoConstSize_t(arrTy->getNumElements()); 812 return DtoConstSize_t(arrTy->getNumElements());
813 else
814 return DtoLoad(DtoGEPi(s->ptr, 0,0, "tmp"));
813 } 815 }
814 return DtoLoad(DtoGEPi(v->getRVal(), 0,0, "tmp")); 816 return DtoLoad(DtoGEPi(v->getRVal(), 0,0, "tmp"));
815 } 817 }
816 else if (t->ty == Tsarray) { 818 else if (t->ty == Tsarray) {
817 assert(!v->isSlice()); 819 assert(!v->isSlice());
829 { 831 {
830 Type* t = DtoDType(v->getType()); 832 Type* t = DtoDType(v->getType());
831 if (t->ty == Tarray) { 833 if (t->ty == Tarray) {
832 if (DSliceValue* s = v->isSlice()) { 834 if (DSliceValue* s = v->isSlice()) {
833 if (s->len) return s->ptr; 835 if (s->len) return s->ptr;
836 const llvm::Type* t = s->ptr->getType()->getContainedType(0);
837 Logger::cout() << "ptr of full slice: " << *s->ptr << '\n';
834 const llvm::ArrayType* arrTy = isaArray(s->ptr->getType()->getContainedType(0)); 838 const llvm::ArrayType* arrTy = isaArray(s->ptr->getType()->getContainedType(0));
835 assert(arrTy); 839 if (arrTy)
836 return DtoGEPi(s->ptr, 0,0, "tmp"); 840 return DtoGEPi(s->ptr, 0,0, "tmp");
841 else
842 return DtoLoad(DtoGEPi(s->ptr, 0,1, "tmp"));
837 } 843 }
838 return DtoLoad(DtoGEPi(v->getRVal(), 0,1, "tmp")); 844 return DtoLoad(DtoGEPi(v->getRVal(), 0,1, "tmp"));
839 } 845 }
840 else if (t->ty == Tsarray) { 846 else if (t->ty == Tsarray) {
841 return DtoGEPi(v->getRVal(), 0,0, "tmp"); 847 return DtoGEPi(v->getRVal(), 0,0, "tmp");