mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
Implemented GetSafeNodeByAddr
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user