comparison gen/toir.cpp @ 283:9bb48fb57a7d trunk

[svn r304] Fix associative array literals by always reserving a zero inited temporary for them.
author ChristianK
date Sat, 21 Jun 2008 00:54:55 +0200
parents 74348f162225
children 70c370e97944
comparison
equal deleted inserted replaced
282:74348f162225 283:9bb48fb57a7d
2813 assert(values); 2813 assert(values);
2814 assert(keys->dim == values->dim); 2814 assert(keys->dim == values->dim);
2815 2815
2816 Type* aatype = DtoDType(type); 2816 Type* aatype = DtoDType(type);
2817 Type* vtype = aatype->next; 2817 Type* vtype = aatype->next;
2818 2818 const LLType* aalltype = DtoType(type);
2819 DValue* aa; 2819
2820 if (p->topexp() && p->topexp()->e2 == this) 2820 // it should be possible to avoid the temporary in some cases
2821 { 2821 LLValue* tmp = new llvm::AllocaInst(aalltype,"aaliteral",p->topallocapoint());
2822 aa = p->topexp()->v; 2822 DValue* aa = new DVarValue(type, tmp, true);
2823 } 2823 DtoStore(LLConstant::getNullValue(aalltype), tmp);
2824 else
2825 {
2826 LLValue* tmp = new llvm::AllocaInst(DtoType(type),"aaliteral",p->topallocapoint());
2827 aa = new DVarValue(type, tmp, true);
2828 }
2829 2824
2830 const size_t n = keys->dim; 2825 const size_t n = keys->dim;
2831 for (size_t i=0; i<n; ++i) 2826 for (size_t i=0; i<n; ++i)
2832 { 2827 {
2833 Expression* ekey = (Expression*)keys->data[i]; 2828 Expression* ekey = (Expression*)keys->data[i];