Another fix for nested context in structs.

This commit is contained in:
Alexey Prokhin
2010-11-05 11:55:23 +03:00
parent 45606689c5
commit 59d1ec5e0b
3 changed files with 7 additions and 3 deletions

View File

@@ -68,7 +68,7 @@ static FuncDeclaration* getParentFunc(Dsymbol* sym, bool stopOnStatic) {
return (parent ? parent->isFuncDeclaration() : NULL);
}
DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd)
DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd, bool byref)
{
Logger::println("DtoNestedVariable for %s @ %s", vd->toChars(), loc.toChars());
LOG_SCOPE;
@@ -150,7 +150,7 @@ DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd)
val = DtoGEPi(val, 0, vd->ir.irLocal->nestedIndex, vd->toChars());
Logger::cout() << "Addr: " << *val << '\n';
Logger::cout() << "of type: " << *val->getType() << '\n';
if (vd->ir.irLocal->byref) {
if (vd->ir.irLocal->byref || byref) {
val = DtoAlignedLoad(val);
Logger::cout() << "Was byref, now: " << *val << '\n';
Logger::cout() << "of type: " << *val->getType() << '\n';

View File

@@ -28,6 +28,6 @@ LLValue* DtoResolveNestedContext(Loc loc, ClassDeclaration *decl, LLValue *value
llvm::Value* DtoNestedContext(Loc loc, Dsymbol* sym);
/// Gets the DValue of a nested variable with arbitrary nesting.
DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd);
DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd, bool byref = false);
#endif

View File

@@ -1202,7 +1202,11 @@ DValue* ThisExp::toElem(IRState* p)
LLValue* v;
if (vd->toParent2() != p->func()->decl) {
Logger::println("nested this exp");
#if STRUCTTHISREF
return DtoNestedVariable(loc, type, vd, type->ty == Tstruct);
#else
return DtoNestedVariable(loc, type, vd);
#endif
}
else {
Logger::println("normal this exp");