Mercurial > projects > ldc
comparison gen/toir.c @ 68:c4b3f5d2cd9b trunk
[svn r72] Calling a nested function that is not a delegate was not working.
author | lindquist |
---|---|
date | Sun, 28 Oct 2007 03:14:29 +0100 |
parents | f918f3e2e99e |
children | 2b5a2eaa88be |
comparison
equal
deleted
inserted
replaced
67:f918f3e2e99e | 68:c4b3f5d2cd9b |
---|---|
1034 if (fn->funcdecl && fn->funcdecl->llvmInternal == LLVMva_start) | 1034 if (fn->funcdecl && fn->funcdecl->llvmInternal == LLVMva_start) |
1035 n = 1; | 1035 n = 1; |
1036 if (fn->arg || delegateCall) n++; | 1036 if (fn->arg || delegateCall) n++; |
1037 if (retinptr) n++; | 1037 if (retinptr) n++; |
1038 if (tf->linkage == LINKd && tf->varargs == 1) n+=2; | 1038 if (tf->linkage == LINKd && tf->varargs == 1) n+=2; |
1039 if (fn->funcdecl && fn->funcdecl->isNested()) n++; | |
1039 | 1040 |
1040 llvm::Value* funcval = fn->getValue(); | 1041 llvm::Value* funcval = fn->getValue(); |
1041 assert(funcval != 0); | 1042 assert(funcval != 0); |
1042 std::vector<llvm::Value*> llargs(n, 0); | 1043 std::vector<llvm::Value*> llargs(n, 0); |
1043 | 1044 |
1122 // delegate context arguments | 1123 // delegate context arguments |
1123 else if (delegateCall) { | 1124 else if (delegateCall) { |
1124 Logger::println("Delegate Call"); | 1125 Logger::println("Delegate Call"); |
1125 llvm::Value* contextptr = LLVM_DtoGEP(fn->mem,zero,zero,"tmp",p->scopebb()); | 1126 llvm::Value* contextptr = LLVM_DtoGEP(fn->mem,zero,zero,"tmp",p->scopebb()); |
1126 llargs[j] = new llvm::LoadInst(contextptr,"tmp",p->scopebb()); | 1127 llargs[j] = new llvm::LoadInst(contextptr,"tmp",p->scopebb()); |
1128 ++j; | |
1129 ++argiter; | |
1130 } | |
1131 // nested call | |
1132 else if (fn->funcdecl && fn->funcdecl->isNested()) { | |
1133 Logger::println("Nested Call"); | |
1134 llvm::Value* contextptr = p->func().decl->llvmNested; | |
1135 assert(contextptr); | |
1136 llargs[j] = p->ir->CreateBitCast(contextptr, llvm::PointerType::get(llvm::Type::Int8Ty), "tmp"); | |
1127 ++j; | 1137 ++j; |
1128 ++argiter; | 1138 ++argiter; |
1129 } | 1139 } |
1130 | 1140 |
1131 // va arg function special argument passing | 1141 // va arg function special argument passing |