comparison gen/classes.cpp @ 778:4adf0f742896

Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead. Fixed some casts to bool that were using truncation.
author Christian Kamm <kamm incasoftware de>
date Sat, 22 Nov 2008 18:35:52 +0100
parents f04dde6e882c
children 6e7a4c3b64d2
comparison
equal deleted inserted replaced
777:961e249eb2aa 778:4adf0f742896
922 Logger::println("DtoCastClass(%s, %s)", val->getType()->toChars(), _to->toChars()); 922 Logger::println("DtoCastClass(%s, %s)", val->getType()->toChars(), _to->toChars());
923 LOG_SCOPE; 923 LOG_SCOPE;
924 924
925 Type* to = _to->toBasetype(); 925 Type* to = _to->toBasetype();
926 if (to->ty == Tpointer) { 926 if (to->ty == Tpointer) {
927 Logger::println("to pointer");
927 const LLType* tolltype = DtoType(_to); 928 const LLType* tolltype = DtoType(_to);
928 LLValue* rval = DtoBitCast(val->getRVal(), tolltype); 929 LLValue* rval = DtoBitCast(val->getRVal(), tolltype);
929 return new DImValue(_to, rval); 930 return new DImValue(_to, rval);
931 }
932 else if (to->ty == Tbool) {
933 Logger::println("to bool");
934 LLValue* llval = val->getRVal();
935 LLValue* zero = LLConstant::getNullValue(llval->getType());
936 return new DImValue(_to, gIR->ir->CreateICmpNE(llval, zero, "tmp"));
930 } 937 }
931 938
932 assert(to->ty == Tclass); 939 assert(to->ty == Tclass);
933 TypeClass* tc = (TypeClass*)to; 940 TypeClass* tc = (TypeClass*)to;
934 941
945 Logger::println("from object"); 952 Logger::println("from object");
946 return DtoDynamicCastObject(val, _to); 953 return DtoDynamicCastObject(val, _to);
947 } 954 }
948 } 955 }
949 else { 956 else {
950 Logger::println("to object"); 957 Logger::println("to class");
951 int poffset; 958 int poffset;
952 if (fc->sym->isInterfaceDeclaration()) { 959 if (fc->sym->isInterfaceDeclaration()) {
953 Logger::println("interface cast"); 960 Logger::println("interface cast");
954 return DtoCastInterfaceToObject(val, _to); 961 return DtoCastInterfaceToObject(val, _to);
955 } 962 }