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.cc | |
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.cc')
-rw-r--r-- | src/ir.cc | 51 |
1 files changed, 27 insertions, 24 deletions
@@ -52,6 +52,10 @@ Index Module::GetFuncTypeIndex(const Var& var) const { return func_type_bindings.FindIndex(var); } +Index Module::GetExceptIndex(const Var& var) const { + return except_bindings.FindIndex(var); +} + Index Func::GetLocalIndex(const Var& var) const { if (var.type == VarType::Index) return var.index; @@ -278,6 +282,25 @@ Block::~Block() { DestroyExprList(first); } +Catch::Catch(Expr* first) : first(first) { + WABT_ZERO_MEMORY(loc); +} + +Catch::Catch(Var var, Expr* first) : var(var), first(first) { + WABT_ZERO_MEMORY(loc); +} + +Catch::~Catch() { + delete first; +} + +void destroy_catches(CatchVector* catches) { + for (Catch* catch_ : *catches) + delete catch_; + delete catches; +} + + Expr::Expr() : type(ExprType::Binary), next(nullptr) { WABT_ZERO_MEMORY(loc); binary.opcode = Opcode::Nop; @@ -308,11 +331,6 @@ Expr::~Expr() { case ExprType::CallIndirect: call_indirect.var.~Var(); break; - case ExprType::Catch: - case ExprType::CatchAll: - catch_.var.~Var(); - DestroyExprList(catch_.first); - break; case ExprType::GetGlobal: get_global.var.~Var(); break; @@ -343,7 +361,7 @@ Expr::~Expr() { break; case ExprType::TryBlock: delete try_block.block; - DestroyExprList(try_block.first_catch); + destroy_catches(try_block.catches); break; case ExprType::Binary: case ExprType::Compare: @@ -414,21 +432,6 @@ Expr* Expr::CreateCallIndirect(Var var) { } // static -Expr* Expr::CreateCatch(Var var, Expr* first) { - Expr* expr = new Expr(ExprType::Catch); - expr->catch_.var = var; - expr->catch_.first = first; - return expr; -} - -// static -Expr* Expr::CreateCatchAll(Expr* first) { - Expr* expr = new Expr(ExprType::CatchAll); - expr->catch_.first = first; - return expr; -} - -// static Expr* Expr::CreateCompare(Opcode opcode) { Expr* expr = new Expr(ExprType::Compare); expr->compare.opcode = opcode; @@ -562,10 +565,10 @@ Expr* Expr::CreateThrow(Var var) { } // static -Expr* Expr::CreateTry(Block* block, Expr* first_catch) { +Expr* Expr::CreateTry() { Expr* expr = new Expr(ExprType::TryBlock); - expr->try_block.block = block; - expr->try_block.first_catch = first_catch; + expr->try_block.block = nullptr; + expr->try_block.catches = new CatchVector(); return expr; } |