/** * @override */ function obfuscate(array &$names) { // Obfuscate all function names first, in case a function is called before it is defined $Funcs = $this->get_nodes_by_symbol(J_FUNC_DECL, 1); foreach ($Funcs as $Func) { // Function declaration always has identifier as second child $Identifier = $Func->get_child(1); if ($Identifier instanceof JIdentifierNode) { $Identifier->__obfuscate($names); } } // continue as per default parent::obfuscate($names); // now we can recurse with function names in scope // careful with &refs as we need to isolate the name spaces foreach ($Funcs as $i => $Func) { $scope = $names; $Func->obfuscate($scope); } // Handle function Expressions which could be at any depth foreach ($this->get_nodes_by_symbol(J_FUNC_EXPR) as $Func) { $scope = $names; $Func->obfuscate($scope); } }
/** * @override */ function format_lines(&$line, array &$lines) { $Node = $this->reset(); do { $Node->format_lines($line, $lines); } while (($Node = $this->next()) && !$Node->is_symbol(J_FUNC_BODY)); // at body, break after "{" JNodeBase::format_newline('', $line, $lines); $funclines = array(); $Node->format_lines($line, $funclines); // indent function lines foreach ($funclines as $funcline) { $lines[] = "\t" . $funcline; } // close body // only break after declarations if ($this->is_symbol(J_FUNC_EXPR)) { $line .= '} '; } else { if ($line) { JNodeBase::format_newline('', $line, $lines); } JNodeBase::format_newline('}', $line, $lines); } }
/** * @override */ function format_lines(&$line, array &$lines) { foreach ($this->children as $Node) { if ($Node->is_symbol(':')) { $line = rtrim($line, ' '); JNodeBase::format_newline(':', $line, $lines); } else { $Node->format_lines($line, $lines); } } }
/** * @override */ function format_lines(&$line, array &$lines) { $Node = $this->reset(); // it could be a new constructor if ($Node->is_symbol(J_NEW)) { return parent::format_lines($line, $lines); } // Else it is a member chain, no whitespace ? do { $Node->format_lines($line, $lines); $line = trim($line); } while ($Node = $this->next()); $line .= ' '; }
/** * @override */ function format_lines(&$line, array &$lines) { $Block = $this->get_child(1); if (!$Block->is_symbol(J_STATEMENT_LIST)) { JNodeBase::format_newline('{ }', $line, $lines); return; } // else collect block statement JNodeBase::format_newline('{', $line, $lines); $blocklines = array(); $Block->format_lines($line, $blocklines); // indent block foreach ($blocklines as $blockline) { $lines[] = "\t" . $blockline; } if ($line) { JNodeBase::format_newline('', $line, $lines); } JNodeBase::format_newline('}', $line, $lines); }
/** * @override */ function format_lines(&$line, array &$lines) { foreach ($this->children as $Node) { if ($Node->is_symbol('{')) { JNodeBase::format_newline('{', $line, $lines); } else { if ($Node->is_symbol('}')) { if ($line) { JNodeBase::format_newline('', $line, $lines); } JNodeBase::format_newline('}', $line, $lines); } else { // ident case blocks $blocklines = array(); $Node->format_lines($line, $blocklines); foreach ($blocklines as $blockline) { $lines[] = "\t" . $blockline; } } } } }
/** * @override */ function evaluate() { return parent::evaluate(); }