diff options
| author | KiritoDv <kiritodev01@gmail.com> | 2025-01-29 22:44:12 -0600 |
|---|---|---|
| committer | Lywx <kiritodev01@gmail.com> | 2025-01-30 10:35:05 -0600 |
| commit | 7b83e15d8068c6fc18b52c90b0cbc425b5abd63f (patch) | |
| tree | 81b7423aba054d097177f5b593863db59f243dc2 /src/Companion.cpp | |
| parent | f3d6841fcb7e233ea8e8d435a23559f0ba82d960 (diff) | |
Implemented GetSafeNodeByAddr
Diffstat (limited to 'src/Companion.cpp')
| -rw-r--r-- | src/Companion.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Companion.cpp b/src/Companion.cpp index 4a7a3fc..8b0def9 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -1398,6 +1398,24 @@ std::optional<std::tuple<std::string, YAML::Node>> Companion::GetNodeByAddr(cons return this->gAddrMap[this->gCurrentFile][addr]; } +std::optional<std::tuple<std::string, YAML::Node>> Companion::GetSafeNodeByAddr(const uint32_t addr, std::string type) { + auto node = this->GetNodeByAddr(addr); + + if(!node.has_value()) { + return std::nullopt; + } + + auto [name, n] = node.value(); + auto n_type = GetSafeNode<std::string>(n, "type"); + + if(n_type != type) { + throw std::runtime_error("Requested node type does not match with the target node type at " + Torch::to_hex(addr, false)); + } + + return node; + +} + std::optional<ParseResultData> Companion::GetParseDataByAddr(uint32_t addr) { if(!this->gParseResults.contains(this->gCurrentFile)){ for (auto &file : this->gCurrentExternalFiles) { |
