Skip to content

Commit

Permalink
Merge pull request #1585 from phalcon/development
Browse files Browse the repository at this point in the history
0.10.1
  • Loading branch information
sergeyklay authored Oct 10, 2017
2 parents a788fb1 + a30c5c1 commit 312fa08
Show file tree
Hide file tree
Showing 33 changed files with 82 additions and 46 deletions.
1 change: 1 addition & 0 deletions Library/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir;

use Zephir\Compiler\CompilerException;
use Zephir\Detectors\ReadDetector;

/**
Expand Down
1 change: 1 addition & 0 deletions Library/ClassConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir;

use Zephir\Compiler\CompilerException;
use Zephir\Expression\Constants;

/**
Expand Down
1 change: 1 addition & 0 deletions Library/ClassDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use Zephir\Documentation\Docblock;
use Zephir\Documentation\DocblockParser;
use Zephir\Compiler\CompilerException;

/**
* ClassDefinition
Expand Down
3 changes: 2 additions & 1 deletion Library/ClassMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir;

use Zephir\Compiler\CompilerException;
use Zephir\Passes\LocalContextPass;
use Zephir\Passes\StaticTypeInference;
use Zephir\Passes\CallGathererPass;
Expand Down Expand Up @@ -370,7 +371,7 @@ public function setIsInitializer($initializer)
/**
* Returns the class definition where the method was declared
*
* @return ClassDefinition
* @return ClassDefinition|null
*/
public function getClassDefinition()
{
Expand Down
2 changes: 2 additions & 0 deletions Library/ClassMethodParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Zephir;

use Zephir\Compiler\CompilerException;

/**
* ClassMethodParameters
*
Expand Down
1 change: 1 addition & 0 deletions Library/ClassProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir;

use Zephir\Compiler\CompilerException;
use Zephir\Expression\Builder\Statements\LetStatement as ExpressionLetStatement;
use Zephir\Expression\Builder\BuilderFactory;
use Zephir\Expression\Builder\Operators\BinaryOperator;
Expand Down
9 changes: 0 additions & 9 deletions Library/Commands/CommandHelp.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@
*/
class CommandHelp extends CommandAbstract
{
const LOGO = '
_____ __ _
/__ / ___ ____ / /_ (_)____
/ / / _ \/ __ \/ __ \/ / ___/
/ /__/ __/ /_/ / / / / / /
/____/\___/ .___/_/ /_/_/_/
/_/
';

/**
* {@inheritdoc}
*
Expand Down
9 changes: 5 additions & 4 deletions Library/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
class Compiler
{
const VERSION = '0.10.0';
const VERSION = '0.10.1';

public $parserCompiled = false;

Expand Down Expand Up @@ -1151,7 +1151,7 @@ public function stubs(CommandInterface $command, $fromGenerate = false)
* @param CommandInterface $command
* @param boolean $development
*
* @throws Exception
* @throws CompilerException
*/
public function install(CommandInterface $command, $development = false)
{
Expand Down Expand Up @@ -2014,14 +2014,13 @@ public function generateFunctionInformation()
/**
* Create argument info
*/

foreach ($this->functionDefinitions as $func) {
$funcName = $func->getInternalName();
$argInfoName = 'arginfo_' . strtolower($funcName);

$headerPrinter->output('PHP_FUNCTION(' . $funcName . ');');
$parameters = $func->getParameters();
if (count($parameters)) {
if (count($parameters->getParameters())) {
$headerPrinter->output(
'ZEND_BEGIN_ARG_INFO_EX(' . $argInfoName . ', 0, 0, ' .
$func->getNumberOfRequiredParameters() . ')'
Expand All @@ -2040,7 +2039,9 @@ public function generateFunctionInformation()
if (isset($parameter['cast'])) {
switch ($parameter['cast']['type']) {
case 'variable':
$compilationContext = $func->getCallGathererPass()->getCompilationContext();
$value = $parameter['cast']['value'];

$headerPrinter->output(
"\t" . 'ZEND_ARG_OBJ_INFO(0, ' .
$parameter['name'] . ', ' .
Expand Down
5 changes: 3 additions & 2 deletions Library/CompilerFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Zephir\Parser\ParseException;
use Zephir\Compiler\FileInterface;
use Zephir\Compiler\CompilerException;
use Zephir\Documentation\DocblockParser;
use Zephir\Exception\IllegalStateException;

Expand Down Expand Up @@ -592,7 +593,7 @@ public function preCompile(Compiler $compiler)
/**
* Compilation context stores common objects required by compilation entities
*/
$compilationContext = new CompilationContext;
$compilationContext = new CompilationContext();

/**
* Set global compiler in the compilation context
Expand Down Expand Up @@ -832,7 +833,7 @@ public function compile(Compiler $compiler, StringsManager $stringsManager)
/**
* Compilation context stores common objects required by compilation entities
*/
$compilationContext = new CompilationContext;
$compilationContext = new CompilationContext();

/**
* Set global compiler in the compilation context
Expand Down
2 changes: 1 addition & 1 deletion Library/CompilerFileAnonymous.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function compile(Compiler $compiler, StringsManager $stringsManager)
/**
* Compilation context stores common objects required by compilation entities
*/
$compilationContext = new CompilationContext;
$compilationContext = new CompilationContext();

/**
* Set global compiler in the compilation context
Expand Down
1 change: 1 addition & 0 deletions Library/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir;

use Zephir\Compiler\CompilerException;
use Zephir\Operators\Arithmetical\AddOperator;
use Zephir\Operators\Arithmetical\SubOperator;
use Zephir\Operators\Arithmetical\MulOperator;
Expand Down
2 changes: 1 addition & 1 deletion Library/Expression/PropertyAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function setNoisy($noisy)
*
* @param array $expression
* @param CompilationContext $compilationContext
* @return \CompiledExpression
* @return CompiledExpression
*/
public function compile($expression, CompilationContext $compilationContext)
{
Expand Down
2 changes: 1 addition & 1 deletion Library/Expression/PropertyDynamicAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function setNoisy($noisy)
*
* @param array $expression
* @param CompilationContext $compilationContext
* @return \CompiledExpression
* @return CompiledExpression
*/
public function compile($expression, CompilationContext $compilationContext)
{
Expand Down
1 change: 1 addition & 0 deletions Library/Expression/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace Zephir\Expression;

use Zephir\Exception;
use Zephir\GlobalConstant;
use Zephir\Variable;
use Zephir\CompilationContext;
use Zephir\CompiledExpression;
Expand Down
1 change: 1 addition & 0 deletions Library/Expression/StaticPropertyAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir\Expression;

use Zephir\ClassProperty;
use Zephir\Variable;
use Zephir\CompilationContext;
use Zephir\CompiledExpression;
Expand Down
2 changes: 1 addition & 1 deletion Library/FileSystem/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function isInitialized()
*/
public function initialize()
{
$this->redis = new \Redis;
$this->redis = new \Redis();
$this->redis->connect('127.0.0.1', 6379);
$this->initialized = true;
}
Expand Down
1 change: 1 addition & 0 deletions Library/FunctionCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir;

use Zephir\Compiler\CompilerException;
use Zephir\Optimizers\OptimizerAbstract;

/**
Expand Down
2 changes: 2 additions & 0 deletions Library/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace Zephir;

use Zephir\Compiler\CompilerException;

/**
* Logger
*
Expand Down
1 change: 1 addition & 0 deletions Library/MethodCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir;

use Zephir\Compiler\CompilerException;
use Zephir\Detectors\ReadDetector;

/**
Expand Down
3 changes: 1 addition & 2 deletions Library/Operators/Unary/MinusOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ class MinusOperator extends BaseOperator
* @param CompilationContext $compilationContext
* @return CompiledExpression
* @throws CompilerException
* @throws Exception
*/
public function compile($expression, CompilationContext $compilationContext)
{
if (!isset($expression['left'])) {
throw new \Exception("Missing left part of the expression");
throw new CompilerException("Missing left part of the expression");
}

$leftExpr = new Expression($expression['left']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Zephir\Call;
use Zephir\CompilationContext;
use Zephir\CompiledExpression;
use Zephir\Compiler\CompilerException;
use Zephir\Optimizers\OptimizerAbstract;

/**
Expand Down
40 changes: 23 additions & 17 deletions Library/Passes/CallGathererPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,38 @@

/*
+--------------------------------------------------------------------------+
| Zephir Language |
+--------------------------------------------------------------------------+
| Copyright (c) 2013-2017 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 |
| Zephir |
| Copyright (c) 2013-present Zephir (https://zephir-lang.com/) |
| |
| 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. |
| 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 |
+--------------------------------------------------------------------------+
*/
*/

namespace Zephir\Passes;

use Zephir\StatementsBlock;
use Zephir\FunctionCall;
use Zephir\StatementsBlock;
use Zephir\CompilationContext;

/**
* CallGathererPass
* Zephir\Passes\CallGathererPass
*
* This pass counts how many times the same function is called inside a
* statements block. It also count how many times a method is calling
* trying to track the possible caller.
*
* This pass is used by the function/method caches to explore possible
* optimizations by implementing inline caches.
*
* @package Zephir\Passes
*/
class CallGathererPass
{
protected $functionCalls = array();
protected $functionCalls = [];

protected $methodCalls = array();
protected $methodCalls = [];

protected $compilationContext;

Expand All @@ -51,6 +47,16 @@ public function __construct(CompilationContext $compilationContext)
$this->compilationContext = $compilationContext;
}

/**
* Gets current CompilationContext.
*
* @return CompilationContext
*/
public function getCompilationContext()
{
return $this->compilationContext;
}

/**
* Returns the number of calls a function had
*
Expand Down Expand Up @@ -83,7 +89,7 @@ public function getNumberOfMethodCalls($className, $methodName)
/**
* Returns all the method calls
*
* @return int
* @return array
*/
public function getAllMethodCalls()
{
Expand Down
4 changes: 2 additions & 2 deletions Library/Statements/ForStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ForStatement extends StatementAbstract
* Compiles a for statement that use a 'range' as expression
*
* @param array $exprRaw
* @param \CompilationContext $compilationContext
* @param CompilationContext $compilationContext
* @return boolean
*/
public function compileRange($exprRaw, CompilationContext $compilationContext)
Expand Down Expand Up @@ -403,7 +403,7 @@ public function compileRange($exprRaw, CompilationContext $compilationContext)
* Compiles a 'for' statement that use an 'iterator' as expression
*
* @param array $exprRaw
* @param \CompilationContext $compilationContext
* @param CompilationContext $compilationContext
* @return boolean
*/
public function compileIterator(array $exprRaw, CompilationContext $compilationContext)
Expand Down
1 change: 1 addition & 0 deletions Library/Statements/Let/StaticProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir\Statements\Let;

use Zephir\ClassProperty;
use Zephir\CompilationContext;
use Zephir\Compiler\CompilerException;
use Zephir\Expression;
Expand Down
1 change: 1 addition & 0 deletions Library/Statements/Let/StaticPropertyAppend.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir\Statements\Let;

use Zephir\ClassProperty;
use Zephir\CompilationContext;
use Zephir\Compiler\CompilerException;
use Zephir\CompiledExpression;
Expand Down
1 change: 1 addition & 0 deletions Library/Statements/Let/StaticPropertyArrayIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir\Statements\Let;

use Zephir\ClassProperty;
use Zephir\CompilationContext;
use Zephir\Compiler\CompilerException;
use Zephir\Expression;
Expand Down
1 change: 1 addition & 0 deletions Library/Statements/Let/StaticPropertyArrayIndexAppend.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir\Statements\Let;

use Zephir\ClassProperty;
use Zephir\CompilationContext;
use Zephir\Compiler\CompilerException;
use Zephir\Expression;
Expand Down
1 change: 1 addition & 0 deletions Library/StaticCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir;

use Zephir\Compiler\CompilerException;
use Zephir\Detectors\ReadDetector;

/**
Expand Down
1 change: 1 addition & 0 deletions Library/SymbolTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Zephir;

use Zephir\Compiler\CompilerException;
use Zephir\Variable\Globals;
use Zephir\Passes\LocalContextPass;

Expand Down
Loading

0 comments on commit 312fa08

Please sign in to comment.