Bridges to one Pops Model Expression The @value is the expression This is used to represent the body of a class, definition, or node, and for each parameter’s default value expression.
The 3x requires code plugged in to an AST to have this in certain positions in the tree. The purpose is to either print the content, or to look for things that needs to be defined. This implementation cheats by always returning an empty array. (This allows simple files to not require a “Program” at the top.
# File lib/puppet/parser/ast/pops_bridge.rb, line 59 def children [] end
Adapts to 3x where top level constructs needs to have each to iterate over children. Short circuit this by yielding self. By adding this there is no need to wrap a pops expression inside an AST::BlockExpression
# File lib/puppet/parser/ast/pops_bridge.rb, line 39 def each yield self end
# File lib/puppet/parser/ast/pops_bridge.rb, line 31 def evaluate(scope) object = @@evaluator.evaluate(scope, @value) @@evaluator.convert_to_3x(object, scope) end
# File lib/puppet/parser/ast/pops_bridge.rb, line 43 def sequence_with(other) if value.nil? # This happens when testing and not having a complete setup other else # When does this happen ? Ever ? raise "sequence_with called on Puppet::Parser::AST::PopsBridge::Expression - please report use case" # What should be done if the above happens (We don't want this to happen). # Puppet::Parser::AST::BlockExpression.new(:children => [self] + other.children) end end
# File lib/puppet/parser/ast/pops_bridge.rb, line 26 def source_text source_adapter = Puppet::Pops::Utils.find_closest_positioned(@value) source_adapter ? source_adapter.extract_text() : nil end
# File lib/puppet/parser/ast/pops_bridge.rb, line 22 def to_s Puppet::Pops::Model::ModelTreeDumper.new.dump(@value) end
# File lib/puppet/parser/ast/pops_bridge.rb, line 17 def initialize args super @@evaluator ||= Puppet::Pops::Parser::EvaluatingParser.new() end