mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
Add non static evaluation for simple expressions
This commit is contained in:
parent
403d7f2c44
commit
886bcfeaf8
@ -110,7 +110,7 @@ namespace IW4
|
|||||||
if (!dvarNameExpression->IsStatic())
|
if (!dvarNameExpression->IsStatic())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto staticDvarNameExpressionValue = dvarNameExpression->Evaluate();
|
const auto staticDvarNameExpressionValue = dvarNameExpression->EvaluateStatic();
|
||||||
if (staticDvarNameExpressionValue.m_type != SimpleExpressionValue::Type::STRING)
|
if (staticDvarNameExpressionValue.m_type != SimpleExpressionValue::Type::STRING)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ namespace IW4
|
|||||||
{
|
{
|
||||||
if (!m_disable_optimizations && expression->IsStatic())
|
if (!m_disable_optimizations && expression->IsStatic())
|
||||||
{
|
{
|
||||||
const auto expressionStaticValue = expression->Evaluate();
|
const auto expressionStaticValue = expression->EvaluateStatic();
|
||||||
ConvertExpressionEntryExpressionValue(entries, &expressionStaticValue);
|
ConvertExpressionEntryExpressionValue(entries, &expressionStaticValue);
|
||||||
}
|
}
|
||||||
else if (const auto* expressionValue = dynamic_cast<const SimpleExpressionValue*>(expression))
|
else if (const auto* expressionValue = dynamic_cast<const SimpleExpressionValue*>(expression))
|
||||||
@ -419,7 +419,7 @@ namespace IW4
|
|||||||
|
|
||||||
if (expression->IsStatic())
|
if (expression->IsStatic())
|
||||||
{
|
{
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
switch (value.m_type)
|
switch (value.m_type)
|
||||||
{
|
{
|
||||||
case SimpleExpressionValue::Type::DOUBLE:
|
case SimpleExpressionValue::Type::DOUBLE:
|
||||||
@ -447,7 +447,7 @@ namespace IW4
|
|||||||
|
|
||||||
if (expression->IsStatic())
|
if (expression->IsStatic())
|
||||||
{
|
{
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
switch (value.m_type)
|
switch (value.m_type)
|
||||||
{
|
{
|
||||||
case SimpleExpressionValue::Type::STRING:
|
case SimpleExpressionValue::Type::STRING:
|
||||||
@ -474,7 +474,7 @@ namespace IW4
|
|||||||
|
|
||||||
if (expression->IsStatic())
|
if (expression->IsStatic())
|
||||||
{
|
{
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
switch (value.m_type)
|
switch (value.m_type)
|
||||||
{
|
{
|
||||||
case SimpleExpressionValue::Type::STRING:
|
case SimpleExpressionValue::Type::STRING:
|
||||||
@ -507,7 +507,7 @@ namespace IW4
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
isStatic = expression->IsStatic();
|
isStatic = expression->IsStatic();
|
||||||
isTruthy = isStatic && expression->Evaluate().IsTruthy();
|
isTruthy = isStatic && expression->EvaluateStatic().IsTruthy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isStatic)
|
if (isStatic)
|
||||||
@ -580,7 +580,7 @@ namespace IW4
|
|||||||
|
|
||||||
if(!m_disable_optimizations && condition->m_condition->IsStatic())
|
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)
|
if(staticValueIsTruthy)
|
||||||
ConvertEventHandlerElements(elements, condition->m_condition_elements.get(), menu, item);
|
ConvertEventHandlerElements(elements, condition->m_condition_elements.get(), menu, item);
|
||||||
@ -725,7 +725,7 @@ namespace IW4
|
|||||||
|
|
||||||
if (expressionIsStatic)
|
if (expressionIsStatic)
|
||||||
{
|
{
|
||||||
const auto evaluatedValue = expression->Evaluate();
|
const auto evaluatedValue = expression->EvaluateStatic();
|
||||||
|
|
||||||
if (evaluatedValue.m_type == SimpleExpressionValue::Type::INT)
|
if (evaluatedValue.m_type == SimpleExpressionValue::Type::INT)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,12 @@ bool CommonExpressionBaseFunctionCall::IsStatic() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleExpressionValue CommonExpressionBaseFunctionCall::Evaluate() const
|
SimpleExpressionValue CommonExpressionBaseFunctionCall::EvaluateStatic() const
|
||||||
|
{
|
||||||
|
return SimpleExpressionValue(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleExpressionValue CommonExpressionBaseFunctionCall::EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const
|
||||||
{
|
{
|
||||||
return SimpleExpressionValue(0);
|
return SimpleExpressionValue(0);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ namespace menu
|
|||||||
|
|
||||||
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
||||||
_NODISCARD bool IsStatic() 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleExpressionValue CommonExpressionCustomFunctionCall::Evaluate() const
|
SimpleExpressionValue CommonExpressionCustomFunctionCall::EvaluateStatic() const
|
||||||
|
{
|
||||||
|
return SimpleExpressionValue(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleExpressionValue CommonExpressionCustomFunctionCall::EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const
|
||||||
{
|
{
|
||||||
return SimpleExpressionValue(0);
|
return SimpleExpressionValue(0);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace menu
|
|||||||
|
|
||||||
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
||||||
_NODISCARD bool IsStatic() 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())
|
if (!expression || !expression->IsStatic())
|
||||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), "Not a valid static expression");
|
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)
|
if (value.m_type != SimpleExpressionValue::Type::INT)
|
||||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), "Expression MUST be int type");
|
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())
|
if (!expression || !expression->IsStatic())
|
||||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), "Not a valid static expression");
|
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)
|
if (value.m_type == SimpleExpressionValue::Type::INT)
|
||||||
return value.m_int_value;
|
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)
|
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 << "\" \"";
|
state->m_current_script << "\"" << ScriptKeywordForType(type) << "\" \"" << varName << "\" \"";
|
||||||
const auto staticValue = expression->Evaluate();
|
const auto staticValue = expression->EvaluateStatic();
|
||||||
CheckStaticValueType(pos, type, staticValue);
|
CheckStaticValueType(pos, type, staticValue);
|
||||||
EmitStaticValue(state, staticValue);
|
EmitStaticValue(state, staticValue);
|
||||||
state->m_current_script << "\" ; ";
|
state->m_current_script << "\" ; ";
|
||||||
|
@ -327,7 +327,7 @@ bool DefinesStreamProxy::MatchIfDirective(const ParserLine& line, const unsigned
|
|||||||
if (!expression)
|
if (!expression)
|
||||||
throw ParsingException(CreatePos(line, currentPos), "Failed to parse if expression");
|
throw ParsingException(CreatePos(line, currentPos), "Failed to parse if expression");
|
||||||
|
|
||||||
m_modes.push(expression->Evaluate().IsTruthy() ? BlockMode::IN_BLOCK : BlockMode::NOT_IN_BLOCK);
|
m_modes.push(expression->EvaluateStatic().IsTruthy() ? BlockMode::IN_BLOCK : BlockMode::NOT_IN_BLOCK);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -369,7 +369,7 @@ bool DefinesStreamProxy::MatchElIfDirective(const ParserLine& line, const unsign
|
|||||||
if (!expression)
|
if (!expression)
|
||||||
throw ParsingException(CreatePos(line, currentPos), "Failed to parse elif expression");
|
throw ParsingException(CreatePos(line, currentPos), "Failed to parse elif expression");
|
||||||
|
|
||||||
m_modes.top() = expression->Evaluate().IsTruthy() ? BlockMode::IN_BLOCK : BlockMode::NOT_IN_BLOCK;
|
m_modes.top() = expression->EvaluateStatic().IsTruthy() ? BlockMode::IN_BLOCK : BlockMode::NOT_IN_BLOCK;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,24 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "Utils/ClassUtils.h"
|
#include "Utils/ClassUtils.h"
|
||||||
|
|
||||||
class SimpleExpressionValue;
|
class SimpleExpressionValue;
|
||||||
|
class ISimpleExpressionScopeValues
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
ISimpleExpressionScopeValues() = default;
|
||||||
|
public:
|
||||||
|
virtual ~ISimpleExpressionScopeValues() = default;
|
||||||
|
ISimpleExpressionScopeValues(const ISimpleExpressionScopeValues& other) = default;
|
||||||
|
ISimpleExpressionScopeValues(ISimpleExpressionScopeValues&& other) noexcept = default;
|
||||||
|
ISimpleExpressionScopeValues& operator=(const ISimpleExpressionScopeValues& other) = default;
|
||||||
|
ISimpleExpressionScopeValues& operator=(ISimpleExpressionScopeValues&& other) noexcept = default;
|
||||||
|
|
||||||
|
_NODISCARD virtual SimpleExpressionValue ValueByName(const std::string& name) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class ISimpleExpression
|
class ISimpleExpression
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@ -16,7 +32,8 @@ public:
|
|||||||
|
|
||||||
_NODISCARD virtual bool Equals(const ISimpleExpression* other) const = 0;
|
_NODISCARD virtual bool Equals(const ISimpleExpression* other) const = 0;
|
||||||
_NODISCARD virtual bool IsStatic() const = 0;
|
_NODISCARD virtual bool IsStatic() const = 0;
|
||||||
_NODISCARD virtual SimpleExpressionValue Evaluate() const = 0;
|
_NODISCARD virtual SimpleExpressionValue EvaluateStatic() const = 0;
|
||||||
|
_NODISCARD virtual SimpleExpressionValue EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Include SimpleExpressionValue after definition to avoid "base class not defined"
|
// Include SimpleExpressionValue after definition to avoid "base class not defined"
|
||||||
|
@ -460,7 +460,12 @@ bool SimpleExpressionBinaryOperation::IsStatic() const
|
|||||||
return m_operand1->IsStatic() && m_operand2->IsStatic();
|
return m_operand1->IsStatic() && m_operand2->IsStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleExpressionValue SimpleExpressionBinaryOperation::Evaluate() const
|
SimpleExpressionValue SimpleExpressionBinaryOperation::EvaluateStatic() const
|
||||||
{
|
{
|
||||||
return m_operation_type->m_evaluation_function(m_operand1->Evaluate(), m_operand2->Evaluate());
|
return m_operation_type->m_evaluation_function(m_operand1->EvaluateStatic(), m_operand2->EvaluateStatic());
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleExpressionValue SimpleExpressionBinaryOperation::EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const
|
||||||
|
{
|
||||||
|
return m_operation_type->m_evaluation_function(m_operand1->EvaluateNonStatic(scopeValues), m_operand2->EvaluateNonStatic(scopeValues));
|
||||||
}
|
}
|
||||||
|
@ -95,5 +95,6 @@ public:
|
|||||||
|
|
||||||
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
||||||
_NODISCARD bool IsStatic() const override;
|
_NODISCARD bool IsStatic() const override;
|
||||||
_NODISCARD SimpleExpressionValue Evaluate() const override;
|
_NODISCARD SimpleExpressionValue EvaluateStatic() const override;
|
||||||
|
_NODISCARD SimpleExpressionValue EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const override;
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,14 @@ bool SimpleExpressionConditionalOperator::IsStatic() const
|
|||||||
return m_condition->IsStatic() && m_true_value->IsStatic() && m_false_value->IsStatic();
|
return m_condition->IsStatic() && m_true_value->IsStatic() && m_false_value->IsStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleExpressionValue SimpleExpressionConditionalOperator::Evaluate() const
|
SimpleExpressionValue SimpleExpressionConditionalOperator::EvaluateStatic() const
|
||||||
{
|
{
|
||||||
return m_condition->Evaluate().IsTruthy() ? m_true_value->Evaluate() : m_false_value->Evaluate();
|
return m_condition->EvaluateStatic().IsTruthy() ? m_true_value->EvaluateStatic() : m_false_value->EvaluateStatic();
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleExpressionValue SimpleExpressionConditionalOperator::EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const
|
||||||
|
{
|
||||||
|
return m_condition->EvaluateNonStatic(scopeValues).IsTruthy()
|
||||||
|
? m_true_value->EvaluateNonStatic(scopeValues)
|
||||||
|
: m_false_value->EvaluateNonStatic(scopeValues);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ public:
|
|||||||
|
|
||||||
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
||||||
_NODISCARD bool IsStatic() const override;
|
_NODISCARD bool IsStatic() const override;
|
||||||
_NODISCARD SimpleExpressionValue Evaluate() const override;
|
_NODISCARD SimpleExpressionValue EvaluateStatic() const override;
|
||||||
|
_NODISCARD SimpleExpressionValue EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const override;
|
||||||
|
|
||||||
SimpleExpressionConditionalOperator();
|
SimpleExpressionConditionalOperator();
|
||||||
SimpleExpressionConditionalOperator(std::unique_ptr<ISimpleExpression> condition, std::unique_ptr<ISimpleExpression> trueExpression, std::unique_ptr<ISimpleExpression> falseExpression);
|
SimpleExpressionConditionalOperator(std::unique_ptr<ISimpleExpression> condition, std::unique_ptr<ISimpleExpression> trueExpression, std::unique_ptr<ISimpleExpression> falseExpression);
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
#include "SimpleExpressionScopeValue.h"
|
||||||
|
|
||||||
|
SimpleExpressionScopeValue::SimpleExpressionScopeValue(std::string valueName)
|
||||||
|
: m_value_name(std::move(valueName))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SimpleExpressionScopeValue::Equals(const ISimpleExpression* other) const
|
||||||
|
{
|
||||||
|
const auto* otherScopeValue = dynamic_cast<const SimpleExpressionScopeValue*>(other);
|
||||||
|
|
||||||
|
return otherScopeValue && otherScopeValue->m_value_name == m_value_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SimpleExpressionScopeValue::IsStatic() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleExpressionValue SimpleExpressionScopeValue::EvaluateStatic() const
|
||||||
|
{
|
||||||
|
return SimpleExpressionValue(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleExpressionValue SimpleExpressionScopeValue::EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const
|
||||||
|
{
|
||||||
|
return scopeValues->ValueByName(m_value_name);
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "ISimpleExpression.h"
|
||||||
|
#include "SimpleExpressionValue.h"
|
||||||
|
|
||||||
|
class SimpleExpressionScopeValue final : public ISimpleExpression
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string m_value_name;
|
||||||
|
|
||||||
|
explicit SimpleExpressionScopeValue(std::string valueName);
|
||||||
|
|
||||||
|
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
||||||
|
_NODISCARD bool IsStatic() const override;
|
||||||
|
_NODISCARD SimpleExpressionValue EvaluateStatic() const override;
|
||||||
|
_NODISCARD SimpleExpressionValue EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const override;
|
||||||
|
};
|
@ -78,7 +78,12 @@ bool SimpleExpressionUnaryOperation::IsStatic() const
|
|||||||
return m_operand->IsStatic();
|
return m_operand->IsStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleExpressionValue SimpleExpressionUnaryOperation::Evaluate() const
|
SimpleExpressionValue SimpleExpressionUnaryOperation::EvaluateStatic() const
|
||||||
{
|
{
|
||||||
return m_operation_type->m_evaluation_function(m_operand->Evaluate());
|
return m_operation_type->m_evaluation_function(m_operand->EvaluateStatic());
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleExpressionValue SimpleExpressionUnaryOperation::EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const
|
||||||
|
{
|
||||||
|
return m_operation_type->m_evaluation_function(m_operand->EvaluateNonStatic(scopeValues));
|
||||||
}
|
}
|
||||||
|
@ -48,5 +48,6 @@ public:
|
|||||||
|
|
||||||
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
||||||
_NODISCARD bool IsStatic() const override;
|
_NODISCARD bool IsStatic() const override;
|
||||||
_NODISCARD SimpleExpressionValue Evaluate() const override;
|
_NODISCARD SimpleExpressionValue EvaluateStatic() const override;
|
||||||
|
_NODISCARD SimpleExpressionValue EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const override;
|
||||||
};
|
};
|
||||||
|
@ -46,7 +46,12 @@ bool SimpleExpressionValue::IsStatic() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleExpressionValue SimpleExpressionValue::Evaluate() const
|
SimpleExpressionValue SimpleExpressionValue::EvaluateStatic() const
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleExpressionValue SimpleExpressionValue::EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
|
|
||||||
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
_NODISCARD bool Equals(const ISimpleExpression* other) const override;
|
||||||
_NODISCARD bool IsStatic() const override;
|
_NODISCARD bool IsStatic() const override;
|
||||||
_NODISCARD SimpleExpressionValue Evaluate() const override;
|
_NODISCARD SimpleExpressionValue EvaluateStatic() const override;
|
||||||
|
_NODISCARD SimpleExpressionValue EvaluateNonStatic(ISimpleExpressionScopeValues* scopeValues) const override;
|
||||||
_NODISCARD bool IsTruthy() const;
|
_NODISCARD bool IsTruthy() const;
|
||||||
};
|
};
|
||||||
|
@ -1047,7 +1047,7 @@ namespace test::parsing::menu::sequence::event_handler_set
|
|||||||
|
|
||||||
REQUIRE(conditionElement->m_condition != nullptr);
|
REQUIRE(conditionElement->m_condition != nullptr);
|
||||||
REQUIRE(conditionElement->m_condition->IsStatic());
|
REQUIRE(conditionElement->m_condition->IsStatic());
|
||||||
const auto staticValue = conditionElement->m_condition->Evaluate();
|
const auto staticValue = conditionElement->m_condition->EvaluateStatic();
|
||||||
REQUIRE(staticValue.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(staticValue.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(staticValue.m_int_value == 1337);
|
REQUIRE(staticValue.m_int_value == 1337);
|
||||||
|
|
||||||
@ -1140,7 +1140,7 @@ namespace test::parsing::menu::sequence::event_handler_set
|
|||||||
|
|
||||||
REQUIRE(conditionElement->m_condition != nullptr);
|
REQUIRE(conditionElement->m_condition != nullptr);
|
||||||
REQUIRE(conditionElement->m_condition->IsStatic());
|
REQUIRE(conditionElement->m_condition->IsStatic());
|
||||||
const auto staticValue = conditionElement->m_condition->Evaluate();
|
const auto staticValue = conditionElement->m_condition->EvaluateStatic();
|
||||||
REQUIRE(staticValue.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(staticValue.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(staticValue.m_int_value == 1337);
|
REQUIRE(staticValue.m_int_value == 1337);
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1337);
|
REQUIRE(value.m_int_value == 1337);
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 420);
|
REQUIRE(value.m_int_value == 420);
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 420);
|
REQUIRE(value.m_int_value == 420);
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1337);
|
REQUIRE(value.m_int_value == 1337);
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 420);
|
REQUIRE(value.m_int_value == 420);
|
||||||
}
|
}
|
||||||
@ -276,7 +276,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 0x2AAAAAA0);
|
REQUIRE(value.m_int_value == 0x2AAAAAA0);
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 7);
|
REQUIRE(value.m_int_value == 7);
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 420);
|
REQUIRE(value.m_int_value == 420);
|
||||||
}
|
}
|
||||||
@ -348,7 +348,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1337);
|
REQUIRE(value.m_int_value == 1337);
|
||||||
}
|
}
|
||||||
@ -372,7 +372,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1);
|
REQUIRE(value.m_int_value == 1);
|
||||||
}
|
}
|
||||||
@ -396,7 +396,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1);
|
REQUIRE(value.m_int_value == 1);
|
||||||
}
|
}
|
||||||
@ -420,7 +420,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1);
|
REQUIRE(value.m_int_value == 1);
|
||||||
}
|
}
|
||||||
@ -444,7 +444,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1);
|
REQUIRE(value.m_int_value == 1);
|
||||||
}
|
}
|
||||||
@ -468,7 +468,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1);
|
REQUIRE(value.m_int_value == 1);
|
||||||
}
|
}
|
||||||
@ -492,7 +492,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 0);
|
REQUIRE(value.m_int_value == 0);
|
||||||
}
|
}
|
||||||
@ -516,7 +516,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 420);
|
REQUIRE(value.m_int_value == 420);
|
||||||
}
|
}
|
||||||
@ -540,7 +540,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1337);
|
REQUIRE(value.m_int_value == 1337);
|
||||||
}
|
}
|
||||||
@ -568,7 +568,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 420);
|
REQUIRE(value.m_int_value == 420);
|
||||||
}
|
}
|
||||||
@ -596,7 +596,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 420);
|
REQUIRE(value.m_int_value == 420);
|
||||||
}
|
}
|
||||||
@ -622,7 +622,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 420);
|
REQUIRE(value.m_int_value == 420);
|
||||||
}
|
}
|
||||||
@ -648,7 +648,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1337);
|
REQUIRE(value.m_int_value == 1337);
|
||||||
}
|
}
|
||||||
@ -678,7 +678,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 421);
|
REQUIRE(value.m_int_value == 421);
|
||||||
}
|
}
|
||||||
@ -708,7 +708,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1338);
|
REQUIRE(value.m_int_value == 1338);
|
||||||
}
|
}
|
||||||
@ -738,7 +738,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 420);
|
REQUIRE(value.m_int_value == 420);
|
||||||
}
|
}
|
||||||
@ -768,7 +768,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 420);
|
REQUIRE(value.m_int_value == 420);
|
||||||
}
|
}
|
||||||
@ -798,7 +798,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1337);
|
REQUIRE(value.m_int_value == 1337);
|
||||||
}
|
}
|
||||||
@ -817,7 +817,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 1);
|
REQUIRE(value.m_int_value == 1);
|
||||||
}
|
}
|
||||||
@ -834,7 +834,7 @@ namespace test::parsing::simple::expression
|
|||||||
const auto& expression = helper.m_state->m_expression;
|
const auto& expression = helper.m_state->m_expression;
|
||||||
REQUIRE(expression->IsStatic());
|
REQUIRE(expression->IsStatic());
|
||||||
|
|
||||||
const auto value = expression->Evaluate();
|
const auto value = expression->EvaluateStatic();
|
||||||
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
|
||||||
REQUIRE(value.m_int_value == 11);
|
REQUIRE(value.m_int_value == 11);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user