diff options
author | Alon Zakai <azakai@google.com> | 2020-12-05 15:49:34 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-05 15:49:34 -0800 |
commit | 18cf8a7557e34f722704c294f3d95817bac8cfc0 (patch) | |
tree | e1c6f0edecb13c8e5710a134e737cfebe0cc224e /src/wasm-type.h | |
parent | 51dfeef750acacea8dd1331213aa87ae76423dea (diff) | |
download | binaryen-18cf8a7557e34f722704c294f3d95817bac8cfc0.tar.gz binaryen-18cf8a7557e34f722704c294f3d95817bac8cfc0.tar.bz2 binaryen-18cf8a7557e34f722704c294f3d95817bac8cfc0.zip |
[GC] Support reading and writing of Struct and Array types (#3423)
This adds support in the text and binary format handling, which allows us
to have a full test of reading and writing the types.
This also adds a "name" field to struct fields, which the text format supports.
Diffstat (limited to 'src/wasm-type.h')
-rw-r--r-- | src/wasm-type.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/wasm-type.h b/src/wasm-type.h index 39ec1640e..98c6c70ed 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -17,6 +17,7 @@ #ifndef wasm_wasm_type_h #define wasm_wasm_type_h +#include "support/name.h" #include "wasm-features.h" #include <ostream> #include <vector> @@ -285,11 +286,12 @@ struct Field { i16, } packedType; // applicable iff type=i32 bool mutable_; + Name name; - Field(Type type, bool mutable_ = false) - : type(type), packedType(not_packed), mutable_(mutable_) {} - Field(PackedType packedType, bool mutable_ = false) - : type(Type::i32), packedType(packedType), mutable_(mutable_) {} + Field(Type type, bool mutable_, Name name = Name()) + : type(type), packedType(not_packed), mutable_(mutable_), name(name) {} + Field(PackedType packedType, bool mutable_, Name name = Name()) + : type(Type::i32), packedType(packedType), mutable_(mutable_), name(name) {} constexpr bool isPacked() const { if (packedType != not_packed) { @@ -300,6 +302,8 @@ struct Field { } bool operator==(const Field& other) const { + // Note that the name is not checked here - it is pure metadata for printing + // purposes only. return type == other.type && packedType == other.packedType && mutable_ == other.mutable_; } @@ -362,6 +366,7 @@ struct HeapType { HeapType(const HeapType& other); ~HeapType(); + bool isBasic() const { return kind <= _last_basic_kind; } bool isSignature() const { return kind == SignatureKind; } Signature getSignature() const { assert(isSignature() && "Not a signature"); |