mirror of https://github.com/Icinga/icinga2.git
parent
04b8724cb8
commit
3587dbbd13
|
@ -34,12 +34,12 @@ AExpression::AExpression(AOperator op, const AValue& operand1, const AValue& ope
|
|||
op == AEBinaryAnd || op == AEBinaryOr || op == AEShiftLeft || op == AEShiftRight);
|
||||
}
|
||||
|
||||
Value AExpression::Evaluate(const Object::Ptr& thisRef) const
|
||||
Value AExpression::Evaluate(const Dictionary::Ptr& locals) const
|
||||
{
|
||||
Value left, right;
|
||||
|
||||
left = m_Operand1.Evaluate(thisRef);
|
||||
right = m_Operand2.Evaluate(thisRef);
|
||||
left = m_Operand1.Evaluate(locals);
|
||||
right = m_Operand2.Evaluate(locals);
|
||||
|
||||
switch (m_Operator) {
|
||||
case AEReturn:
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "config/i2-config.h"
|
||||
#include "config/avalue.h"
|
||||
#include "base/object.h"
|
||||
#include "base/dictionary.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
AExpression(AOperator op, const AValue& operand1);
|
||||
AExpression(AOperator op, const AValue& operand1, const AValue& operand2);
|
||||
|
||||
Value Evaluate(const Object::Ptr& thisRef) const;
|
||||
Value Evaluate(const Dictionary::Ptr& locals) const;
|
||||
|
||||
private:
|
||||
AOperator m_Operator;
|
||||
|
|
|
@ -35,17 +35,20 @@ AValue::AValue(AValueType type, const Value& value)
|
|||
: m_Type(type), m_Value(value)
|
||||
{ }
|
||||
|
||||
Value AValue::Evaluate(const Object::Ptr& thisRef) const
|
||||
Value AValue::Evaluate(const Dictionary::Ptr& locals) const
|
||||
{
|
||||
switch (m_Type) {
|
||||
case ATSimple:
|
||||
return m_Value;
|
||||
case ATVariable:
|
||||
return ScriptVariable::Get(m_Value);
|
||||
if (locals && locals->Contains(m_Value))
|
||||
return locals->Get(m_Value);
|
||||
else
|
||||
return ScriptVariable::Get(m_Value);
|
||||
case ATThisRef:
|
||||
VERIFY(!"Not implemented.");
|
||||
case ATExpression:
|
||||
return m_Expression->Evaluate(thisRef);
|
||||
return m_Expression->Evaluate(locals);
|
||||
default:
|
||||
ASSERT(!"Invalid type.");
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "config/i2-config.h"
|
||||
#include "base/value.h"
|
||||
#include "base/object.h"
|
||||
#include "base/dictionary.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
AValue(const shared_ptr<AExpression>& expr);
|
||||
AValue(AValueType type, const Value& value);
|
||||
|
||||
Value Evaluate(const Object::Ptr& thisRef) const;
|
||||
Value Evaluate(const Dictionary::Ptr& locals) const;
|
||||
|
||||
private:
|
||||
AValueType m_Type;
|
||||
|
|
|
@ -668,7 +668,7 @@ value: simplevalue
|
|||
| aterm
|
||||
{
|
||||
AExpression::Ptr aexpr = *$1;
|
||||
$$ = new Value(aexpr->Evaluate(Object::Ptr()));
|
||||
$$ = new Value(aexpr->Evaluate(Dictionary::Ptr()));
|
||||
delete $1;
|
||||
}
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue