PHP Class Zephir\SymbolTable

A symbol table stores all the variables defined in a method, their data types and default values
Mostra file Open project: phalcon/zephir Class Usage Examples

Protected Properties

Property Type Description
$branchTempVariables
$branchVariables
$compilationContext
$localContext Zephir\Passes\LocalContextPass
$mustGrownStack
$tempVarCount

Public Methods

Method Description
__construct ( zephir\CompilationContext $compilationContext ) SymbolTable
addRawVariable ( Variable $variable ) : Variable Adds a raw variable to the symbol table (root branch)
addTemp ( string $type, zephir\CompilationContext $context ) : Variable Creates a temporary variable
addVariable ( integer $type, string $name, zephir\CompilationContext $compilationContext, mixed $defaultValue = null ) : Variable Adds a variable to the symbol table
getExpectedMutations ( string $variable ) : integer Returns the number of expected mutations for a variable
getLastCallLine ( ) : integer Returns the last line where any kind of call was performed within the method This is not necessary related to the symbol table but this information is gathered by the LocalContextPass
getLastUnsetLine ( ) : integer Returns the last line where an 'unset' operation was made within the current method This is not necessary related to the symbol table but this information is gathered by the LocalContextPass
getMustGrownStack ( ) : boolean Returns if the current symbol label must add a memory frame
getNextTempVar ( $compilationContext = null )
getTempComplexLiteralVariableForWrite ( string $type, zephir\CompilationContext $context ) : Variable Creates a temporary variable to be used in a write operation the body of the variable is freed between iterations instead of request a new full zval variable
getTempLocalVariableForWrite ( string $type, zephir\CompilationContext $context ) : Variable Creates a temporary variable to be used in a write operation
getTempNonTrackedUninitializedVariable ( string $type, zephir\CompilationContext $context ) : Variable Creates a temporary variable to be used in a read-only operation within native-array-access and property-access These kind of variables MUST not be tracked by the Zephir memory manager
getTempNonTrackedVariable ( $type, zephir\CompilationContext $context, boolean $initNonReferenced = false ) : Variable Creates a temporary variable to be used to point to a heap variable These kind of variables MUST not be tracked by the Zephir memory manager
getTempVariable ( string $type, zephir\CompilationContext $compilationContext ) : Variable Returns a temporal variable
getTempVariableForObserve ( string $type, zephir\CompilationContext $context ) : Variable Creates a temporary variable to be used as intermediate variable of a read operation Variables are automatically tracked by the memory manager
getTempVariableForObserveOrNullify ( string $type, zephir\CompilationContext $context ) : Variable Creates a temporary variable to be used as intermediate variable in a call operation Variables are automatically tracked by the memory manager
getTempVariableForWrite ( string $type, zephir\CompilationContext $context, $init = true ) : Variable Creates a temporary variable to be used in a write operation
getTemporalVariables ( ) : array Returns the temporal variables declared in a given context
getVariable ( $name, $compilationContext = null ) : Variable | boolean Returns a variable in the symbol table
getVariableForRead ( string $name, zephir\CompilationContext $compilationContext = null, array $statement = null ) : Variable Return a variable in the symbol table, it will be used for a read operation
getVariableForUpdate ( string $name, zephir\CompilationContext $compilationContext, array $statement = null ) : Variable Return a variable in the symbol table, it will be used for a mutating operation This method implies mutation of one of the members of the variable but no the variables it self
getVariableForWrite ( string $name, zephir\CompilationContext $compilationContext, array $statement = null ) : boolean | Variable Return a variable in the symbol table, it will be used for a write operation Some variables aren't writable themselves but their members do
getVariables ( ) : array Returns all the variables defined in the symbol table
getVariablesByBranch ( $branchId )
hasVariable ( string $name, $compilationContext = null ) : boolean Check if a variable is declared in the current symbol table
hasVariableInBranch ( $name, $compareBranch, $compilationContext = null )
isSuperGlobal ( string $name ) : boolean Checks if a variable is a superglobal
markTemporalVariablesIdle ( zephir\CompilationContext $compilationContext ) Traverses temporal variables created in a specific branch marking them as idle
mustGrownStack ( boolean $mustGrownStack ) Return a variable in the symbol table, it will be used for a write operation
resolveVariableToBranch ( $name, $compilationContext )
setLocalContext ( LocalContextPass $localContext ) Sets the local context information

