mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-24 16:43:14 +01:00
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Fixed some casts to bool that were using truncation.
This commit is contained in:
@@ -924,10 +924,17 @@ DValue* DtoCastClass(DValue* val, Type* _to)
|
||||
|
||||
Type* to = _to->toBasetype();
|
||||
if (to->ty == Tpointer) {
|
||||
Logger::println("to pointer");
|
||||
const LLType* tolltype = DtoType(_to);
|
||||
LLValue* rval = DtoBitCast(val->getRVal(), tolltype);
|
||||
return new DImValue(_to, rval);
|
||||
}
|
||||
else if (to->ty == Tbool) {
|
||||
Logger::println("to bool");
|
||||
LLValue* llval = val->getRVal();
|
||||
LLValue* zero = LLConstant::getNullValue(llval->getType());
|
||||
return new DImValue(_to, gIR->ir->CreateICmpNE(llval, zero, "tmp"));
|
||||
}
|
||||
|
||||
assert(to->ty == Tclass);
|
||||
TypeClass* tc = (TypeClass*)to;
|
||||
@@ -947,7 +954,7 @@ DValue* DtoCastClass(DValue* val, Type* _to)
|
||||
}
|
||||
}
|
||||
else {
|
||||
Logger::println("to object");
|
||||
Logger::println("to class");
|
||||
int poffset;
|
||||
if (fc->sym->isInterfaceDeclaration()) {
|
||||
Logger::println("interface cast");
|
||||
|
||||
Reference in New Issue
Block a user