From f2c68b5a3132edd176f07536f05c45b4241c10e7 Mon Sep 17 00:00:00 2001 From: Eduar Carvajal Date: Mon, 25 Nov 2013 18:47:18 -0500 Subject: [PATCH] Add GetClassNsOptimizer.php --- .../FunctionCall/GetClassNsOptimizer.php | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Library/Optimizers/FunctionCall/GetClassNsOptimizer.php diff --git a/Library/Optimizers/FunctionCall/GetClassNsOptimizer.php b/Library/Optimizers/FunctionCall/GetClassNsOptimizer.php new file mode 100644 index 00000000000..5e58156fed0 --- /dev/null +++ b/Library/Optimizers/FunctionCall/GetClassNsOptimizer.php @@ -0,0 +1,66 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if ($symbolVariable->getType() != 'variable' && $symbolVariable->getType() != 'string') { + throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression); + } + + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + + $context->headersManager->add('kernel/string'); + + $symbolVariable->setDynamicTypes('string'); + + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + $context->codePrinter->output('zephir_get_class_ns(' . $symbolVariable->getName() . ', ' . $resolvedParams[0] . ', 0);'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } + +} \ No newline at end of file