mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
Add menu unary expression for minus
This commit is contained in:
parent
ebb8eb9e5b
commit
9a2e74d083
@ -31,10 +31,24 @@ const CommonExpressionUnaryOperationType CommonExpressionUnaryOperationType::OPE
|
||||
}
|
||||
);
|
||||
|
||||
const CommonExpressionUnaryOperationType CommonExpressionUnaryOperationType::OPERATION_NEGATIVE(
|
||||
"-",
|
||||
[](const CommonExpressionValue& operand) -> CommonExpressionValue
|
||||
{
|
||||
if(operand.m_type == CommonExpressionValue::Type::INT)
|
||||
return CommonExpressionValue(-operand.m_int_value);
|
||||
if (operand.m_type == CommonExpressionValue::Type::DOUBLE)
|
||||
return CommonExpressionValue(-operand.m_double_value);
|
||||
|
||||
return CommonExpressionValue(0);
|
||||
}
|
||||
);
|
||||
|
||||
const CommonExpressionUnaryOperationType* const CommonExpressionUnaryOperationType::ALL_OPERATION_TYPES[static_cast<int>(UnaryOperationId::COUNT)]
|
||||
{
|
||||
&OPERATION_NOT,
|
||||
&OPERATION_BITWISE_NOT,
|
||||
&OPERATION_NEGATIVE,
|
||||
};
|
||||
|
||||
CommonExpressionUnaryOperation::CommonExpressionUnaryOperation(const CommonExpressionUnaryOperationType* operationType, std::unique_ptr<ICommonExpression> operand)
|
||||
|
@ -13,6 +13,7 @@ namespace menu
|
||||
{
|
||||
NOT,
|
||||
BITWISE_NOT,
|
||||
NEGATIVE,
|
||||
|
||||
COUNT
|
||||
};
|
||||
@ -31,6 +32,7 @@ namespace menu
|
||||
public:
|
||||
static const CommonExpressionUnaryOperationType OPERATION_NOT;
|
||||
static const CommonExpressionUnaryOperationType OPERATION_BITWISE_NOT;
|
||||
static const CommonExpressionUnaryOperationType OPERATION_NEGATIVE;
|
||||
|
||||
static const CommonExpressionUnaryOperationType* const ALL_OPERATION_TYPES[static_cast<int>(UnaryOperationId::COUNT)];
|
||||
};
|
||||
|
@ -276,6 +276,10 @@ std::unique_ptr<MenuCommonMatchers::matcher_t> MenuCommonMatchers::ParseUnaryOpe
|
||||
{
|
||||
return SimpleParserValue::Integer(values[0].get().GetPos(), static_cast<int>(UnaryOperationId::BITWISE_NOT));
|
||||
}),
|
||||
create.Char('-').Transform([](const MenuMatcherFactory::token_list_t& values)
|
||||
{
|
||||
return SimpleParserValue::Integer(values[0].get().GetPos(), static_cast<int>(UnaryOperationId::NEGATIVE));
|
||||
}),
|
||||
}).Tag(TAG_EXPRESSION_UNARY_OPERATION).Capture(CAPTURE_UNARY_OPERATION_TYPE);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user