summaryrefslogtreecommitdiff
path: root/src/wasm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm.h')
-rw-r--r--src/wasm.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/wasm.h b/src/wasm.h
index b5dee81b8..b13011bae 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -833,11 +833,13 @@ public:
Name name;
ExpressionList list;
- void finalize() {
- if (list.size() > 0) {
- type = list.back()->type;
- }
+ // set the type of a block if you already know it
+ void finalize(WasmType type_) {
+ type = type;
}
+
+ // set the type of a block based on its contents. this scans the block, so it is not fast
+ void finalize();
};
class If : public SpecificExpression<Expression::IfId> {
@@ -877,6 +879,12 @@ public:
Name name;
Expression *value;
Expression *condition;
+
+ void finalize() {
+ if (condition) {
+ type = none;
+ }
+ }
};
class Switch : public SpecificExpression<Expression::SwitchId> {
@@ -1022,7 +1030,6 @@ public:
if (isRelational()) {
type = i32;
} else {
- assert(left->type != unreachable && right->type != unreachable ? left->type == right->type : true);
type = getReachableWasmType(left->type, right->type);
}
}