Implemented GetSafeNodeByAddr

This commit is contained in:
KiritoDv
2025-01-30 10:35:05 -06:00
committed by Lywx
parent f3d6841fcb
commit 7b83e15d80
3 changed files with 29 additions and 10 deletions
+18
View File
@@ -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) {