Skip to content

Commit

Permalink
Merge pull request #1592 from sergeyklay/development
Browse files Browse the repository at this point in the history
Deal with #1530
  • Loading branch information
sergeyklay committed Oct 29, 2017
2 parents 07c821e + 4af55a8 commit 075d4e9
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 98 deletions.
2 changes: 1 addition & 1 deletion Library/Backends/ZendEngine3/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ public function resolveValue($value, CompilationContext $context, $usePointer =
if ($value == 'null' || $value == 'true' || $value == 'false') {
$varName = '__$' . $value;
if (!$context->symbolTable->hasVariable($varName)) {
$tempVariable = new Variable('variable', $varName, $context->currentBranch);
$tempVariable = new Variable('variable', $varName, $context->branchManager->getCurrentBranch());
$context->symbolTable->addRawVariable($tempVariable);
}
$tempVariable = $context->symbolTable->getVariableForWrite($varName, $context);
Expand Down
9 changes: 7 additions & 2 deletions Library/BranchManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
*/
class BranchManager
{
/** @var Branch|null */
protected $currentBranch;

protected $level = 0;

protected $uniqueId = 1;

protected $rootBranch = null;
/** @var Branch|null */
protected $rootBranch;

/**
* Sets the current active branch in the manager
Expand Down Expand Up @@ -68,7 +70,7 @@ public function removeBranch(Branch $branch)
/**
* Returns the active branch in the manager
*
* @return Branch
* @return null|Branch
*/
public function getCurrentBranch()
{
Expand All @@ -85,6 +87,9 @@ public function setRootBranch(Branch $branch)
$this->rootBranch = $branch;
}

/**
* @return null|Branch
*/
public function getRootBranch()
{
return $this->rootBranch;
Expand Down
2 changes: 1 addition & 1 deletion Library/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ public function getReadOnlyResolvedParams($parameters, CompilationContext $compi
public function addCallStatusFlag(CompilationContext $compilationContext)
{
if (!$compilationContext->symbolTable->hasVariable('ZEPHIR_LAST_CALL_STATUS')) {
$callStatus = new Variable('int', 'ZEPHIR_LAST_CALL_STATUS', $compilationContext->currentBranch);
$callStatus = new Variable('int', 'ZEPHIR_LAST_CALL_STATUS', $compilationContext->branchManager->getCurrentBranch());
$callStatus->setIsInitialized(true, $compilationContext);
$callStatus->increaseUses();
$callStatus->setReadOnly(true);
Expand Down
27 changes: 14 additions & 13 deletions Library/ClassMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,20 @@ public function compile(CompilationContext $compilationContext)
$typeInference = $this->typeInference;
$callGathererPass = $this->callGathererPass;

/**
* Initialization of parameters happens in a fictitious external branch
*/
$branch = new Branch();
$branch->setType(Branch::TYPE_EXTERNAL);

/**
* BranchManager helps to create graphs of conditional/loop/root/jump branches
*/
$branchManager = new BranchManager();
$branchManager->addBranch($branch);

$compilationContext->branchManager = $branchManager;

/**
* Every method has its own symbol table
*/
Expand All @@ -1531,25 +1545,12 @@ public function compile(CompilationContext $compilationContext)
}
}

/**
* Initialization of parameters happens in a fictitious external branch
*/
$branch = new Branch();
$branch->setType(Branch::TYPE_EXTERNAL);

/**
* BranchManager helps to create graphs of conditional/loop/root/jump branches
*/
$branchManager = new BranchManager();
$branchManager->addBranch($branch);

/**
* Cache Manager manages function calls, method calls and class entries caches
*/
$cacheManager = new CacheManager();
$cacheManager->setGatherer($callGathererPass);

$compilationContext->branchManager = $branchManager;
$compilationContext->cacheManager = $cacheManager;
$compilationContext->typeInference = $typeInference;
$compilationContext->symbolTable = $symbolTable;
Expand Down
2 changes: 1 addition & 1 deletion Library/Commands/CommandBuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getUsage()
Description:
The options are as follows:
--backend=ZendEngine2|ZendEngine3 The extension namespace.
--backend=ZendEngine2|ZendEngine3 Used backend to build extension.
EOL;

return sprintf($template, $this->getCommand());
Expand Down
2 changes: 1 addition & 1 deletion Library/Commands/CommandBuildDev.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getUsage()
Description:
The options are as follows:
--backend=ZendEngine2|ZendEngine3 The extension namespace.
--backend=ZendEngine2|ZendEngine3 Used backend to build extension.
EOL;

return sprintf($template, $this->getCommand());
Expand Down
2 changes: 1 addition & 1 deletion Library/Commands/CommandCompile.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getUsage()
Description:
The options are as follows:
--backend=ZendEngine2|ZendEngine3 The extension namespace.
--backend=ZendEngine2|ZendEngine3 Used backend to compile extension.
EOL;

return sprintf($template, $this->getCommand());
Expand Down
2 changes: 1 addition & 1 deletion Library/Commands/CommandGenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getUsage()
Description:
The options are as follows:
--backend=ZendEngine2|ZendEngine3 The extension namespace.
--backend=ZendEngine2|ZendEngine3 Used backend to generate extension.
EOL;

return sprintf($template, $this->getCommand());
Expand Down
3 changes: 2 additions & 1 deletion Library/Commands/CommandInitialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public function getUsage()
Description:
The options are as follows:
namespace The extension namespace.
namespace The extension namespace.
--backend=ZendEngine2|ZendEngine3 Used backend to create extension.
EOL;

return sprintf($template, $this->getCommand());
Expand Down
5 changes: 4 additions & 1 deletion Library/Expression/StaticPropertyAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ class StaticPropertyAccess

protected $_readOnly = false;

/**
* @var Variable|null
*/
protected $_expectingVariable;

/**
* Sets if the variable must be resolved into a direct variable symbol
* create a temporary value or ignore the return value
*
* @param boolean $expecting
* @param Variable $expectingVariable
* @param Variable|null $expectingVariable
*/
public function setExpectReturn($expecting, Variable $expectingVariable = null)
{
Expand Down
Loading

0 comments on commit 075d4e9

Please sign in to comment.