diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-04-29 14:58:17 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-04-29 15:03:30 -0700 |
commit | 8ac323bb58c0e1891dea6492160939eb1b6bb1d2 (patch) | |
tree | d86a3fe87034f59051c21eb581af0b24143f6c6f /src/wasm.h | |
parent | 623918767242c36b9197e83a9e3b4e35ee17f8db (diff) | |
download | binaryen-8ac323bb58c0e1891dea6492160939eb1b6bb1d2.tar.gz binaryen-8ac323bb58c0e1891dea6492160939eb1b6bb1d2.tar.bz2 binaryen-8ac323bb58c0e1891dea6492160939eb1b6bb1d2.zip |
add wasm.cpp which does full type detection for blocks, and prepare for full type checking everywhere
Diffstat (limited to 'src/wasm.h')
-rw-r--r-- | src/wasm.h | 17 |
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); } } |