Mercurial > projects > ldc
comparison gen/tollvm.c @ 67:f918f3e2e99e trunk
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
Some cleanups in VarExp::toElem.
author | lindquist |
---|---|
date | Sun, 28 Oct 2007 02:46:06 +0200 |
parents | b86e00b938a5 |
children | 2b5a2eaa88be |
comparison
equal
deleted
inserted
replaced
66:0c5f410d973c | 67:f918f3e2e99e |
---|---|
1304 IRFunction* fcur = &gIR->func(); | 1304 IRFunction* fcur = &gIR->func(); |
1305 FuncDeclaration* f = fcur->decl; | 1305 FuncDeclaration* f = fcur->decl; |
1306 | 1306 |
1307 // on this stack | 1307 // on this stack |
1308 if (fd == f) { | 1308 if (fd == f) { |
1309 return LLVM_DtoGEPi(vd->llvmValue,0,unsigned(vd->llvmNestedIndex),"tmp"); | 1309 llvm::Value* v = LLVM_DtoGEPi(vd->llvmValue,0,unsigned(vd->llvmNestedIndex),"tmp"); |
1310 if (vd->isParameter() && (vd->isRef() || vd->isOut())) | |
1311 v = gIR->ir->CreateLoad(v,"tmp"); | |
1312 return v; | |
1310 } | 1313 } |
1311 | 1314 |
1312 // on a caller stack | 1315 // on a caller stack |
1313 llvm::Value* ptr = f->llvmThisVar; | 1316 llvm::Value* ptr = f->llvmThisVar; |
1314 assert(ptr); | 1317 assert(ptr); |
1323 | 1326 |
1324 Logger::cout() << "nested var reference:" << '\n' << *ptr << *nesttype << '\n'; | 1327 Logger::cout() << "nested var reference:" << '\n' << *ptr << *nesttype << '\n'; |
1325 | 1328 |
1326 while (f) { | 1329 while (f) { |
1327 if (fd == f) { | 1330 if (fd == f) { |
1328 return LLVM_DtoGEPi(ptr,0,vd->llvmNestedIndex,"tmp"); | 1331 llvm::Value* v = LLVM_DtoGEPi(ptr,0,vd->llvmNestedIndex,"tmp"); |
1332 if (vd->isParameter() && (vd->isRef() || vd->isOut())) | |
1333 v = gIR->ir->CreateLoad(v,"tmp"); | |
1334 return v; | |
1329 } | 1335 } |
1330 else { | 1336 else { |
1331 ptr = LLVM_DtoGEPi(ptr,0,0,"tmp"); | 1337 ptr = LLVM_DtoGEPi(ptr,0,0,"tmp"); |
1332 ptr = gIR->ir->CreateLoad(ptr,"tmp"); | 1338 ptr = gIR->ir->CreateLoad(ptr,"tmp"); |
1333 } | 1339 } |