summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-03 19:38:15 -0500
committerLuke Kanies <luke@madstop.com>2007-09-03 19:38:15 -0500
commit0faf76ee187c7fa7c67a7fb7e7c345897006b7d8 (patch)
tree21b680c617e869b11579172ab9aac33518db68da /lib/puppet/parser/ast
parent9d70b9746c09f648efd6a315b3ea088da38ecd1e (diff)
More refactoring. I have removed a few more extraneous methods from Scope, mostly just pointing directly to the compile, and I have begun (but commented out) the move to having resources to model each of the classes and nodes, in addition to the definitions. This will, again, enable a real Configuration object, and it will enable class versioning and similar features.
Diffstat (limited to 'lib/puppet/parser/ast')
-rw-r--r--lib/puppet/parser/ast/definition.rb18
-rw-r--r--lib/puppet/parser/ast/hostclass.rb8
-rw-r--r--lib/puppet/parser/ast/node.rb10
-rw-r--r--lib/puppet/parser/ast/resourceoverride.rb2
4 files changed, 25 insertions, 13 deletions
diff --git a/lib/puppet/parser/ast/definition.rb b/lib/puppet/parser/ast/definition.rb
index cd59da8af..c350c2cdb 100644
--- a/lib/puppet/parser/ast/definition.rb
+++ b/lib/puppet/parser/ast/definition.rb
@@ -32,7 +32,7 @@ class Puppet::Parser::AST
resource = options[:resource]
# Create a new scope.
- scope = subscope(origscope, resource.title)
+ scope = subscope(origscope, resource)
scope.virtual = true if resource.virtual or origscope.virtual?
scope.exported = true if resource.exported or origscope.exported?
@@ -125,14 +125,22 @@ class Puppet::Parser::AST
end
# Create a new subscope in which to evaluate our code.
- def subscope(scope, name = nil)
+ def subscope(scope, resource = nil)
+ if resource
+ type = resource.type
+ else
+ type = self.classname
+ end
args = {
- :type => self.classname,
+ :resource => resource,
+ :type => type,
:keyword => self.keyword,
- :namespace => self.namespace
+ :namespace => self.namespace,
+ :source => self
}
- args[:name] = name if name
+ args[:name] = resource.title if resource
+
oldscope = scope
scope = scope.newscope(args)
scope.source = self
diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb
index 8959dc900..41ca34432 100644
--- a/lib/puppet/parser/ast/hostclass.rb
+++ b/lib/puppet/parser/ast/hostclass.rb
@@ -24,7 +24,7 @@ class Puppet::Parser::AST
scope = options[:scope]
# Verify that we haven't already been evaluated. This is
# what provides the singleton aspect.
- if existing_scope = scope.class_scope(self)
+ if existing_scope = scope.compile.class_scope(self)
Puppet.debug "%s class already evaluated" % @type
return nil
end
@@ -38,7 +38,7 @@ class Puppet::Parser::AST
end
unless options[:nosubscope]
- scope = subscope(scope)
+ scope = subscope(scope, options[:resource])
end
if pnames
@@ -49,7 +49,7 @@ class Puppet::Parser::AST
# Set the class before we do anything else, so that it's set
# during the evaluation and can be inspected.
- scope.setclass(self)
+ scope.compile.class_set(self.classname, scope)
# Now evaluate our code, yo.
if self.code
@@ -65,7 +65,7 @@ class Puppet::Parser::AST
end
def parent_scope(scope, klass)
- if s = scope.class_scope(klass)
+ if s = scope.compile.class_scope(klass)
return s
else
raise Puppet::DevError, "Could not find scope for %s" % klass.fqname
diff --git a/lib/puppet/parser/ast/node.rb b/lib/puppet/parser/ast/node.rb
index 695c15f42..d46df3cff 100644
--- a/lib/puppet/parser/ast/node.rb
+++ b/lib/puppet/parser/ast/node.rb
@@ -33,7 +33,7 @@ class Puppet::Parser::AST
# Mark our node name as a class, too, but strip it of the domain
# name. Make the mark before we evaluate the code, so that it is
# marked within the code itself.
- scope.setclass(self)
+ scope.compile.class_set(self.classname, scope)
# And then evaluate our code if we have any
if self.code
@@ -53,6 +53,12 @@ class Puppet::Parser::AST
end
end
+ # Make sure node scopes are marked as such.
+ def subscope(*args)
+ scope = super
+ scope.nodescope = true
+ end
+
private
# Search for the object matching our parent class.
def find_parentclass
@@ -60,5 +66,3 @@ class Puppet::Parser::AST
end
end
end
-
-# $Id$
diff --git a/lib/puppet/parser/ast/resourceoverride.rb b/lib/puppet/parser/ast/resourceoverride.rb
index 26d69ae97..418c9c8e4 100644
--- a/lib/puppet/parser/ast/resourceoverride.rb
+++ b/lib/puppet/parser/ast/resourceoverride.rb
@@ -44,7 +44,7 @@ class Puppet::Parser::AST
# Now we tell the scope that it's an override, and it behaves as
# necessary.
- scope.setoverride(obj)
+ scope.compile.store_override(obj)
obj
end