Mercurial > projects > ldc
changeset 521:99e95dae90d5
Do not need to allocate temporary for function literal.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 16 Aug 2008 14:01:23 +0200 |
parents | 73e41129b7f3 |
children | cd4eeb6cc5f6 |
files | gen/toir.cpp |
diffstat | 1 files changed, 10 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/toir.cpp Sat Aug 16 13:33:37 2008 +0200 +++ b/gen/toir.cpp Sat Aug 16 14:01:23 2008 +0200 @@ -2063,6 +2063,7 @@ Logger::println("kind = %s\n", fd->kind()); DtoForceDefineDsymbol(fd); + assert(fd->ir.irFunc->func); LLValue *lval, *fptr; if(fd->tok == TOKdelegate) { @@ -2082,19 +2083,17 @@ DtoStore(cval, context); fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb()); + + LLValue* castfptr = DtoBitCast(fd->ir.irFunc->func, fptr->getType()->getContainedType(0)); + DtoStore(castfptr, fptr); + + return new DVarValue(type, lval, true); + } else if(fd->tok == TOKfunction) { - const LLType* fnty = DtoType(type); - lval = DtoAlloca(fnty,"fnstorage"); - fptr = lval; + return new DVarValue(type, fd->ir.irFunc->func, false); } - else - assert(0 && "fd->tok must be TOKfunction or TOKdelegate"); - - assert(fd->ir.irFunc->func); - LLValue* castfptr = DtoBitCast(fd->ir.irFunc->func, fptr->getType()->getContainedType(0)); - DtoStore(castfptr, fptr); - - return new DVarValue(type, lval, true); + + assert(0 && "fd->tok must be TOKfunction or TOKdelegate"); } //////////////////////////////////////////////////////////////////////////////////////////