Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.

Fixed some casts to bool that were using truncation.
This commit is contained in:
Christian Kamm
2008-11-22 18:35:52 +01:00
parent 660ca009b9
commit 6efc9a3324
7 changed files with 50 additions and 80 deletions

View File

@@ -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");