summaryrefslogtreecommitdiff
path: root/src/wasm-builder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-builder.h')
-rw-r--r--src/wasm-builder.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index d3af93896..6800aa2ed 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -588,10 +588,10 @@ public:
ret->finalize();
return ret;
}
- RefFunc* makeRefFunc(Name func) {
+ RefFunc* makeRefFunc(Name func, Type type) {
auto* ret = wasm.allocator.alloc<RefFunc>();
ret->func = func;
- ret->finalize();
+ ret->finalize(type);
return ret;
}
RefEq* makeRefEq(Expression* left, Expression* right) {
@@ -769,8 +769,7 @@ public:
}
if (type.isFunction()) {
if (!value.isNull()) {
- // TODO: with typed function references we need to do more for the type
- return makeRefFunc(value.getFunc());
+ return makeRefFunc(value.getFunc(), type);
}
return makeRefNull(type);
}
@@ -951,7 +950,12 @@ public:
return makeConstantExpression(Literal::makeZeros(curr->type));
}
if (curr->type.isFunction()) {
- return ExpressionManipulator::refNull(curr, curr->type);
+ if (curr->type.isNullable()) {
+ return ExpressionManipulator::refNull(curr, curr->type);
+ } else {
+ // We can't do any better, keep the original.
+ return curr;
+ }
}
Literal value;
// TODO: reuse node conditionally when possible for literals