Move the VMFrame class to libbase

refs #8065
This commit is contained in:
Gunnar Beutner 2014-12-12 15:33:02 +01:00
parent aa38dde1fc
commit cfd775c948
31 changed files with 158 additions and 159 deletions

View File

@ -27,7 +27,7 @@ set(base_SOURCES
convert.cpp debuginfo.cpp dictionary.cpp dictionary-script.cpp dynamicobject.cpp dynamicobject.thpp dynamictype.cpp
exception.cpp fifo.cpp filelogger.cpp filelogger.thpp initialize.cpp json.cpp logger.cpp logger.thpp
netstring.cpp networkstream.cpp number.cpp number-script.cpp object.cpp object-script.cpp primitivetype.cpp process.cpp
ringbuffer.cpp scripterror.cpp scriptfunction.cpp scriptfunctionwrapper.cpp scriptsignal.cpp
ringbuffer.cpp scripterror.cpp scriptframe.cpp scriptfunction.cpp scriptfunctionwrapper.cpp scriptsignal.cpp
scriptutils.cpp scriptvariable.cpp serializer.cpp socket.cpp stacktrace.cpp
statsfunction.cpp stdiostream.cpp stream.cpp streamlogger.cpp streamlogger.thpp string.cpp string-script.cpp
sysloglogger.cpp sysloglogger.thpp tcpsocket.cpp thinmutex.cpp threadpool.cpp timer.cpp

View File

@ -20,55 +20,55 @@
#include "base/array.hpp"
#include "base/scriptfunction.hpp"
#include "base/scriptfunctionwrapper.hpp"
#include "config/vmframe.hpp"
#include "base/scriptframe.hpp"
using namespace icinga;
static double ArrayLen(void)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
return self->GetLength();
}
static void ArraySet(int index, const Value& value)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
self->Set(index, value);
}
static void ArrayAdd(const Value& value)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
self->Add(value);
}
static void ArrayRemove(int index)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
self->Remove(index);
}
static bool ArrayContains(const Value& value)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
return self->Contains(value);
}
static void ArrayClear(void)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
self->Clear();
}
static void ArrayClone(void)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
self->ShallowClone();
}

View File

@ -21,13 +21,13 @@
#include "base/convert.hpp"
#include "base/scriptfunction.hpp"
#include "base/scriptfunctionwrapper.hpp"
#include "config/vmframe.hpp"
#include "base/scriptframe.hpp"
using namespace icinga;
static String BooleanToString(void)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
bool self = vframe->Self;
return self ? "true" : "false";
}

View File

@ -20,41 +20,41 @@
#include "base/dictionary.hpp"
#include "base/scriptfunction.hpp"
#include "base/scriptfunctionwrapper.hpp"
#include "config/vmframe.hpp"
#include "base/scriptframe.hpp"
using namespace icinga;
static double DictionaryLen(void)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
return self->GetLength();
}
static void DictionarySet(const String& key, const Value& value)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
self->Set(key, value);
}
static void DictionaryRemove(const String& key)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
self->Remove(key);
}
static bool DictionaryContains(const String& key)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
return self->Contains(key);
}
static void DictionaryClone(void)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
self->ShallowClone();
}

View File

@ -21,13 +21,13 @@
#include "base/convert.hpp"
#include "base/scriptfunction.hpp"
#include "base/scriptfunctionwrapper.hpp"
#include "config/vmframe.hpp"
#include "base/scriptframe.hpp"
using namespace icinga;
static String NumberToString(void)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
double self = vframe->Self;
return Convert::ToString(self);
}

View File

@ -21,13 +21,13 @@
#include "base/dictionary.hpp"
#include "base/scriptfunction.hpp"
#include "base/scriptfunctionwrapper.hpp"
#include "config/vmframe.hpp"
#include "base/scriptframe.hpp"
using namespace icinga;
static String ObjectToString(void)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Object::Ptr self = static_cast<Object::Ptr>(vframe->Self);
return self->ToString();
}

View File

@ -17,8 +17,8 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#include "config/vmframe.hpp"
#include "base/scriptframe.hpp"
using namespace icinga;
boost::thread_specific_ptr<VMFrame *> VMFrame::m_CurrentFrame;
boost::thread_specific_ptr<ScriptFrame *> ScriptFrame::m_CurrentFrame;

