comparison gen/toobj.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 b688ad419f8c
children c4b3f5d2cd9b
comparison
equal deleted inserted replaced
66:0c5f410d973c 67:f918f3e2e99e
767 j++; 767 j++;
768 } 768 }
769 for (std::set<VarDeclaration*>::iterator i=llvmNestedVars.begin(); i!=llvmNestedVars.end(); ++i) { 769 for (std::set<VarDeclaration*>::iterator i=llvmNestedVars.begin(); i!=llvmNestedVars.end(); ++i) {
770 VarDeclaration* vd = *i; 770 VarDeclaration* vd = *i;
771 vd->llvmNestedIndex = j++; 771 vd->llvmNestedIndex = j++;
772 nestTypes.push_back(LLVM_DtoType(vd->type)); 772 if (vd->isParameter()) {
773 assert(vd->llvmValue);
774 nestTypes.push_back(vd->llvmValue->getType());
775 }
776 else {
777 nestTypes.push_back(LLVM_DtoType(vd->type));
778 }
773 } 779 }
774 const llvm::StructType* nestSType = llvm::StructType::get(nestTypes); 780 const llvm::StructType* nestSType = llvm::StructType::get(nestTypes);
775 Logger::cout() << "nested var struct has type:" << '\n' << *nestSType; 781 Logger::cout() << "nested var struct has type:" << '\n' << *nestSType;
776 llvmNested = new llvm::AllocaInst(nestSType,"nestedvars",f->llvmAllocaPoint); 782 llvmNested = new llvm::AllocaInst(nestSType,"nestedvars",f->llvmAllocaPoint);
777 if (parentNested) { 783 if (parentNested) {
778 assert(llvmThisVar); 784 assert(llvmThisVar);
779 llvm::Value* ptr = gIR->ir->CreateBitCast(llvmThisVar, parentNested->getType(), "tmp"); 785 llvm::Value* ptr = gIR->ir->CreateBitCast(llvmThisVar, parentNested->getType(), "tmp");
780 gIR->ir->CreateStore(ptr, LLVM_DtoGEPi(llvmNested, 0,0, "tmp")); 786 gIR->ir->CreateStore(ptr, LLVM_DtoGEPi(llvmNested, 0,0, "tmp"));
787 }
788 for (std::set<VarDeclaration*>::iterator i=llvmNestedVars.begin(); i!=llvmNestedVars.end(); ++i) {
789 VarDeclaration* vd = *i;
790 if (vd->isParameter()) {
791 gIR->ir->CreateStore(vd->llvmValue, LLVM_DtoGEPi(llvmNested, 0, vd->llvmNestedIndex, "tmp"));
792 }
781 } 793 }
782 } 794 }
783 795
784 // copy _argptr to a memory location 796 // copy _argptr to a memory location
785 if (f->linkage == LINKd && f->varargs == 1) 797 if (f->linkage == LINKd && f->varargs == 1)