Protected Methods

Method Description
registerTempVariable ( string $type, string $location, Variable $variable, $compilationContext = null ) Register a variable as temporal
reuseTempVariable ( string $type, string $location, $compilationContext = null ) : Variable Reuse variables marked as idle after leave a branch

Method Details

__construct() public method

SymbolTable
public __construct ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext

addRawVariable() public method

Adds a raw variable to the symbol table (root branch)
public addRawVariable ( Variable $variable ) : Variable
$variable Variable
return Variable

addTemp() public method

Creates a temporary variable
public addTemp ( string $type, zephir\CompilationContext $context ) : Variable
$type string
$context zephir\CompilationContext
return Variable

addVariable() public method

Adds a variable to the symbol table
public addVariable ( integer $type, string $name, zephir\CompilationContext $compilationContext, mixed $defaultValue = null ) : Variable
$type integer
$name string
$compilationContext zephir\CompilationContext
$defaultValue mixed
return Variable

getExpectedMutations() public method

Returns the number of expected mutations for a variable
public getExpectedMutations ( string $variable ) : integer
$variable string
return integer

getLastCallLine() public method

Returns the last line where any kind of call was performed within the method This is not necessary related to the symbol table but this information is gathered by the LocalContextPass
public getLastCallLine ( ) : integer
return integer

getLastUnsetLine() public method

Returns the last line where an 'unset' operation was made within the current method This is not necessary related to the symbol table but this information is gathered by the LocalContextPass
public getLastUnsetLine ( ) : integer
return integer

getMustGrownStack() public method

Returns if the current symbol label must add a memory frame
public getMustGrownStack ( ) : boolean
return boolean

getNextTempVar() public method

public getNextTempVar ( $compilationContext = null )

getTempComplexLiteralVariableForWrite() public method

Creates a temporary variable to be used in a write operation the body of the variable is freed between iterations instead of request a new full zval variable
public getTempComplexLiteralVariableForWrite ( string $type, zephir\CompilationContext $context ) : Variable
$type string
$context zephir\CompilationContext
return Variable

getTempLocalVariableForWrite() public method

Creates a temporary variable to be used in a write operation
public getTempLocalVariableForWrite ( string $type, zephir\CompilationContext $context ) : Variable
$type string
$context zephir\CompilationContext
return Variable

getTempNonTrackedUninitializedVariable() public method

Creates a temporary variable to be used in a read-only operation within native-array-access and property-access These kind of variables MUST not be tracked by the Zephir memory manager
public getTempNonTrackedUninitializedVariable ( string $type, zephir\CompilationContext $context ) : Variable
$type string
$context zephir\CompilationContext
return Variable

getTempNonTrackedVariable() public method

Creates a temporary variable to be used to point to a heap variable These kind of variables MUST not be tracked by the Zephir memory manager
public getTempNonTrackedVariable ( $type, zephir\CompilationContext $context, boolean $initNonReferenced = false ) : Variable
$type
$context zephir\CompilationContext
$initNonReferenced boolean
return Variable

getTempVariable() public method

Returns a temporal variable
public getTempVariable ( string $type, zephir\CompilationContext $compilationContext ) : Variable
$type string
$compilationContext zephir\CompilationContext
return Variable

getTempVariableForObserve() public method

Creates a temporary variable to be used as intermediate variable of a read operation Variables are automatically tracked by the memory manager
public getTempVariableForObserve ( string $type, zephir\CompilationContext $context ) : Variable
$type string
$context zephir\CompilationContext
return Variable

