Mercurial > projects > ldc
comparison gen/statements.cpp @ 747:46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sat, 01 Nov 2008 18:25:10 +0100 |
parents | 5761d7e6f628 |
children | f04dde6e882c |
comparison
equal
deleted
inserted
replaced
746:693d681c846c | 747:46d0755451a4 |
---|---|
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 DtoDeclarationExp(match); | 157 DtoRawVarDeclaration(match); |
158 | 158 |
159 DValue* cond_e = condition->toElem(p); | 159 DValue* cond_e = condition->toElem(p); |
160 LLValue* cond_val = cond_e->getRVal(); | 160 LLValue* cond_val = cond_e->getRVal(); |
161 | 161 |
162 llvm::BasicBlock* oldend = gIR->scopeend(); | 162 llvm::BasicBlock* oldend = gIR->scopeend(); |
924 | 924 |
925 // key | 925 // key |
926 const LLType* keytype = key ? DtoType(key->type) : DtoSize_t(); | 926 const LLType* keytype = key ? DtoType(key->type) : DtoSize_t(); |
927 LLValue* keyvar; | 927 LLValue* keyvar; |
928 if (key) | 928 if (key) |
929 { | 929 keyvar = DtoRawVarDeclaration(key); |
930 DtoDeclarationExp(key); | |
931 keyvar = key->ir.irLocal->value; | |
932 } | |
933 else | 930 else |
934 keyvar = DtoAlloca(keytype, "foreachkey"); | 931 keyvar = DtoAlloca(keytype, "foreachkey"); |
935 LLValue* zerokey = llvm::ConstantInt::get(keytype,0,false); | 932 LLValue* zerokey = llvm::ConstantInt::get(keytype,0,false); |
936 | 933 |
937 // value | 934 // value |
938 Logger::println("value = %s", value->toPrettyChars()); | 935 Logger::println("value = %s", value->toPrettyChars()); |
939 DtoDeclarationExp(value); | 936 DtoRawVarDeclaration(value); |
940 const LLType* valtype = DtoType(value->type); | 937 const LLType* valtype = DtoType(value->type); |
941 LLValue* valvar = NULL; | 938 LLValue* valvar = NULL; |
942 if (!value->isRef() && !value->isOut()) | 939 if (!value->isRef() && !value->isOut()) |
943 valvar = value->ir.irLocal->value; | 940 valvar = value->ir.irLocal->value; |
944 | 941 |
1147 | 1144 |
1148 assert(exp); | 1145 assert(exp); |
1149 assert(body); | 1146 assert(body); |
1150 | 1147 |
1151 DValue* e = exp->toElem(p); | 1148 DValue* e = exp->toElem(p); |
1152 | 1149 LLValue* mem = DtoRawVarDeclaration(wthis); |
1153 // DtoDeclarationExp(wthis); or preferably equivalent without initialization... | 1150 DtoStore(e->getRVal(), mem); |
1154 if (wthis->ir.isSet()) | |
1155 { | |
1156 assert(wthis->nestedref); | |
1157 assert(wthis->ir.irLocal); | |
1158 assert(!wthis->ir.irLocal->value); | |
1159 wthis->ir.irLocal->value = DtoAlloca(DtoType(wthis->type), wthis->toChars()); | |
1160 | |
1161 // store the address into the nested vars array | |
1162 assert(wthis->ir.irLocal->nestedIndex >= 0); | |
1163 LLValue* gep = DtoGEPi(gIR->func()->decl->ir.irFunc->nestedVar, 0, wthis->ir.irLocal->nestedIndex); | |
1164 assert(isaPointer(wthis->ir.irLocal->value)); | |
1165 LLValue* val = DtoBitCast(wthis->ir.irLocal->value, getVoidPtrType()); | |
1166 DtoStore(val, gep); | |
1167 } | |
1168 else | |
1169 { | |
1170 assert(!wthis->nestedref); | |
1171 wthis->ir.irLocal = new IrLocal(wthis); | |
1172 wthis->ir.irLocal->value = DtoAlloca(DtoType(wthis->type), wthis->toChars()); | |
1173 } | |
1174 | |
1175 DtoStore(e->getRVal(), wthis->ir.irLocal->value); | |
1176 | 1151 |
1177 body->toIR(p); | 1152 body->toIR(p); |
1178 } | 1153 } |
1179 | 1154 |
1180 ////////////////////////////////////////////////////////////////////////////// | 1155 ////////////////////////////////////////////////////////////////////////////// |