summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index ef41dec93..cf4824323 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -2830,9 +2830,24 @@ Expression* SExpressionWasmBuilder::makeTupleExtract(Element& s) {
}
Expression* SExpressionWasmBuilder::makeCallRef(Element& s, bool isReturn) {
+ Index operandsStart = 1;
+ HeapType sigType;
+ if (isReturn) {
+ sigType = parseHeapType(*s[1]);
+ operandsStart = 2;
+ }
std::vector<Expression*> operands;
- parseOperands(s, 1, s.size() - 1, operands);
+ parseOperands(s, operandsStart, s.size() - 1, operands);
auto* target = parseExpression(s[s.size() - 1]);
+
+ if (isReturn) {
+ if (!sigType.isSignature()) {
+ throw ParseException(
+ "return_call_ref type annotation should be a signature", s.line, s.col);
+ }
+ return Builder(wasm).makeCallRef(
+ target, operands, sigType.getSignature().results, isReturn);
+ }
return ValidatingBuilder(wasm, s.line, s.col)
.validateAndMakeCallRef(target, operands, isReturn);
}