# HG changeset patch # User lindquist # Date 1201221756 -3600 # Node ID 336ec4f4bbb3e032db2e1306e109fe5c97936fd7 # Parent a123dca8349b8bc28ee3cc55cd708b2414ce323d [svn r147] tango.io.Console is now working. True this time :) Yay! diff -r a123dca8349b -r 336ec4f4bbb3 gen/dvalue.h --- a/gen/dvalue.h Wed Jan 23 15:48:19 2008 +0100 +++ b/gen/dvalue.h Fri Jan 25 01:42:36 2008 +0100 @@ -69,7 +69,7 @@ llvm::Value* val; bool inplace; - DImValue(Type* t, llvm::Value* v, bool i = false) { type = t; val = v; inplace = i; } + DImValue(Type* t, llvm::Value* v, bool in_place = false) { type = t; val = v; inplace = in_place; } virtual llvm::Value* getRVal() { assert(val); return val; } diff -r a123dca8349b -r 336ec4f4bbb3 gen/toir.cpp --- a/gen/toir.cpp Wed Jan 23 15:48:19 2008 +0100 +++ b/gen/toir.cpp Fri Jan 25 01:42:36 2008 +0100 @@ -2173,19 +2173,20 @@ Logger::print("DelegateExp::toElem: %s | %s\n", toChars(), type->toChars()); LOG_SCOPE; - DValue* u = e1->toElem(p); - const llvm::PointerType* int8ptrty = getPtrToType(llvm::Type::Int8Ty); llvm::Value* lval; + bool inplace = false; if (p->topexp() && p->topexp()->e2 == this) { assert(p->topexp()->v); lval = p->topexp()->v->getLVal(); + inplace = true; } else { lval = new llvm::AllocaInst(DtoType(type), "tmpdelegate", p->topallocapoint()); } + DValue* u = e1->toElem(p); llvm::Value* uval; if (DFuncValue* f = u->isFunc()) { //assert(f->vthis); @@ -2197,9 +2198,21 @@ uval = llvm::ConstantPointerNull::get(int8ptrty); } else { - uval = u->getRVal(); + DValue* src = u; + if (ClassDeclaration* cd = u->getType()->isClassHandle()) + { + Logger::println("context type is class handle"); + if (cd->isInterfaceDeclaration()) + { + Logger::println("context type is interface"); + src = DtoCastInterfaceToObject(u, ClassDeclaration::object->type); + } + } + uval = src->getRVal(); } + Logger::cout() << "context = " << *uval << '\n'; + llvm::Value* context = DtoGEPi(lval,0,0,"tmp"); llvm::Value* castcontext = DtoBitCast(uval, int8ptrty); DtoStore(castcontext, context); @@ -2221,7 +2234,7 @@ castfptr = DtoBitCast(castfptr, fptr->getType()->getContainedType(0)); DtoStore(castfptr, fptr); - return new DVarValue(type, lval, true); + return new DImValue(type, lval, inplace); } ////////////////////////////////////////////////////////////////////////////////////////// diff -r a123dca8349b -r 336ec4f4bbb3 llvmdc.kdevelop --- a/llvmdc.kdevelop Wed Jan 23 15:48:19 2008 +0100 +++ b/llvmdc.kdevelop Fri Jan 25 01:42:36 2008 +0100 @@ -572,94 +572,6 @@ dmd25/utf.h dmd25/version.c dmd25/version.h - dmd26 - dmd26/access.c - dmd26/aggregate.h - dmd26/array.c - dmd26/arraytypes.h - dmd26/attrib.c - dmd26/attrib.h - dmd26/cast.c - dmd26/class.c - dmd26/complex_t.h - dmd26/cond.c - dmd26/cond.h - dmd26/constfold.c - dmd26/dchar.c - dmd26/dchar.h - dmd26/declaration.c - dmd26/declaration.h - dmd26/delegatize.c - dmd26/doc.c - dmd26/doc.h - dmd26/dsymbol.c - dmd26/dsymbol.h - dmd26/dump.c - dmd26/entity.c - dmd26/enum.c - dmd26/enum.h - dmd26/expression.c - dmd26/expression.h - dmd26/func.c - dmd26/gnuc.c - dmd26/gnuc.h - dmd26/hdrgen.c - dmd26/hdrgen.h - dmd26/html.c - dmd26/html.h - dmd26/identifier.c - dmd26/identifier.h - dmd26/idgen.c - dmd26/impcnvgen.c - dmd26/import.c - dmd26/import.h - dmd26/inifile.c - dmd26/init.c - dmd26/init.h - dmd26/inline.c - dmd26/interpret.c - dmd26/lexer.c - dmd26/lexer.h - dmd26/link.c - dmd26/lstring.c - dmd26/lstring.h - dmd26/macro.c - dmd26/macro.h - dmd26/mangle.c - dmd26/mars.c - dmd26/mars.h - dmd26/mem.c - dmd26/mem.h - dmd26/module.c - dmd26/module.h - dmd26/mtype.c - dmd26/mtype.h - dmd26/opover.c - dmd26/optimize.c - dmd26/parse.c - dmd26/parse.h - dmd26/port.h - dmd26/root.c - dmd26/root.h - dmd26/scope.c - dmd26/scope.h - dmd26/statement.c - dmd26/statement.h - dmd26/staticassert.c - dmd26/staticassert.h - dmd26/stringtable.c - dmd26/stringtable.h - dmd26/struct.c - dmd26/template.c - dmd26/template.h - dmd26/total.h - dmd26/unialpha.c - dmd26/utf.c - dmd26/utf.h - dmd26/version.c - dmd26/version.h - todo - todo/lib.d make diff -r a123dca8349b -r 336ec4f4bbb3 tango/lib/compiler/llvmdc/cast.d --- a/tango/lib/compiler/llvmdc/cast.d Wed Jan 23 15:48:19 2008 +0100 +++ b/tango/lib/compiler/llvmdc/cast.d Fri Jan 25 01:42:36 2008 +0100 @@ -27,7 +27,7 @@ extern (C): -debug = PRINTF; +//debug = PRINTF; debug(PRINTF) int printf(char*, ...); /****************************************** diff -r a123dca8349b -r 336ec4f4bbb3 tangotests/t.d --- a/tangotests/t.d Wed Jan 23 15:48:19 2008 +0100 +++ b/tangotests/t.d Fri Jan 25 01:42:36 2008 +0100 @@ -1,33 +1,34 @@ interface MyInterface { - void func(); -} - -abstract class MyBaseClass : MyInterface -{ - abstract void func(); + int func(); } -class MyClass : MyBaseClass +class MyClass : MyInterface { - void func() + int var; + int func() { + return var; } +} - MyBaseClass toBase() - { - return this; - } +void func1(MyInterface i) +{ + int delegate() dg = &i.func; + func2(dg); +} + +extern(C) int printf(char*, ...); + +void func2(int delegate() dg) +{ + int i = dg(); + printf("%d\n", i); } void main() { - printf("STARTING\n"); auto c = new MyClass; - printf("c = %p\n", c); - auto b = c.toBase; - printf("b = %p\n", b); - printf("FINISHED\n"); + c.var = 42; + func1(c); } - -extern(C) int printf(char*, ...);