From e204ef629ff890a1d24d53bc6bd205b4ce237085 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 10 Jan 2022 20:02:18 +0100 Subject: [PATCH] patterns: Fixed passing structs to functions as argument Fixes #385 --- .../include/hex/pattern_language/ast_node.hpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/libimhex/include/hex/pattern_language/ast_node.hpp b/plugins/libimhex/include/hex/pattern_language/ast_node.hpp index cb3cf2d7c..67b273941 100644 --- a/plugins/libimhex/include/hex/pattern_language/ast_node.hpp +++ b/plugins/libimhex/include/hex/pattern_language/ast_node.hpp @@ -1717,15 +1717,21 @@ namespace hex::pl { currPattern = newPattern; } - if (auto structPattern = dynamic_cast(currPattern)) + PatternData *indexPattern; + if (currPattern->isLocal()) + indexPattern = std::get(evaluator->getStack()[currPattern->getOffset()]); + else + indexPattern = currPattern; + + if (auto structPattern = dynamic_cast(indexPattern)) searchScope = structPattern->getMembers(); - else if (auto unionPattern = dynamic_cast(currPattern)) + else if (auto unionPattern = dynamic_cast(indexPattern)) searchScope = unionPattern->getMembers(); - else if (auto bitfieldPattern = dynamic_cast(currPattern)) + else if (auto bitfieldPattern = dynamic_cast(indexPattern)) searchScope = bitfieldPattern->getFields(); - else if (auto dynamicArrayPattern = dynamic_cast(currPattern)) + else if (auto dynamicArrayPattern = dynamic_cast(indexPattern)) searchScope = dynamicArrayPattern->getEntries(); - else if (auto staticArrayPattern = dynamic_cast(currPattern)) + else if (auto staticArrayPattern = dynamic_cast(indexPattern)) searchScope = { staticArrayPattern->getTemplate() }; }