mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-26 16:43:13 +01:00
[svn r147] tango.io.Console is now working. True this time :) Yay!
This commit is contained in:
@@ -69,7 +69,7 @@ struct DImValue : DValue
|
||||
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; }
|
||||
|
||||
|
||||
21
gen/toir.cpp
21
gen/toir.cpp
@@ -2173,19 +2173,20 @@ DValue* DelegateExp::toElem(IRState* p)
|
||||
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 @@ DValue* DelegateExp::toElem(IRState* p)
|
||||
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 @@ DValue* DelegateExp::toElem(IRState* p)
|
||||
castfptr = DtoBitCast(castfptr, fptr->getType()->getContainedType(0));
|
||||
DtoStore(castfptr, fptr);
|
||||
|
||||
return new DVarValue(type, lval, true);
|
||||
return new DImValue(type, lval, inplace);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
extern (C):
|
||||
|
||||
debug = PRINTF;
|
||||
//debug = PRINTF;
|
||||
debug(PRINTF) int printf(char*, ...);
|
||||
|
||||
/******************************************
|
||||
|
||||
@@ -1,33 +1,34 @@
|
||||
interface MyInterface
|
||||
{
|
||||
void func();
|
||||
int func();
|
||||
}
|
||||
|
||||
abstract class MyBaseClass : MyInterface
|
||||
class MyClass : MyInterface
|
||||
{
|
||||
abstract void func();
|
||||
int var;
|
||||
int func()
|
||||
{
|
||||
return var;
|
||||
}
|
||||
}
|
||||
|
||||
class MyClass : MyBaseClass
|
||||
void func1(MyInterface i)
|
||||
{
|
||||
void func()
|
||||
{
|
||||
}
|
||||
int delegate() dg = &i.func;
|
||||
func2(dg);
|
||||
}
|
||||
|
||||
MyBaseClass toBase()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
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*, ...);
|
||||
|
||||
Reference in New Issue
Block a user