Mercurial > projects > ldc
diff gen/toir.cpp @ 119:79c9ac745fbc trunk
[svn r123] Fixed some typeinfo module name mismatches.
Fixed D-style varargs returning through pointer.
Fixed converting nested function to delegate.
Added std.string and std.format to Phobos.
author | lindquist |
---|---|
date | Mon, 26 Nov 2007 06:45:13 +0100 |
parents | d580b95cce2b |
children | 5ce8ab11e75a |
line wrap: on
line diff
--- a/gen/toir.cpp Mon Nov 26 05:50:33 2007 +0100 +++ b/gen/toir.cpp Mon Nov 26 06:45:13 2007 +0100 @@ -2088,17 +2088,31 @@ lval = new llvm::AllocaInst(DtoType(type), "tmpdelegate", p->topallocapoint()); } + llvm::Value* uval; + if (DFuncValue* f = u->isFunc()) { + //assert(f->vthis); + //uval = f->vthis; + llvm::Value* nestvar = p->func()->decl->llvmNested; + if (nestvar) + uval = nestvar; + else + uval = llvm::ConstantPointerNull::get(llvm::PointerType::get(llvm::Type::Int8Ty)); + } + else { + uval = u->getRVal(); + } + llvm::Value* context = DtoGEP(lval,zero,zero,"tmp",p->scopebb()); - llvm::Value* castcontext = new llvm::BitCastInst(u->getRVal(),int8ptrty,"tmp",p->scopebb()); + llvm::Value* castcontext = DtoBitCast(uval,int8ptrty); new llvm::StoreInst(castcontext, context, p->scopebb()); llvm::Value* fptr = DtoGEP(lval,zero,one,"tmp",p->scopebb()); assert(func->llvmValue); - llvm::Value* castfptr = new llvm::BitCastInst(func->llvmValue,fptr->getType()->getContainedType(0),"tmp",p->scopebb()); + llvm::Value* castfptr = DtoBitCast(func->llvmValue,fptr->getType()->getContainedType(0)); new llvm::StoreInst(castfptr, fptr, p->scopebb()); - return new DImValue(type, u->getRVal(), true); + return new DVarValue(type, lval, true); } //////////////////////////////////////////////////////////////////////////////////////////