comparison gen/toir.cpp @ 452:30ef3c7bddca

Fixed problems with nested 'this'. Fixes #39 . Fixed problem with debug info order of intrinsic calls (func.start after declare).
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sat, 02 Aug 2008 00:50:39 +0200
parents cc40db549aea
children 121624c14053 9db9099583ca
comparison
equal deleted inserted replaced
451:4d9108f1fbf4 452:30ef3c7bddca
967 Logger::print("ThisExp::toElem: %s | %s\n", toChars(), type->toChars()); 967 Logger::print("ThisExp::toElem: %s | %s\n", toChars(), type->toChars());
968 LOG_SCOPE; 968 LOG_SCOPE;
969 969
970 // this seems to happen for dmd generated assert statements like: 970 // this seems to happen for dmd generated assert statements like:
971 // assert(this, "null this"); 971 // assert(this, "null this");
972 // FIXME: check for TOKthis in AssertExp instead
972 if (!var) 973 if (!var)
973 { 974 {
974 LLValue* v = p->func()->thisVar; 975 LLValue* v = p->func()->thisVar;
975 assert(v); 976 assert(v);
976 return new DImValue(type, v); 977 return new DImValue(type, v);
977 } 978 }
978 // regular this expr 979 // regular this expr
979 else if (VarDeclaration* vd = var->isVarDeclaration()) { 980 else if (VarDeclaration* vd = var->isVarDeclaration()) {
980 LLValue* v; 981 LLValue* v;
981 v = p->func()->decl->ir.irFunc->thisVar; 982 if (vd->toParent2() != p->func()->decl) {
982 if (llvm::isa<llvm::AllocaInst>(v)) 983 Logger::println("nested this exp");
983 v = DtoLoad(v); 984 v = DtoLoad(DtoNestedVariable(vd));
985 }
986 else {
987 Logger::println("normal this exp");
988 v = p->func()->decl->ir.irFunc->thisVar;
989 if (llvm::isa<llvm::AllocaInst>(v))
990 v = DtoLoad(v);
991 }
984 const LLType* t = DtoType(type); 992 const LLType* t = DtoType(type);
985 if (v->getType() != t) 993 if (v->getType() != t)
986 v = DtoBitCast(v, t); 994 v = DtoBitCast(v, t);
987 return new DThisValue(type, vd, v); 995 return new DThisValue(type, vd, v);
988 } 996 }