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 | |
| 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')
| -rw-r--r-- | lib/puppet/parser/ast/astarray.rb | 7 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/caseopt.rb | 5 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/casestatement.rb | 9 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/classdef.rb | 31 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/compdef.rb | 26 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/component.rb | 51 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/hostclass.rb | 49 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/leaf.rb | 12 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/node.rb | 35 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/nodedef.rb | 7 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/objectdef.rb | 49 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/objectparam.rb | 7 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/objectref.rb | 7 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/selector.rb | 11 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/typedefaults.rb | 7 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/vardef.rb | 7 |
16 files changed, 201 insertions, 119 deletions
diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb index 1e7bdb81c..356258a96 100644 --- a/lib/puppet/parser/ast/astarray.rb +++ b/lib/puppet/parser/ast/astarray.rb @@ -15,7 +15,8 @@ class Puppet::Parser::AST end # Evaluate our children. - def evaluate(scope) + def evaluate(hash) + scope = hash[:scope] rets = nil # We basically always operate declaratively, and when we # do we need to evaluate the settor-like statements first. This @@ -35,12 +36,12 @@ class Puppet::Parser::AST end } rets = [settors,others].flatten.collect { |child| - child.safeevaluate(scope) + child.safeevaluate(:scope => scope) } else # If we're not declarative, just do everything in order. rets = @children.collect { |item| - item.safeevaluate(scope) + item.safeevaluate(:scope => scope) } end diff --git a/lib/puppet/parser/ast/caseopt.rb b/lib/puppet/parser/ast/caseopt.rb index 258f5081a..366b6e939 100644 --- a/lib/puppet/parser/ast/caseopt.rb +++ b/lib/puppet/parser/ast/caseopt.rb @@ -50,8 +50,9 @@ class Puppet::Parser::AST # Evaluate the actual statements; this only gets called if # our option matched. - def evaluate(scope) - return @statements.safeevaluate(scope.newscope) + def evaluate(hash) + scope = hash[:scope] + return @statements.safeevaluate(:scope => scope.newscope) end def tree(indent = 0) diff --git a/lib/puppet/parser/ast/casestatement.rb b/lib/puppet/parser/ast/casestatement.rb index cd87cfd08..e51cc7522 100644 --- a/lib/puppet/parser/ast/casestatement.rb +++ b/lib/puppet/parser/ast/casestatement.rb @@ -6,8 +6,9 @@ class Puppet::Parser::AST # Short-curcuit evaluation. Return the value of the statements for # the first option that matches. - def evaluate(scope) - value = @test.safeevaluate(scope) + def evaluate(hash) + scope = hash[:scope] + value = @test.safeevaluate(:scope => scope) retvalue = nil found = false @@ -16,7 +17,7 @@ class Puppet::Parser::AST @options.each { |option| if option.eachvalue { |opval| break true if opval == value } # we found a matching option - retvalue = option.safeevaluate(scope) + retvalue = option.safeevaluate(:scope => scope) found = true break end @@ -25,7 +26,7 @@ class Puppet::Parser::AST # Unless we found something, look for the default. unless found if defined? @default - retvalue = @default.safeevaluate(scope) + retvalue = @default.safeevaluate(:scope => scope) else Puppet.debug "No true answers and no default" end diff --git a/lib/puppet/parser/ast/classdef.rb b/lib/puppet/parser/ast/classdef.rb index 147ab88e5..0a6a86816 100644 --- a/lib/puppet/parser/ast/classdef.rb +++ b/lib/puppet/parser/ast/classdef.rb @@ -9,36 +9,37 @@ class Puppet::Parser::AST def each if @parentclass - #[@name,@args,@parentclass,@code].each { |child| yield child } - [@name,@parentclass,@code].each { |child| yield child } + #[@type,@args,@parentclass,@code].each { |child| yield child } + [@type,@parentclass,@code].each { |child| yield child } else - #[@name,@args,@code].each { |child| yield child } - [@name,@code].each { |child| yield child } + #[@type,@args,@code].each { |child| yield child } + [@type,@code].each { |child| yield child } end end - # Store our parse tree according to name. - def evaluate(scope) - name = @name.safeevaluate(scope) - #args = @args.safeevaluate(scope) + # Store our parse tree according to type. + def evaluate(hash) + scope = hash[:scope] + type = @type.safeevaluate(:scope => scope) + #args = @args.safeevaluate(:scope => scope) #:args => args, arghash = { - :name => name, + :type => type, :code => @code } if @parentclass - arghash[:parentclass] = @parentclass.safeevaluate(scope) + arghash[:parentclass] = @parentclass.safeevaluate(:scope => scope) end #Puppet.debug("defining hostclass '%s' with arguments [%s]" % - # [name,args]) + # [type,args]) begin hclass = HostClass.new(arghash) hclass.keyword = self.keyword - scope.settype(name, hclass) + scope.settype(type, hclass) rescue Puppet::ParseError => except except.line = self.line except.file = self.file @@ -61,7 +62,7 @@ class Puppet::Parser::AST def tree(indent = 0) #@args.tree(indent + 1), return [ - @name.tree(indent + 1), + @type.tree(indent + 1), ((@@indline * 4 * indent) + self.typewrap("class")), @parentclass ? @parentclass.tree(indent + 1) : "", @code.tree(indent + 1), @@ -70,8 +71,8 @@ class Puppet::Parser::AST def to_s return "class %s(%s) inherits %s {\n%s }" % - [@name, @parentclass, @code] - #[@name, @args, @parentclass, @code] + [@type, @parentclass, @code] + #[@type, @args, @parentclass, @code] end end diff --git a/lib/puppet/parser/ast/compdef.rb b/lib/puppet/parser/ast/compdef.rb index 07eda339e..f1b947ec4 100644 --- a/lib/puppet/parser/ast/compdef.rb +++ b/lib/puppet/parser/ast/compdef.rb @@ -9,25 +9,26 @@ class Puppet::Parser::AST # encounter an error if the component is instantiated more than # once. class CompDef < AST::Branch - attr_accessor :name, :args, :code, :keyword + attr_accessor :type, :args, :code, :keyword def each - [@name,@args,@code].each { |child| yield child } + [@type,@args,@code].each { |child| yield child } end # Store the parse tree. - def evaluate(scope) - name = @name.safeevaluate(scope) - args = @args.safeevaluate(scope) + def evaluate(hash) + scope = hash[:scope] + type = @type.safeevaluate(:scope => scope) + args = @args.safeevaluate(:scope => scope) begin comp = AST::Component.new( - :name => name, + :type => type, :args => args, :code => @code ) comp.keyword = self.keyword - scope.settype(name, comp) + scope.settype(type, comp) rescue Puppet::ParseError => except except.line = self.line except.file = self.file @@ -48,12 +49,17 @@ class Puppet::Parser::AST @keyword = "define" super - #Puppet.debug "Defining type %s" % @name.value + #if @parentclass + # Puppet.notice "Parent class of %s is %s" % + # [@type.value, @parentclass.value] + #end + + #Puppet.debug "Defining type %s" % @type.value end def tree(indent = 0) return [ - @name.tree(indent + 1), + @type.tree(indent + 1), ((@@indline * 4 * indent) + self.typewrap("define")), @args.tree(indent + 1), @code.tree(indent + 1), @@ -61,7 +67,7 @@ class Puppet::Parser::AST end def to_s - return "define %s(%s) {\n%s }" % [@name, @args, @code] + return "define %s(%s) {\n%s }" % [@type, @args, @code] end end end diff --git a/lib/puppet/parser/ast/component.rb b/lib/puppet/parser/ast/component.rb index 858ef86f6..aa29624fd 100644 --- a/lib/puppet/parser/ast/component.rb +++ b/lib/puppet/parser/ast/component.rb @@ -10,20 +10,35 @@ class Puppet::Parser::AST # The class name @name = :component - attr_accessor :name, :args, :code, :scope, :autoname, :keyword - - def evaluate(scope,hash,objtype,objname) - scope = scope.newscope + attr_accessor :type, :args, :code, :scope, :autoname, :keyword + + #def evaluate(scope,hash,objtype,objname) + def evaluate(hash) + scope = hash[:scope] + objtype = hash[:type] + objname = hash[:name] + arguments = hash[:arguments] || {} + + scope = scope.newscope( + :type => @type, + :name => objname, + :keyword => self.keyword, + :autoname => self.autoname + ) + if hash[:newcontext] + #scope.warning "Setting context to %s" % self.object_id + scope.context = self.object_id + end @scope = scope # The type is the component or class name - scope.type = objtype + #scope.type = objtype # The name is the name the user has chosen or that has # been dynamically generated. This is almost never used - scope.name = objname + #scope.name = objname - scope.keyword = self.keyword + #scope.keyword = self.keyword # Retain the fact that we were autonamed, if so if self.autoname @@ -36,9 +51,10 @@ class Puppet::Parser::AST # Additionally, add a tag for whatever kind of class # we are - scope.tag(objtype) + scope.tag(@type) - unless objname =~ /-\d+/ # it was generated + unless objname.nil? + #Puppet.info "tagging with %s" % objname.inspect scope.tag(objname) end #scope.base = self.class.name @@ -46,21 +62,20 @@ class Puppet::Parser::AST # define all of the arguments in our local scope if self.args - # Verify that all required arguments are either present or # have been provided with defaults. # FIXME This should probably also require each parent # class's arguments... self.args.each { |arg, default| - unless hash.include?(arg) + unless arguments.include?(arg) if defined? default and ! default.nil? - hash[arg] = default + arguments[arg] = default #Puppet.debug "Got default %s for %s in %s" % # [default.inspect, arg.inspect, objname.inspect] else error = Puppet::ParseError.new( "Must pass %s to %s of type %s" % - [arg.inspect,name,objtype] + [arg.inspect,objname,@type] ) error.line = self.line error.file = self.file @@ -72,10 +87,10 @@ class Puppet::Parser::AST # Set each of the provided arguments as variables in the # component's scope. - hash["name"] = objname - hash.each { |arg,value| + arguments["name"] = objname + arguments.each { |arg,value| begin - scope.setvar(arg,hash[arg]) + scope.setvar(arg,arguments[arg]) rescue Puppet::ParseError => except except.line = self.line except.file = self.file @@ -94,7 +109,7 @@ class Puppet::Parser::AST } # Now just evaluate the code with our new bindings. - self.code.safeevaluate(scope) + self.code.safeevaluate(:scope => scope) # We return the scope, so that our children can make their scopes # under ours. This allows them to find our definitions. @@ -120,7 +135,7 @@ class Puppet::Parser::AST if found # It's a valid arg for us return true - elsif @parentclass + elsif defined? @parentclass and @parentclass # Else, check any existing parent parent = @scope.lookuptype(@parentclass) if parent and parent != [] diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb index d6b323fb7..3952cd4dc 100644 --- a/lib/puppet/parser/ast/hostclass.rb +++ b/lib/puppet/parser/ast/hostclass.rb @@ -6,26 +6,45 @@ class Puppet::Parser::AST @name = :class attr_accessor :parentclass - def evaluate(scope,hash,objtype,objname) + #def evaluate(scope,hash,objtype,objname) + def evaluate(hash) + scope = hash[:scope] + objtype = hash[:type] + objname = hash[:name] + hash = hash[:arguments] # Verify that we haven't already been evaluated # FIXME The second subclass won't evaluate the parent class # code at all, and any overrides will throw an error. if scope.lookupclass(self.object_id) - Puppet.debug "%s class already evaluated" % @name + Puppet.debug "%s class already evaluated" % @type return nil end - if tmp = self.evalparent(scope, hash, objname) + # Default to creating a new context + newcontext = true + if parentscope = self.evalparent( + :scope => scope, :arguments => hash, :name => objname + ) # Override our scope binding with the parent scope # binding. This is quite hackish, but I can't think # of another way to make sure our scopes end up under # our parent scopes. - scope = tmp + scope = parentscope + + # But don't create a new context if our parent created one + newcontext = false end # just use the Component evaluate method, but change the type # to our own type - retval = super(scope,hash,@name,objname) + #retval = super(scope,hash,@name,objname) + retval = super( + :scope => scope, + :arguments => hash, + :type => @type, + :name => objname, + :newcontext => newcontext + ) # Set the mark after we evaluate, so we don't record it but # then encounter an error @@ -36,8 +55,14 @@ class Puppet::Parser::AST # Evaluate our parent class. Parent classes are evaluated in the # exact same scope as the children. This is maybe not a good idea # but, eh. - def evalparent(scope, args, name) + #def evalparent(scope, args, name) + def evalparent(hash) + scope = hash[:scope] + args = hash[:arguments] + name = hash[:name] if @parentclass + #scope.warning "parent class of %s is %s" % + # [@type, @parentclass.inspect] parentobj = nil begin @@ -65,13 +90,21 @@ class Puppet::Parser::AST unless parentobj.class == self.class error = Puppet::ParseError.new( "Class %s has incompatible parent type, %s vs %s" % - [@name, parentobj.class, self.class] + [@type, parentobj.class, self.class] ) error.file = self.file error.line = self.line raise error end - return parentobj.safeevaluate(scope,args,@parentclass,name) + # We don't need to pass the type, because the parent will just + # use its own type + return parentobj.safeevaluate( + :scope => scope, + :arguments => args, + :name => name + ) + else + return false end end diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb index 5d70460ae..b0f9cca04 100644 --- a/lib/puppet/parser/ast/leaf.rb +++ b/lib/puppet/parser/ast/leaf.rb @@ -6,7 +6,7 @@ class Puppet::Parser::AST attr_accessor :value, :type # Return our value. - def evaluate(scope) + def evaluate(hash) return @value end @@ -44,8 +44,8 @@ class Puppet::Parser::AST class String < AST::Leaf # Interpolate the string looking for variables, and then return # the result. - def evaluate(scope) - return scope.strinterp(@value) + def evaluate(hash) + return hash[:scope].strinterp(@value) end end @@ -53,7 +53,7 @@ class Puppet::Parser::AST class FlatString < AST::Leaf # Interpolate the string looking for variables, and then return # the result. - def evaluate(scope) + def evaluate(hash) return @value end end @@ -74,9 +74,9 @@ class Puppet::Parser::AST class Variable < Name # Looks up the value of the object in the scope tree (does # not include syntactical constructs, like '$' and '{}'). - def evaluate(scope) + def evaluate(hash) begin - return scope.lookupvar(@value) + return hash[:scope].lookupvar(@value) rescue Puppet::ParseError => except except.line = self.line except.file = self.file 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 diff --git a/lib/puppet/parser/ast/nodedef.rb b/lib/puppet/parser/ast/nodedef.rb index da93069b2..d41eeecde 100644 --- a/lib/puppet/parser/ast/nodedef.rb +++ b/lib/puppet/parser/ast/nodedef.rb @@ -10,8 +10,9 @@ class Puppet::Parser::AST end # Do implicit iteration over each of the names passed. - def evaluate(scope) - names = @names.safeevaluate(scope) + def evaluate(hash) + scope = hash[:scope] + names = @names.safeevaluate(:scope => scope) unless names.is_a?(Array) names = [names] @@ -26,7 +27,7 @@ class Puppet::Parser::AST } if @parentclass - arghash[:parentclass] = @parentclass.safeevaluate(scope) + arghash[:parentclass] = @parentclass.safeevaluate(:scope => scope) end begin diff --git a/lib/puppet/parser/ast/objectdef.rb b/lib/puppet/parser/ast/objectdef.rb index e75b07ccb..4ed48d3a4 100644 --- a/lib/puppet/parser/ast/objectdef.rb +++ b/lib/puppet/parser/ast/objectdef.rb @@ -40,12 +40,13 @@ class Puppet::Parser::AST # Does not actually return an object; instead sets an object # in the current scope. - def evaluate(scope) + def evaluate(hash) + scope = hash[:scope] @scope = scope hash = {} # Get our type and name. - objtype = @type.safeevaluate(scope) + objtype = @type.safeevaluate(:scope => scope) # If the type was a variable, we wouldn't have typechecked yet. # Do it now, if so. @@ -70,17 +71,18 @@ class Puppet::Parser::AST end autonamed = false + objnames = [nil] # Autogenerate the name if one was not passed. - if defined? @name - objnames = @name.safeevaluate(scope) - else - objnames = self.autoname(objtype, object) - autonamed = true - end + if self.name + objnames = @name.safeevaluate(:scope => scope) + # it's easier to always use an array, even for only one name + unless objnames.is_a?(Array) + objnames = [objnames] + end + #else + # objnames = self.autoname(objtype, object) + # autonamed = true - # it's easier to always use an array, even for only one name - unless objnames.is_a?(Array) - objnames = [objnames] end # Retrieve the defaults for our type @@ -88,7 +90,7 @@ class Puppet::Parser::AST # then set all of the specified params @params.each { |param| - ary = param.safeevaluate(scope) + ary = param.safeevaluate(:scope => scope) hash[ary[0]] = ary[1] } @@ -99,6 +101,11 @@ class Puppet::Parser::AST # If the object is a class, that means it's a builtin type, so # we just store it in the scope unless object + unless objname + raise Puppet::ParseError, + "Object of type %s created with no name" % objtype + end + begin #Puppet.debug( # ("Setting object '%s' " + @@ -107,11 +114,11 @@ class Puppet::Parser::AST # [objname, scope.object_id, hash.inspect] #) obj = scope.setobject( - objtype, - objname, - hash, - @file, - @line + :type => objtype, + :name => objname, + :arguments => hash, + :file => @file, + :line => @line ) rescue Puppet::ParseError => except except.line = self.line @@ -129,7 +136,13 @@ class Puppet::Parser::AST # one of those, evaluate that with our arguments #Puppet.debug("Calling object '%s' with arguments %s" % # [object.name, hash.inspect]) - obj = object.safeevaluate(scope,hash,objtype,objname) + #obj = object.safeevaluate(scope,hash,objtype,objname) + obj = object.safeevaluate( + :scope => scope, + :arguments => hash, + :type => objtype, + :name => objname + ) # Retain any name generation stuff obj.autoname = autonamed diff --git a/lib/puppet/parser/ast/objectparam.rb b/lib/puppet/parser/ast/objectparam.rb index 41cd050ef..87c3e5e8e 100644 --- a/lib/puppet/parser/ast/objectparam.rb +++ b/lib/puppet/parser/ast/objectparam.rb @@ -8,9 +8,10 @@ class Puppet::Parser::AST end # Return the parameter and the value. - def evaluate(scope) - param = @param.safeevaluate(scope) - value = @value.safeevaluate(scope) + def evaluate(hash) + scope = hash[:scope] + param = @param.safeevaluate(:scope => scope) + value = @value.safeevaluate(:scope => scope) return [param, value] end diff --git a/lib/puppet/parser/ast/objectref.rb b/lib/puppet/parser/ast/objectref.rb index 6418c14fb..12e36360f 100644 --- a/lib/puppet/parser/ast/objectref.rb +++ b/lib/puppet/parser/ast/objectref.rb @@ -12,9 +12,10 @@ class Puppet::Parser::AST # Evaluate our object, but just return a simple array of the type # and name. - def evaluate(scope) - objtype = @type.safeevaluate(scope) - objnames = @name.safeevaluate(scope) + def evaluate(hash) + scope = hash[:scope] + objtype = @type.safeevaluate(:scope => scope) + objnames = @name.safeevaluate(:scope => scope) # it's easier to always use an array, even for only one name unless objnames.is_a?(Array) diff --git a/lib/puppet/parser/ast/selector.rb b/lib/puppet/parser/ast/selector.rb index 51d880ed9..299473fda 100644 --- a/lib/puppet/parser/ast/selector.rb +++ b/lib/puppet/parser/ast/selector.rb @@ -9,21 +9,22 @@ class Puppet::Parser::AST end # Find the value that corresponds with the test. - def evaluate(scope) + def evaluate(hash) + scope = hash[:scope] retvalue = nil found = nil # Get our parameter. - paramvalue = @param.safeevaluate(scope) + paramvalue = @param.safeevaluate(:scope => scope) default = nil # Then look for a match in the options. @values.each { |obj| - param = obj.param.safeevaluate(scope) + param = obj.param.safeevaluate(:scope => scope) if param == paramvalue # we found a matching option - retvalue = obj.value.safeevaluate(scope) + retvalue = obj.value.safeevaluate(:scope => scope) found = true break elsif obj.param.is_a?(Default) @@ -34,7 +35,7 @@ class Puppet::Parser::AST # Unless we found something, look for the default. unless found if default - retvalue = default.value.safeevaluate(scope) + retvalue = default.value.safeevaluate(:scope => scope) else error = Puppet::ParseError.new( "No value for selector param '%s'" % paramvalue diff --git a/lib/puppet/parser/ast/typedefaults.rb b/lib/puppet/parser/ast/typedefaults.rb index c1f8cce52..e6ffe7080 100644 --- a/lib/puppet/parser/ast/typedefaults.rb +++ b/lib/puppet/parser/ast/typedefaults.rb @@ -10,9 +10,10 @@ class Puppet::Parser::AST # As opposed to ObjectDef, this stores each default for the given # object type. - def evaluate(scope) - type = @type.safeevaluate(scope) - params = @params.safeevaluate(scope) + def evaluate(hash) + scope = hash[:scope] + type = @type.safeevaluate(:scope => scope) + params = @params.safeevaluate(:scope => scope) begin scope.setdefaults(type.downcase,params) diff --git a/lib/puppet/parser/ast/vardef.rb b/lib/puppet/parser/ast/vardef.rb index 52548a42c..4b1eb90d2 100644 --- a/lib/puppet/parser/ast/vardef.rb +++ b/lib/puppet/parser/ast/vardef.rb @@ -5,9 +5,10 @@ class Puppet::Parser::AST # Look up our name and value, and store them appropriately. The # lexer strips off the syntax stuff like '$'. - def evaluate(scope) - name = @name.safeevaluate(scope) - value = @value.safeevaluate(scope) + def evaluate(hash) + scope = hash[:scope] + name = @name.safeevaluate(:scope => scope) + value = @value.safeevaluate(:scope => scope) begin scope.setvar(name,value) |
