summaryrefslogtreecommitdiff
path: root/src/passes/Print.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/passes/Print.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/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index ee7aa9ac7..d7691fe07 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -1685,7 +1685,7 @@ struct PrintExpressionContents
}
void visitStructGet(StructGet* curr) {
const auto& field =
- curr->value->type.getHeapType().getStruct().fields[curr->index];
+ curr->ref->type.getHeapType().getStruct().fields[curr->index];
if (field.type == Type::i32 && field.packedType != Field::not_packed) {
if (curr->signed_) {
printMedium(o, "struct.get_s ");
@@ -1695,13 +1695,15 @@ struct PrintExpressionContents
} else {
printMedium(o, "struct.get ");
}
- printHeapTypeName(o, curr->value->type.getHeapType());
+ printHeapTypeName(o, curr->ref->type.getHeapType());
o << ' ';
o << curr->index;
}
void visitStructSet(StructSet* curr) {
- printMedium(o, "struct.set");
- WASM_UNREACHABLE("TODO (gc): struct.set");
+ printMedium(o, "struct.set ");
+ printHeapTypeName(o, curr->ref->type.getHeapType());
+ o << ' ';
+ o << curr->index;
}
void visitArrayNew(ArrayNew* curr) {
WASM_UNREACHABLE("TODO (gc): array.new");
@@ -2372,13 +2374,16 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
o << '(';
PrintExpressionContents(currFunction, o).visit(curr);
incIndent();
- printFullLine(curr->value);
+ printFullLine(curr->ref);
decIndent();
}
void visitStructSet(StructSet* curr) {
o << '(';
PrintExpressionContents(currFunction, o).visit(curr);
- WASM_UNREACHABLE("TODO (gc): struct.set");
+ incIndent();
+ printFullLine(curr->ref);
+ printFullLine(curr->value);
+ decIndent();
}
void visitArrayNew(ArrayNew* curr) {
o << '(';