diff options
author | Alon Zakai <azakai@google.com> | 2020-12-10 15:25:23 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-10 15:25:23 -0800 |
commit | c93da3de39a4592abc6cddbed30b5c7074069a24 (patch) | |
tree | 265bcd421a97a21d58493f65eb29f252bf3a6001 /src/wasm.h | |
parent | 57a9e77add02dc1d874fdbfee2c61cae8c0eefa1 (diff) | |
download | binaryen-c93da3de39a4592abc6cddbed30b5c7074069a24.tar.gz binaryen-c93da3de39a4592abc6cddbed30b5c7074069a24.tar.bz2 binaryen-c93da3de39a4592abc6cddbed30b5c7074069a24.zip |
[GC] Add Array operations (#3436)
array.new/get/set/len - pretty straightforward after structs and all the
infrastructure for them.
Also fixes validation of the unnecessary heapType param in the
text and binary formats in structs as well as arrays.
Fixes printing of packed types in type names, which emitted i32
for them. That broke when we emitted the same name for an array
of i8 and i32 as in the new testing here.
Also fix a bug in Field::operator< which was wrong for packed
types; again, this was easy to notice with the new testing.
Diffstat (limited to 'src/wasm.h')
-rw-r--r-- | src/wasm.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/wasm.h b/src/wasm.h index c23819d51..0cc2f430c 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -1385,28 +1385,48 @@ class ArrayNew : public SpecificExpression<Expression::ArrayNewId> { public: ArrayNew(MixedArena& allocator) {} - void finalize() { WASM_UNREACHABLE("TODO (gc): array.new"); } + Expression* rtt; + Expression* size; + // If set, then the initial value is assigned to all entries in the array. If + // not set, this is array.new_with_default and the default of the type is + // used. + Expression* init = nullptr; + + bool isWithDefault() { return !init; } + + void finalize(); }; class ArrayGet : public SpecificExpression<Expression::ArrayGetId> { public: ArrayGet(MixedArena& allocator) {} - void finalize() { WASM_UNREACHABLE("TODO (gc): array.get"); } + Expression* ref; + Expression* index; + // Packed fields have a sign. + bool signed_ = false; + + void finalize(); }; class ArraySet : public SpecificExpression<Expression::ArraySetId> { public: ArraySet(MixedArena& allocator) {} - void finalize() { WASM_UNREACHABLE("TODO (gc): array.set"); } + Expression* ref; + Expression* index; + Expression* value; + + void finalize(); }; class ArrayLen : public SpecificExpression<Expression::ArrayLenId> { public: ArrayLen(MixedArena& allocator) {} - void finalize() { WASM_UNREACHABLE("TODO (gc): array.len"); } + Expression* ref; + + void finalize(); }; // Globals |