mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 23:08:05 -05:00
Add non static evaluation for simple expressions
This commit is contained in:
@ -110,7 +110,7 @@ namespace IW4
|
||||
if (!dvarNameExpression->IsStatic())
|
||||
return false;
|
||||
|
||||
const auto staticDvarNameExpressionValue = dvarNameExpression->Evaluate();
|
||||
const auto staticDvarNameExpressionValue = dvarNameExpression->EvaluateStatic();
|
||||
if (staticDvarNameExpressionValue.m_type != SimpleExpressionValue::Type::STRING)
|
||||
return false;
|
||||
|
||||
@ -353,7 +353,7 @@ namespace IW4
|
||||
{
|
||||
if (!m_disable_optimizations && expression->IsStatic())
|
||||
{
|
||||
const auto expressionStaticValue = expression->Evaluate();
|
||||
const auto expressionStaticValue = expression->EvaluateStatic();
|
||||
ConvertExpressionEntryExpressionValue(entries, &expressionStaticValue);
|
||||
}
|
||||
else if (const auto* expressionValue = dynamic_cast<const SimpleExpressionValue*>(expression))
|
||||
@ -419,7 +419,7 @@ namespace IW4
|
||||
|
||||
if (expression->IsStatic())
|
||||
{
|
||||
const auto value = expression->Evaluate();
|
||||
const auto value = expression->EvaluateStatic();
|
||||
switch (value.m_type)
|
||||
{
|
||||
case SimpleExpressionValue::Type::DOUBLE:
|
||||
@ -447,7 +447,7 @@ namespace IW4
|
||||
|
||||
if (expression->IsStatic())
|
||||
{
|
||||
const auto value = expression->Evaluate();
|
||||
const auto value = expression->EvaluateStatic();
|
||||
switch (value.m_type)
|
||||
{
|
||||
case SimpleExpressionValue::Type::STRING:
|
||||
@ -474,7 +474,7 @@ namespace IW4
|
||||
|
||||
if (expression->IsStatic())
|
||||
{
|
||||
const auto value = expression->Evaluate();
|
||||
const auto value = expression->EvaluateStatic();
|
||||
switch (value.m_type)
|
||||
{
|
||||
case SimpleExpressionValue::Type::STRING:
|
||||
@ -507,7 +507,7 @@ namespace IW4
|
||||
else
|
||||
{
|
||||
isStatic = expression->IsStatic();
|
||||
isTruthy = isStatic && expression->Evaluate().IsTruthy();
|
||||
isTruthy = isStatic && expression->EvaluateStatic().IsTruthy();
|
||||
}
|
||||
|
||||
if (isStatic)
|
||||
@ -580,7 +580,7 @@ namespace IW4
|
||||
|
||||
if(!m_disable_optimizations && condition->m_condition->IsStatic())
|
||||
{
|
||||
const auto staticValueIsTruthy = condition->m_condition->Evaluate().IsTruthy();
|
||||
const auto staticValueIsTruthy = condition->m_condition->EvaluateStatic().IsTruthy();
|
||||
|
||||
if(staticValueIsTruthy)
|
||||
ConvertEventHandlerElements(elements, condition->m_condition_elements.get(), menu, item);
|
||||
@ -725,7 +725,7 @@ namespace IW4
|
||||
|
||||
if (expressionIsStatic)
|
||||
{
|
||||
const auto evaluatedValue = expression->Evaluate();
|
||||
const auto evaluatedValue = expression->EvaluateStatic();
|
||||
|
||||
if (evaluatedValue.m_type == SimpleExpressionValue::Type::INT)
|
||||
{
|
||||
|
@ -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