diff options
author | Ben Smith <binjimin@gmail.com> | 2019-02-13 16:27:24 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-13 16:27:24 -0800 |
commit | 19191efaf1b5b92b0357b303be1b25cf439be9a2 (patch) | |
tree | 1bd4be08904c059f809a69fff660de3a3cc5321c /src/type-checker.cc | |
parent | e448ac7cbd74f7a048b1de15ce1a2716340a57c8 (diff) | |
download | wabt-19191efaf1b5b92b0357b303be1b25cf439be9a2.tar.gz wabt-19191efaf1b5b92b0357b303be1b25cf439be9a2.tar.bz2 wabt-19191efaf1b5b92b0357b303be1b25cf439be9a2.zip |
Add br_on_exn instruction (#1016)
It takes two u32 immediates: the branch depth and an exception index. The
stack signature is `[expect_ref] -> [except_ref]`, so the `except_ref`
can be tested easily against multiple exception types.
Diffstat (limited to 'src/type-checker.cc')
-rw-r--r-- | src/type-checker.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/type-checker.cc b/src/type-checker.cc index 3b90bdc3..e5c56e9c 100644 --- a/src/type-checker.cc +++ b/src/type-checker.cc @@ -384,6 +384,20 @@ Result TypeChecker::OnBrIf(Index depth) { return result; } +Result TypeChecker::OnBrOnExn(Index depth, const TypeVector& types) { + Result result = PopAndCheck1Type(Type::ExceptRef, "br_on_exn"); + Label* label; + CHECK_RESULT(GetLabel(depth, &label)); + if (Failed(CheckTypes(types, label->br_types()))) { + PrintError("br_on_exn has inconsistent types: expected %s, got %s", + TypesToString(label->br_types()).c_str(), + TypesToString(types).c_str()); + result = Result::Error; + } + PushType(Type::ExceptRef); + return result; +} + Result TypeChecker::BeginBrTable() { br_table_sig_ = nullptr; return PopAndCheck1Type(Type::I32, "br_table"); |