try {
expression = ConfigCompiler::CompileFile(initconfig);
- ScriptFrame frame;
+ ScriptFrame frame(true);
expression->Evaluate(frame);
} catch (const std::exception& ex) {
Log(LogCritical, "config", DiagnosticInformation(ex));
Value Function::InvokeThis(const Value& otherThis, const std::vector<Value>& arguments)
{
- ScriptFrame frame(otherThis, false);
+ ScriptFrame frame(false, otherThis);
return m_Callback(arguments);
}
InitializeFrame();
}
-ScriptFrame::ScriptFrame(const Value& self, bool allocLocals)
+ScriptFrame::ScriptFrame(bool allocLocals, const Value& self)
: Locals(allocLocals ? new Dictionary() : nullptr), Self(self), Sandboxed(false), Depth(0)
{
InitializeFrame();
bool Sandboxed;
int Depth;
- ScriptFrame(bool allocLocals = true);
- ScriptFrame(const Value& self, bool allocLocals = true);
+ ScriptFrame(bool allocLocals);
+ ScriptFrame(bool allocLocals, const Value& self);
~ScriptFrame(void);
void IncreaseStackDepth(void);
extern "C" void dbg_spawn_console(void)
{
- ScriptFrame frame;
+ ScriptFrame frame(true);
ConsoleCommand::RunScriptConsole(frame);
}
std::unique_ptr<Expression> expr;
try {
- ScriptFrame frame;
+ ScriptFrame frame(true);
expr = ConfigCompiler::CompileText("<dbg>", text);
Value result = Serialize(expr->Evaluate(frame), 0);
dbg_inspect_value(result);
std::unique_ptr<Expression> expr;
try {
- ScriptFrame frame;
+ ScriptFrame frame(true);
frame.Locals = new Dictionary();
frame.Locals->Set("arg", value);
expr = ConfigCompiler::CompileText("<dbg>", text);
std::unique_ptr<Expression> expr;
try {
- ScriptFrame frame;
+ ScriptFrame frame(true);
frame.Locals = new Dictionary();
frame.Locals->Set("arg", object);
expr = ConfigCompiler::CompileText("<dbg>", text);
#endif /* HAVE_EDITLINE */
String addr, session;
- ScriptFrame scriptFrame;
+ ScriptFrame scriptFrame(true);
session = Utility::NewUniqueID();
return false;
try {
- ScriptFrame frame;
+ ScriptFrame frame(true);
expression->Evaluate(frame);
} catch (const std::exception& ex) {
Log(LogCritical, "config", DiagnosticInformation(ex));
std::unique_ptr<icinga::Expression> expression = icinga::ConfigCompiler::CompileText(name, fragment); \
VERIFY(expression); \
try { \
- icinga::ScriptFrame frame; \
+ icinga::ScriptFrame frame(true); \
expression->Evaluate(frame); \
} catch (const std::exception& ex) { \
std::cerr << icinga::DiagnosticInformation(ex) << std::endl; \
DebugHint debugHints;
- ScriptFrame frame(dobj);
+ ScriptFrame frame(true, dobj);
if (m_Scope)
m_Scope->CopyTo(frame.Locals);
try {
if (expression) {
try {
- ScriptFrame frame;
+ ScriptFrame frame(true);
expression->Evaluate(frame);
} catch (const std::exception& ex) {
Log(LogCritical, "config", DiagnosticInformation(ex));
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- ScriptFrame frame;
+ ScriptFrame frame(true);
if (rule.GetScope())
rule.GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);
CONTEXT("Evaluating rule for group '" + group_name + "'");
- ScriptFrame frame;
+ ScriptFrame frame(true);
if (group->GetScope())
group->GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- ScriptFrame frame;
+ ScriptFrame frame(true);
if (rule.GetScope())
rule.GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
- ScriptFrame frame;
+ ScriptFrame frame(true);
if (rule.GetScope())
rule.GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);
msgbuf << "Evaluating 'apply' rule (" << di << ")";
CONTEXT(msgbuf.str());
- ScriptFrame frame;
+ ScriptFrame frame(true);
if (rule.GetScope())
rule.GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);
Host::Ptr host = service->GetHost();
- ScriptFrame frame;
+ ScriptFrame frame(true);
if (group->GetScope())
group->GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);
CONTEXT("Evaluating rule for group '" + group_name + "'");
- ScriptFrame frame;
+ ScriptFrame frame(true);
if (group->GetScope())
group->GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("user", user);
try {
ActivationScope ascope;
- ScriptFrame frame;
+ ScriptFrame frame(true);
expr->Evaluate(frame);
expr.reset();
try {
expr = ConfigCompiler::CompileText(fileName, command);
- ScriptFrame frame;
+ ScriptFrame frame(true);
frame.Locals = lsf.Locals;
frame.Self = lsf.Locals;
frame.Sandboxed = sandboxed;
Array::Ptr results = new Array();
Dictionary::Ptr resultInfo = new Dictionary();
- ScriptFrame frame;
+ ScriptFrame frame(true);
frame.Locals = lsf.Locals;
frame.Self = lsf.Locals;
frame.Sandboxed = sandboxed;
void EventQueue::ProcessEvent(const Dictionary::Ptr& event)
{
- ScriptFrame frame;
+ ScriptFrame frame(true);
frame.Sandboxed = true;
try {
Expression *permissionFilter;
CheckPermission(user, qd.Permission, &permissionFilter);
- ScriptFrame permissionFrame;
+ ScriptFrame permissionFrame(true);
for (const String& type : qd.Types) {
String attr = type;
if (qd.Types.find(type) == qd.Types.end())
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type specified for this query."));
- ScriptFrame frame;
+ ScriptFrame frame(true);
frame.Sandboxed = true;
Dictionary::Ptr uvars = new Dictionary();
BOOST_AUTO_TEST_CASE(simple)
{
- ScriptFrame frame;
+ ScriptFrame frame(true);
std::unique_ptr<Expression> expr;
Dictionary::Ptr dict;
BOOST_AUTO_TEST_CASE(advanced)
{
- ScriptFrame frame;
+ ScriptFrame frame(true);
std::unique_ptr<Expression> expr;
Function::Ptr func;
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
Object::Ptr self = new Object();
- ScriptFrame frame2(self);
+ ScriptFrame frame2(true, self);
expr = ConfigCompiler::CompileText("<test>", "this");
BOOST_CHECK(expr->Evaluate(frame2).GetValue() == Value(self));