Mercurial > projects > ldc
changeset 49:e5c4bece7fa1 trunk
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
author | lindquist |
---|---|
date | Fri, 19 Oct 2007 17:43:46 +0200 |
parents | 4d171915a77b |
children | 6fcc08a4d406 |
files | gen/toir.c gen/tollvm.c test/bug19.d |
diffstat | 3 files changed, 49 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/toir.c Fri Oct 19 17:15:30 2007 +0200 +++ b/gen/toir.c Fri Oct 19 17:43:46 2007 +0200 @@ -570,8 +570,10 @@ e->inplace = true; e->mem = l->mem; } - else - assert(0); + else { + LLVM_DtoDelegateCopy(l->mem, r->getValue()); + e->mem = l->mem; + } } else assert(0); @@ -2581,6 +2583,39 @@ ////////////////////////////////////////////////////////////////////////////////////////// +elem* FuncExp::toElem(IRState* p) +{ + Logger::print("FuncExp::toElem: %s | %s\n", toChars(), type->toChars()); + LOG_SCOPE; + + assert(fd); + + if (fd->isNested()) Logger::println("nested"); + Logger::println("kind = %s\n", fd->kind()); + + fd->toObjFile(); + + llvm::Value* lval = p->toplval(); + + elem* e = new elem; + + llvm::Value* context = LLVM_DtoGEPi(lval,0,0,"tmp",p->scopebb()); + //llvm::Value* castcontext = llvm::ConstantPointerNull::get(context->getType()); + //new llvm::StoreInst(castcontext, context, p->scopebb()); + + llvm::Value* fptr = LLVM_DtoGEPi(lval,0,1,"tmp",p->scopebb()); + + assert(fd->llvmValue); + llvm::Value* castfptr = new llvm::BitCastInst(fd->llvmValue,fptr->getType()->getContainedType(0),"tmp",p->scopebb()); + new llvm::StoreInst(castfptr, fptr, p->scopebb()); + + e->inplace = true; + + return e; +} + +////////////////////////////////////////////////////////////////////////////////////////// + #define STUB(x) elem *x::toElem(IRState * p) {error("Exp type "#x" not implemented: %s", toChars()); fatal(); return 0; } //STUB(IdentityExp); //STUB(CondExp); @@ -2622,7 +2657,7 @@ STUB(TypeDotIdExp); //STUB(DotVarExp); //STUB(AssertExp); -STUB(FuncExp); +//STUB(FuncExp); //STUB(DelegateExp); //STUB(VarExp); //STUB(DeclarationExp);
--- a/gen/tollvm.c Fri Oct 19 17:15:30 2007 +0200 +++ b/gen/tollvm.c Fri Oct 19 17:43:46 2007 +0200 @@ -276,6 +276,10 @@ else assert(0); } + else if (fdecl->isNested()) { + paramvec.push_back(llvm::PointerType::get(llvm::Type::Int8Ty)); + usesthis = true; + } size_t n = Argument::dim(f->parameters); for (int i=0; i < n; ++i) {