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/wasm-s-parser.cpp | |
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/wasm-s-parser.cpp')
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 85bc2aba9..c1c227d21 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -932,10 +932,10 @@ Type SExpressionWasmBuilder::elementToType(Element& s) { std::string("invalid reference type qualifier"), s.line, s.col); } // FIXME: for now, force all inputs to be nullable - bool nullable = true; + Nullability nullable = Nullable; size_t i = 1; if (size == 3) { - nullable = true; + nullable = Nullable; i++; } return Type(parseHeapType(*s[i]), nullable); @@ -1925,8 +1925,7 @@ Expression* SExpressionWasmBuilder::makeRefFunc(Element& s) { ret->func = func; // To support typed function refs, we give the reference not just a general // funcref, but a specific subtype with the actual signature. - ret->finalize( - Type(HeapType(functionSignatures[func]), /* nullable = */ true)); + ret->finalize(Type(HeapType(functionSignatures[func]), Nullable)); return ret; } @@ -2826,7 +2825,7 @@ HeapType SExpressionWasmBuilder::parseHeapType(Element& s) { } // It's a struct or an array. auto parseField = [&](Element* t) { - bool mutable_ = false; + Mutability mutable_ = Immutable; // t is a list, containing either // TYPE // or @@ -2842,7 +2841,7 @@ HeapType SExpressionWasmBuilder::parseHeapType(Element& s) { } // The element may also be (mut (..)). if (elementStartsWith(t, MUT)) { - mutable_ = true; + mutable_ = Mutable; t = (*t)[1]; } if (t->isStr()) { |