summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-12-07 16:58:43 -0800
committerGitHub <noreply@github.com>2020-12-07 16:58:43 -0800
commita84898c11df3d93fb69365fb274a9bb06d60ed47 (patch)
treec2bc444354ec5731dccb090e5437f00840bf7d9a /src/wasm/wasm-s-parser.cpp
parent72a7881b42ebed6b2ef36e912a8f5937106e5824 (diff)
downloadbinaryen-a84898c11df3d93fb69365fb274a9bb06d60ed47.tar.gz
binaryen-a84898c11df3d93fb69365fb274a9bb06d60ed47.tar.bz2
binaryen-a84898c11df3d93fb69365fb274a9bb06d60ed47.zip
[GC] Add struct.set (#3430)
Mostly straightforward after struct.get. This renames the value field in struct.get to ref. I think this makes more sense because struct.set has both a reference to a thing, and a value to set onto that thing. So calling the former ref seems more consistent, giving us ref, value. This mirrors load/store for example where we use ptr, value, and ref is playing the role of ptr here basically.
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 3e605429d..37592fcd5 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -2142,15 +2142,16 @@ Expression* SExpressionWasmBuilder::makeStructGet(Element& s, bool signed_) {
auto structType = parseHeapType(*s[1]);
auto index = getStructIndex(structType, *s[2]);
auto type = structType.getStruct().fields[index].type;
- auto value = parseExpression(*s[3]);
- return Builder(wasm).makeStructGet(index, value, type, signed_);
+ auto ref = parseExpression(*s[3]);
+ return Builder(wasm).makeStructGet(index, ref, type, signed_);
}
Expression* SExpressionWasmBuilder::makeStructSet(Element& s) {
- auto ret = allocator.alloc<StructSet>();
- WASM_UNREACHABLE("TODO (gc): struct.set");
- ret->finalize();
- return ret;
+ auto structType = parseHeapType(*s[1]);
+ auto index = getStructIndex(structType, *s[2]);
+ auto ref = parseExpression(*s[3]);
+ auto value = parseExpression(*s[4]);
+ return Builder(wasm).makeStructSet(index, ref, value);
}
Expression* SExpressionWasmBuilder::makeArrayNew(Element& s, bool default_) {