summaryrefslogtreecommitdiff
path: root/src/Companion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Companion.cpp')
-rw-r--r--src/Companion.cpp18
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) {