mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-12 15:58:28 -05:00
Add non static evaluation for simple expressions
This commit is contained in:
@ -37,7 +37,12 @@ bool CommonExpressionBaseFunctionCall::IsStatic() const
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleExpressionValue CommonExpressionBaseFunctionCall::Evaluate() const
|
||||
SimpleExpressionValue CommonExpressionBaseFunctionCall::EvaluateStatic() const
|
||||
{
|
||||
return SimpleExpressionValue(0);
|
||||
}
|
||||
|
||||
SimpleExpressionValue CommonExpressionBaseFunctionCall::EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const
|
||||
{
|
||||
return SimpleExpressionValue(0);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ namespace menu
|
||||
|
||||
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
||||
_NODISCARD bool IsStatic() const override;
|
||||
_NODISCARD SimpleExpressionValue Evaluate() const override;
|
||||
_NODISCARD SimpleExpressionValue EvaluateStatic() const override;
|
||||
_NODISCARD SimpleExpressionValue EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const override;
|
||||
};
|
||||
}
|
||||
|
@ -18,7 +18,12 @@ bool CommonExpressionCustomFunctionCall::IsStatic() const
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleExpressionValue CommonExpressionCustomFunctionCall::Evaluate() const
|
||||
SimpleExpressionValue CommonExpressionCustomFunctionCall::EvaluateStatic() const
|
||||
{
|
||||
return SimpleExpressionValue(0);
|
||||
}
|
||||
|
||||
SimpleExpressionValue CommonExpressionCustomFunctionCall::EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const
|
||||
{
|
||||
return SimpleExpressionValue(0);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace menu
|
||||
|
||||
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
||||
_NODISCARD bool IsStatic() const override;
|
||||
_NODISCARD SimpleExpressionValue Evaluate() const override;
|
||||
_NODISCARD SimpleExpressionValue EvaluateStatic() const override;
|
||||
_NODISCARD SimpleExpressionValue EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const override;
|
||||
};
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ int MenuMatcherFactory::TokenIntExpressionValue(MenuFileParserState* state, Sequ
|
||||
if (!expression || !expression->IsStatic())
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), "Not a valid static expression");
|
||||
|
||||
const auto value = expression->Evaluate();
|
||||
const auto value = expression->EvaluateStatic();
|
||||
|
||||
if (value.m_type != SimpleExpressionValue::Type::INT)
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), "Expression MUST be int type");
|
||||
@ -150,7 +150,7 @@ double MenuMatcherFactory::TokenNumericExpressionValue(MenuFileParserState* stat
|
||||
if (!expression || !expression->IsStatic())
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), "Not a valid static expression");
|
||||
|
||||
const auto value = expression->Evaluate();
|
||||
const auto value = expression->EvaluateStatic();
|
||||
|
||||
if (value.m_type == SimpleExpressionValue::Type::INT)
|
||||
return value.m_int_value;
|
||||
|
@ -573,7 +573,7 @@ namespace menu::event_handler_set_scope_sequences
|
||||
static void EmitStaticSetLocalVar(MenuFileParserState* state, const TokenPos& pos, const SetLocalVarType type, const std::string& varName, std::unique_ptr<ISimpleExpression> expression)
|
||||
{
|
||||
state->m_current_script << "\"" << ScriptKeywordForType(type) << "\" \"" << varName << "\" \"";
|
||||
const auto staticValue = expression->Evaluate();
|
||||
const auto staticValue = expression->EvaluateStatic();
|
||||
CheckStaticValueType(pos, type, staticValue);
|
||||
EmitStaticValue(state, staticValue);
|
||||
state->m_current_script << "\" ; ";
|
||||
|
Reference in New Issue
Block a user