View File

@ -27,35 +27,35 @@
namespace icinga
{
struct VMFrame
struct I2_BASE_API ScriptFrame
{
Dictionary::Ptr Locals;
Value Self;
VMFrame *NextFrame;
ScriptFrame *NextFrame;
VMFrame(void)
ScriptFrame(void)
: Locals(new Dictionary()), Self(Locals)
{
NextFrame = GetCurrentFrame();
SetCurrentFrame(this);
}
VMFrame(const Value& self)
ScriptFrame(const Value& self)
: Locals(new Dictionary()), Self(self)
{
NextFrame = GetCurrentFrame();
SetCurrentFrame(this);
}
~VMFrame(void)
~ScriptFrame(void)
{
ASSERT(GetCurrentFrame() == this);
SetCurrentFrame(NextFrame);
}
static inline VMFrame *GetCurrentFrame(void)
static inline ScriptFrame *GetCurrentFrame(void)
{
VMFrame **pframe = m_CurrentFrame.get();
ScriptFrame **pframe = m_CurrentFrame.get();
if (pframe)
return *pframe;
@ -64,14 +64,14 @@ struct VMFrame
}
private:
static boost::thread_specific_ptr<VMFrame *> m_CurrentFrame;
static boost::thread_specific_ptr<ScriptFrame *> m_CurrentFrame;
static inline void SetCurrentFrame(VMFrame *frame)
static inline void SetCurrentFrame(ScriptFrame *frame)
{
m_CurrentFrame.reset(new VMFrame *(frame));
m_CurrentFrame.reset(new ScriptFrame *(frame));
}
};
}
#endif /* VMOPS_H */
#endif /* SCRIPTFRAME_H */

View File

@ -21,20 +21,20 @@
#include "base/dictionary.hpp"
#include "base/scriptfunction.hpp"
#include "base/scriptfunctionwrapper.hpp"
#include "config/vmframe.hpp"
#include "base/scriptframe.hpp"
using namespace icinga;
static int StringLen(void)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
String self = vframe->Self;
return self.GetLength();
}
static String StringToString(void)
{
VMFrame *vframe = VMFrame::GetCurrentFrame();
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
return vframe->Self;
}

View File

@ -65,7 +65,7 @@ static String LoadAppType(const String& typeSpec)
static void ExecuteExpression(Expression *expression)
{
try {
VMFrame frame;
ScriptFrame frame;
expression->Evaluate(frame);
} catch (const ScriptError& ex) {
ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), ex.GetDebugInfo());

View File

