summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2021-02-26 21:27:31 -0800
committerGitHub <noreply@github.com>2021-02-26 21:27:31 -0800
commit32bfd1c5b32a1ce38da310deb67819c471becb45 (patch)
tree37d73a6bcd461104dea2f5e389677ab4fccf0a26 /src/wasm/wasm-validator.cpp
parenta276c7e9687a98bb4cb222c71278a8658633d80f (diff)
downloadbinaryen-32bfd1c5b32a1ce38da310deb67819c471becb45.tar.gz
binaryen-32bfd1c5b32a1ce38da310deb67819c471becb45.tar.bz2
binaryen-32bfd1c5b32a1ce38da310deb67819c471becb45.zip
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`.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp14
1 files changed, 9 insertions, 5 deletions
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";
}
}