PHP Class Zephir\SymbolTable

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

Protected Properties

Свойство Type Description
$branchTempVariables
$branchVariables
$compilationContext
$localContext Zephir\Passes\LocalContextPass
$mustGrownStack
$tempVarCount

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode 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 méthode

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

addRawVariable() public méthode

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

addTemp() public méthode

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

addVariable() public méthode

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
Résultat Variable

getExpectedMutations() public méthode

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

getLastCallLine() public méthode

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
Résultat integer

getLastUnsetLine() public méthode

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
Résultat integer

getMustGrownStack() public méthode

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

getNextTempVar() public méthode

public getNextTempVar ( $compilationContext = null )

getTempComplexLiteralVariableForWrite() public méthode

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
Résultat Variable

getTempLocalVariableForWrite() public méthode

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

getTempNonTrackedUninitializedVariable() public méthode

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
Résultat Variable

getTempNonTrackedVariable() public méthode

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
Résultat Variable

getTempVariable() public méthode

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

getTempVariableForObserve() public méthode

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
Résultat Variable

getTempVariableForObserveOrNullify() public méthode

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
Résultat Variable

getTempVariableForWrite() public méthode

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
Résultat Variable

getTemporalVariables() public méthode

Returns the temporal variables declared in a given context
public getTemporalVariables ( ) : array
Résultat array

getVariable() public méthode

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

getVariableForRead() public méthode

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
Résultat Variable

getVariableForUpdate() public méthode

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
Résultat Variable

getVariableForWrite() public méthode

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
Résultat boolean | Variable

getVariables() public méthode

Returns all the variables defined in the symbol table
public getVariables ( ) : array
Résultat array

getVariablesByBranch() public méthode

public getVariablesByBranch ( $branchId )

hasVariable() public méthode

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

hasVariableInBranch() public méthode

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

isSuperGlobal() public méthode

Checks if a variable is a superglobal
public isSuperGlobal ( string $name ) : boolean
$name string
Résultat boolean

markTemporalVariablesIdle() public méthode

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

mustGrownStack() public méthode

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

registerTempVariable() protected méthode

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

resolveVariableToBranch() public méthode

public resolveVariableToBranch ( $name, $compilationContext )

reuseTempVariable() protected méthode

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

setLocalContext() public méthode

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
Résultat Zephir\Passes\LocalContextPass

$mustGrownStack protected_oe property

protected $mustGrownStack

$tempVarCount protected_oe property

protected $tempVarCount