summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-02-22 12:10:19 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-02-22 12:10:19 +0000
commitfa02d67a9de63e457b122ccedf4fb329ee04949b (patch)
tree435176b0f24fd80a762c8da46fdbbe548a33f74c /lib/puppet
parentd145aae53ddf43de1a5140ce9226e1b2f383376f (diff)
downloadpuppet-fa02d67a9de63e457b122ccedf4fb329ee04949b.tar.gz
puppet-fa02d67a9de63e457b122ccedf4fb329ee04949b.tar.xz
puppet-fa02d67a9de63e457b122ccedf4fb329ee04949b.zip
Fixing #472. Apparently this has been broken since I did the parser redesign. I had to fix the scope trees so that subclass scopes are subscopes of the parent scopes, which used to be the case but was far more complicated.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2220 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parser/ast/component.rb2
-rw-r--r--lib/puppet/parser/ast/hostclass.rb18
-rw-r--r--lib/puppet/parser/scope.rb13
3 files changed, 27 insertions, 6 deletions
diff --git a/lib/puppet/parser/ast/component.rb b/lib/puppet/parser/ast/component.rb
index 1b14d508b..8f82d530a 100644
--- a/lib/puppet/parser/ast/component.rb
+++ b/lib/puppet/parser/ast/component.rb
@@ -39,7 +39,7 @@ class Puppet::Parser::AST
if exported or origscope.exported?
scope.exported = true
end
- scope = scope
+
# Additionally, add a tag for whatever kind of class
# we are
if @type != "" and ! @type.nil?
diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb
index 4a4664f0f..65dd27542 100644
--- a/lib/puppet/parser/ast/hostclass.rb
+++ b/lib/puppet/parser/ast/hostclass.rb
@@ -33,19 +33,21 @@ class Puppet::Parser::AST
if @parentclass
if pklass = self.parentclass
pklass.safeevaluate :scope => scope
+
+ scope = parent_scope(scope, pklass)
else
parsefail "Could not find class %s" % @parentclass
end
end
- # Set the class before we do anything else, so that it's set
- # during the evaluation and can be inspected.
- scope.setclass(self)
-
unless hash[:nosubscope]
scope = subscope(scope)
end
+ # Set the class before we do anything else, so that it's set
+ # during the evaluation and can be inspected.
+ scope.setclass(self)
+
# Now evaluate our code, yo.
if self.code
return self.code.evaluate(:scope => scope)
@@ -58,6 +60,14 @@ class Puppet::Parser::AST
@parentclass = nil
super
end
+
+ def parent_scope(scope, klass)
+ if s = scope.class_scope(klass)
+ return s
+ else
+ raise Puppet::DevError, "Could not find scope for %s" % klass.fqname
+ end
+ end
end
end
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index 12a3c3430..83a8d8d7f 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -108,6 +108,17 @@ class Puppet::Parser::Scope
return true
end
+ # Return the scope associated with a class. This is just here so
+ # that subclasses can set their parent scopes to be the scope of
+ # their parent class.
+ def class_scope(klass)
+ if klass.respond_to?(:fqname)
+ @classtable[klass.fqname]
+ else
+ @classtable[klass]
+ end
+ end
+
# Return the list of collections.
def collections
@collecttable
@@ -411,7 +422,7 @@ class Puppet::Parser::Scope
raise Puppet::DevError, "Got a %s with no fully qualified name" %
obj.class
end
- @classtable[obj.fqname] = obj
+ @classtable[obj.fqname] = self
else
raise Puppet::DevError, "Invalid class %s" % obj.inspect
end