From eff70e05b38e4e86ccbae169dbd400711f2fd561 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Tue, 15 Dec 2020 00:12:42 -0500 Subject: 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`. --- src/wasm/wasm-s-parser.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/wasm/wasm-s-parser.cpp') 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()) { -- cgit v1.2.3