@ -56,7 +56,7 @@ void ReplCommand::InitParameters(boost::program_options::options_description& vi
*/
int ReplCommand::Run(const po::variables_map& vm, const std::vector<std::string>& ap) const
{
VMFrame frame;
ScriptFrame frame;
while (std::cin.good()) {
std::cout << ConsoleColorTag(Console_ForegroundRed)

View File

@ -235,7 +235,7 @@ bool RepositoryUtility::AddObject(const String& name, const String& type, const
BOOST_FOREACH(boost::tie(fname, fragment), ConfigFragmentRegistry::GetInstance()->GetItems()) {
Expression *expression = ConfigCompiler::CompileText(fname, fragment);
if (expression) {
VMFrame frame;
ScriptFrame frame;
expression->Evaluate(frame);
delete expression;
}

View File

@ -35,7 +35,6 @@ set(config_SOURCES
configcompilercontext.cpp configcompiler.cpp configitembuilder.cpp
configitem.cpp ${FLEX_config_lexer_OUTPUTS} ${BISON_config_parser_OUTPUTS}
configtype.cpp expression.cpp objectrule.cpp typerule.cpp typerulelist.cpp
vmframe.cpp
)
if(ICINGA2_UNITY_BUILD)

View File

@ -86,7 +86,7 @@ void ApplyRule::AddRule(const String& sourceType, const String& targetType, cons
m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, fkvar, fvvar, fterm, di, scope));
}
bool ApplyRule::EvaluateFilter(VMFrame& frame) const
bool ApplyRule::EvaluateFilter(ScriptFrame& frame) const
{
return m_Filter->Evaluate(frame).ToBool();
}

View File

@ -49,7 +49,7 @@ public:
void AddMatch(void);
bool HasMatches(void) const;
bool EvaluateFilter(VMFrame& frame) const;
bool EvaluateFilter(ScriptFrame& frame) const;
static void AddRule(const String& sourceType, const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression,
const boost::shared_ptr<Expression>& filter, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, const DebugInfo& di, const Dictionary::Ptr& scope);

View File

@ -316,7 +316,7 @@ library: T_LIBRARY T_STRING
constant: T_CONST identifier T_SET rterm
{
VMFrame frame;
ScriptFrame frame;
ScriptVariable::Ptr sv = ScriptVariable::Set($2, $4->Evaluate(frame));
free($2);
delete $4;

View File

@ -164,7 +164,7 @@ DynamicObject::Ptr ConfigItem::Commit(bool discard)
DebugHint debugHints;
try {
VMFrame frame(dobj);
ScriptFrame frame(dobj);
frame.Locals = m_Scope;
m_Expression->Evaluate(frame, &debugHints);
} catch (const ScriptError& ex) {

View File

@ -34,7 +34,7 @@ using namespace icinga;
Expression::~Expression(void)
{ }
Value Expression::Evaluate(VMFrame& frame, DebugHint *dhint) const
Value Expression::Evaluate(ScriptFrame& frame, DebugHint *dhint) const
{
try {
#ifdef _DEBUG
@ -77,7 +77,7 @@ LiteralExpression::LiteralExpression(const Value& value)
: m_Value(value)
{ }
Value LiteralExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value LiteralExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Value;
}
@ -87,102 +87,102 @@ const DebugInfo& DebuggableExpression::GetDebugInfo(void) const
return m_DebugInfo;
}
Value VariableExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value VariableExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return VMOps::Variable(frame, m_Variable, GetDebugInfo());
}
Value NegateExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value NegateExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return ~(long)m_Operand->Evaluate(frame);
}
Value LogicalNegateExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value LogicalNegateExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return !m_Operand->Evaluate(frame).ToBool();
}
Value AddExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value AddExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) + m_Operand2->Evaluate(frame);
}
Value SubtractExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value SubtractExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) - m_Operand2->Evaluate(frame);
}
Value MultiplyExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value MultiplyExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) * m_Operand2->Evaluate(frame);
}
Value DivideExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value DivideExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) / m_Operand2->Evaluate(frame);
}
Value ModuloExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value ModuloExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return (long)m_Operand1->Evaluate(frame) % (long)m_Operand2->Evaluate(frame);
}
Value XorExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value XorExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return (long)m_Operand1->Evaluate(frame) ^ (long)m_Operand2->Evaluate(frame);
}
Value BinaryAndExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value BinaryAndExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) & m_Operand2->Evaluate(frame);
}
Value BinaryOrExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value BinaryOrExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) | m_Operand2->Evaluate(frame);
}
Value ShiftLeftExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value ShiftLeftExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) << m_Operand2->Evaluate(frame);
}
Value ShiftRightExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value ShiftRightExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) >> m_Operand2->Evaluate(frame);
}
Value EqualExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value EqualExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) == m_Operand2->Evaluate(frame);
}
Value NotEqualExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value NotEqualExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) != m_Operand2->Evaluate(frame);
}
Value LessThanExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value LessThanExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) < m_Operand2->Evaluate(frame);
}
Value GreaterThanExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value GreaterThanExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) > m_Operand2->Evaluate(frame);
}
Value LessThanOrEqualExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value LessThanOrEqualExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) <= m_Operand2->Evaluate(frame);
}
Value GreaterThanOrEqualExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value GreaterThanOrEqualExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame) >= m_Operand2->Evaluate(frame);
}
Value InExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value InExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
Value right = m_Operand2->Evaluate(frame);
@ -197,7 +197,7 @@ Value InExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
return arr->Contains(left);
}
Value NotInExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value NotInExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
Value right = m_Operand2->Evaluate(frame);
@ -212,17 +212,17 @@ Value NotInExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
return !arr->Contains(left);
}
Value LogicalAndExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value LogicalAndExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame).ToBool() && m_Operand2->Evaluate(frame).ToBool();
}
Value LogicalOrExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value LogicalOrExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Operand1->Evaluate(frame).ToBool() || m_Operand2->Evaluate(frame).ToBool();
}
Value FunctionCallExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value FunctionCallExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
Value self, funcName;
@ -257,7 +257,7 @@ Value FunctionCallExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
return VMOps::FunctionCall(frame, self, funcName, arguments);
}
Value ArrayExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value ArrayExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
Array::Ptr result = new Array();
@ -268,10 +268,10 @@ Value ArrayExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
return result;
}
Value DictExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value DictExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
VMFrame *dframe;
VMFrame rframe;
ScriptFrame *dframe;
ScriptFrame rframe;
if (!m_Inline) {
dframe = &rframe;
@ -293,7 +293,7 @@ Value DictExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
return dframe->Self;
}
Value SetExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value SetExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
DebugHint *psdhint = dhint;
DebugHint sdhint;
@ -396,7 +396,7 @@ Value SetExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
return right;
}
Value ConditionalExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value ConditionalExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
if (m_Condition->Evaluate(frame, dhint).ToBool())
return m_TrueBranch->Evaluate(frame, dhint);
@ -406,17 +406,17 @@ Value ConditionalExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
return Empty;
}
Value ReturnExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value ReturnExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
BOOST_THROW_EXCEPTION(InterruptExecutionError(m_Operand->Evaluate(frame)));
}
Value IndexerExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value IndexerExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return VMOps::Indexer(frame, m_Indexer, GetDebugInfo());
}
Value ImportExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value ImportExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
String type = VMOps::GetField(frame.Self, "type", GetDebugInfo());
Value name = m_Name->Evaluate(frame);
@ -431,23 +431,23 @@ Value ImportExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
return Empty;
}
Value FunctionExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value FunctionExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return VMOps::NewFunction(frame, m_Name, m_Args, m_ClosedVars, m_Expression);
}
Value SlotExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value SlotExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return VMOps::NewSlot(frame, m_Signal, m_Slot->Evaluate(frame));
}
Value ApplyExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value ApplyExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return VMOps::NewApply(frame, m_Type, m_Target, m_Name->Evaluate(frame), m_Filter,
m_FKVar, m_FVVar, m_FTerm, m_ClosedVars, m_Expression, m_DebugInfo);
}
Value ObjectExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value ObjectExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
String name;
@ -458,7 +458,7 @@ Value ObjectExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
m_ClosedVars, m_Expression, m_DebugInfo);
}
Value ForExpression::DoEvaluate(VMFrame& frame, DebugHint *dhint) const
Value ForExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
Value value = m_Value->Evaluate(frame, dhint);

