mirror of https://github.com/Icinga/icinga2.git
parent
27955843c0
commit
ddc548bb5d
|
@ -24,6 +24,7 @@
|
|||
#include "base/context.h"
|
||||
#include "base/scriptfunction.h"
|
||||
#include "base/scriptvariable.h"
|
||||
#include "base/utility.h"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/exception_ptr.hpp>
|
||||
#include <boost/exception/errinfo_nested_exception.hpp>
|
||||
|
@ -41,7 +42,7 @@ AExpression::AExpression(OpCallback op, const Value& operand1, const Value& oper
|
|||
Value AExpression::Evaluate(const Dictionary::Ptr& locals) const
|
||||
{
|
||||
try {
|
||||
return (this->*m_Operator)(locals);
|
||||
return m_Operator(this, locals);
|
||||
} catch (const std::exception& ex) {
|
||||
if (boost::get_error_info<boost::errinfo_nested_exception>(ex))
|
||||
throw;
|
||||
|
@ -59,20 +60,23 @@ void AExpression::ExtractPath(const std::vector<String>& path, const Array::Ptr&
|
|||
BOOST_FOREACH(const AExpression::Ptr& expr, exprl) {
|
||||
expr->ExtractPath(path, result);
|
||||
}
|
||||
} else if (m_Operator == &AExpression::OpSet && path[0] == m_Operand1) {
|
||||
} else if ((m_Operator == &AExpression::OpSet || m_Operator == &AExpression::OpSetPlus ||
|
||||
m_Operator == &AExpression::OpSetMinus || m_Operator == &AExpression::OpSetMultiply ||
|
||||
m_Operator == &AExpression::OpSetDivide) && path[0] == m_Operand1) {
|
||||
AExpression::Ptr exprl = m_Operand2;
|
||||
|
||||
if (path.size() == 1) {
|
||||
result->Add(m_Operand1);
|
||||
VERIFY(exprl->m_Operator == &AExpression::OpDict);
|
||||
Array::Ptr subexprl = exprl->m_Operand1;
|
||||
BOOST_FOREACH(const AExpression::Ptr& expr, subexprl) {
|
||||
result->Add(expr);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<String> sub_path(path.begin() + 1, path.end());
|
||||
exprl->ExtractPath(sub_path, result);
|
||||
} else if (m_Operator == &AExpression::OpDict && static_cast<bool>(m_Operand2)) {
|
||||
AExpression::Ptr exprl = m_Operand1;
|
||||
exprl->ExtractPath(path, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +89,9 @@ void AExpression::FindDebugInfoPath(const std::vector<String>& path, DebugInfo&
|
|||
BOOST_FOREACH(const AExpression::Ptr& expr, exprl) {
|
||||
expr->FindDebugInfoPath(path, result);
|
||||
}
|
||||
} else if (m_Operator == &AExpression::OpSet && path[0] == m_Operand1) {
|
||||
} else if ((m_Operator == &AExpression::OpSet || m_Operator == &AExpression::OpSetPlus ||
|
||||
m_Operator == &AExpression::OpSetMinus || m_Operator == &AExpression::OpSetMultiply ||
|
||||
m_Operator == &AExpression::OpSetDivide) && path[0] == m_Operand1) {
|
||||
AExpression::Ptr exprl = m_Operand2;
|
||||
|
||||
if (path.size() == 1) {
|
||||
|
@ -94,9 +100,6 @@ void AExpression::FindDebugInfoPath(const std::vector<String>& path, DebugInfo&
|
|||
std::vector<String> sub_path(path.begin() + 1, path.end());
|
||||
exprl->FindDebugInfoPath(sub_path, result);
|
||||
}
|
||||
} else if (m_Operator == &AExpression::OpDict && static_cast<bool>(m_Operand2)) {
|
||||
AExpression::Ptr exprl = m_Operand1;
|
||||
exprl->FindDebugInfoPath(path, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,6 +109,32 @@ void AExpression::MakeInline(void)
|
|||
m_Operand2 = true;
|
||||
}
|
||||
|
||||
void AExpression::DumpOperand(std::ostream& stream, const Value& operand, int indent) {
|
||||
if (operand.IsObjectType<Array>()) {
|
||||
Array::Ptr arr = operand;
|
||||
stream << String(indent, ' ') << "Array:\n";
|
||||
BOOST_FOREACH(const Value& elem, arr) {
|
||||
DumpOperand(stream, elem, indent + 1);
|
||||
}
|
||||
} else if (operand.IsObjectType<AExpression>()) {
|
||||
AExpression::Ptr left = operand;
|
||||
left->Dump(stream, indent);
|
||||
} else {
|
||||
stream << String(indent, ' ') << JsonSerialize(operand) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void AExpression::Dump(std::ostream& stream, int indent)
|
||||
{
|
||||
String sym = Utility::GetSymbolName(reinterpret_cast<const void *>(m_Operator));
|
||||
stream << String(indent, ' ') << "op: " << Utility::DemangleSymbolName(sym) << "\n";
|
||||
stream << String(indent, ' ') << "left:\n";
|
||||
DumpOperand(stream, m_Operand1, indent + 1);
|
||||
|
||||
stream << String(indent, ' ') << "right:\n";
|
||||
DumpOperand(stream, m_Operand2, indent + 1);
|
||||
}
|
||||
|
||||
Value AExpression::EvaluateOperand1(const Dictionary::Ptr& locals) const
|
||||
{
|
||||
return static_cast<AExpression::Ptr>(m_Operand1)->Evaluate(locals);
|
||||
|
@ -116,102 +145,102 @@ Value AExpression::EvaluateOperand2(const Dictionary::Ptr& locals) const
|
|||
return static_cast<AExpression::Ptr>(m_Operand2)->Evaluate(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpLiteral(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpLiteral(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return m_Operand1;
|
||||
return expr->m_Operand1;
|
||||
}
|
||||
|
||||
Value AExpression::OpVariable(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpVariable(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
if (locals && locals->Contains(m_Operand1))
|
||||
return locals->Get(m_Operand1);
|
||||
if (locals && locals->Contains(expr->m_Operand1))
|
||||
return locals->Get(expr->m_Operand1);
|
||||
else
|
||||
return ScriptVariable::Get(m_Operand1);
|
||||
return ScriptVariable::Get(expr->m_Operand1);
|
||||
}
|
||||
|
||||
Value AExpression::OpNegate(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpNegate(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return ~(long)EvaluateOperand1(locals);
|
||||
return ~(long)expr->EvaluateOperand1(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpAdd(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpAdd(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) + EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) + expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpSubtract(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpSubtract(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) - EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) - expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpMultiply(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpMultiply(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) * EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) * expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpDivide(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpDivide(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) / EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) / expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpBinaryAnd(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpBinaryAnd(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) & EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) & expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpBinaryOr(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpBinaryOr(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) | EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) | expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpShiftLeft(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpShiftLeft(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) << EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) << expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpShiftRight(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpShiftRight(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) >> EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) >> expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpEqual(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpEqual(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) == EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) == expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpNotEqual(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpNotEqual(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) != EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) != expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpLessThan(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpLessThan(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) < EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) < expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpGreaterThan(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpGreaterThan(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) > EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) > expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpLessThanOrEqual(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpLessThanOrEqual(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) <= EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) <= expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpGreaterThanOrEqual(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpGreaterThanOrEqual(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals) >= EvaluateOperand2(locals);
|
||||
return expr->EvaluateOperand1(locals) >= expr->EvaluateOperand2(locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpIn(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpIn(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
Value right = EvaluateOperand2(locals);
|
||||
Value right = expr->EvaluateOperand2(locals);
|
||||
|
||||
if (!right.IsObjectType<Array>())
|
||||
BOOST_THROW_EXCEPTION(ConfigError("Invalid right side argument for 'in' operator: " + JsonSerialize(right)));
|
||||
|
||||
Value left = EvaluateOperand1(locals);
|
||||
Value left = expr->EvaluateOperand1(locals);
|
||||
|
||||
Array::Ptr arr = right;
|
||||
bool found = false;
|
||||
|
@ -225,30 +254,30 @@ Value AExpression::OpIn(const Dictionary::Ptr& locals) const
|
|||
return found;
|
||||
}
|
||||
|
||||
Value AExpression::OpNotIn(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpNotIn(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return !OpIn(locals);
|
||||
return !OpIn(expr, locals);
|
||||
}
|
||||
|
||||
Value AExpression::OpLogicalAnd(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpLogicalAnd(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals).ToBool() && EvaluateOperand2(locals).ToBool();
|
||||
return expr->EvaluateOperand1(locals).ToBool() && expr->EvaluateOperand2(locals).ToBool();
|
||||
}
|
||||
|
||||
Value AExpression::OpLogicalOr(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpLogicalOr(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
return EvaluateOperand1(locals).ToBool() || EvaluateOperand2(locals).ToBool();
|
||||
return expr->EvaluateOperand1(locals).ToBool() || expr->EvaluateOperand2(locals).ToBool();
|
||||
}
|
||||
|
||||
Value AExpression::OpFunctionCall(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpFunctionCall(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
String funcName = m_Operand1;
|
||||
String funcName = expr->m_Operand1;
|
||||
ScriptFunction::Ptr func = ScriptFunctionRegistry::GetInstance()->GetItem(funcName);
|
||||
|
||||
if (!func)
|
||||
BOOST_THROW_EXCEPTION(ConfigError("Function '" + funcName + "' does not exist."));
|
||||
|
||||
Array::Ptr arr = EvaluateOperand2(locals);
|
||||
Array::Ptr arr = expr->EvaluateOperand2(locals);
|
||||
std::vector<Value> arguments;
|
||||
BOOST_FOREACH(const AExpression::Ptr& aexpr, arr) {
|
||||
arguments.push_back(aexpr->Evaluate(locals));
|
||||
|
@ -257,9 +286,9 @@ Value AExpression::OpFunctionCall(const Dictionary::Ptr& locals) const
|
|||
return func->Invoke(arguments);
|
||||
}
|
||||
|
||||
Value AExpression::OpArray(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpArray(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
Array::Ptr arr = m_Operand1;
|
||||
Array::Ptr arr = expr->m_Operand1;
|
||||
Array::Ptr result = make_shared<Array>();
|
||||
|
||||
if (arr) {
|
||||
|
@ -271,10 +300,10 @@ Value AExpression::OpArray(const Dictionary::Ptr& locals) const
|
|||
return result;
|
||||
}
|
||||
|
||||
Value AExpression::OpDict(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpDict(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
Array::Ptr arr = m_Operand1;
|
||||
bool in_place = m_Operand2;
|
||||
Array::Ptr arr = expr->m_Operand1;
|
||||
bool in_place = expr->m_Operand2;
|
||||
Dictionary::Ptr result = make_shared<Dictionary>();
|
||||
|
||||
if (arr) {
|
||||
|
@ -286,71 +315,87 @@ Value AExpression::OpDict(const Dictionary::Ptr& locals) const
|
|||
return result;
|
||||
}
|
||||
|
||||
Value AExpression::OpSet(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpSet(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
Value right = EvaluateOperand2(locals);
|
||||
locals->Set(m_Operand1, right);
|
||||
Value right = expr->EvaluateOperand2(locals);
|
||||
locals->Set(expr->m_Operand1, right);
|
||||
return right;
|
||||
}
|
||||
|
||||
Value AExpression::OpSetPlus(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpSetPlus(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
Value left = locals->Get(m_Operand1);
|
||||
AExpression::Ptr exp_right = m_Operand2;
|
||||
Value left = locals->Get(expr->m_Operand1);
|
||||
AExpression::Ptr exp_right = expr->m_Operand2;
|
||||
Dictionary::Ptr xlocals = locals;
|
||||
|
||||
if (exp_right->m_Operator == &AExpression::OpDict)
|
||||
if (exp_right->m_Operator == &AExpression::OpDict) {
|
||||
xlocals = left;
|
||||
|
||||
Value result = left + EvaluateOperand2(xlocals);
|
||||
locals->Set(m_Operand1, result);
|
||||
if (!xlocals)
|
||||
xlocals = make_shared<Dictionary>();
|
||||
}
|
||||
|
||||
Value result = left + expr->EvaluateOperand2(xlocals);
|
||||
locals->Set(expr->m_Operand1, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Value AExpression::OpSetMinus(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpSetMinus(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
Value left = locals->Get(m_Operand1);
|
||||
AExpression::Ptr exp_right = m_Operand2;
|
||||
Value left = locals->Get(expr->m_Operand1);
|
||||
AExpression::Ptr exp_right = expr->m_Operand2;
|
||||
Dictionary::Ptr xlocals = locals;
|
||||
|
||||
if (exp_right->m_Operator == &AExpression::OpDict)
|
||||
if (exp_right->m_Operator == &AExpression::OpDict) {
|
||||
xlocals = left;
|
||||
|
||||
Value result = left - EvaluateOperand2(xlocals);
|
||||
locals->Set(m_Operand1, result);
|
||||
if (!xlocals)
|
||||
xlocals = make_shared<Dictionary>();
|
||||
}
|
||||
|
||||
Value result = left - expr->EvaluateOperand2(xlocals);
|
||||
locals->Set(expr->m_Operand1, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Value AExpression::OpSetMultiply(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpSetMultiply(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
Value left = locals->Get(m_Operand1);
|
||||
AExpression::Ptr exp_right = m_Operand2;
|
||||
Value left = locals->Get(expr->m_Operand1);
|
||||
AExpression::Ptr exp_right = expr->m_Operand2;
|
||||
Dictionary::Ptr xlocals = locals;
|
||||
|
||||
if (exp_right->m_Operator == &AExpression::OpDict)
|
||||
if (exp_right->m_Operator == &AExpression::OpDict) {
|
||||
xlocals = left;
|
||||
|
||||
Value result = left * EvaluateOperand2(xlocals);
|
||||
locals->Set(m_Operand1, result);
|
||||
if (!xlocals)
|
||||
xlocals = make_shared<Dictionary>();
|
||||
}
|
||||
|
||||
Value result = left * expr->EvaluateOperand2(xlocals);
|
||||
locals->Set(expr->m_Operand1, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Value AExpression::OpSetDivide(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpSetDivide(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
Value left = locals->Get(m_Operand1);
|
||||
AExpression::Ptr exp_right = m_Operand2;
|
||||
Value left = locals->Get(expr->m_Operand1);
|
||||
AExpression::Ptr exp_right = expr->m_Operand2;
|
||||
Dictionary::Ptr xlocals = locals;
|
||||
|
||||
if (exp_right->m_Operator == &AExpression::OpDict)
|
||||
if (exp_right->m_Operator == &AExpression::OpDict) {
|
||||
xlocals = left;
|
||||
|
||||
Value result = left / EvaluateOperand2(xlocals);
|
||||
locals->Set(m_Operand1, result);
|
||||
if (!xlocals)
|
||||
xlocals = make_shared<Dictionary>();
|
||||
}
|
||||
|
||||
Value result = left / expr->EvaluateOperand2(xlocals);
|
||||
locals->Set(expr->m_Operand1, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Value AExpression::OpIndexer(const Dictionary::Ptr& locals) const
|
||||
Value AExpression::OpIndexer(const AExpression *expr, const Dictionary::Ptr& locals)
|
||||
{
|
||||
Dictionary::Ptr dict = locals->Get(m_Operand1);
|
||||
return dict->Get(m_Operand2);
|
||||
Dictionary::Ptr dict = locals->Get(expr->m_Operand1);
|
||||
return dict->Get(expr->m_Operand2);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class I2_CONFIG_API AExpression : public Object
|
|||
public:
|
||||
DECLARE_PTR_TYPEDEFS(AExpression);
|
||||
|
||||
typedef Value (AExpression::*OpCallback)(const Dictionary::Ptr&) const;
|
||||
typedef Value (*OpCallback)(const AExpression *, const Dictionary::Ptr&);
|
||||
|
||||
AExpression(OpCallback op, const Value& operand1, const DebugInfo& di);
|
||||
AExpression(OpCallback op, const Value& operand1, const Value& operand2, const DebugInfo& di);
|
||||
|
@ -47,36 +47,38 @@ public:
|
|||
|
||||
void MakeInline(void);
|
||||
|
||||
Value OpLiteral(const Dictionary::Ptr& locals) const;
|
||||
Value OpVariable(const Dictionary::Ptr& locals) const;
|
||||
Value OpNegate(const Dictionary::Ptr& locals) const;
|
||||
Value OpAdd(const Dictionary::Ptr& locals) const;
|
||||
Value OpSubtract(const Dictionary::Ptr& locals) const;
|
||||
Value OpMultiply(const Dictionary::Ptr& locals) const;
|
||||
Value OpDivide(const Dictionary::Ptr& locals) const;
|
||||
Value OpBinaryAnd(const Dictionary::Ptr& locals) const;
|
||||
Value OpBinaryOr(const Dictionary::Ptr& locals) const;
|
||||
Value OpShiftLeft(const Dictionary::Ptr& locals) const;
|
||||
Value OpShiftRight(const Dictionary::Ptr& locals) const;
|
||||
Value OpEqual(const Dictionary::Ptr& locals) const;
|
||||
Value OpNotEqual(const Dictionary::Ptr& locals) const;
|
||||
Value OpLessThan(const Dictionary::Ptr& locals) const;
|
||||
Value OpGreaterThan(const Dictionary::Ptr& locals) const;
|
||||
Value OpLessThanOrEqual(const Dictionary::Ptr& locals) const;
|
||||
Value OpGreaterThanOrEqual(const Dictionary::Ptr& locals) const;
|
||||
Value OpIn(const Dictionary::Ptr& locals) const;
|
||||
Value OpNotIn(const Dictionary::Ptr& locals) const;
|
||||
Value OpLogicalAnd(const Dictionary::Ptr& locals) const;
|
||||
Value OpLogicalOr(const Dictionary::Ptr& locals) const;
|
||||
Value OpFunctionCall(const Dictionary::Ptr& locals) const;
|
||||
Value OpArray(const Dictionary::Ptr& locals) const;
|
||||
Value OpDict(const Dictionary::Ptr& locals) const;
|
||||
Value OpSet(const Dictionary::Ptr& locals) const;
|
||||
Value OpSetPlus(const Dictionary::Ptr& locals) const;
|
||||
Value OpSetMinus(const Dictionary::Ptr& locals) const;
|
||||
Value OpSetMultiply(const Dictionary::Ptr& locals) const;
|
||||
Value OpSetDivide(const Dictionary::Ptr& locals) const;
|
||||
Value OpIndexer(const Dictionary::Ptr& locals) const;
|
||||
void Dump(std::ostream& stream, int indent = 0);
|
||||
|
||||
static Value OpLiteral(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpVariable(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpNegate(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpAdd(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpSubtract(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpMultiply(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpDivide(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpBinaryAnd(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpBinaryOr(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpShiftLeft(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpShiftRight(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpEqual(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpNotEqual(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpLessThan(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpGreaterThan(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpLessThanOrEqual(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpGreaterThanOrEqual(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpIn(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpNotIn(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpLogicalAnd(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpLogicalOr(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpFunctionCall(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpArray(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpDict(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpSet(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpSetPlus(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpSetMinus(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpSetMultiply(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpSetDivide(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
static Value OpIndexer(const AExpression *expr, const Dictionary::Ptr& locals);
|
||||
|
||||
private:
|
||||
OpCallback m_Operator;
|
||||
|
@ -86,6 +88,8 @@ private:
|
|||
|
||||
Value EvaluateOperand1(const Dictionary::Ptr& locals) const;
|
||||
Value EvaluateOperand2(const Dictionary::Ptr& locals) const;
|
||||
|
||||
static void DumpOperand(std::ostream& stream, const Value& operand, int indent);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -520,7 +520,7 @@ lterm_items: lterm_items_inner
|
|||
|
||||
lterm_items_inner: /* empty */
|
||||
{
|
||||
$$ = NULL;
|
||||
$$ = new Array();
|
||||
}
|
||||
| lterm
|
||||
{
|
||||
|
@ -540,13 +540,14 @@ lterm_items_inner: /* empty */
|
|||
}
|
||||
;
|
||||
|
||||
lterm: T_IDENTIFIER lbinary_op rterm
|
||||
lterm: identifier lbinary_op rterm
|
||||
{
|
||||
AExpression::Ptr aexpr = static_cast<AExpression::Ptr>(*$3);
|
||||
if ($2 == &AExpression::OpSetPlus || $2 == &AExpression::OpSetMinus || $2 == &AExpression::OpSetMultiply || $2 == &AExpression::OpSetDivide)
|
||||
aexpr->MakeInline();
|
||||
|
||||
$$ = new Value(make_shared<AExpression>($2, $1, aexpr, DebugInfoRange(@1, @3)));
|
||||
free($1);
|
||||
delete $3;
|
||||
}
|
||||
| identifier '[' T_STRING ']' lbinary_op rterm
|
||||
|
@ -606,7 +607,7 @@ rterm_items: rterm_items_inner
|
|||
|
||||
rterm_items_inner: /* empty */
|
||||
{
|
||||
$$ = NULL;
|
||||
$$ = new Array();
|
||||
}
|
||||
| rterm
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue