Mercurial > projects > ldc
changeset 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 | 4d9108f1fbf4 |
children | 60332cd85308 |
files | gen/functions.cpp gen/llvmhelpers.cpp gen/toir.cpp llvmdc-tango tests/mini/nested14.d |
diffstat | 5 files changed, 42 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/functions.cpp Fri Aug 01 21:56:13 2008 +0200 +++ b/gen/functions.cpp Sat Aug 02 00:50:39 2008 +0200 @@ -559,6 +559,9 @@ llvm::Instruction* allocaPoint = new llvm::AllocaInst(LLType::Int32Ty, "alloca point", beginbb); gIR->func()->allocapoint = allocaPoint; + // debug info - after all allocas, but before any llvm.dbg.declare etc + if (global.params.symdebug) DtoDwarfFuncStart(fd); + // need result variable? (not nested) if (fd->vresult && !fd->vresult->nestedref) { Logger::println("non-nested vresult value"); @@ -625,9 +628,6 @@ } } - // debug info - if (global.params.symdebug) DtoDwarfFuncStart(fd); - LLValue* parentNested = NULL; if (FuncDeclaration* fd2 = fd->toParent2()->isFuncDeclaration()) { if (!fd->isStatic()) // huh?
--- a/gen/llvmhelpers.cpp Fri Aug 01 21:56:13 2008 +0200 +++ b/gen/llvmhelpers.cpp Sat Aug 02 00:50:39 2008 +0200 @@ -485,14 +485,6 @@ LLValue* ptr = DtoNestedContext(func); assert(ptr && "nested var, but no context"); - // if the nested var is a this pointer it's a class member and not a magic struct - // so we're done here! - // this happens since 1.033 for some reason... always correct ? - if (vd->ident == Id::This) - { - return ptr; - } - // handle a "normal" nested variable // we must cast here to be sure. nested classes just have a void*
--- a/gen/toir.cpp Fri Aug 01 21:56:13 2008 +0200 +++ b/gen/toir.cpp Sat Aug 02 00:50:39 2008 +0200 @@ -969,6 +969,7 @@ // this seems to happen for dmd generated assert statements like: // assert(this, "null this"); + // FIXME: check for TOKthis in AssertExp instead if (!var) { LLValue* v = p->func()->thisVar; @@ -978,9 +979,16 @@ // regular this expr else if (VarDeclaration* vd = var->isVarDeclaration()) { LLValue* v; - v = p->func()->decl->ir.irFunc->thisVar; - if (llvm::isa<llvm::AllocaInst>(v)) - v = DtoLoad(v); + if (vd->toParent2() != p->func()->decl) { + Logger::println("nested this exp"); + v = DtoLoad(DtoNestedVariable(vd)); + } + else { + Logger::println("normal this exp"); + v = p->func()->decl->ir.irFunc->thisVar; + if (llvm::isa<llvm::AllocaInst>(v)) + v = DtoLoad(v); + } const LLType* t = DtoType(type); if (v->getType() != t) v = DtoBitCast(v, t);
--- a/llvmdc-tango Fri Aug 01 21:56:13 2008 +0200 +++ b/llvmdc-tango Sat Aug 02 00:50:39 2008 +0200 @@ -1,4 +1,4 @@ -profile=tango +ignore=object compiler=llvmdc inifile=llvmdc.conf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/mini/nested14.d Sat Aug 02 00:50:39 2008 +0200 @@ -0,0 +1,27 @@ +module mini.nested14; + +extern(C) int printf(char*, ...); + +class C +{ + void foo() + { + void bar() + { + car(); + } + + bar(); + } + + void car() + { + printf("great\n"); + } +} + +void main() +{ + scope c = new C; + c.foo(); +}