From 5a0e34b4f8da22e1830ec7d0a730c3686665bceb Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Fri, 8 Feb 2008 14:25:52 -0600 Subject: Refactoring the AST classes just a bit. I realized that all of the evaluate() methods only ever accepted a scope, and sometimes one other option, so I switched them all to use named arguments instead of a hash. --- lib/puppet/parser/ast/astarray.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/puppet/parser/ast/astarray.rb') diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb index 5f1e838d0..b66fd6bba 100644 --- a/lib/puppet/parser/ast/astarray.rb +++ b/lib/puppet/parser/ast/astarray.rb @@ -15,8 +15,7 @@ class Puppet::Parser::AST end # Evaluate our children. - def evaluate(hash) - scope = hash[:scope] + def evaluate(scope) rets = nil # We basically always operate declaratively, and when we # do we need to evaluate the settor-like statements first. This @@ -51,7 +50,7 @@ class Puppet::Parser::AST } rets = [settors, others].flatten.collect { |child| - child.safeevaluate(:scope => scope) + child.safeevaluate(scope) } return rets.reject { |o| o.nil? } end -- cgit From fd1573fdb696803deb7a220d6bfd06b8afff55fb Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 28 Feb 2008 17:21:35 -0600 Subject: Fixed #1047 -- Puppet's parser no longer changes the order in which statements are evaluated, which means that case statements can now set variables that are used by other variables. --- lib/puppet/parser/ast/astarray.rb | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'lib/puppet/parser/ast/astarray.rb') diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb index b66fd6bba..8f09aa922 100644 --- a/lib/puppet/parser/ast/astarray.rb +++ b/lib/puppet/parser/ast/astarray.rb @@ -16,16 +16,6 @@ class Puppet::Parser::AST # Evaluate our children. def evaluate(scope) - rets = nil - # We basically always operate declaratively, and when we - # do we need to evaluate the settor-like statements first. This - # is basically variable and type-default declarations. - # This is such a stupid hack. I've no real idea how to make a - # "real" declarative language, so I hack it so it looks like - # one, yay. - settors = [] - others = [] - # Make a new array, so we don't have to deal with the details of # flattening and such items = [] @@ -34,22 +24,14 @@ class Puppet::Parser::AST @children.each { |child| if child.instance_of?(AST::ASTArray) child.each do |ac| - if ac.class.settor? - settors << ac - else - others << ac - end + items << ac end else - if child.class.settor? - settors << child - else - others << child - end + items << child end } - rets = [settors, others].flatten.collect { |child| + rets = items.flatten.collect { |child| child.safeevaluate(scope) } return rets.reject { |o| o.nil? } -- cgit