@@ -947,8 +947,9 @@ class ToElemVisitor : public Visitor {
947947 // Logger::println("FuncDeclaration");
948948 FuncDeclaration *fd = fv->func ;
949949 assert (fd);
950- result =
951- fv->type == e->type ? fv : new DFuncValue (e->type , fd, fv->funcPtr );
950+ result = fv->type == e->type
951+ ? fv
952+ : new DFuncValue (e->type , fd, fv->funcPtr , fv->vthis );
952953 return ;
953954 }
954955 if (v->isIm ()) {
@@ -986,9 +987,10 @@ class ToElemVisitor : public Visitor {
986987 if (e->type ->toBasetype ()->ty == TY::Tfunction) {
987988 DValue *dv = toElem (e->e1 );
988989 if (DFuncValue *dfv = dv->isFunc ()) {
989- result = dfv->type == e->type
990- ? dfv
991- : new DFuncValue (e->type , dfv->func , dfv->funcPtr );
990+ result =
991+ dfv->type == e->type
992+ ? dfv
993+ : new DFuncValue (e->type , dfv->func , dfv->funcPtr , dfv->vthis );
992994 } else {
993995 // FIXME: should not reach this
994996 result = new DImValue (e->type , DtoRVal (dv));
@@ -1955,9 +1957,11 @@ class ToElemVisitor : public Visitor {
19551957 DValue *u = toElem (e->e1 );
19561958 LLValue *contextptr;
19571959 if (DFuncValue *f = u->isFunc ()) {
1958- assert (f->func );
1959- // FIXME: use f->vthis
1960- contextptr = DtoNestedContext (e->loc , f->func );
1960+ contextptr = f->vthis ;
1961+ if (!contextptr) {
1962+ assert (f->func );
1963+ contextptr = DtoNestedContext (e->loc , f->func );
1964+ }
19611965 } else {
19621966 contextptr = (DtoIsInMemoryOnly (u->type ) ? DtoLVal (u) : DtoRVal (u));
19631967 }
@@ -1993,9 +1997,7 @@ class ToElemVisitor : public Visitor {
19931997 fptr = DtoCallee (e->func );
19941998 }
19951999
1996- // FIXME: use DFuncValue
1997- result = new DImValue (
1998- e->type , DtoAggrPair (DtoType (e->type ), contextptr, fptr, " .dg" ));
2000+ result = new DFuncValue (e->type , e->func , fptr, contextptr);
19992001 }
20002002
20012003 // ////////////////////////////////////////////////////////////////////////////
@@ -2286,11 +2288,11 @@ class ToElemVisitor : public Visitor {
22862288 genFuncLiteral (fd, e);
22872289 LLFunction *callee = DtoCallee (fd, false );
22882290
2289- if (fd-> isNested ()) { // FIXME: if e->type->toBasetype() is a Tdelegate?
2291+ if (e->type ->toBasetype ()-> ty == TY:: Tdelegate) {
22902292 LLValue *cval = DtoNestedContext (e->loc , fd);
2291- // FIXME: use DFuncValue
2292- result = new DImValue (e->type , DtoAggrPair (cval, callee, " .func" ));
2293+ result = new DFuncValue (e->type , fd, callee, cval);
22932294 } else {
2295+ assert (!fd->isNested ());
22942296 result = new DFuncValue (e->type , fd, callee);
22952297 }
22962298 }
0 commit comments