diff options
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r-- | src/wasm/wasm.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 36eff681f..96ca8fbc8 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -248,7 +248,9 @@ void Loop::finalize() { void Break::finalize() { if (condition) { - if (value) { + if (condition->type == unreachable) { + type = unreachable; + } else if (value) { type = value->type; } else { type = none; @@ -258,6 +260,10 @@ void Break::finalize() { } } +void Switch::finalize() { + type = unreachable; +} + bool FunctionType::structuralComparison(FunctionType& b) { if (result != b.result) return false; if (params.size() != b.params.size()) return false; @@ -286,6 +292,11 @@ void SetLocal::setTee(bool is) { void Store::finalize() { assert(valueType != none); // must be set + if (ptr->type == unreachable || value->type == unreachable) { + type = unreachable; + } else { + type = none; + } } Const* Const::set(Literal value_) { @@ -299,6 +310,10 @@ bool Unary::isRelational() { } void Unary::finalize() { + if (value->type == unreachable) { + type = unreachable; + return; + } switch (op) { case ClzInt32: case CtzInt32: @@ -390,16 +405,22 @@ bool Binary::isRelational() { void Binary::finalize() { assert(left && right); - if (isRelational()) { + if (left->type == unreachable || right->type == unreachable) { + type = unreachable; + } else if (isRelational()) { type = i32; } else { - type = getReachableWasmType(left->type, right->type); + type = left->type; } } void Select::finalize() { assert(ifTrue && ifFalse); - type = getReachableWasmType(ifTrue->type, ifFalse->type); + if (ifTrue->type == unreachable || ifFalse->type == unreachable || condition->type == unreachable) { + type = unreachable; + } else { + type = ifTrue->type; + } } void Host::finalize() { |