summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/scope.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/scope.rb')
-rw-r--r--lib/puppet/parser/scope.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index f800c38ec..bff1f24a0 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -475,6 +475,7 @@ module Puppet::Parser
hash[:declarative] = true
end
self.istop(hash[:declarative])
+ @inside = nil
else
# This is here, rather than in newchild(), so that all
# of the later variable initialization works.
@@ -484,6 +485,7 @@ module Puppet::Parser
@interp = @parent.interp
@topscope = @parent.topscope
@context = @parent.context
+ @inside = @parent.inside
end
# Our child scopes and objects
@@ -525,6 +527,19 @@ module Puppet::Parser
}
end
+ # Associate the object directly with the scope, so that contained objects
+ # can look up what container they're running within.
+ def inside(arg = nil)
+ return @inside unless arg
+
+ old = @inside
+ @inside = arg
+ yield
+ ensure
+ #Puppet.warning "exiting %s" % @inside.name
+ @inside = old
+ end
+
# Mark that we're the top scope, and set some hard-coded info.
def istop(declarative = true)
# the level is mostly used for debugging
@@ -797,6 +812,12 @@ module Puppet::Parser
# Define our type.
def settype(name,ltype)
+ unless name
+ raise Puppet::DevError, "Got told to set type with a nil type"
+ end
+ unless ltype
+ raise Puppet::DevError, "Got told to set type with a nil object"
+ end
# Don't let them redefine the class in this scope.
if @typetable.include?(name)
raise Puppet::ParseError,