summaryrefslogtreecommitdiff
path: root/inc/lib/Twig/Node/Expression/Function.php
diff options
context:
space:
mode:
authorczaks <marcin@6irc.net>2013-08-05 06:03:40 -0400
committerczaks <marcin@6irc.net>2013-08-05 06:03:40 -0400
commita84c4510fccfdc0cfb6f187633daea10dc70f326 (patch)
tree6077f5211196ae40cac0184bb7cc67b81d320b0b /inc/lib/Twig/Node/Expression/Function.php
parent33c7abf11f3a9b5c0964a2d7a25533c2849dbc78 (diff)
parenta8327c3a37fd22d2aa5d63061c9d3eaa30ae425a (diff)
Merge branch 'master' of github.com:vichan-devel/Tinyboard
Conflicts: js/post-hider.js
Diffstat (limited to 'inc/lib/Twig/Node/Expression/Function.php')
-rw-r--r--inc/lib/Twig/Node/Expression/Function.php38
1 files changed, 12 insertions, 26 deletions
diff --git a/inc/lib/Twig/Node/Expression/Function.php b/inc/lib/Twig/Node/Expression/Function.php
index 3f457199..3e1f6b55 100644
--- a/inc/lib/Twig/Node/Expression/Function.php
+++ b/inc/lib/Twig/Node/Expression/Function.php
@@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-class Twig_Node_Expression_Function extends Twig_Node_Expression
+class Twig_Node_Expression_Function extends Twig_Node_Expression_Call
{
public function __construct($name, Twig_NodeInterface $arguments, $lineno)
{
@@ -17,33 +17,19 @@ class Twig_Node_Expression_Function extends Twig_Node_Expression
public function compile(Twig_Compiler $compiler)
{
- $function = $compiler->getEnvironment()->getFunction($this->getAttribute('name'));
- if (false === $function) {
- throw new Twig_Error_Syntax(sprintf('The function "%s" does not exist', $this->getAttribute('name')), $this->getLine());
- }
-
- $compiler
- ->raw($function->compile().'(')
- ->raw($function->needsEnvironment() ? '$this->env' : '')
- ;
-
- if ($function->needsContext()) {
- $compiler->raw($function->needsEnvironment() ? ', $context' : '$context');
- }
+ $name = $this->getAttribute('name');
+ $function = $compiler->getEnvironment()->getFunction($name);
- $first = true;
- foreach ($this->getNode('arguments') as $node) {
- if (!$first) {
- $compiler->raw(', ');
- } else {
- if ($function->needsEnvironment() || $function->needsContext()) {
- $compiler->raw(', ');
- }
- $first = false;
- }
- $compiler->subcompile($node);
+ $this->setAttribute('name', $name);
+ $this->setAttribute('type', 'function');
+ $this->setAttribute('thing', $function);
+ $this->setAttribute('needs_environment', $function->needsEnvironment());
+ $this->setAttribute('needs_context', $function->needsContext());
+ $this->setAttribute('arguments', $function->getArguments());
+ if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) {
+ $this->setAttribute('callable', $function->getCallable());
}
- $compiler->raw(')');
+ $this->compileCallable($compiler);
}
}