diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-26 05:39:58 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-26 05:39:58 +0000 |
commit | 46ce36b175962ce89e06af4863d2c9dc50f2a02f (patch) | |
tree | aeff2dacfd81caddce54666e2d155e07b6ad09e8 /lib/puppet/parser/ast/astarray.rb | |
parent | ccc4d95dd28164f6f10763a758db85db0d48984c (diff) | |
download | puppet-46ce36b175962ce89e06af4863d2c9dc50f2a02f.tar.gz puppet-46ce36b175962ce89e06af4863d2c9dc50f2a02f.tar.xz puppet-46ce36b175962ce89e06af4863d2c9dc50f2a02f.zip |
Creating a simplistic, generic function framework in the parser, so it is now very easy to add new functions. There is a pretty crappy, hardwired distinction between functions that return values and those that do not, but I do not see a good way around it right now. Functions are also currently responsible for handling their own arity, although I have plans for fixing that.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1134 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser/ast/astarray.rb')
-rw-r--r-- | lib/puppet/parser/ast/astarray.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb index 356258a96..f8f88b816 100644 --- a/lib/puppet/parser/ast/astarray.rb +++ b/lib/puppet/parser/ast/astarray.rb @@ -22,20 +22,29 @@ class Puppet::Parser::AST # do we need to evaluate the settor-like statements first. This # is basically variable and type-default declarations. if scope.declarative? - test = [ - AST::VarDef, AST::TypeDefaults + # 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. + definelist = [ + AST::CompDef, AST::NodeDef, AST::ClassDef + ] + setlist = [ + AST::VarDef, AST::TypeDefaults, AST::Function ] + definers = [] settors = [] others = [] @children.each { |child| - if test.include?(child.class) - settors.push child + if definelist.include?(child.class) + definers << child + elsif setlist.include?(child.class) + settors << child else - others.push child + others << child end } - rets = [settors,others].flatten.collect { |child| + rets = [definers, settors, others].flatten.collect { |child| child.safeevaluate(:scope => scope) } else |