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/binary-reader-objdump.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/binary-reader-objdump.cc')
-rw-r--r-- | src/binary-reader-objdump.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index 52e6d27a..80850541 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -548,6 +548,8 @@ class BinaryReaderObjdumpDisassemble : public BinaryReaderObjdumpBase { Result OnOpcodeBlockSig(Type sig_type) override; Result OnOpcodeType(Type type) override; + Result OnTryTableExpr(Type sig_type, + const CatchClauseVector& catches) override; Result OnBrTableExpr(Index num_targets, Index* target_depths, Index default_target_depth) override; @@ -903,6 +905,50 @@ Result BinaryReaderObjdumpDisassemble::OnOpcodeType(Type type) { return Result::Ok; } +Result BinaryReaderObjdumpDisassemble::OnTryTableExpr( + Type sig_type, + const CatchClauseVector& catches) { + if (!in_function_body) { + return Result::Ok; + } + + std::string buffer = std::string(); + + if (sig_type != Type::Void) { + buffer.append(BlockSigToString(sig_type).c_str()).append(" "); + } + + for (auto& catch_ : catches) { + switch (catch_.kind) { + case CatchKind::Catch: + buffer.append("catch "); + break; + case CatchKind::CatchRef: + buffer.append("catch_ref "); + break; + case CatchKind::CatchAll: + buffer.append("catch_all "); + break; + case CatchKind::CatchAllRef: + buffer.append("catch_all_ref "); + break; + } + if (catch_.kind == CatchKind::Catch || catch_.kind == CatchKind::CatchRef) { + buffer.append(std::to_string(catch_.tag)); + } + buffer.append(" ").append(std::to_string(catch_.depth)).append(" "); + } + + if (!buffer.empty()) { + // remove trailing space + buffer.pop_back(); + } + + LogOpcode("%s", buffer.c_str()); + indent_level++; + return Result::Ok; +} + Result BinaryReaderObjdumpDisassemble::OnBrTableExpr( Index num_targets, Index* target_depths, |