View File

@ -21,12 +21,12 @@
#define EXPRESSION_H
#include "config/i2-config.hpp"
#include "config/vmframe.hpp"
#include "base/debuginfo.hpp"
#include "base/array.hpp"
#include "base/dictionary.hpp"
#include "base/scriptfunction.hpp"
#include "base/scripterror.hpp"
#include "base/scriptframe.hpp"
#include "base/convert.hpp"
#include <boost/foreach.hpp>
#include <boost/thread/future.hpp>
@ -135,9 +135,9 @@ class I2_CONFIG_API Expression
public:
virtual ~Expression(void);
Value Evaluate(VMFrame& frame, DebugHint *dhint = NULL) const;
Value Evaluate(ScriptFrame& frame, DebugHint *dhint = NULL) const;
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const = 0;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const = 0;
virtual const DebugInfo& GetDebugInfo(void) const;
};
@ -151,7 +151,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Expression->DoEvaluate(frame, dhint);
}
@ -173,7 +173,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
return m_Future.get()->DoEvaluate(frame, dhint);
}
@ -193,7 +193,7 @@ public:
LiteralExpression(const Value& value = Value());
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
Value m_Value;
@ -265,7 +265,7 @@ public:
}
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
String m_Variable;
@ -279,7 +279,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API LogicalNegateExpression : public UnaryExpression
@ -290,7 +290,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API AddExpression : public BinaryExpression
@ -301,7 +301,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API SubtractExpression : public BinaryExpression
@ -312,7 +312,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API MultiplyExpression : public BinaryExpression
@ -323,7 +323,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API DivideExpression : public BinaryExpression
@ -334,7 +334,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API ModuloExpression : public BinaryExpression
@ -345,7 +345,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API XorExpression : public BinaryExpression
@ -356,7 +356,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API BinaryAndExpression : public BinaryExpression
@ -367,7 +367,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API BinaryOrExpression : public BinaryExpression
@ -378,7 +378,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API ShiftLeftExpression : public BinaryExpression
@ -389,7 +389,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API ShiftRightExpression : public BinaryExpression
@ -400,7 +400,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API EqualExpression : public BinaryExpression
@ -411,7 +411,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API NotEqualExpression : public BinaryExpression
@ -422,7 +422,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API LessThanExpression : public BinaryExpression
@ -433,7 +433,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API GreaterThanExpression : public BinaryExpression
@ -444,7 +444,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API LessThanOrEqualExpression : public BinaryExpression
@ -455,7 +455,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API GreaterThanOrEqualExpression : public BinaryExpression
@ -466,7 +466,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API InExpression : public BinaryExpression
@ -477,7 +477,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API NotInExpression : public BinaryExpression
@ -488,7 +488,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API LogicalAndExpression : public BinaryExpression
@ -499,7 +499,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API LogicalOrExpression : public BinaryExpression
@ -510,7 +510,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API FunctionCallExpression : public DebuggableExpression
@ -532,7 +532,7 @@ public:
}
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
public:
std::vector<Expression *> m_IName;
@ -554,7 +554,7 @@ public:
}
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
std::vector<Expression *> m_Expressions;
@ -576,7 +576,7 @@ public:
void MakeInline(void);
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
std::vector<Expression *> m_Expressions;
@ -599,7 +599,7 @@ public:
}
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
CombinedSetOp m_Op;
@ -624,7 +624,7 @@ public:
}
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
Expression *m_Condition;
@ -640,7 +640,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
};
class I2_CONFIG_API IndexerExpression : public DebuggableExpression
@ -657,7 +657,7 @@ public:
}
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
std::vector<Expression *> m_Indexer;
@ -676,7 +676,7 @@ public:
}
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
Expression *m_Name;
@ -691,7 +691,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
String m_Name;
@ -708,7 +708,7 @@ public:
{ }
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
String m_Signal;
@ -733,7 +733,7 @@ public:
}
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
String m_Type;
@ -763,7 +763,7 @@ public:
}
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
bool m_Abstract;
@ -789,7 +789,7 @@ public:
}
protected:
virtual Value DoEvaluate(VMFrame& frame, DebugHint *dhint) const;
virtual Value DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const;
private:
String m_FKVar;

