mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
patterns: Fixed offset being incorrectly incremented when calling functions
This commit is contained in:
@@ -41,6 +41,9 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
[[nodiscard]] std::unique_ptr<ASTNode> evaluate(Evaluator *evaluator) const override {
|
||||
auto startOffset = evaluator->dataOffset();
|
||||
ON_SCOPE_EXIT { evaluator->dataOffset() = startOffset; };
|
||||
|
||||
std::vector<Token::Literal> evaluatedParams;
|
||||
for (auto ¶m : this->m_params) {
|
||||
const auto expression = param->evaluate(evaluator)->evaluate(evaluator);
|
||||
|
||||
@@ -48,9 +48,11 @@ namespace hex::pl {
|
||||
evaluator->addCustomFunction(this->m_name, paramCount, [this](Evaluator *ctx, const std::vector<Token::Literal> ¶ms) -> std::optional<Token::Literal> {
|
||||
std::vector<std::shared_ptr<Pattern>> variables;
|
||||
|
||||
auto startOffset = ctx->dataOffset();
|
||||
ctx->pushScope(nullptr, variables);
|
||||
ON_SCOPE_EXIT {
|
||||
ctx->popScope();
|
||||
ctx->dataOffset() = startOffset;
|
||||
};
|
||||
|
||||
if (this->m_parameterPack.has_value()) {
|
||||
|
||||
Reference in New Issue
Block a user