Mercurial > projects > ldc
comparison gen/statements.cpp @ 745:5761d7e6f628
Tried using DtoDeclarationExp for VarDecls in Statements to fix nesting issues
(see bug #104), but a separate helper that doesn't initialize would be nicer.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 01 Nov 2008 16:48:17 +0100 |
parents | cc8ba72c0350 |
children | 46d0755451a4 |
comparison
equal
deleted
inserted
replaced
744:ef5f75ae6895 | 745:5761d7e6f628 |
---|---|
152 | 152 |
153 if (global.params.symdebug) | 153 if (global.params.symdebug) |
154 DtoDwarfStopPoint(loc.linnum); | 154 DtoDwarfStopPoint(loc.linnum); |
155 | 155 |
156 if (match) | 156 if (match) |
157 { | 157 DtoDeclarationExp(match); |
158 LLValue* allocainst = DtoAlloca(DtoType(match->type), "._tmp_if_var"); | |
159 match->ir.irLocal = new IrLocal(match); | |
160 match->ir.irLocal->value = allocainst; | |
161 } | |
162 | 158 |
163 DValue* cond_e = condition->toElem(p); | 159 DValue* cond_e = condition->toElem(p); |
164 LLValue* cond_val = cond_e->getRVal(); | 160 LLValue* cond_val = cond_e->getRVal(); |
165 | 161 |
166 llvm::BasicBlock* oldend = gIR->scopeend(); | 162 llvm::BasicBlock* oldend = gIR->scopeend(); |
926 | 922 |
927 Logger::println("aggr = %s", aggr->toChars()); | 923 Logger::println("aggr = %s", aggr->toChars()); |
928 | 924 |
929 // key | 925 // key |
930 const LLType* keytype = key ? DtoType(key->type) : DtoSize_t(); | 926 const LLType* keytype = key ? DtoType(key->type) : DtoSize_t(); |
931 LLValue* keyvar = DtoAlloca(keytype, "foreachkey"); | 927 LLValue* keyvar; |
932 if (key) | 928 if (key) |
933 { | 929 { |
934 //key->llvmValue = keyvar; | 930 DtoDeclarationExp(key); |
935 assert(!key->ir.irLocal); | 931 keyvar = key->ir.irLocal->value; |
936 key->ir.irLocal = new IrLocal(key); | 932 } |
937 key->ir.irLocal->value = keyvar; | 933 else |
938 } | 934 keyvar = DtoAlloca(keytype, "foreachkey"); |
939 LLValue* zerokey = llvm::ConstantInt::get(keytype,0,false); | 935 LLValue* zerokey = llvm::ConstantInt::get(keytype,0,false); |
940 | 936 |
941 // value | 937 // value |
942 Logger::println("value = %s", value->toPrettyChars()); | 938 Logger::println("value = %s", value->toPrettyChars()); |
939 DtoDeclarationExp(value); | |
943 const LLType* valtype = DtoType(value->type); | 940 const LLType* valtype = DtoType(value->type); |
944 LLValue* valvar = NULL; | 941 LLValue* valvar = NULL; |
945 if (!value->isRef() && !value->isOut()) | 942 if (!value->isRef() && !value->isOut()) |
946 valvar = DtoAlloca(valtype, "foreachval"); | 943 valvar = value->ir.irLocal->value; |
947 if (!value->ir.irLocal) | |
948 value->ir.irLocal = new IrLocal(value); | |
949 | 944 |
950 // what to iterate | 945 // what to iterate |
951 DValue* aggrval = aggr->toElem(p); | 946 DValue* aggrval = aggr->toElem(p); |
952 Type* aggrtype = aggr->type->toBasetype(); | 947 Type* aggrtype = aggr->type->toBasetype(); |
953 | 948 |
1153 assert(exp); | 1148 assert(exp); |
1154 assert(body); | 1149 assert(body); |
1155 | 1150 |
1156 DValue* e = exp->toElem(p); | 1151 DValue* e = exp->toElem(p); |
1157 | 1152 |
1153 // DtoDeclarationExp(wthis); or preferably equivalent without initialization... | |
1158 if (wthis->ir.isSet()) | 1154 if (wthis->ir.isSet()) |
1159 { | 1155 { |
1160 assert(wthis->nestedref); | 1156 assert(wthis->nestedref); |
1161 assert(wthis->ir.irLocal); | 1157 assert(wthis->ir.irLocal); |
1162 assert(!wthis->ir.irLocal->value); | 1158 assert(!wthis->ir.irLocal->value); |