View File

@ -45,7 +45,7 @@ namespace icinga
class VMOps
{
public:
static inline Value Variable(VMFrame& frame, const String& name, const DebugInfo& debugInfo = DebugInfo())
static inline Value Variable(ScriptFrame& frame, const String& name, const DebugInfo& debugInfo = DebugInfo())
{
if (name == "this")
return frame.Self;
@ -58,7 +58,7 @@ public:
return ScriptVariable::Get(name);
}
static inline Value FunctionCall(VMFrame& frame, const Value& self, const Value& funcName, const std::vector<Value>& arguments)
static inline Value FunctionCall(ScriptFrame& frame, const Value& self, const Value& funcName, const std::vector<Value>& arguments)
{
ScriptFunction::Ptr func;
@ -70,17 +70,17 @@ public:
if (!func)
BOOST_THROW_EXCEPTION(ScriptError("Function '" + funcName + "' does not exist."));
boost::shared_ptr<VMFrame> vframe;
boost::shared_ptr<ScriptFrame> vframe;
if (!self.IsEmpty())
vframe = boost::make_shared<VMFrame>(self); /* passes self to the callee using a TLS variable */
vframe = boost::make_shared<ScriptFrame>(self); /* passes self to the callee using a TLS variable */
else
vframe = boost::make_shared<VMFrame>();
vframe = boost::make_shared<ScriptFrame>();
return func->Invoke(arguments);
}
static inline Value Indexer(VMFrame& frame, const std::vector<Expression *>& indexer, const DebugInfo& debugInfo = DebugInfo())
static inline Value Indexer(ScriptFrame& frame, const std::vector<Expression *>& indexer, const DebugInfo& debugInfo = DebugInfo())
{
Value result = indexer[0]->Evaluate(frame);
@ -95,7 +95,7 @@ public:
return result;
}
static inline Value NewFunction(VMFrame& frame, const String& name, const std::vector<String>& args,
static inline Value NewFunction(ScriptFrame& frame, const String& name, const std::vector<String>& args,
std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression)
{
ScriptFunction::Ptr func = new ScriptFunction(boost::bind(&FunctionWrapper, _1, args,
@ -107,7 +107,7 @@ public:
return func;
}
static inline Value NewSlot(VMFrame& frame, const String& signal, const Value& slot)
static inline Value NewSlot(ScriptFrame& frame, const String& signal, const Value& slot)
{
ScriptSignal::Ptr sig = ScriptSignal::GetByName(signal);
@ -119,7 +119,7 @@ public:
return Empty;
}
static inline Value NewApply(VMFrame& frame, const String& type, const String& target, const String& name, const boost::shared_ptr<Expression>& filter,
static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const boost::shared_ptr<Expression>& filter,
const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, std::map<String, Expression *> *closedVars,
const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
{
@ -129,7 +129,7 @@ public:
return Empty;
}
static inline Value NewObject(VMFrame& frame, bool abstract, const String& type, const String& name, const boost::shared_ptr<Expression>& filter,
static inline Value NewObject(ScriptFrame& frame, bool abstract, const String& type, const String& name, const boost::shared_ptr<Expression>& filter,
const String& zone, std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
{
ConfigItemBuilder::Ptr item = new ConfigItemBuilder(debugInfo);
@ -175,7 +175,7 @@ public:
return Empty;
}
static inline Value For(VMFrame& frame, const String& fkvar, const String& fvvar, const Value& value, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
static inline Value For(ScriptFrame& frame, const String& fkvar, const String& fvvar, const Value& value, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
{
if (value.IsObjectType<Array>()) {
if (!fvvar.IsEmpty())
@ -336,8 +336,8 @@ private:
if (arguments.size() < funcargs.size())
BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function"));
VMFrame *vframe = VMFrame::GetCurrentFrame();
VMFrame frame(vframe->Self);
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
ScriptFrame frame(vframe->Self);
if (closedVars)
closedVars->CopyTo(frame.Locals);
@ -370,7 +370,7 @@ private:
func->Invoke(arguments);
}
static inline Dictionary::Ptr EvaluateClosedVars(VMFrame& frame, std::map<String, Expression *> *closedVars)
static inline Dictionary::Ptr EvaluateClosedVars(ScriptFrame& frame, std::map<String, Expression *> *closedVars)
{
Dictionary::Ptr locals;

View File

@ -42,7 +42,7 @@ void Dependency::RegisterApplyRuleHandler(void)
ApplyRule::RegisterType("Dependency", targets);
}
void Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, VMFrame& frame, const ApplyRule& rule)
void Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule)
{
DebugInfo di = rule.GetDebugInfo();
@ -87,7 +87,7 @@ bool Dependency::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyR
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
VMFrame frame;
ScriptFrame frame;
if (rule.GetScope())
rule.GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);

View File

@ -28,7 +28,7 @@ namespace icinga
{
class ApplyRule;
struct VMFrame;
struct ScriptFrame;
class Host;
class Service;
@ -66,7 +66,7 @@ private:
Checkable::Ptr m_Parent;
Checkable::Ptr m_Child;
static void EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, VMFrame& frame, const ApplyRule& rule);
static void EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule);
static bool EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule);
};

View File

@ -44,7 +44,7 @@ bool HostGroup::EvaluateObjectRule(const Host::Ptr& host, const ConfigItem::Ptr&
CONTEXT("Evaluating rule for group '" + group_name + "'");
VMFrame frame;
ScriptFrame frame;
if (group->GetScope())
group->GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);

View File

@ -42,7 +42,7 @@ void Notification::RegisterApplyRuleHandler(void)
ApplyRule::RegisterType("Notification", targets);
}
void Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, VMFrame& frame, const ApplyRule& rule)
void Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule)
{
DebugInfo di = rule.GetDebugInfo();
@ -86,7 +86,7 @@ bool Notification::EvaluateApplyRule(const Checkable::Ptr& checkable, const Appl
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
VMFrame frame;
ScriptFrame frame;
if (rule.GetScope())
rule.GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);

View File

@ -68,7 +68,7 @@ enum NotificationType
class NotificationCommand;
class Checkable;
class ApplyRule;
struct VMFrame;
struct ScriptFrame;
class Host;
class Service;
@ -123,7 +123,7 @@ protected:
private:
void ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const CheckResult::Ptr& cr, bool force, const String& author = "", const String& text = "");
static void EvaluateApplyRuleInstance(const intrusive_ptr<Checkable>& checkable, const String& name, VMFrame& frame, const ApplyRule& rule);
static void EvaluateApplyRuleInstance(const intrusive_ptr<Checkable>& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule);
static bool EvaluateApplyRule(const intrusive_ptr<Checkable>& checkable, const ApplyRule& rule);
};

View File

@ -41,7 +41,7 @@ void ScheduledDowntime::RegisterApplyRuleHandler(void)
ApplyRule::RegisterType("ScheduledDowntime", targets);
}
void ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, VMFrame& frame, const ApplyRule& rule)
void ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule)
{
DebugInfo di = rule.GetDebugInfo();
@ -85,7 +85,7 @@ bool ScheduledDowntime::EvaluateApplyRule(const Checkable::Ptr& checkable, const
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
VMFrame frame;
ScriptFrame frame;
if (rule.GetScope())
rule.GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);

View File

@ -29,7 +29,7 @@ namespace icinga
{
class ApplyRule;
struct VMFrame;
struct ScriptFrame;
class Host;
class Service;
@ -62,7 +62,7 @@ private:
std::pair<double, double> FindNextSegment(void);
void CreateNextDowntime(void);
static void EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, VMFrame& frame, const ApplyRule& rule);
static void EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule);
static bool EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule);
};

