diff --git a/lib/config/applyrule.cpp b/lib/config/applyrule.cpp index 87399711e..5d401edc6 100644 --- a/lib/config/applyrule.cpp +++ b/lib/config/applyrule.cpp @@ -11,9 +11,9 @@ ApplyRule::RuleMap ApplyRule::m_Rules; ApplyRule::TypeMap ApplyRule::m_Types; ApplyRule::ApplyRule(String name, Expression::Ptr expression, - Expression::Ptr filter, String package, String fkvar, String fvvar, Expression::Ptr fterm, + Expression::Ptr filter, String zone, String package, String fkvar, String fvvar, Expression::Ptr fterm, bool ignoreOnError, DebugInfo di, Dictionary::Ptr scope) - : m_Name(std::move(name)), m_Expression(std::move(expression)), m_Filter(std::move(filter)), m_Package(std::move(package)), m_FKVar(std::move(fkvar)), + : m_Name(std::move(name)), m_Expression(std::move(expression)), m_Filter(std::move(filter)), m_Zone(std::move(zone)), m_Package(std::move(package)), m_FKVar(std::move(fkvar)), m_FVVar(std::move(fvvar)), m_FTerm(std::move(fterm)), m_IgnoreOnError(ignoreOnError), m_DebugInfo(std::move(di)), m_Scope(std::move(scope)), m_HasMatches(false) { } @@ -32,6 +32,11 @@ Expression::Ptr ApplyRule::GetFilter() const return m_Filter; } +String ApplyRule::GetZone() const +{ + return m_Zone; +} + String ApplyRule::GetPackage() const { return m_Package; @@ -58,7 +63,7 @@ Dictionary::Ptr ApplyRule::GetScope() const } void ApplyRule::AddRule(const String& sourceType, const String& targetType, const String& name, - const Expression::Ptr& expression, const Expression::Ptr& filter, const String& package, const String& fkvar, + const Expression::Ptr& expression, const Expression::Ptr& filter, const String& zone, const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope) { auto actualTargetType (&targetType); @@ -71,7 +76,7 @@ void ApplyRule::AddRule(const String& sourceType, const String& targetType, cons } } - ApplyRule::Ptr rule = new ApplyRule(name, expression, filter, package, fkvar, fvvar, fterm, ignoreOnError, di, scope); + ApplyRule::Ptr rule = new ApplyRule(name, expression, filter, zone, package, fkvar, fvvar, fterm, ignoreOnError, di, scope); auto& rules (m_Rules[Type::GetByName(sourceType).get()]); if (!AddTargetedRule(rule, *actualTargetType, rules)) { diff --git a/lib/config/applyrule.hpp b/lib/config/applyrule.hpp index cf9b6e5e6..ec78af824 100644 --- a/lib/config/applyrule.hpp +++ b/lib/config/applyrule.hpp @@ -55,6 +55,7 @@ public: String GetName() const; Expression::Ptr GetExpression() const; Expression::Ptr GetFilter() const; + String GetZone() const; String GetPackage() const; inline const String& GetFKVar() const noexcept @@ -77,7 +78,7 @@ public: bool EvaluateFilter(ScriptFrame& frame) const; static void AddRule(const String& sourceType, const String& targetType, const String& name, const Expression::Ptr& expression, - const Expression::Ptr& filter, const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm, + const Expression::Ptr& filter, const String& zone, const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope); static const std::vector& GetRules(const Type::Ptr& sourceType, const Type::Ptr& targetType); static const std::set& GetTargetedHostRules(const Type::Ptr& sourceType, const String& host); @@ -97,6 +98,7 @@ private: String m_Name; Expression::Ptr m_Expression; Expression::Ptr m_Filter; + String m_Zone; String m_Package; String m_FKVar; String m_FVVar; @@ -117,7 +119,7 @@ private: static const Value * GetConst(Expression* exp, const Dictionary::Ptr& constants); ApplyRule(String name, Expression::Ptr expression, - Expression::Ptr filter, String package, String fkvar, String fvvar, Expression::Ptr fterm, + Expression::Ptr filter, String zone, String package, String fkvar, String fvvar, Expression::Ptr fterm, bool ignoreOnError, DebugInfo di, Dictionary::Ptr scope); }; diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index 939681e68..7a8e8d4f9 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -1221,7 +1221,7 @@ apply: std::unique_ptr fterm{context->m_FTerm.top()}; context->m_FTerm.pop(); - $$ = new ApplyExpression(std::move(type), std::move(target), std::unique_ptr($4), std::move(filter), context->GetPackage(), std::move(fkvar), std::move(fvvar), std::move(fterm), std::move(*$7), $8, std::unique_ptr($10), DebugInfoRange(@2, @8)); + $$ = new ApplyExpression(std::move(type), std::move(target), std::unique_ptr($4), std::move(filter), context->GetZone(), context->GetPackage(), std::move(fkvar), std::move(fvvar), std::move(fterm), std::move(*$7), $8, std::unique_ptr($10), DebugInfoRange(@2, @8)); delete $7; } ; diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index 09b860cde..a20e3acdf 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -915,7 +915,7 @@ ExpressionResult ApplyExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhin ExpressionResult nameres = m_Name->Evaluate(frame); CHECK_RESULT(nameres); - return VMOps::NewApply(frame, m_Type, m_Target, nameres.GetValue(), m_Filter, + return VMOps::NewApply(frame, m_Type, m_Target, nameres.GetValue(), m_Filter, m_Zone, m_Package, m_FKVar, m_FVVar, m_FTerm, m_ClosedVars, m_IgnoreOnError, m_Expression, m_DebugInfo); } diff --git a/lib/config/expression.hpp b/lib/config/expression.hpp index 644548d28..5cde480ed 100644 --- a/lib/config/expression.hpp +++ b/lib/config/expression.hpp @@ -830,11 +830,11 @@ class ApplyExpression final : public DebuggableExpression { public: ApplyExpression(String type, String target, std::unique_ptr name, - std::unique_ptr filter, String package, String fkvar, String fvvar, + std::unique_ptr filter, String zone, String package, String fkvar, String fvvar, std::unique_ptr fterm, std::map >&& closedVars, bool ignoreOnError, std::unique_ptr expression, const DebugInfo& debugInfo = DebugInfo()) : DebuggableExpression(debugInfo), m_Type(std::move(type)), m_Target(std::move(target)), - m_Name(std::move(name)), m_Filter(filter.release()), m_Package(std::move(package)), m_FKVar(std::move(fkvar)), m_FVVar(std::move(fvvar)), + m_Name(std::move(name)), m_Filter(filter.release()), m_Zone(std::move(zone)), m_Package(std::move(package)), m_FKVar(std::move(fkvar)), m_FVVar(std::move(fvvar)), m_FTerm(fterm.release()), m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)), m_Expression(expression.release()) { } @@ -847,6 +847,7 @@ private: String m_Target; std::unique_ptr m_Name; Expression::Ptr m_Filter; + String m_Zone; String m_Package; String m_FKVar; String m_FVVar; diff --git a/lib/config/vmops.hpp b/lib/config/vmops.hpp index ea3098359..53e19dae6 100644 --- a/lib/config/vmops.hpp +++ b/lib/config/vmops.hpp @@ -115,11 +115,11 @@ public: return new Function(name, wrapper, argNames); } - static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const Expression::Ptr& filter, + static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const Expression::Ptr& filter, const String& zone, const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm, const std::map >& closedVars, bool ignoreOnError, const Expression::Ptr& expression, const DebugInfo& debugInfo = DebugInfo()) { - ApplyRule::AddRule(type, target, name, expression, filter, package, fkvar, + ApplyRule::AddRule(type, target, name, expression, filter, zone, package, fkvar, fvvar, fterm, ignoreOnError, debugInfo, EvaluateClosedVars(frame, closedVars)); return Empty;