Fixed invoking of delegates inside CTFE.

This commit is contained in:
Alexey Prokhin
2010-12-17 12:55:28 +03:00
parent c089205395
commit f5f5c2e1f9
2 changed files with 29 additions and 1 deletions

View File

@@ -1145,6 +1145,7 @@ struct AddrExp : UnaExp
#if IN_LLVM
DValue* toElem(IRState* irs);
llvm::Constant *toConstElem(IRState *irs);
Expression *interpret(InterState *istate);
#endif
};

View File

@@ -1193,6 +1193,25 @@ Expression *DelegateExp::interpret(InterState *istate)
return this;
}
#if IN_LLVM
Expression *AddrExp::interpret(InterState *istate)
{
#if LOG
printf("AddrExpExp::interpret() %s\n", toChars());
#endif
if (e1->op == TOKvar)
{ VarExp *ve = (VarExp *)e1;
if (ve->var->isFuncDeclaration())
return this;
}
error("Cannot interpret %s at compile time", toChars());
return EXP_CANT_INTERPRET;
}
#endif
// -------------------------------------------------------------
// Remove out, ref, and this
@@ -2714,9 +2733,17 @@ Expression *CallExp::interpret(InterState *istate)
fd = ((SymOffExp *)vd->value)->var->isFuncDeclaration();
else {
ecall = vd->value->interpret(istate);
#if IN_LLVM
if (ecall->op == TOKaddress) {
AddrExp *e = (AddrExp*)ecall;
if (e->e1->op == TOKvar)
fd = ((VarExp *)e->e1)->var->isFuncDeclaration();
}
#else
if (ecall->op == TOKsymoff)
fd = ((SymOffExp *)ecall)->var->isFuncDeclaration();
}
#endif
}
}
else
ecall = ((PtrExp*)ecall)->e1->interpret(istate);