View File

@ -40,7 +40,7 @@ void Service::RegisterApplyRuleHandler(void)
ApplyRule::RegisterType("Service", targets);
}
void Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& name, VMFrame& frame, const ApplyRule& rule)
void Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& name, ScriptFrame& frame, const ApplyRule& rule)
{
DebugInfo di = rule.GetDebugInfo();
@ -75,7 +75,7 @@ bool Service::EvaluateApplyRule(const Host::Ptr& host, const ApplyRule& rule)
msgbuf << "Evaluating 'apply' rule (" << di << ")";
CONTEXT(msgbuf.str());
VMFrame frame;
ScriptFrame frame;
if (rule.GetScope())
rule.GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);

View File

@ -61,7 +61,7 @@ protected:
private:
Host::Ptr m_Host;
static void EvaluateApplyRuleInstance(const Host::Ptr& host, const String& name, VMFrame& frame, const ApplyRule& rule);
static void EvaluateApplyRuleInstance(const Host::Ptr& host, const String& name, ScriptFrame& frame, const ApplyRule& rule);
static bool EvaluateApplyRule(const Host::Ptr& host, const ApplyRule& rule);
};

View File

@ -46,7 +46,7 @@ bool ServiceGroup::EvaluateObjectRule(const Service::Ptr& service, const ConfigI
Host::Ptr host = service->GetHost();
VMFrame frame;
ScriptFrame frame;
if (group->GetScope())
group->GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);

View File

@ -44,7 +44,7 @@ bool UserGroup::EvaluateObjectRule(const User::Ptr& user, const ConfigItem::Ptr&
CONTEXT("Evaluating rule for group '" + group_name + "'");
VMFrame frame;
ScriptFrame frame;
if (group->GetScope())
group->GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("user", user);