summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
authorDaniel Wirtz <dcode@dcode.io>2020-09-24 12:02:09 +0200
committerGitHub <noreply@github.com>2020-09-24 12:02:09 +0200
commite9e1b2ff00aeb05aaeb57af3811add267dc25323 (patch)
tree4e19032813858b2e650f0cda46fe9fa227aa0a7f /src/wasm/wasm-s-parser.cpp
parenta42423fafa8cf731c69303ddc0acbe80c890e0ab (diff)
downloadbinaryen-e9e1b2ff00aeb05aaeb57af3811add267dc25323.tar.gz
binaryen-e9e1b2ff00aeb05aaeb57af3811add267dc25323.tar.bz2
binaryen-e9e1b2ff00aeb05aaeb57af3811add267dc25323.zip
GC: Add i31 instructions (#3154)
Adds the `i31.new` and `i31.get_s/u` instructions for creating and working with `i31ref` typed values. Does not include fuzzer integration just yet because the fuzzer expects that trivial values it creates are suitable in global initializers, which is not the case for trivial `i31ref` expressions.
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 1bb83ec94..166fc88bb 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -1979,6 +1979,21 @@ Expression* SExpressionWasmBuilder::makeTupleExtract(Element& s) {
return ret;
}
+Expression* SExpressionWasmBuilder::makeI31New(Element& s) {
+ auto ret = allocator.alloc<I31New>();
+ ret->value = parseExpression(s[1]);
+ ret->finalize();
+ return ret;
+}
+
+Expression* SExpressionWasmBuilder::makeI31Get(Element& s, bool signed_) {
+ auto ret = allocator.alloc<I31Get>();
+ ret->i31 = parseExpression(s[1]);
+ ret->signed_ = signed_;
+ ret->finalize();
+ return ret;
+}
+
// converts an s-expression string representing binary data into an output
// sequence of raw bytes this appends to data, which may already contain
// content.