From 2841eddaabc7a5e24517e043a1aab8adc6d5c1e4 Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Thu, 17 Sep 2020 12:58:21 +0200 Subject: Refactor Host expression to MemorySize and MemoryGrow (#3137) Aligns the internal representations of `memory.size` and `memory.grow` with other more recent memory instructions by removing the legacy `Host` expression class and adding separate expression classes for `MemorySize` and `MemoryGrow`. Simplifies related APIs, but is also a breaking API change. --- src/wasm/wasm-s-parser.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/wasm/wasm-s-parser.cpp') diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 97da80fea..2883519f2 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -1021,19 +1021,15 @@ Expression* SExpressionWasmBuilder::makeDrop(Element& s) { return ret; } -Expression* SExpressionWasmBuilder::makeHost(Element& s, HostOp op) { - auto ret = allocator.alloc(); - ret->op = op; - parseCallOperands(s, 1, s.size(), ret); - if (ret->op == HostOp::MemoryGrow) { - if (ret->operands.size() != 1) { - throw ParseException("memory.grow needs one operand", s.line, s.col); - } - } else { - if (ret->operands.size() != 0) { - throw ParseException("host needs zero operands", s.line, s.col); - } - } +Expression* SExpressionWasmBuilder::makeMemorySize(Element& s) { + auto ret = allocator.alloc(); + ret->finalize(); + return ret; +} + +Expression* SExpressionWasmBuilder::makeMemoryGrow(Element& s) { + auto ret = allocator.alloc(); + ret->delta = parseExpression(s[1]); ret->finalize(); return ret; } -- cgit v1.2.3