summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2008-11-15 13:22:26 +0100
committerJames Turnbull <james@lovedthanlost.net>2008-11-17 21:05:50 +1100
commit2c05a0abcb55347c179e66bb0c9d23698e729046 (patch)
tree0de423bda9b6cd03d7417f7a693c6aec800e25e8 /lib/puppet/parser/ast
parent064fb006a350e9555abe766c5cb4aeb803fd623a (diff)
downloadpuppet-2c05a0abcb55347c179e66bb0c9d23698e729046.tar.gz
puppet-2c05a0abcb55347c179e66bb0c9d23698e729046.tar.xz
puppet-2c05a0abcb55347c179e66bb0c9d23698e729046.zip
Move function existance test to parser evaluation
The aim is to let --parseonly succeeds even if the function is not (yet) present. This is usefull in commit-hooks and for the inline documentation generation system. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/parser/ast')
-rw-r--r--lib/puppet/parser/ast/function.rb28
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/puppet/parser/ast/function.rb b/lib/puppet/parser/ast/function.rb
index 192940a7a..fc3797f15 100644
--- a/lib/puppet/parser/ast/function.rb
+++ b/lib/puppet/parser/ast/function.rb
@@ -11,20 +11,9 @@ class Puppet::Parser::AST
@settor = true
def evaluate(scope)
- # We don't need to evaluate the name, because it's plaintext
- args = @arguments.safeevaluate(scope)
-
- return scope.send("function_" + @name, args)
- end
-
- def initialize(hash)
- @ftype = hash[:ftype] || :rvalue
- hash.delete(:ftype) if hash.include? :ftype
-
- super(hash)
# Make sure it's a defined function
- unless @fname = Puppet::Parser::Functions.function(@name)
+ unless @fname
raise Puppet::ParseError, "Unknown function %s" % @name
end
@@ -45,6 +34,21 @@ class Puppet::Parser::AST
raise Puppet::DevError, "Invalid function type %s" % @ftype.inspect
end
+
+
+ # We don't need to evaluate the name, because it's plaintext
+ args = @arguments.safeevaluate(scope)
+
+ return scope.send("function_" + @name, args)
+ end
+
+ def initialize(hash)
+ @ftype = hash[:ftype] || :rvalue
+ hash.delete(:ftype) if hash.include? :ftype
+
+ super(hash)
+
+ @fname = Puppet::Parser::Functions.function(@name)
# Lastly, check the parity
end
end