PHP Class Zephir\Passes\LocalContextPass

This pass tries to check whether variables only do exist in the local context of the method block or if they're used externally which will unallow variables to be placed in the stack This pass also tracks the number of initializations a variable may have, this allows to mark variables as read-only after their last initialization. The number of mutations is relative, since assignments inside cycles/loops may perform a n-number of mutations
Show file Open project: phalcon/zephir Class Usage Examples

Protected Properties

Property Type Description
$lastCallLine
$lastUnsetLine
$mutations
$uses
$variables

Public Methods

Method Description
declareVariables ( array $statement )
getLastCallLine ( ) : integer Returns the line where the latest call in the method was made
getLastUnsetLine ( ) : integer Returns the line where the latest unset operation was made
getLastVariableUseLine ( string $variable ) : integer Returns the latest line where a variable was read
getNumberOfMutations ( string $variable ) : integer Returns the number of assignment instructions that mutated a variable
increaseMutations ( string $variable ) Increase the number of mutations a variable has inside a statement block
markLastUse ( string $variable, array $node ) Marks the latest use/read of a variable
markVariableNoLocal ( string $variable ) Marks a variable to mandatory be stored in the heap
pass ( Zephir\StatementsBlock $block ) Do the compilation pass
passArray ( array $expression )
passCall ( array $expression )
passExpression ( array $expression )
passLetStatement ( array $statement )
passNew ( array $expression )
passStatementBlock ( array $statements )
shouldBeLocal ( string $variable ) : boolean Asks the local context information whether a variable can be stored in the stack instead of the heap

Method Details

declareVariables() public method

public declareVariables ( array $statement )
$statement array

getLastCallLine() public method

Returns the line where the latest call in the method was made
public getLastCallLine ( ) : integer
return integer

getLastUnsetLine() public method

Returns the line where the latest unset operation was made
public getLastUnsetLine ( ) : integer
return integer

getLastVariableUseLine() public method

Returns the latest line where a variable was read
public getLastVariableUseLine ( string $variable ) : integer
$variable string
return integer

getNumberOfMutations() public method

Returns the number of assignment instructions that mutated a variable
public getNumberOfMutations ( string $variable ) : integer
$variable string
return integer

increaseMutations() public method

Increase the number of mutations a variable has inside a statement block
public increaseMutations ( string $variable )
$variable string

markLastUse() public method

Marks the latest use/read of a variable
public markLastUse ( string $variable, array $node )
$variable string
$node array

markVariableNoLocal() public method

Marks a variable to mandatory be stored in the heap
public markVariableNoLocal ( string $variable )
$variable string

pass() public method

Do the compilation pass
public pass ( Zephir\StatementsBlock $block )
$block Zephir\StatementsBlock

passArray() public method

public passArray ( array $expression )
$expression array

passCall() public method

public passCall ( array $expression )
$expression array

passExpression() public method

public passExpression ( array $expression )
$expression array

passLetStatement() public method

public passLetStatement ( array $statement )
$statement array

passNew() public method

public passNew ( array $expression )
$expression array

passStatementBlock() public method

public passStatementBlock ( array $statements )
$statements array

shouldBeLocal() public method

Asks the local context information whether a variable can be stored in the stack instead of the heap
public shouldBeLocal ( string $variable ) : boolean
$variable string
return boolean

Property Details

$lastCallLine protected property

protected $lastCallLine

$lastUnsetLine protected property

protected $lastUnsetLine

$mutations protected property

protected $mutations

$uses protected property

protected $uses

$variables protected property

protected $variables