diff options
Diffstat (limited to 'src/ste/VariableNode.php')
-rw-r--r-- | src/ste/VariableNode.php | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/ste/VariableNode.php b/src/ste/VariableNode.php index 5fd59ff..18bb6a4 100644 --- a/src/ste/VariableNode.php +++ b/src/ste/VariableNode.php @@ -3,23 +3,23 @@ namespace kch42\ste; class VariableNode extends ASTNode { - public $name; - public $arrayfields = array(); - public function transcompile() { - $varaccess = '@$ste->scope[' . (is_numeric($this->name) ? $this->name : '"' . Misc::escape_text($this->name) . '"'). ']'; - foreach($this->arrayfields as $af) { - if((count($af) == 1) and ($af[0] instanceof TextNode) and is_numeric($af[0]->text)) { - $varaccess .= '[' . $af->text . ']'; - } else { - $varaccess .= '[' . implode(".", array_map(function($node) { - if($node instanceof TextNode) { - return "\"" . Misc::escape_text($node->text) . "\""; - } else if($node instanceof VariableNode) { - return $node->transcompile(); - } - }, $af)). ']'; - } - } - return $varaccess; - } + public $name; + public $arrayfields = array(); + public function transcompile() { + $varaccess = '@$ste->scope[' . (is_numeric($this->name) ? $this->name : '"' . Misc::escape_text($this->name) . '"'). ']'; + foreach($this->arrayfields as $af) { + if((count($af) == 1) and ($af[0] instanceof TextNode) and is_numeric($af[0]->text)) { + $varaccess .= '[' . $af->text . ']'; + } else { + $varaccess .= '[' . implode(".", array_map(function($node) { + if($node instanceof TextNode) { + return "\"" . Misc::escape_text($node->text) . "\""; + } else if($node instanceof VariableNode) { + return $node->transcompile(); + } + }, $af)). ']'; + } + } + return $varaccess; + } } |