mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-29 22:50:53 +03:00
Adapt to new DMD lambda inference mechanism.
Rewriting types this late is a questionable design and prone to break non-DMD client code; this should be discussed again with Kenji.
This commit is contained in:
parent
26217eabb2
commit
b3f59134c1
2 changed files with 44 additions and 2 deletions
24
gen/toir.cpp
24
gen/toir.cpp
|
@ -2689,13 +2689,22 @@ DValue* FuncExp::toElem(IRState* p)
|
||||||
|
|
||||||
assert(fd);
|
assert(fd);
|
||||||
|
|
||||||
|
if (fd->tok == TOKreserved && type->ty == Tpointer)
|
||||||
|
{
|
||||||
|
// This is a lambda that was inferred to be a function literal instead
|
||||||
|
// of a delegate, so set tok here in order to get correct types/mangling.
|
||||||
|
// Horrible hack, but DMD does the same thing.
|
||||||
|
fd->tok = TOKfunction;
|
||||||
|
fd->vthis = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (fd->isNested()) Logger::println("nested");
|
if (fd->isNested()) Logger::println("nested");
|
||||||
Logger::println("kind = %s", fd->kind());
|
Logger::println("kind = %s", fd->kind());
|
||||||
|
|
||||||
fd->codegen(Type::sir);
|
fd->codegen(Type::sir);
|
||||||
assert(fd->ir.irFunc->func);
|
assert(fd->ir.irFunc->func);
|
||||||
|
|
||||||
if(fd->isNested() && !(fd->tok == TOKreserved && type->ty == Tpointer && fd->vthis)) {
|
if (fd->isNested()) {
|
||||||
LLType* dgty = DtoType(type);
|
LLType* dgty = DtoType(type);
|
||||||
|
|
||||||
LLValue* cval;
|
LLValue* cval;
|
||||||
|
@ -2745,7 +2754,18 @@ LLConstant* FuncExp::toConstElem(IRState* p)
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
assert(fd);
|
assert(fd);
|
||||||
if (fd->tok != TOKfunction && !(fd->tok == TOKreserved && type->ty == Tpointer && fd->vthis))
|
|
||||||
|
if (fd->tok == TOKreserved && type->ty == Tpointer)
|
||||||
|
{
|
||||||
|
// This is a lambda that was inferred to be a function literal instead
|
||||||
|
// of a delegate, so set tok here in order to get correct types/mangling.
|
||||||
|
// Horrible hack, but DMD does the same thing in FuncExp::toElem and
|
||||||
|
// other random places.
|
||||||
|
fd->tok = TOKfunction;
|
||||||
|
fd->vthis = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fd->tok != TOKfunction)
|
||||||
{
|
{
|
||||||
assert(fd->tok == TOKdelegate || fd->tok == TOKreserved);
|
assert(fd->tok == TOKdelegate || fd->tok == TOKreserved);
|
||||||
error("delegate literals as constant expressions are not yet allowed");
|
error("delegate literals as constant expressions are not yet allowed");
|
||||||
|
|
|
@ -164,6 +164,28 @@ IrTypePointer* IrTypePointer::get(Type* dt)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (dt->nextOf()->ty == Tfunction)
|
||||||
|
{
|
||||||
|
TypeFunction* tf = static_cast<TypeFunction*>(dt->nextOf());
|
||||||
|
if (tf->funcdecl)
|
||||||
|
{
|
||||||
|
if (FuncLiteralDeclaration* fld =
|
||||||
|
tf->funcdecl->isFuncLiteralDeclaration())
|
||||||
|
{
|
||||||
|
if (fld->tok == TOKreserved)
|
||||||
|
{
|
||||||
|
// This is the type of a lambda that was inferred to be
|
||||||
|
// a function literal instead of a delegate, so set tok
|
||||||
|
// here in order to get correct types/mangling. Horrible
|
||||||
|
// hack, but DMD does the same thing in FuncExp::toElem
|
||||||
|
// and other random places.
|
||||||
|
fld->tok = TOKfunction;
|
||||||
|
fld->vthis = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
elemType = DtoTypeNotVoid(dt->nextOf());
|
elemType = DtoTypeNotVoid(dt->nextOf());
|
||||||
|
|
||||||
// DtoTypeNotVoid could have already created the same type, e.g. for
|
// DtoTypeNotVoid could have already created the same type, e.g. for
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue