From 32bfd1c5b32a1ce38da310deb67819c471becb45 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Fri, 26 Feb 2021 21:27:31 -0800 Subject: Use enum instead of bool for StackSignature kind (#3625) As a readability improvement, use an enum with `Polymorphic` and `Fixed` variants to represent the polymorphic behavior of StackSignatures rather than a `bool uneachable`. --- src/wasm/wasm-validator.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/wasm/wasm-validator.cpp') diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 1a5894343..97146a7c4 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -666,8 +666,8 @@ void FunctionValidator::validatePoppyBlockElements(Block* curr) { !info.quiet) { getStream() << "(on index " << i << ":\n" << expr << "\n), required: " << sig.params << ", available: "; - if (blockSig.unreachable) { - getStream() << "unreachable, "; + if (blockSig.kind == StackSignature::Polymorphic) { + getStream() << "polymorphic, "; } getStream() << blockSig.results << "\n"; return; @@ -675,18 +675,22 @@ void FunctionValidator::validatePoppyBlockElements(Block* curr) { blockSig += sig; } if (curr->type == Type::unreachable) { - shouldBeTrue(blockSig.unreachable, + shouldBeTrue(blockSig.kind == StackSignature::Polymorphic, curr, "unreachable block should have unreachable element"); } else { if (!shouldBeTrue( StackSignature::isSubType( - blockSig, StackSignature(Type::none, curr->type, false)), + blockSig, + StackSignature(Type::none, curr->type, StackSignature::Fixed)), curr, "block contents should satisfy block type") && !info.quiet) { getStream() << "contents: " << blockSig.results - << (blockSig.unreachable ? " [unreachable]" : "") << "\n" + << (blockSig.kind == StackSignature::Polymorphic + ? " [polymorphic]" + : "") + << "\n" << "expected: " << curr->type << "\n"; } } -- cgit v1.2.3