diff options
author | KarlSchimpf <karlschimpf@gmail.com> | 2017-06-22 07:59:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-22 07:59:09 -0700 |
commit | 917d3bfa6593c9a85c81b674770aec2ca404a4a2 (patch) | |
tree | ff279590a68c00714889d1667da9739f7e7cbd9a /src/ir.h | |
parent | c0ae2e69b53f12e57833270e1b48a01864fb5156 (diff) | |
download | wabt-917d3bfa6593c9a85c81b674770aec2ca404a4a2.tar.gz wabt-917d3bfa6593c9a85c81b674770aec2ca404a4a2.tar.bz2 wabt-917d3bfa6593c9a85c81b674770aec2ca404a4a2.zip |
Fix the validator to be able to validate exception handling constructs. (#514)
* Save state.
* Add exception declaration syntax.
* Extend validator to handle exception declarations.
* Fix binary writer to handle exception declarations.
* Fix code to handle external exception kind.
* Regenerate lexer.
* Fix bug with last merge.
* Add exception declarations, and add examples.
* Fix nits.
* Initial extensions for expr visitor.
* Save state.
* Fix issues with master merge.
* Reconcile issues with merge of tools wast2wasm and wast-desugar.
* Save state.
* Save work to move to mtv.
* Fix resolving names on try/throw constructs.
* Completed implementation of validation for exception handling.
* Fix nits.
* Combine Catch and CatchAll in IR.
* Remove tryblock visitors.
* Clean up to only use one visitor for each catch.
* Rework the structure of try blocks and catches.
* Remove the need for common CLI options.
* Fix issues raised by binji.
* Fix re2c generated file.
* Fix memory leak, and fix nits.
Diffstat (limited to 'src/ir.h')
-rw-r--r-- | src/ir.h | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -88,8 +88,6 @@ enum class ExprType { BrTable, Call, CallIndirect, - Catch, - CatchAll, Compare, Const, Convert, @@ -130,6 +128,22 @@ struct Block { Expr* first; }; +struct Catch { + WABT_DISALLOW_COPY_AND_ASSIGN(Catch); + Catch() = delete; + explicit Catch(Expr* first); + Catch(Var var, Expr* first); + ~Catch(); + Location loc; + Var var; + struct Expr* first; + bool IsCatchAll() const { + return var.type == VarType::Index && var.index == kInvalidIndex; + } +}; + +typedef std::vector<Catch*> CatchVector; + struct Expr { WABT_DISALLOW_COPY_AND_ASSIGN(Expr); Expr(); @@ -143,8 +157,6 @@ struct Expr { static Expr* CreateBrTable(VarVector* targets, Var default_target); static Expr* CreateCall(Var); static Expr* CreateCallIndirect(Var); - static Expr* CreateCatch(Var v, Expr* first); - static Expr* CreateCatchAll(Expr* first); static Expr* CreateCompare(Opcode); static Expr* CreateConst(const Const&); static Expr* CreateConvert(Opcode); @@ -165,7 +177,7 @@ struct Expr { static Expr* CreateStore(Opcode, Address align, uint32_t offset); static Expr* CreateTeeLocal(Var); static Expr* CreateThrow(Var); - static Expr* CreateTry(Block* block, Expr* first_catch); + static Expr* CreateTry(); static Expr* CreateUnary(Opcode); static Expr* CreateUnreachable(); @@ -175,9 +187,7 @@ struct Expr { union { struct { Opcode opcode; } binary, compare, convert, unary; struct Block *block, *loop; - struct { Block* block; Expr* first_catch; } try_block; - struct { Var var; Expr* first; } catch_; - struct { Expr* first; } catch_all; + struct { Block* block; CatchVector* catches; } try_block; struct { Var var; } throw_, rethrow_; struct { Var var; } br, br_if; struct { VarVector* targets; Var default_target; } br_table; @@ -193,6 +203,7 @@ struct Expr { struct Exception { StringSlice name; TypeVector sig; + ~Exception() { destroy_string_slice(&name); } }; struct FuncSignature { @@ -401,6 +412,7 @@ struct Module { const Global* GetGlobal(const Var&) const; Global* GetGlobal(const Var&); const Export* GetExport(const StringSlice&) const; + Index GetExceptIndex(const Var&) const; Location loc; StringSlice name; |