From 9f86139b7604ea782a35e09bf9d0c55154197051 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Sat, 24 May 2014 13:07:19 +0200 Subject: Added ste:setlocal and refined test_scope. --- Transcompiler.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Transcompiler.php') 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 .", $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 .", $ast->tpl, $ast->offset); -- cgit v1.2.3-54-g00ecf