Mercurial > projects > ldc
comparison gen/toir.cpp @ 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 | ca2dfe98036c |
comparison
equal
deleted
inserted
replaced
520:73e41129b7f3 | 521:99e95dae90d5 |
---|---|
2061 | 2061 |
2062 if (fd->isNested()) Logger::println("nested"); | 2062 if (fd->isNested()) Logger::println("nested"); |
2063 Logger::println("kind = %s\n", fd->kind()); | 2063 Logger::println("kind = %s\n", fd->kind()); |
2064 | 2064 |
2065 DtoForceDefineDsymbol(fd); | 2065 DtoForceDefineDsymbol(fd); |
2066 assert(fd->ir.irFunc->func); | |
2066 | 2067 |
2067 LLValue *lval, *fptr; | 2068 LLValue *lval, *fptr; |
2068 if(fd->tok == TOKdelegate) { | 2069 if(fd->tok == TOKdelegate) { |
2069 const LLType* dgty = DtoType(type); | 2070 const LLType* dgty = DtoType(type); |
2070 lval = DtoAlloca(dgty,"dgstorage"); | 2071 lval = DtoAlloca(dgty,"dgstorage"); |
2080 cval = getNullPtr(getVoidPtrType()); | 2081 cval = getNullPtr(getVoidPtrType()); |
2081 cval = DtoBitCast(cval, context->getType()->getContainedType(0)); | 2082 cval = DtoBitCast(cval, context->getType()->getContainedType(0)); |
2082 DtoStore(cval, context); | 2083 DtoStore(cval, context); |
2083 | 2084 |
2084 fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb()); | 2085 fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb()); |
2086 | |
2087 LLValue* castfptr = DtoBitCast(fd->ir.irFunc->func, fptr->getType()->getContainedType(0)); | |
2088 DtoStore(castfptr, fptr); | |
2089 | |
2090 return new DVarValue(type, lval, true); | |
2091 | |
2085 } else if(fd->tok == TOKfunction) { | 2092 } else if(fd->tok == TOKfunction) { |
2086 const LLType* fnty = DtoType(type); | 2093 return new DVarValue(type, fd->ir.irFunc->func, false); |
2087 lval = DtoAlloca(fnty,"fnstorage"); | 2094 } |
2088 fptr = lval; | 2095 |
2089 } | 2096 assert(0 && "fd->tok must be TOKfunction or TOKdelegate"); |
2090 else | |
2091 assert(0 && "fd->tok must be TOKfunction or TOKdelegate"); | |
2092 | |
2093 assert(fd->ir.irFunc->func); | |
2094 LLValue* castfptr = DtoBitCast(fd->ir.irFunc->func, fptr->getType()->getContainedType(0)); | |
2095 DtoStore(castfptr, fptr); | |
2096 | |
2097 return new DVarValue(type, lval, true); | |
2098 } | 2097 } |
2099 | 2098 |
2100 ////////////////////////////////////////////////////////////////////////////////////////// | 2099 ////////////////////////////////////////////////////////////////////////////////////////// |
2101 | 2100 |
2102 DValue* ArrayLiteralExp::toElem(IRState* p) | 2101 DValue* ArrayLiteralExp::toElem(IRState* p) |