diff options
Diffstat (limited to 'inc/Twig/Node/Expression/Binary')
22 files changed, 461 insertions, 0 deletions
diff --git a/inc/Twig/Node/Expression/Binary/Add.php b/inc/Twig/Node/Expression/Binary/Add.php new file mode 100644 index 00000000..0ef8e117 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/Add.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Add extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('+'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/And.php b/inc/Twig/Node/Expression/Binary/And.php new file mode 100644 index 00000000..d5752ebb --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/And.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_And extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('&&'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/BitwiseAnd.php b/inc/Twig/Node/Expression/Binary/BitwiseAnd.php new file mode 100644 index 00000000..9a46d845 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/BitwiseAnd.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_BitwiseAnd extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('&'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/BitwiseOr.php b/inc/Twig/Node/Expression/Binary/BitwiseOr.php new file mode 100644 index 00000000..058a20bf --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/BitwiseOr.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_BitwiseOr extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('|'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/BitwiseXor.php b/inc/Twig/Node/Expression/Binary/BitwiseXor.php new file mode 100644 index 00000000..f4da73d4 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/BitwiseXor.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_BitwiseXor extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('^'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/Concat.php b/inc/Twig/Node/Expression/Binary/Concat.php new file mode 100644 index 00000000..f9a64627 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/Concat.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Concat extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('.'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/Div.php b/inc/Twig/Node/Expression/Binary/Div.php new file mode 100644 index 00000000..e0797a61 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/Div.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Div extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('/'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/Equal.php b/inc/Twig/Node/Expression/Binary/Equal.php new file mode 100644 index 00000000..7b1236d0 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/Equal.php | |||
@@ -0,0 +1,17 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | class Twig_Node_Expression_Binary_Equal extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | public function operator(Twig_Compiler $compiler) | ||
14 | { | ||
15 | return $compiler->raw('=='); | ||
16 | } | ||
17 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/FloorDiv.php b/inc/Twig/Node/Expression/Binary/FloorDiv.php new file mode 100644 index 00000000..7fbd0556 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/FloorDiv.php | |||
@@ -0,0 +1,29 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | /** | ||
14 | * Compiles the node to PHP. | ||
15 | * | ||
16 | * @param Twig_Compiler A Twig_Compiler instance | ||
17 | */ | ||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $compiler->raw('intval(floor('); | ||
21 | parent::compile($compiler); | ||
22 | $compiler->raw('))'); | ||
23 | } | ||
24 | |||
25 | public function operator(Twig_Compiler $compiler) | ||
26 | { | ||
27 | return $compiler->raw('/'); | ||
28 | } | ||
29 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/Greater.php b/inc/Twig/Node/Expression/Binary/Greater.php new file mode 100644 index 00000000..a110bd92 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/Greater.php | |||
@@ -0,0 +1,17 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | class Twig_Node_Expression_Binary_Greater extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | public function operator(Twig_Compiler $compiler) | ||
14 | { | ||
15 | return $compiler->raw('>'); | ||
16 | } | ||
17 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/GreaterEqual.php b/inc/Twig/Node/Expression/Binary/GreaterEqual.php new file mode 100644 index 00000000..3754fed2 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/GreaterEqual.php | |||
@@ -0,0 +1,17 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | class Twig_Node_Expression_Binary_GreaterEqual extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | public function operator(Twig_Compiler $compiler) | ||
14 | { | ||
15 | return $compiler->raw('>='); | ||
16 | } | ||
17 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/In.php b/inc/Twig/Node/Expression/Binary/In.php new file mode 100644 index 00000000..788f9377 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/In.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | class Twig_Node_Expression_Binary_In extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | /** | ||
14 | * Compiles the node to PHP. | ||
15 | * | ||
16 | * @param Twig_Compiler A Twig_Compiler instance | ||
17 | */ | ||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $compiler | ||
21 | ->raw('twig_in_filter(') | ||
22 | ->subcompile($this->getNode('left')) | ||
23 | ->raw(', ') | ||
24 | ->subcompile($this->getNode('right')) | ||
25 | ->raw(')') | ||
26 | ; | ||
27 | } | ||
28 | |||
29 | public function operator(Twig_Compiler $compiler) | ||
30 | { | ||
31 | return $compiler->raw('in'); | ||
32 | } | ||
33 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/Less.php b/inc/Twig/Node/Expression/Binary/Less.php new file mode 100644 index 00000000..45fd3004 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/Less.php | |||
@@ -0,0 +1,17 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | class Twig_Node_Expression_Binary_Less extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | public function operator(Twig_Compiler $compiler) | ||
14 | { | ||
15 | return $compiler->raw('<'); | ||
16 | } | ||
17 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/LessEqual.php b/inc/Twig/Node/Expression/Binary/LessEqual.php new file mode 100644 index 00000000..e38e257c --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/LessEqual.php | |||
@@ -0,0 +1,17 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | class Twig_Node_Expression_Binary_LessEqual extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | public function operator(Twig_Compiler $compiler) | ||
14 | { | ||
15 | return $compiler->raw('<='); | ||
16 | } | ||
17 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/Mod.php b/inc/Twig/Node/Expression/Binary/Mod.php new file mode 100644 index 00000000..9924114f --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/Mod.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Mod extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('%'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/Mul.php b/inc/Twig/Node/Expression/Binary/Mul.php new file mode 100644 index 00000000..c91529ca --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/Mul.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Mul extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('*'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/NotEqual.php b/inc/Twig/Node/Expression/Binary/NotEqual.php new file mode 100644 index 00000000..26867ba2 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/NotEqual.php | |||
@@ -0,0 +1,17 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | class Twig_Node_Expression_Binary_NotEqual extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | public function operator(Twig_Compiler $compiler) | ||
14 | { | ||
15 | return $compiler->raw('!='); | ||
16 | } | ||
17 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/NotIn.php b/inc/Twig/Node/Expression/Binary/NotIn.php new file mode 100644 index 00000000..f347b7b6 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/NotIn.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | class Twig_Node_Expression_Binary_NotIn extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | /** | ||
14 | * Compiles the node to PHP. | ||
15 | * | ||
16 | * @param Twig_Compiler A Twig_Compiler instance | ||
17 | */ | ||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $compiler | ||
21 | ->raw('!twig_in_filter(') | ||
22 | ->subcompile($this->getNode('left')) | ||
23 | ->raw(', ') | ||
24 | ->subcompile($this->getNode('right')) | ||
25 | ->raw(')') | ||
26 | ; | ||
27 | } | ||
28 | |||
29 | public function operator(Twig_Compiler $compiler) | ||
30 | { | ||
31 | return $compiler->raw('not in'); | ||
32 | } | ||
33 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/Or.php b/inc/Twig/Node/Expression/Binary/Or.php new file mode 100644 index 00000000..adba49c6 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/Or.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Or extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('||'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/Power.php b/inc/Twig/Node/Expression/Binary/Power.php new file mode 100644 index 00000000..b2c59040 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/Power.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | class Twig_Node_Expression_Binary_Power extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | /** | ||
14 | * Compiles the node to PHP. | ||
15 | * | ||
16 | * @param Twig_Compiler A Twig_Compiler instance | ||
17 | */ | ||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $compiler | ||
21 | ->raw('pow(') | ||
22 | ->subcompile($this->getNode('left')) | ||
23 | ->raw(', ') | ||
24 | ->subcompile($this->getNode('right')) | ||
25 | ->raw(')') | ||
26 | ; | ||
27 | } | ||
28 | |||
29 | public function operator(Twig_Compiler $compiler) | ||
30 | { | ||
31 | return $compiler->raw('**'); | ||
32 | } | ||
33 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/Range.php b/inc/Twig/Node/Expression/Binary/Range.php new file mode 100644 index 00000000..bea4f2a6 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/Range.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | class Twig_Node_Expression_Binary_Range extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | /** | ||
14 | * Compiles the node to PHP. | ||
15 | * | ||
16 | * @param Twig_Compiler A Twig_Compiler instance | ||
17 | */ | ||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $compiler | ||
21 | ->raw('range(') | ||
22 | ->subcompile($this->getNode('left')) | ||
23 | ->raw(', ') | ||
24 | ->subcompile($this->getNode('right')) | ||
25 | ->raw(')') | ||
26 | ; | ||
27 | } | ||
28 | |||
29 | public function operator(Twig_Compiler $compiler) | ||
30 | { | ||
31 | return $compiler->raw('..'); | ||
32 | } | ||
33 | } | ||
diff --git a/inc/Twig/Node/Expression/Binary/Sub.php b/inc/Twig/Node/Expression/Binary/Sub.php new file mode 100644 index 00000000..d4463991 --- /dev/null +++ b/inc/Twig/Node/Expression/Binary/Sub.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Sub extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('-'); | ||
17 | } | ||
18 | } | ||