Mercurial > projects > ldc
changeset 143:336ec4f4bbb3 trunk
[svn r147] tango.io.Console is now working. True this time :) Yay!
author | lindquist |
---|---|
date | Fri, 25 Jan 2008 01:42:36 +0100 |
parents | a123dca8349b |
children | a27941d00351 |
files | gen/dvalue.h gen/toir.cpp llvmdc.kdevelop tango/lib/compiler/llvmdc/cast.d tangotests/t.d |
diffstat | 5 files changed, 39 insertions(+), 113 deletions(-) [+] |
line wrap: on
line diff
--- 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; }
--- 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); } //////////////////////////////////////////////////////////////////////////////////////////
--- 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 @@ <path>dmd25/utf.h</path> <path>dmd25/version.c</path> <path>dmd25/version.h</path> - <path>dmd26</path> - <path>dmd26/access.c</path> - <path>dmd26/aggregate.h</path> - <path>dmd26/array.c</path> - <path>dmd26/arraytypes.h</path> - <path>dmd26/attrib.c</path> - <path>dmd26/attrib.h</path> - <path>dmd26/cast.c</path> - <path>dmd26/class.c</path> - <path>dmd26/complex_t.h</path> - <path>dmd26/cond.c</path> - <path>dmd26/cond.h</path> - <path>dmd26/constfold.c</path> - <path>dmd26/dchar.c</path> - <path>dmd26/dchar.h</path> - <path>dmd26/declaration.c</path> - <path>dmd26/declaration.h</path> - <path>dmd26/delegatize.c</path> - <path>dmd26/doc.c</path> - <path>dmd26/doc.h</path> - <path>dmd26/dsymbol.c</path> - <path>dmd26/dsymbol.h</path> - <path>dmd26/dump.c</path> - <path>dmd26/entity.c</path> - <path>dmd26/enum.c</path> - <path>dmd26/enum.h</path> - <path>dmd26/expression.c</path> - <path>dmd26/expression.h</path> - <path>dmd26/func.c</path> - <path>dmd26/gnuc.c</path> - <path>dmd26/gnuc.h</path> - <path>dmd26/hdrgen.c</path> - <path>dmd26/hdrgen.h</path> - <path>dmd26/html.c</path> - <path>dmd26/html.h</path> - <path>dmd26/identifier.c</path> - <path>dmd26/identifier.h</path> - <path>dmd26/idgen.c</path> - <path>dmd26/impcnvgen.c</path> - <path>dmd26/import.c</path> - <path>dmd26/import.h</path> - <path>dmd26/inifile.c</path> - <path>dmd26/init.c</path> - <path>dmd26/init.h</path> - <path>dmd26/inline.c</path> - <path>dmd26/interpret.c</path> - <path>dmd26/lexer.c</path> - <path>dmd26/lexer.h</path> - <path>dmd26/link.c</path> - <path>dmd26/lstring.c</path> - <path>dmd26/lstring.h</path> - <path>dmd26/macro.c</path> - <path>dmd26/macro.h</path> - <path>dmd26/mangle.c</path> - <path>dmd26/mars.c</path> - <path>dmd26/mars.h</path> - <path>dmd26/mem.c</path> - <path>dmd26/mem.h</path> - <path>dmd26/module.c</path> - <path>dmd26/module.h</path> - <path>dmd26/mtype.c</path> - <path>dmd26/mtype.h</path> - <path>dmd26/opover.c</path> - <path>dmd26/optimize.c</path> - <path>dmd26/parse.c</path> - <path>dmd26/parse.h</path> - <path>dmd26/port.h</path> - <path>dmd26/root.c</path> - <path>dmd26/root.h</path> - <path>dmd26/scope.c</path> - <path>dmd26/scope.h</path> - <path>dmd26/statement.c</path> - <path>dmd26/statement.h</path> - <path>dmd26/staticassert.c</path> - <path>dmd26/staticassert.h</path> - <path>dmd26/stringtable.c</path> - <path>dmd26/stringtable.h</path> - <path>dmd26/struct.c</path> - <path>dmd26/template.c</path> - <path>dmd26/template.h</path> - <path>dmd26/total.h</path> - <path>dmd26/unialpha.c</path> - <path>dmd26/utf.c</path> - <path>dmd26/utf.h</path> - <path>dmd26/version.c</path> - <path>dmd26/version.h</path> - <path>todo</path> - <path>todo/lib.d</path> </blacklist> <build> <buildtool>make</buildtool>
--- 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*, ...); /******************************************
--- 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*, ...);