# HG changeset patch # User Christian Kamm # Date 1218888083 -7200 # Node ID 99e95dae90d51e6d657a223f57729292cdd1f6fa # Parent 73e41129b7f38e821c6949b348792ea3295b4f2c Do not need to allocate temporary for function literal. diff -r 73e41129b7f3 -r 99e95dae90d5 gen/toir.cpp --- 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"); } //////////////////////////////////////////////////////////////////////////////////////////