-
-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now exceptions thrown shows the Zephir file where they were generated
- Loading branch information
phalcon
committed
Apr 2, 2014
1 parent
86abc8b
commit aa09356
Showing
18 changed files
with
339 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
*/ | ||
class Compiler | ||
{ | ||
const VERSION = '0.4.0a'; | ||
const VERSION = '0.4.1a'; | ||
|
||
/** | ||
* @var CompilerFile[] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
Library/Optimizers/FunctionCall/UniquePathKeyOptimizer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
/* | ||
+--------------------------------------------------------------------------+ | ||
| Zephir Language | | ||
+--------------------------------------------------------------------------+ | ||
| Copyright (c) 2013-2014 Zephir Team and contributors | | ||
+--------------------------------------------------------------------------+ | ||
| This source file is subject the MIT license, that is bundled with | | ||
| this package in the file LICENSE, and is available through the | | ||
| world-wide-web at the following url: | | ||
| http://zephir-lang.com/license.html | | ||
| | | ||
| If you did not receive a copy of the MIT license and are unable | | ||
| to obtain it through the world-wide-web, please send a note to | | ||
| license@zephir-lang.com so we can mail you a copy immediately. | | ||
+--------------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Zephir\Optimizers\FunctionCall; | ||
|
||
use Zephir\Call; | ||
use Zephir\CompilationContext; | ||
use Zephir\CompilerException; | ||
use Zephir\CompiledExpression; | ||
use Zephir\Optimizers\OptimizerAbstract; | ||
|
||
/** | ||
* UniquePathKeyOptimizer | ||
* | ||
* Optimizes calls to 'unique_path_key' using internal function | ||
*/ | ||
class UniquePathKeyOptimizer extends OptimizerAbstract | ||
{ | ||
/** | ||
* @param array $expression | ||
* @param Call $call | ||
* @param CompilationContext $context | ||
* @return bool|CompiledExpression|mixed | ||
* @throws CompilerException | ||
*/ | ||
public function optimize(array $expression, Call $call, CompilationContext $context) | ||
{ | ||
if (!isset($expression['parameters'])) { | ||
return false; | ||
} | ||
|
||
if (count($expression['parameters']) != 1) { | ||
throw new CompilerException("'unique_path_key' only accepts three parameter"); | ||
} | ||
|
||
/** | ||
* Process the expected symbol to be returned | ||
*/ | ||
$call->processExpectedReturn($context); | ||
|
||
$symbolVariable = $call->getSymbolVariable(); | ||
if ($symbolVariable->isNotVariableAndString()) { | ||
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/file'); | ||
|
||
$resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); | ||
$context->codePrinter->output('zephir_unique_path_key(' . $symbolVariable->getName() . ', ' . $resolvedParams[0] . ' TSRMLS_CC);'); | ||
return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.