Remove the ScopeCurrent constant

fixes #9044
This commit is contained in:
Gunnar Beutner 2015-04-15 08:36:17 +02:00
parent 03ce0ec908
commit f69c0bd5a2
8 changed files with 16 additions and 19 deletions

View File

@ -521,7 +521,7 @@ lterm: library
FunctionExpression *fexpr = new FunctionExpression(*$4, $6, $7, @$);
delete $4;
$$ = new SetExpression(MakeIndexer(ScopeCurrent, $2), OpSetLiteral, fexpr, @$);
$$ = new SetExpression(MakeIndexer(ScopeThis, $2), OpSetLiteral, fexpr, @$);
free($2);
}
| T_CONST T_IDENTIFIER T_SET rterm
@ -780,7 +780,7 @@ rterm_no_side_effect: T_STRING
| rterm_scope_require_side_effect
{
Expression *expr = $1;
BindToScope(expr, ScopeCurrent);
BindToScope(expr, ScopeThis);
$$ = expr;
}
| '('

View File

@ -94,7 +94,7 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void)
Array::Ptr templateArray = new Array();
templateArray->Add(m_Name);
exprs.push_back(new SetExpression(MakeIndexer(ScopeCurrent, "templates"), OpSetAdd,
exprs.push_back(new SetExpression(MakeIndexer(ScopeThis, "templates"), OpSetAdd,
new LiteralExpression(templateArray), m_DebugInfo));
DictExpression *dexpr = new DictExpression(m_Expressions, m_DebugInfo);

View File

@ -473,8 +473,6 @@ ExpressionResult GetScopeExpression::DoEvaluate(ScriptFrame& frame, DebugHint *d
{
if (m_ScopeSpec == ScopeLocal)
return frame.Locals;
else if (m_ScopeSpec == ScopeCurrent)
return frame.Self;
else if (m_ScopeSpec == ScopeThis)
return frame.Self;
else if (m_ScopeSpec == ScopeGlobal)

View File

@ -123,7 +123,6 @@ enum CombinedSetOp
enum ScopeSpecifier
{
ScopeLocal,
ScopeCurrent,
ScopeThis,
ScopeGlobal
};

View File

@ -60,16 +60,16 @@ bool Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, cons
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "parent_host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "child_host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "parent_host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "child_host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di));
if (service)
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "child_service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "child_service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di));
String zone = checkable->GetZoneName();
if (!zone.IsEmpty())
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
builder->AddExpression(new OwnedExpression(rule.GetExpression()));

View File

@ -60,15 +60,15 @@ bool Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, co
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di));
if (service)
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di));
String zone = checkable->GetZoneName();
if (!zone.IsEmpty())
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
builder->AddExpression(new OwnedExpression(rule.GetExpression()));

View File

@ -59,15 +59,15 @@ bool ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkabl
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di));
if (service)
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di));
String zone = checkable->GetZoneName();
if (!zone.IsEmpty())
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
builder->AddExpression(new OwnedExpression(rule.GetExpression()));

View File

@ -54,14 +54,14 @@ bool Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& nam
builder->SetName(name);
builder->SetScope(frame.Locals->ShallowClone());
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "name"), OpSetLiteral, MakeLiteral(name), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "name"), OpSetLiteral, MakeLiteral(name), di));
String zone = host->GetZoneName();
if (!zone.IsEmpty())
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
builder->AddExpression(new OwnedExpression(rule.GetExpression()));