diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-12-15 00:12:42 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-14 21:12:42 -0800 |
commit | eff70e05b38e4e86ccbae169dbd400711f2fd561 (patch) | |
tree | 75216172ec8be03b9c75c89886692d5dcdca2936 /src/wasm-type.h | |
parent | b4928af5e70c85d309f7a074ed80bbcd1ee414f9 (diff) | |
download | binaryen-eff70e05b38e4e86ccbae169dbd400711f2fd561.tar.gz binaryen-eff70e05b38e4e86ccbae169dbd400711f2fd561.tar.bz2 binaryen-eff70e05b38e4e86ccbae169dbd400711f2fd561.zip |
Use enums for mutability and nullability (#3443)
Previously we were using bools for both of these concepts, but using enums makes
the code clearer. In particular, the PR removes many instances of
`/*nullability=*/ true`.
Diffstat (limited to 'src/wasm-type.h')
-rw-r--r-- | src/wasm-type.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/wasm-type.h b/src/wasm-type.h index 0df515f79..0df3bfeed 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -44,6 +44,9 @@ struct Struct; struct Array; struct Rtt; +enum Nullability { NonNullable, Nullable }; +enum Mutability { Immutable, Mutable }; + // The type used for interning IDs in the public interfaces of Type and // HeapType. using TypeID = uint64_t; @@ -93,7 +96,7 @@ public: // Construct from a heap type description. Also covers construction from // Signature, Struct or Array via implicit conversion to HeapType. - Type(HeapType, bool nullable); + Type(HeapType, Nullability nullable); // Construct from rtt description Type(Rtt); @@ -384,12 +387,12 @@ struct Field { i8, i16, } packedType; // applicable iff type=i32 - bool mutable_; + Mutability mutable_; Name name; - Field(Type type, bool mutable_, Name name = Name()) + Field(Type type, Mutability mutable_, Name name = Name()) : type(type), packedType(not_packed), mutable_(mutable_), name(name) {} - Field(PackedType packedType, bool mutable_, Name name = Name()) + Field(PackedType packedType, Mutability mutable_, Name name = Name()) : type(Type::i32), packedType(packedType), mutable_(mutable_), name(name) {} constexpr bool isPacked() const { @@ -483,7 +486,7 @@ struct TypeBuilder { // TypeBuilder's HeapTypes. Temporary Ref and Rtt types are backed by the // HeapType at index `i`. Type getTempTupleType(const Tuple&); - Type getTempRefType(size_t i, bool nullable); + Type getTempRefType(size_t i, Nullability nullable); Type getTempRttType(size_t i, uint32_t depth); // Canonicalizes and returns all of the heap types. May only be called once |