Skip to content

Commit cd03f54

Browse files
committed
[step 2]
1 parent 35b6d1f commit cd03f54

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

gen/toir.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,8 @@ class ToElemVisitor : public Visitor {
947947
// Logger::println("FuncDeclaration");
948948
FuncDeclaration *fd = fv->func;
949949
assert(fd);
950-
result = new DFuncValue(fd, DtoCallee(fd));
950+
result =
951+
fv->type == e->type ? fv : new DFuncValue(e->type, fd, fv->funcPtr);
951952
return;
952953
}
953954
if (v->isIm()) {
@@ -985,8 +986,11 @@ class ToElemVisitor : public Visitor {
985986
if (e->type->toBasetype()->ty == TY::Tfunction) {
986987
DValue *dv = toElem(e->e1);
987988
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);
989992
} else {
993+
// FIXME: should not reach this
990994
result = new DImValue(e->type, DtoRVal(dv));
991995
}
992996
return;
@@ -1952,6 +1956,7 @@ class ToElemVisitor : public Visitor {
19521956
LLValue *contextptr;
19531957
if (DFuncValue *f = u->isFunc()) {
19541958
assert(f->func);
1959+
// FIXME: use f->vthis
19551960
contextptr = DtoNestedContext(e->loc, f->func);
19561961
} else {
19571962
contextptr = (DtoIsInMemoryOnly(u->type) ? DtoLVal(u) : DtoRVal(u));
@@ -1988,6 +1993,7 @@ class ToElemVisitor : public Visitor {
19881993
fptr = DtoCallee(e->func);
19891994
}
19901995

1996+
// FIXME: use DFuncValue
19911997
result = new DImValue(
19921998
e->type, DtoAggrPair(DtoType(e->type), contextptr, fptr, ".dg"));
19931999
}
@@ -2280,8 +2286,9 @@ class ToElemVisitor : public Visitor {
22802286
genFuncLiteral(fd, e);
22812287
LLFunction *callee = DtoCallee(fd, false);
22822288

2283-
if (fd->isNested()) {
2289+
if (fd->isNested()) { // FIXME: if e->type->toBasetype() is a Tdelegate?
22842290
LLValue *cval = DtoNestedContext(e->loc, fd);
2291+
// FIXME: use DFuncValue
22852292
result = new DImValue(e->type, DtoAggrPair(cval, callee, ".func"));
22862293
} else {
22872294
result = new DFuncValue(e->type, fd, callee);

0 commit comments

Comments
 (0)