@@ -947,7 +947,8 @@ class ToElemVisitor : public Visitor {
947
947
// Logger::println("FuncDeclaration");
948
948
FuncDeclaration *fd = fv->func ;
949
949
assert (fd);
950
- result = new DFuncValue (fd, DtoCallee (fd));
950
+ result =
951
+ fv->type == e->type ? fv : new DFuncValue (e->type , fd, fv->funcPtr );
951
952
return ;
952
953
}
953
954
if (v->isIm ()) {
@@ -985,8 +986,11 @@ class ToElemVisitor : public Visitor {
985
986
if (e->type ->toBasetype ()->ty == TY::Tfunction) {
986
987
DValue *dv = toElem (e->e1 );
987
988
if (DFuncValue *dfv = dv->isFunc ()) {
988
- result = new DFuncValue (e->type , dfv->func , dfv->funcPtr );
989
+ result = dfv->type == e->type
990
+ ? dfv
991
+ : new DFuncValue (e->type , dfv->func , dfv->funcPtr );
989
992
} else {
993
+ // FIXME: should not reach this
990
994
result = new DImValue (e->type , DtoRVal (dv));
991
995
}
992
996
return ;
@@ -1952,6 +1956,7 @@ class ToElemVisitor : public Visitor {
1952
1956
LLValue *contextptr;
1953
1957
if (DFuncValue *f = u->isFunc ()) {
1954
1958
assert (f->func );
1959
+ // FIXME: use f->vthis
1955
1960
contextptr = DtoNestedContext (e->loc , f->func );
1956
1961
} else {
1957
1962
contextptr = (DtoIsInMemoryOnly (u->type ) ? DtoLVal (u) : DtoRVal (u));
@@ -1988,6 +1993,7 @@ class ToElemVisitor : public Visitor {
1988
1993
fptr = DtoCallee (e->func );
1989
1994
}
1990
1995
1996
+ // FIXME: use DFuncValue
1991
1997
result = new DImValue (
1992
1998
e->type , DtoAggrPair (DtoType (e->type ), contextptr, fptr, " .dg" ));
1993
1999
}
@@ -2280,8 +2286,9 @@ class ToElemVisitor : public Visitor {
2280
2286
genFuncLiteral (fd, e);
2281
2287
LLFunction *callee = DtoCallee (fd, false );
2282
2288
2283
- if (fd->isNested ()) {
2289
+ if (fd->isNested ()) { // FIXME: if e->type->toBasetype() is a Tdelegate?
2284
2290
LLValue *cval = DtoNestedContext (e->loc , fd);
2291
+ // FIXME: use DFuncValue
2285
2292
result = new DImValue (e->type , DtoAggrPair (cval, callee, " .func" ));
2286
2293
} else {
2287
2294
result = new DFuncValue (e->type , fd, callee);
0 commit comments