1
0
mirror of synced 2024-11-24 15:50:16 +01:00

pattern: Fixed control flow statements not being applied correctly

This commit is contained in:
WerWolv 2022-02-11 21:02:18 +01:00
parent 57f31123e7
commit 585058b500
2 changed files with 11 additions and 9 deletions

View File

@ -2281,17 +2281,16 @@ namespace hex::pl {
FunctionResult execute(Evaluator *evaluator) const override {
auto returnValue = this->getReturnValue();
evaluator->setCurrentControlFlowStatement(this->m_type);
if (returnValue == nullptr)
return std::nullopt;
else {
auto literal = dynamic_cast<ASTNodeLiteral *>(returnValue->evaluate(evaluator));
ON_SCOPE_EXIT { delete literal; };
evaluator->setCurrentControlFlowStatement(this->m_type);
if (literal == nullptr)
return std::nullopt;
else
return literal->getValue();
}
}
private:
ControlFlowStatement m_type;

View File

@ -50,12 +50,15 @@ namespace hex::pl {
[[nodiscard]] bool hasDangerousFunctionBeenCalled() const;
void allowDangerousFunctions(bool allow);
[[nodiscard]] std::vector<PatternData *> &getPatterns() {
return this->m_patterns;
[[nodiscard]] const std::vector<PatternData *> &getPatterns() {
const static std::vector<PatternData *> empty;
if (isRunning()) return empty;
else return this->m_patterns;
}
void reset();
bool isRunning() const { return this->m_running; }
[[nodiscard]] bool isRunning() const { return this->m_running; }
private:
Preprocessor *m_preprocessor;