From 5403d66eb43900532dc58a860db1f1377d2c254d Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Mon, 13 Nov 2017 15:18:30 -0800 Subject: [PATCH] Update call_indirect text syntax to match spec update (#1281) Function type gets its own element rather than being a part of the call_indirect (see WebAssembly/spec#599) EOSIO note: Only cherry-pick the .cpp changes for this. Trying to pull up the tests is not feasible. We don't use the tests anyways. --- src/passes/Print.cpp | 2 +- src/wasm/wasm-s-parser.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 340266fcf76..4ec87135e65 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -261,7 +261,7 @@ struct PrintSExpression : public Visitor { printCallBody(curr); } void visitCallIndirect(CallIndirect *curr) { - printOpening(o, "call_indirect ") << curr->fullType; + printOpening(o, "call_indirect (type ") << curr->fullType << ')'; incIndent(); for (auto operand : curr->operands) { printFullLine(operand); diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 59043f3b8ff..6ef05e0c9a2 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -1318,7 +1318,9 @@ Expression* SExpressionWasmBuilder::makeCallImport(Element& s) { Expression* SExpressionWasmBuilder::makeCallIndirect(Element& s) { if (!wasm.table.exists) throw ParseException("no table"); auto ret = allocator.alloc(); - IString type = s[1]->str(); + Element& typeElement = *s[1]; + if (typeElement[0]->str() != "type") throw ParseException("expected 'type' in call_indirect", s.line, s.col); + IString type = typeElement[1]->str(); auto* fullType = wasm.getFunctionTypeOrNull(type); if (!fullType) throw ParseException("invalid call_indirect type", s.line, s.col); ret->fullType = fullType->name;