getTempVariableForObserveOrNullify() public method

Creates a temporary variable to be used as intermediate variable in a call operation Variables are automatically tracked by the memory manager
public getTempVariableForObserveOrNullify ( string $type, zephir\CompilationContext $context ) : Variable
$type string
$context zephir\CompilationContext
return Variable

getTempVariableForWrite() public method

Creates a temporary variable to be used in a write operation
public getTempVariableForWrite ( string $type, zephir\CompilationContext $context, $init = true ) : Variable
$type string
$context zephir\CompilationContext
return Variable

getTemporalVariables() public method

Returns the temporal variables declared in a given context
public getTemporalVariables ( ) : array
return array

getVariable() public method

Returns a variable in the symbol table
public getVariable ( $name, $compilationContext = null ) : Variable | boolean
$name
return Variable | boolean

getVariableForRead() public method

Return a variable in the symbol table, it will be used for a read operation
public getVariableForRead ( string $name, zephir\CompilationContext $compilationContext = null, array $statement = null ) : Variable
$name string
$compilationContext zephir\CompilationContext
$statement array
return Variable

getVariableForUpdate() public method

Return a variable in the symbol table, it will be used for a mutating operation This method implies mutation of one of the members of the variable but no the variables it self
public getVariableForUpdate ( string $name, zephir\CompilationContext $compilationContext, array $statement = null ) : Variable
$name string
$compilationContext zephir\CompilationContext
$statement array
return Variable

getVariableForWrite() public method

Return a variable in the symbol table, it will be used for a write operation Some variables aren't writable themselves but their members do
public getVariableForWrite ( string $name, zephir\CompilationContext $compilationContext, array $statement = null ) : boolean | Variable
$name string
$compilationContext zephir\CompilationContext
$statement array
return boolean | Variable

getVariables() public method

Returns all the variables defined in the symbol table
public getVariables ( ) : array
return array

getVariablesByBranch() public method

public getVariablesByBranch ( $branchId )

hasVariable() public method

Check if a variable is declared in the current symbol table
public hasVariable ( string $name, $compilationContext = null ) : boolean
$name string
return boolean

hasVariableInBranch() public method

public hasVariableInBranch ( $name, $compareBranch, $compilationContext = null )

isSuperGlobal() public method

Checks if a variable is a superglobal
public isSuperGlobal ( string $name ) : boolean
$name string
return boolean

markTemporalVariablesIdle() public method

Traverses temporal variables created in a specific branch marking them as idle
public markTemporalVariablesIdle ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext

mustGrownStack() public method

Return a variable in the symbol table, it will be used for a write operation
public mustGrownStack ( boolean $mustGrownStack )
$mustGrownStack boolean

registerTempVariable() protected method

Register a variable as temporal
protected registerTempVariable ( string $type, string $location, Variable $variable, $compilationContext = null )
$type string
$location string
$variable Variable

resolveVariableToBranch() public method

public resolveVariableToBranch ( $name, $compilationContext )

reuseTempVariable() protected method

Reuse variables marked as idle after leave a branch
protected reuseTempVariable ( string $type, string $location, $compilationContext = null ) : Variable
$type string
$location string
return Variable

setLocalContext() public method

Sets the local context information
public setLocalContext ( LocalContextPass $localContext )
$localContext Zephir\Passes\LocalContextPass

Property Details

$branchTempVariables protected_oe property

protected $branchTempVariables

$branchVariables protected_oe property

protected $branchVariables

$compilationContext protected_oe property

protected $compilationContext

$localContext protected_oe property

protected LocalContextPass,Zephir\Passes $localContext
return Zephir\Passes\LocalContextPass

$mustGrownStack protected_oe property

protected $mustGrownStack

$tempVarCount protected_oe property

protected $tempVarCount