diff options
Diffstat (limited to 'public/system/library/template/Twig/Node/Expression/Binary')
25 files changed, 524 insertions, 0 deletions
diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Add.php b/public/system/library/template/Twig/Node/Expression/Binary/Add.php new file mode 100644 index 0000000..0ef8e11 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Add.php @@ -0,0 +1,18 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * (c) 2009 Armin Ronacher + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Add extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('+'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/And.php b/public/system/library/template/Twig/Node/Expression/Binary/And.php new file mode 100644 index 0000000..d5752eb --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/And.php @@ -0,0 +1,18 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * (c) 2009 Armin Ronacher + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_And extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('&&'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/BitwiseAnd.php b/public/system/library/template/Twig/Node/Expression/Binary/BitwiseAnd.php new file mode 100644 index 0000000..9a46d84 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/BitwiseAnd.php @@ -0,0 +1,18 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * (c) 2009 Armin Ronacher + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_BitwiseAnd extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('&'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/BitwiseOr.php b/public/system/library/template/Twig/Node/Expression/Binary/BitwiseOr.php new file mode 100644 index 0000000..058a20b --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/BitwiseOr.php @@ -0,0 +1,18 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * (c) 2009 Armin Ronacher + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_BitwiseOr extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('|'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/BitwiseXor.php b/public/system/library/template/Twig/Node/Expression/Binary/BitwiseXor.php new file mode 100644 index 0000000..f4da73d --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/BitwiseXor.php @@ -0,0 +1,18 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * (c) 2009 Armin Ronacher + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_BitwiseXor extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('^'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Concat.php b/public/system/library/template/Twig/Node/Expression/Binary/Concat.php new file mode 100644 index 0000000..f9a6462 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Concat.php @@ -0,0 +1,18 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * (c) 2009 Armin Ronacher + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Concat extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('.'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Div.php b/public/system/library/template/Twig/Node/Expression/Binary/Div.php new file mode 100644 index 0000000..e0797a6 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Div.php @@ -0,0 +1,18 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * (c) 2009 Armin Ronacher + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Div extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('/'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/EndsWith.php b/public/system/library/template/Twig/Node/Expression/Binary/EndsWith.php new file mode 100644 index 0000000..93b3b96 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/EndsWith.php @@ -0,0 +1,30 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2013 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_EndsWith extends Twig_Node_Expression_Binary +{ + public function compile(Twig_Compiler $compiler) + { + $left = $compiler->getVarName(); + $right = $compiler->getVarName(); + $compiler + ->raw(sprintf('(is_string($%s = ', $left)) + ->subcompile($this->getNode('left')) + ->raw(sprintf(') && is_string($%s = ', $right)) + ->subcompile($this->getNode('right')) + ->raw(sprintf(') && (\'\' === $%2$s || $%2$s === substr($%1$s, -strlen($%2$s))))', $left, $right)) + ; + } + + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw(''); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Equal.php b/public/system/library/template/Twig/Node/Expression/Binary/Equal.php new file mode 100644 index 0000000..7b1236d --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Equal.php @@ -0,0 +1,17 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2010 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Equal extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('=='); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/FloorDiv.php b/public/system/library/template/Twig/Node/Expression/Binary/FloorDiv.php new file mode 100644 index 0000000..b606f6d --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/FloorDiv.php @@ -0,0 +1,24 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary +{ + public function compile(Twig_Compiler $compiler) + { + $compiler->raw('intval(floor('); + parent::compile($compiler); + $compiler->raw('))'); + } + + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('/'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Greater.php b/public/system/library/template/Twig/Node/Expression/Binary/Greater.php new file mode 100644 index 0000000..a110bd9 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Greater.php @@ -0,0 +1,17 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2010 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Greater extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('>'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/GreaterEqual.php b/public/system/library/template/Twig/Node/Expression/Binary/GreaterEqual.php new file mode 100644 index 0000000..3754fed --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/GreaterEqual.php @@ -0,0 +1,17 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2010 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_GreaterEqual extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('>='); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/In.php b/public/system/library/template/Twig/Node/Expression/Binary/In.php new file mode 100644 index 0000000..9565a60 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/In.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2010 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_In extends Twig_Node_Expression_Binary +{ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->raw('twig_in_filter(') + ->subcompile($this->getNode('left')) + ->raw(', ') + ->subcompile($this->getNode('right')) + ->raw(')') + ; + } + + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('in'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Less.php b/public/system/library/template/Twig/Node/Expression/Binary/Less.php new file mode 100644 index 0000000..45fd300 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Less.php @@ -0,0 +1,17 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2010 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Less extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('<'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/LessEqual.php b/public/system/library/template/Twig/Node/Expression/Binary/LessEqual.php new file mode 100644 index 0000000..e38e257 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/LessEqual.php @@ -0,0 +1,17 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2010 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_LessEqual extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('<='); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Matches.php b/public/system/library/template/Twig/Node/Expression/Binary/Matches.php new file mode 100644 index 0000000..93bb292 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Matches.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2013 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Matches extends Twig_Node_Expression_Binary +{ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->raw('preg_match(') + ->subcompile($this->getNode('right')) + ->raw(', ') + ->subcompile($this->getNode('left')) + ->raw(')') + ; + } + + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw(''); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Mod.php b/public/system/library/template/Twig/Node/Expression/Binary/Mod.php new file mode 100644 index 0000000..9924114 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Mod.php @@ -0,0 +1,18 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * (c) 2009 Armin Ronacher + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Mod extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('%'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Mul.php b/public/system/library/template/Twig/Node/Expression/Binary/Mul.php new file mode 100644 index 0000000..c91529c --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Mul.php @@ -0,0 +1,18 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * (c) 2009 Armin Ronacher + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Mul extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('*'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/NotEqual.php b/public/system/library/template/Twig/Node/Expression/Binary/NotEqual.php new file mode 100644 index 0000000..26867ba --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/NotEqual.php @@ -0,0 +1,17 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2010 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_NotEqual extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('!='); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/NotIn.php b/public/system/library/template/Twig/Node/Expression/Binary/NotIn.php new file mode 100644 index 0000000..49ab39e --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/NotIn.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2010 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_NotIn extends Twig_Node_Expression_Binary +{ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->raw('!twig_in_filter(') + ->subcompile($this->getNode('left')) + ->raw(', ') + ->subcompile($this->getNode('right')) + ->raw(')') + ; + } + + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('not in'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Or.php b/public/system/library/template/Twig/Node/Expression/Binary/Or.php new file mode 100644 index 0000000..adba49c --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Or.php @@ -0,0 +1,18 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * (c) 2009 Armin Ronacher + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Or extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('||'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Power.php b/public/system/library/template/Twig/Node/Expression/Binary/Power.php new file mode 100644 index 0000000..cd6d046 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Power.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2010 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Power extends Twig_Node_Expression_Binary +{ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->raw('pow(') + ->subcompile($this->getNode('left')) + ->raw(', ') + ->subcompile($this->getNode('right')) + ->raw(')') + ; + } + + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('**'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Range.php b/public/system/library/template/Twig/Node/Expression/Binary/Range.php new file mode 100644 index 0000000..692ec9c --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Range.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2010 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Range extends Twig_Node_Expression_Binary +{ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->raw('range(') + ->subcompile($this->getNode('left')) + ->raw(', ') + ->subcompile($this->getNode('right')) + ->raw(')') + ; + } + + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('..'); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/StartsWith.php b/public/system/library/template/Twig/Node/Expression/Binary/StartsWith.php new file mode 100644 index 0000000..d2e30d6 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/StartsWith.php @@ -0,0 +1,30 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2013 Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_StartsWith extends Twig_Node_Expression_Binary +{ + public function compile(Twig_Compiler $compiler) + { + $left = $compiler->getVarName(); + $right = $compiler->getVarName(); + $compiler + ->raw(sprintf('(is_string($%s = ', $left)) + ->subcompile($this->getNode('left')) + ->raw(sprintf(') && is_string($%s = ', $right)) + ->subcompile($this->getNode('right')) + ->raw(sprintf(') && (\'\' === $%2$s || 0 === strpos($%1$s, $%2$s)))', $left, $right)) + ; + } + + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw(''); + } +} diff --git a/public/system/library/template/Twig/Node/Expression/Binary/Sub.php b/public/system/library/template/Twig/Node/Expression/Binary/Sub.php new file mode 100644 index 0000000..d446399 --- /dev/null +++ b/public/system/library/template/Twig/Node/Expression/Binary/Sub.php @@ -0,0 +1,18 @@ +<?php + +/* + * This file is part of Twig. + * + * (c) 2009 Fabien Potencier + * (c) 2009 Armin Ronacher + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class Twig_Node_Expression_Binary_Sub extends Twig_Node_Expression_Binary +{ + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('-'); + } +} |