mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-26 08:33:14 +01:00
Fixed delegate casts.
This commit is contained in:
@@ -810,6 +810,25 @@ DValue* DtoCastFloat(Loc& loc, DValue* val, Type* to)
|
||||
return new DImValue(to, rval);
|
||||
}
|
||||
|
||||
DValue* DtoCastDelegate(Loc& loc, DValue* val, Type* to)
|
||||
{
|
||||
LLValue* res = 0;
|
||||
to = to->toBasetype();
|
||||
|
||||
if (to->ty == Tdelegate)
|
||||
{
|
||||
const LLType* toll = getPtrToType(DtoType(to));
|
||||
res = DtoBitCast(val->getRVal(), toll);
|
||||
}
|
||||
else
|
||||
{
|
||||
error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars());
|
||||
fatal();
|
||||
}
|
||||
|
||||
return new DImValue(to, res);
|
||||
}
|
||||
|
||||
DValue* DtoCast(Loc& loc, DValue* val, Type* to)
|
||||
{
|
||||
Type* fromtype = DtoDType(val->getType());
|
||||
@@ -832,6 +851,9 @@ DValue* DtoCast(Loc& loc, DValue* val, Type* to)
|
||||
else if (fromtype->ty == Tpointer || fromtype->ty == Tfunction) {
|
||||
return DtoCastPtr(loc, val, to);
|
||||
}
|
||||
else if (fromtype->ty == Tdelegate) {
|
||||
return DtoCastDelegate(loc, val, to);
|
||||
}
|
||||
else {
|
||||
error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars());
|
||||
fatal();
|
||||
|
||||
@@ -48,6 +48,7 @@ DValue* DtoNullValue(Type* t);
|
||||
DValue* DtoCastInt(Loc& loc, DValue* val, Type* to);
|
||||
DValue* DtoCastPtr(Loc& loc, DValue* val, Type* to);
|
||||
DValue* DtoCastFloat(Loc& loc, DValue* val, Type* to);
|
||||
DValue* DtoCastDelegate(Loc& loc, DValue* val, Type* to);
|
||||
DValue* DtoCast(Loc& loc, DValue* val, Type* to);
|
||||
|
||||
// is template instance check
|
||||
|
||||
Reference in New Issue
Block a user