summaryrefslogtreecommitdiff
path: root/Transcompiler.php
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2014-05-24 13:07:19 +0200
committerKevin Chabowski <kevin@kch42.de>2014-05-24 13:07:19 +0200
commit9f86139b7604ea782a35e09bf9d0c55154197051 (patch)
treeee1202b8539a177f3c240d1fd2c898d7f259ef5e /Transcompiler.php
parentf7ddc264d832d163494904da67ca96856335487b (diff)
downloadste-9f86139b7604ea782a35e09bf9d0c55154197051.tar.gz
ste-9f86139b7604ea782a35e09bf9d0c55154197051.tar.bz2
ste-9f86139b7604ea782a35e09bf9d0c55154197051.zip
Added ste:setlocal and refined test_scope.
Diffstat (limited to 'Transcompiler.php')
-rw-r--r--Transcompiler.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/Transcompiler.php b/Transcompiler.php
index b92663c..8f3213b 100644
--- a/Transcompiler.php
+++ b/Transcompiler.php
@@ -336,6 +336,21 @@ class Transcompiler {
return $code;
},
+ "setlocal" => function($ast) {
+ if(empty($ast->params["var"])) {
+ throw new ParseCompileError("self::Transcompile Error: var missing in <ste:set>.", $ast->tpl, $ast->offset);
+ }
+
+ $code = "\$outputstack[] = '';\n\$outputstack_i++;\n";
+ $code .= self::_transcompile($ast->sub);
+ $code .= "\$outputstack_i--;\n";
+
+ list($val, $pre) = self::_transcompile($ast->params["var"], true);
+ $code .= $pre;
+ $code .= "\$ste->set_local_var(" . $val . ", array_pop(\$outputstack));\n";
+
+ return $code;
+ },
"get" => function($ast) {
if(empty($ast->params["var"])) {
throw new ParseCompileError("self::Transcompile Error: var missing in <ste:get>.", $ast->tpl, $ast->offset);