From 37c10d176d8d3b7bb1920bbda66c6f0429b66730 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 27 Feb 2006 07:10:01 +0000 Subject: Switching setclass to use object_ids instead of class names, and adding some comments. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@951 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/parser/ast/hostclass.rb | 7 +++++-- lib/puppet/parser/scope.rb | 13 +++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb index a5a228716..d6b323fb7 100644 --- a/lib/puppet/parser/ast/hostclass.rb +++ b/lib/puppet/parser/ast/hostclass.rb @@ -7,7 +7,10 @@ class Puppet::Parser::AST attr_accessor :parentclass def evaluate(scope,hash,objtype,objname) - if scope.lookupclass(@name) + # 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 return nil end @@ -26,7 +29,7 @@ class Puppet::Parser::AST # Set the mark after we evaluate, so we don't record it but # then encounter an error - scope.setclass(@name) + scope.setclass(self.object_id) return retval end diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index 641a05758..3d1d690f5 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -530,13 +530,15 @@ module Puppet return Puppet::Parser::Scope.new(self) end - # Store the fact that we've evaluated a given class. - # FIXME Shouldn't setclass actually store the code, not just a boolean? - def setclass(klass) + # Store the fact that we've evaluated a given class. We use a hash + # that gets inherited from the nodescope down, rather than a global + # hash. We store the object ID, not class name, so that we + # can support multiple unrelated classes with the same name. + def setclass(id) if self.nodescope? or self.topscope? - @classtable[klass] = true + @classtable[id] = true else - @parent.setclass(klass) + @parent.setclass(id) end end @@ -578,7 +580,6 @@ module Puppet end # Return an interpolated string. - # FIXME We do not yet support a non-interpolated string. def strinterp(string) newstring = string.dup regex = Regexp.new('\$\{(\w+)\}|\$(\w+)') -- cgit