diff options
author | Soni L. <EnderMoneyMod@gmail.com> | 2024-11-20 14:51:48 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 09:51:48 -0800 |
commit | a0b7abef00b59eeafed58c774195189425d020b0 (patch) | |
tree | 6f7b0747d3a3ef435bda9ac14ca22d417877796b /src/type-checker.cc | |
parent | 958d0a72030227bf3133c8b99c7c670bcdbc7636 (diff) | |
download | wabt-a0b7abef00b59eeafed58c774195189425d020b0.tar.gz wabt-a0b7abef00b59eeafed58c774195189425d020b0.tar.bz2 wabt-a0b7abef00b59eeafed58c774195189425d020b0.zip |
binary/wat: Implement EHv4 (#2470)
This pull request implements EHv4. Binary is mostly untested until
interp is working.
Diffstat (limited to 'src/type-checker.cc')
-rw-r--r-- | src/type-checker.cc | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/type-checker.cc b/src/type-checker.cc index 8d6c3a11..96e4153c 100644 --- a/src/type-checker.cc +++ b/src/type-checker.cc @@ -644,7 +644,8 @@ Result TypeChecker::OnEnd() { Result result = Result::Ok; static const char* s_label_type_name[] = { "function", "initializer expression", "block", "loop", - "if", "`if false` branch", "try", "try catch"}; + "if", "`if false` branch", "try", "try table", + "try catch"}; WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(s_label_type_name) == kLabelTypeCount); Label* label; CHECK_RESULT(TopLabel(&label)); @@ -835,6 +836,13 @@ Result TypeChecker::OnThrow(const TypeVector& sig) { return result; } +Result TypeChecker::OnThrowRef() { + Result result = Result::Ok; + result |= PopAndCheck1Type(Type::ExnRef, "throw_ref"); + CHECK_RESULT(SetUnreachable()); + return result; +} + Result TypeChecker::OnReturn() { Result result = Result::Ok; Label* func_label; @@ -882,6 +890,31 @@ Result TypeChecker::OnTry(const TypeVector& param_types, return result; } +Result TypeChecker::BeginTryTable(const TypeVector& param_types) { + Result result = PopAndCheckSignature(param_types, "try_table"); + return result; +} + +Result TypeChecker::OnTryTableCatch(const TypeVector& sig, Index depth) { + Result result = Result::Ok; + Label* label; + CHECK_RESULT(GetLabel(depth, &label)); + TypeVector& label_sig = label->br_types(); + result |= CheckTypes(label_sig, sig); + if (Failed(result)) { + PrintError("catch signature doesn't match target: expected %s, got %s", + TypesToString(sig).c_str(), TypesToString(label_sig).c_str()); + } + return result; +} + +Result TypeChecker::EndTryTable(const TypeVector& param_types, + const TypeVector& result_types) { + PushLabel(LabelType::TryTable, param_types, result_types); + PushTypes(param_types); + return Result::Ok; +} + Result TypeChecker::OnUnary(Opcode opcode) { return CheckOpcode1(opcode); } |