pattern: Fixed control flow statements not being applied correctly
This commit is contained in:
parent
57f31123e7
commit
585058b500
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user