diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-17 12:58:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-17 12:58:21 +0200 |
commit | 2841eddaabc7a5e24517e043a1aab8adc6d5c1e4 (patch) | |
tree | 17f8ed3d71237c4860fc07f7ba9bdc4d9691b76b /src/wasm/wasm-s-parser.cpp | |
parent | e1d74ef2acdd88f06b9e58f91f30bb56b9a26fe8 (diff) | |
download | binaryen-2841eddaabc7a5e24517e043a1aab8adc6d5c1e4.tar.gz binaryen-2841eddaabc7a5e24517e043a1aab8adc6d5c1e4.tar.bz2 binaryen-2841eddaabc7a5e24517e043a1aab8adc6d5c1e4.zip |
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.
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
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<Host>(); - 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<MemorySize>(); + ret->finalize(); + return ret; +} + +Expression* SExpressionWasmBuilder::makeMemoryGrow(Element& s) { + auto ret = allocator.alloc<MemoryGrow>(); + ret->delta = parseExpression(s[1]); ret->finalize(); return ret; } |