diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-27 22:21:44 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-27 22:21:44 +0000 |
commit | 8c821c09eebe117bd8b100b6dc416ded0588b979 (patch) | |
tree | aacd4fb7d966eae215917e5556e9e08eeb43bc53 /lib/puppet/parser/ast/node.rb | |
parent | 37c10d176d8d3b7bb1920bbda66c6f0429b66730 (diff) | |
download | puppet-8c821c09eebe117bd8b100b6dc416ded0588b979.tar.gz puppet-8c821c09eebe117bd8b100b6dc416ded0588b979.tar.xz puppet-8c821c09eebe117bd8b100b6dc416ded0588b979.zip |
Mostly, this is a refactoring commit. There is one significant new feature,
though: overrides now only work within a class heirarchy, which is to say that
a subclass can override an element in a base class, but a child scope cannot
otherwise override an element in a base scope.
I've also done a good bit of refactoring, though; notably, AST#evaluate now
takes named arguments, and I changed the 'name' parameter to 'type' in all of
the Component classes (this was all internal, but was confusing as it was).
I also removed the need for the autonaming stuff -- it's now acceptable for
components not to have names, and everything behaves correctly. I haven't yet
removed the autoname code, though; I'll do that on the next commit.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@952 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser/ast/node.rb')
-rw-r--r-- | lib/puppet/parser/ast/node.rb | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/lib/puppet/parser/ast/node.rb b/lib/puppet/parser/ast/node.rb index 2e33eb672..e8f4c5d87 100644 --- a/lib/puppet/parser/ast/node.rb +++ b/lib/puppet/parser/ast/node.rb @@ -5,18 +5,19 @@ class Puppet::Parser::AST @name = :node attr_accessor :name, :args, :code, :parentclass - def evaluate(scope, facts = {}) - scope = scope.newscope - + #def evaluate(scope, facts = {}) + def evaluate(hash) + scope = hash[:scope] + facts = hash[:facts] || {} # nodes are never instantiated like a normal object, # but we need the type to be the name users would use for # instantiation, otherwise tags don't work out - - # The name has already been evaluated, so it's a normal - # string. - scope.type = @name - scope.name = @name - scope.keyword = @keyword + scope = scope.newscope( + :type => @name, + :name => @name, + :keyword => @keyword + ) + scope.context = self.object_id # Mark this scope as a nodescope, so that classes will be # singletons within it @@ -40,7 +41,7 @@ class Puppet::Parser::AST #super(scope, facts, @name, @name) # And then evaluate our code. - @code.safeevaluate(scope) + @code.safeevaluate(:scope => scope) return scope end @@ -69,14 +70,18 @@ class Puppet::Parser::AST end node = hash[:node] - # Tag the scope with the parent's name/type. - name = node.name - #Puppet.info "Tagging with parent node %s" % name - scope.tag(name) + type = nil + if type = node.type + scope.tag(node.type) + end + + if name = node.name + scope.tag(node.name) unless name == type + end begin code = node.code - code.safeevaluate(scope) + code.safeevaluate(:scope => scope) rescue Puppet::ParseError => except except.line = self.line except.file = self.file |