C# Class Pchp.CodeAnalysis.CodeGen.CodeGenerator

Afficher le fichier Open project: iolevel/peachpie Class Usage Examples

Méthodes publiques

Méthode Description
Emit ( BoundExpression expr ) : TypeSymbol
EmitBox ( TypeSymbol valuetype ) : void
EmitCallMain ( MethodSymbol mainmethod ) : TypeSymbol

Emits call to main method.

EmitCallerRuntimeTypeHandle ( ) : void
EmitConvert ( BoundExpression expr, TypeSymbol to ) : void
EmitConvert ( TypeSymbol from, TypeRefMask fromHint, TypeSymbol to ) : void

Emits conversion from one CLR type to another using PHP conventions.

EmitConvertToBool ( BoundExpression expr, bool negation = false ) : void
EmitConvertToBool ( TypeSymbol from, TypeRefMask fromHint, bool negation = false ) : void
EmitConvertToDouble ( TypeSymbol from, TypeRefMask fromHint ) : TypeSymbol
EmitConvertToInt ( TypeSymbol from, TypeRefMask fromHint ) : void
EmitConvertToIntStringKey ( TypeSymbol from, TypeRefMask fromHint ) : void
EmitConvertToLong ( TypeSymbol from, TypeRefMask fromHint ) : void
EmitConvertToPhpArray ( TypeSymbol from, TypeRefMask fromHint ) : void

Emits conversion to PhpArray.

EmitConvertToPhpNumber ( TypeSymbol from, TypeRefMask fromHint ) : void
EmitConvertToPhpString ( TypeSymbol from, TypeRefMask fromHint ) : void

Emits conversion to Pchp.Core.PhpString (aka writable string).

EmitConvertToPhpValue ( TypeSymbol from, TypeRefMask fromHint ) : TypeSymbol
EmitConvertToPhpValue ( TypeSymbol from, TypeRefMask fromHint, ILBuilder il, Emit module, DiagnosticBag diagnostic ) : TypeSymbol
EmitConvertToString ( TypeSymbol from, TypeRefMask fromHint ) : void

Emits conversion to System.String.

EmitDebugAssert ( string messageOpt = null ) : void

Emits Debug.Assert([stack]).

EmitDebugAssertNotNull ( IPlace place, string messageOpt = null ) : void

Emits Debug.Assert([place]) in debug compile mode.

EmitDeclareFunction ( SourceFunctionSymbol f ) : void

Emits declaring function into the context.

EmitDeclareType ( SourceTypeSymbol t ) : void

Emits declaring type into the context.

EmitEcho ( BoundExpression expr ) : void
EmitFieldAddress ( FieldSymbol fld ) : void

Loads field address on top of evaluation stack.

EmitIntStringKey ( BoundExpression expr ) : void
EmitIntStringKey ( int key ) : void
EmitLoadArgument ( ParameterSymbol targetp, BoundExpression expr, List writebacks ) : void

Loads argument

EmitLoadConstant ( object value, TypeSymbol targetOpt = null ) : TypeSymbol
EmitLoadContext ( ) : TypeSymbol

Emits context onto the evaluation stack.

EmitLoadDefault ( TypeSymbol type, TypeRefMask typemask ) : void
EmitLoadDefaultOfValueType ( TypeSymbol valuetype ) : void

Emits default(valuetype). Handles special types with a default ctor.

EmitLoadToken ( MethodSymbol method, Microsoft.CodeAnalysis.SyntaxNode syntaxNodeOpt ) : TypeSymbol

Loads RuntimeMethodHandle of given method.

EmitLoadToken ( TypeSymbol type, Microsoft.CodeAnalysis.SyntaxNode syntaxNodeOpt ) : TypeSymbol

Loads RuntimeTypeHandle of given type.

EmitLogicNegation ( ) : void

Emits "!= 0" operation. This method expects I4 value on top of evaluation stack.

EmitNotNull ( IPlace place ) : void

Emits place != null expression.

EmitOpCode ( ILOpCode code ) : void
EmitParameterDefaultValue ( ParameterSymbol targetp ) : void

Emits default value of given parameter. Puts value of target parameter's type.

EmitPop ( TypeSymbol type ) : void
EmitRet ( TypeSymbol stack ) : void

Emits .ret instruction with sequence point at closing brace.

EmitRetDefault ( ) : void
EmitThis ( ) : TypeSymbol

Emits reference to this.

EmitThisOrNull ( ) : TypeSymbol
EmitUnset ( BoundReferenceExpression expr ) : void
EmitWithDisabledErrorReporting ( BoundExpression expr ) : TypeSymbol

Emits the expression decorated with error reporting disabling routine.

Emit_NewArray ( TypeSymbol elementType, BoundExpression values ) : void
Emit_PhpAlias_GetValue ( ) : TypeSymbol

Emits load of PhpAlias.Value, expecting PhpAlias on top of evaluation stack, pushing PhpValue on top of the stack.

Emit_PhpAlias_GetValueRef ( ) : void

Emits load of PhpAlias.Value, expecting PhpAlias on top of evaluation stack, pushing PhpValue on top of the stack.

Emit_PhpAlias_SetValue ( ) : void

Emits store to PhpAlias.Value, expecting PhpAlias and PhpValue on top of evaluation stack.

Emit_PhpValue_MakeAlias ( ) : TypeSymbol

Emits new PhpAlias, expecting PhpValue on top of the evaluation stack.

Emit_PhpValue_Null ( ) : TypeSymbol

Emits load of PhpValue representing null.

Emit_PhpValue_Void ( ) : TypeSymbol

Emits load of PhpValue representing void.

GetTemporaryLocal ( TypeSymbol type ) : Microsoft.CodeAnalysis.CodeGen.LocalDefinition

Returns a LocalDefinition of a temporary local variable of a specified TypeSymbol.

If a LocalDefinition of the given TypeSymbol has already been declared and returned to the pool, this local is reused. Otherwise, a new local is declared. Use this method to obtain a short-lived temporary local. Return the local to the pool of locals available for reuse by calling ReturnTemporaryLocal.

GetTemporaryLocal ( TypeSymbol type, bool immediateReturn ) : Microsoft.CodeAnalysis.CodeGen.LocalDefinition

Returns a LocalDefinition of a temporary local variable of a specified TypeSymbol.

If a LocalDefinition of the given TypeSymbol has already been declared and returned to the pool, this local is reused. Otherwise, a new local is declared. Use this method to obtain a short-lived temporary local. If immediateReturn is false, return the local to the pool of locals available for reuse by calling ReturnTemporaryLocal.

ReturnTemporaryLocal ( Microsoft.CodeAnalysis.CodeGen.LocalDefinition definition ) : void

Returns a LocalDefinition previously obtained from GetTemporaryLocal(TypeSymbol,bool) to the pool of locals available for reuse.

Private Methods

Méthode Description
EmitCall ( ILOpCode code, MethodSymbol method ) : TypeSymbol

Emits call to given method.

EmitCall ( ILOpCode code, MethodSymbol method, BoundExpression thisExpr, ImmutableArray arguments ) : TypeSymbol
EmitCastClass ( TypeSymbol type ) : void
EmitCastClass ( TypeSymbol from, TypeSymbol to ) : void
EmitConvertIntToLong ( TypeSymbol stack ) : TypeSymbol

In case there is Int32 or bool on the top of evaluation stack, converts it to Int64.

EmitConvertNumberToDouble ( BoundExpression expr ) : TypeSymbol

In case there is Int32 or bool or PhpNumber on the top of evaluation stack, converts it to double.

EmitConvertToClass ( TypeSymbol from, TypeRefMask fromHint, TypeSymbol to ) : void

Emits conversion to a class object.

EmitConvertToEnum ( TypeSymbol from, NamedTypeSymbol to ) : void
EmitGetProperty ( IPlace holder, PropertySymbol prop ) : TypeSymbol
EmitInitializePlace ( IPlace place ) : void

Initializes place with a default value. This applies to structs without default ctor that won't work properly when uninitialized.

EmitPhpNumberAddr ( ) : void

Copies PhpNumber into a temp variable and loads its address.

EmitPhpValueAddr ( ) : void

Copies PhpValue into a temp variable and loads its address.

EmitSequencePoint ( LangElement element ) : void
EmitSequencePoint ( Span span ) : void
EmitSpecialize ( BoundExpression expr ) : TypeSymbol

If possible, based on type analysis, unwraps more specific type from a value currently on stack without a runtime type check.

EmitSpecialize ( TypeSymbol stack, TypeRefMask tmask ) : TypeSymbol

If possible, based on type analysis, unwraps more specific type from a value currently on stack without a runtime type check.

EmitStructAddr ( TypeSymbol t ) : void

Copies a value type from the top of evaluation stack into a temporary variable and loads its address.

EmitSymbolToken ( FieldSymbol symbol, Microsoft.CodeAnalysis.SyntaxNode syntaxNode ) : void
EmitSymbolToken ( TypeSymbol symbol, Microsoft.CodeAnalysis.SyntaxNode syntaxNode ) : void
EmitThisCall ( MethodSymbol target, MethodSymbol thismethod ) : TypeSymbol

Emits .call to target assuming it takes the same arguments as passed to the caller method (thismethod).

Emit_PhpValue_Void ( ILBuilder il, Emit module, DiagnosticBag diagnostic ) : TypeSymbol

Emits load of PhpValue representing void.

IsArrayOnly ( TypeRefMask tmask ) : bool

Gets value indicating the given type represents only PHP Array.

IsBooleanOnly ( TypeRefMask tmask ) : bool

Gets value indicating the given type represents a long and nothing else.

IsClassOnly ( TypeRefMask tmask ) : bool

Gets value indicating the given type represents only class types.

IsDoubleOnly ( TypeRefMask tmask ) : bool

Gets value indicating the given type represents a double and nothing else.

IsLongOnly ( TypeRefMask tmask ) : bool

Gets value indicating the given type represents a long and nothing else.

IsReadonlyStringOnly ( TypeRefMask tmask ) : bool

Gets value indicating the given type represents UTF16 readonly string and nothing else.

PlaceOrNull ( BoundExpression expr ) : IPlace

If possible, gets IPlace representing given expression (in case of a field or variable).

TryEmitVariableSpecialize ( BoundExpression expr ) : TypeSymbol

If possible, based on type analysis, unwraps most specific type from give variable without a runtime type check.

TryEmitVariableSpecialize ( IPlace place, TypeRefMask tmask ) : TypeSymbol

If possible, based on type analysis, unwraps most specific type from give variable without a runtime type check.

Method Details

Emit() public méthode

public Emit ( BoundExpression expr ) : TypeSymbol
expr Pchp.CodeAnalysis.Semantics.BoundExpression
Résultat TypeSymbol

EmitBox() public méthode

public EmitBox ( TypeSymbol valuetype ) : void
valuetype TypeSymbol
Résultat void

EmitCallMain() public méthode

Emits call to main method.
public EmitCallMain ( MethodSymbol mainmethod ) : TypeSymbol
mainmethod Pchp.CodeAnalysis.Symbols.MethodSymbol Static Main method representing the script global code.
Résultat TypeSymbol

EmitCallerRuntimeTypeHandle() public méthode

public EmitCallerRuntimeTypeHandle ( ) : void
Résultat void

EmitConvert() public méthode

public EmitConvert ( BoundExpression expr, TypeSymbol to ) : void
expr Pchp.CodeAnalysis.Semantics.BoundExpression
to TypeSymbol
Résultat void

EmitConvert() public méthode

Emits conversion from one CLR type to another using PHP conventions.
public EmitConvert ( TypeSymbol from, TypeRefMask fromHint, TypeSymbol to ) : void
from TypeSymbol Type of value on top of evaluation stack.
fromHint TypeRefMask Type hint in case of a multityple type choices (like PhpValue or PhpNumber or PhpAlias).
to TypeSymbol Target CLR type.
Résultat void

EmitConvertToBool() public méthode

public EmitConvertToBool ( BoundExpression expr, bool negation = false ) : void
expr Pchp.CodeAnalysis.Semantics.BoundExpression
negation bool
Résultat void

EmitConvertToBool() public méthode

public EmitConvertToBool ( TypeSymbol from, TypeRefMask fromHint, bool negation = false ) : void
from TypeSymbol
fromHint TypeRefMask
negation bool
Résultat void

EmitConvertToDouble() public méthode

public EmitConvertToDouble ( TypeSymbol from, TypeRefMask fromHint ) : TypeSymbol
from TypeSymbol
fromHint TypeRefMask
Résultat TypeSymbol

EmitConvertToInt() public méthode

public EmitConvertToInt ( TypeSymbol from, TypeRefMask fromHint ) : void
from TypeSymbol
fromHint TypeRefMask
Résultat void

EmitConvertToIntStringKey() public méthode

public EmitConvertToIntStringKey ( TypeSymbol from, TypeRefMask fromHint ) : void
from TypeSymbol
fromHint TypeRefMask
Résultat void

EmitConvertToLong() public méthode

public EmitConvertToLong ( TypeSymbol from, TypeRefMask fromHint ) : void
from TypeSymbol
fromHint TypeRefMask
Résultat void

EmitConvertToPhpArray() public méthode

Emits conversion to PhpArray.
public EmitConvertToPhpArray ( TypeSymbol from, TypeRefMask fromHint ) : void
from TypeSymbol
fromHint TypeRefMask
Résultat void

EmitConvertToPhpNumber() public méthode

public EmitConvertToPhpNumber ( TypeSymbol from, TypeRefMask fromHint ) : void
from TypeSymbol
fromHint TypeRefMask
Résultat void

EmitConvertToPhpString() public méthode

Emits conversion to Pchp.Core.PhpString (aka writable string).
public EmitConvertToPhpString ( TypeSymbol from, TypeRefMask fromHint ) : void
from TypeSymbol
fromHint TypeRefMask
Résultat void

EmitConvertToPhpValue() public méthode

public EmitConvertToPhpValue ( TypeSymbol from, TypeRefMask fromHint ) : TypeSymbol
from TypeSymbol
fromHint TypeRefMask
Résultat TypeSymbol

EmitConvertToPhpValue() public static méthode

public static EmitConvertToPhpValue ( TypeSymbol from, TypeRefMask fromHint, ILBuilder il, Emit module, DiagnosticBag diagnostic ) : TypeSymbol
from TypeSymbol
fromHint TypeRefMask
il Microsoft.CodeAnalysis.CodeGen.ILBuilder
module Emit
diagnostic DiagnosticBag
Résultat TypeSymbol

EmitConvertToString() public méthode

Emits conversion to System.String.
public EmitConvertToString ( TypeSymbol from, TypeRefMask fromHint ) : void
from TypeSymbol
fromHint TypeRefMask
Résultat void

EmitDebugAssert() public méthode

Emits Debug.Assert([stack]).
public EmitDebugAssert ( string messageOpt = null ) : void
messageOpt string Optional second argument for assert.
Résultat void

EmitDebugAssertNotNull() public méthode

Emits Debug.Assert([place]) in debug compile mode.
public EmitDebugAssertNotNull ( IPlace place, string messageOpt = null ) : void
place IPlace The variable to emit assertion for.
messageOpt string Optional second argument for assert.
Résultat void

EmitDeclareFunction() public méthode

Emits declaring function into the context.
public EmitDeclareFunction ( SourceFunctionSymbol f ) : void
f Pchp.CodeAnalysis.Symbols.SourceFunctionSymbol
Résultat void

EmitDeclareType() public méthode

Emits declaring type into the context.
public EmitDeclareType ( SourceTypeSymbol t ) : void
t Pchp.CodeAnalysis.Symbols.SourceTypeSymbol
Résultat void

EmitEcho() public méthode

public EmitEcho ( BoundExpression expr ) : void
expr Pchp.CodeAnalysis.Semantics.BoundExpression
Résultat void

EmitFieldAddress() public méthode

Loads field address on top of evaluation stack.
public EmitFieldAddress ( FieldSymbol fld ) : void
fld Pchp.CodeAnalysis.Symbols.FieldSymbol
Résultat void

EmitIntStringKey() public méthode

public EmitIntStringKey ( BoundExpression expr ) : void
expr Pchp.CodeAnalysis.Semantics.BoundExpression
Résultat void

EmitIntStringKey() public méthode

public EmitIntStringKey ( int key ) : void
key int
Résultat void

EmitLoadArgument() public méthode

Loads argument
public EmitLoadArgument ( ParameterSymbol targetp, BoundExpression expr, List writebacks ) : void
targetp Pchp.CodeAnalysis.Symbols.ParameterSymbol
expr Pchp.CodeAnalysis.Semantics.BoundExpression
writebacks List
Résultat void

EmitLoadConstant() public méthode

public EmitLoadConstant ( object value, TypeSymbol targetOpt = null ) : TypeSymbol
value object
targetOpt TypeSymbol
Résultat TypeSymbol

EmitLoadContext() public méthode

Emits context onto the evaluation stack.
public EmitLoadContext ( ) : TypeSymbol
Résultat TypeSymbol

EmitLoadDefault() public méthode

public EmitLoadDefault ( TypeSymbol type, TypeRefMask typemask ) : void
type TypeSymbol
typemask TypeRefMask
Résultat void

EmitLoadDefaultOfValueType() public méthode

Emits default(valuetype). Handles special types with a default ctor.
public EmitLoadDefaultOfValueType ( TypeSymbol valuetype ) : void
valuetype TypeSymbol
Résultat void

EmitLoadToken() public méthode

Loads RuntimeMethodHandle of given method.
public EmitLoadToken ( MethodSymbol method, Microsoft.CodeAnalysis.SyntaxNode syntaxNodeOpt ) : TypeSymbol
method Pchp.CodeAnalysis.Symbols.MethodSymbol
syntaxNodeOpt Microsoft.CodeAnalysis.SyntaxNode
Résultat TypeSymbol

EmitLoadToken() public méthode

Loads RuntimeTypeHandle of given type.
public EmitLoadToken ( TypeSymbol type, Microsoft.CodeAnalysis.SyntaxNode syntaxNodeOpt ) : TypeSymbol
type TypeSymbol
syntaxNodeOpt Microsoft.CodeAnalysis.SyntaxNode
Résultat TypeSymbol

EmitLogicNegation() public méthode

Emits "!= 0" operation. This method expects I4 value on top of evaluation stack.
public EmitLogicNegation ( ) : void
Résultat void

EmitNotNull() public méthode

Emits place != null expression.
public EmitNotNull ( IPlace place ) : void
place IPlace
Résultat void

EmitOpCode() public méthode

public EmitOpCode ( ILOpCode code ) : void
code ILOpCode
Résultat void

EmitParameterDefaultValue() public méthode

Emits default value of given parameter. Puts value of target parameter's type.
public EmitParameterDefaultValue ( ParameterSymbol targetp ) : void
targetp Pchp.CodeAnalysis.Symbols.ParameterSymbol Parameter to emit its default value.
Résultat void

EmitPop() public méthode

public EmitPop ( TypeSymbol type ) : void
type TypeSymbol
Résultat void

EmitRet() public méthode

Emits .ret instruction with sequence point at closing brace.
public EmitRet ( TypeSymbol stack ) : void
stack TypeSymbol
Résultat void

EmitRetDefault() public méthode

public EmitRetDefault ( ) : void
Résultat void

EmitThis() public méthode

Emits reference to this.
public EmitThis ( ) : TypeSymbol
Résultat TypeSymbol

EmitThisOrNull() public méthode

public EmitThisOrNull ( ) : TypeSymbol
Résultat TypeSymbol

EmitUnset() public méthode

public EmitUnset ( BoundReferenceExpression expr ) : void
expr Pchp.CodeAnalysis.Semantics.BoundReferenceExpression
Résultat void

EmitWithDisabledErrorReporting() public méthode

Emits the expression decorated with error reporting disabling routine.
public EmitWithDisabledErrorReporting ( BoundExpression expr ) : TypeSymbol
expr Pchp.CodeAnalysis.Semantics.BoundExpression
Résultat TypeSymbol

Emit_NewArray() public méthode

public Emit_NewArray ( TypeSymbol elementType, BoundExpression values ) : void
elementType TypeSymbol
values Pchp.CodeAnalysis.Semantics.BoundExpression
Résultat void

Emit_PhpAlias_GetValue() public méthode

Emits load of PhpAlias.Value, expecting PhpAlias on top of evaluation stack, pushing PhpValue on top of the stack.
public Emit_PhpAlias_GetValue ( ) : TypeSymbol
Résultat TypeSymbol

Emit_PhpAlias_GetValueRef() public méthode

Emits load of PhpAlias.Value, expecting PhpAlias on top of evaluation stack, pushing PhpValue on top of the stack.
public Emit_PhpAlias_GetValueRef ( ) : void
Résultat void

Emit_PhpAlias_SetValue() public méthode

Emits store to PhpAlias.Value, expecting PhpAlias and PhpValue on top of evaluation stack.
public Emit_PhpAlias_SetValue ( ) : void
Résultat void

Emit_PhpValue_MakeAlias() public méthode

Emits new PhpAlias, expecting PhpValue on top of the evaluation stack.
public Emit_PhpValue_MakeAlias ( ) : TypeSymbol
Résultat TypeSymbol

Emit_PhpValue_Null() public méthode

Emits load of PhpValue representing null.
public Emit_PhpValue_Null ( ) : TypeSymbol
Résultat TypeSymbol

Emit_PhpValue_Void() public méthode

Emits load of PhpValue representing void.
public Emit_PhpValue_Void ( ) : TypeSymbol
Résultat TypeSymbol

GetTemporaryLocal() public méthode

Returns a LocalDefinition of a temporary local variable of a specified TypeSymbol.
If a LocalDefinition of the given TypeSymbol has already been declared and returned to the pool, this local is reused. Otherwise, a new local is declared. Use this method to obtain a short-lived temporary local. Return the local to the pool of locals available for reuse by calling ReturnTemporaryLocal.
public GetTemporaryLocal ( TypeSymbol type ) : Microsoft.CodeAnalysis.CodeGen.LocalDefinition
type TypeSymbol The requested of the local.
Résultat Microsoft.CodeAnalysis.CodeGen.LocalDefinition

GetTemporaryLocal() public méthode

Returns a LocalDefinition of a temporary local variable of a specified TypeSymbol.
If a LocalDefinition of the given TypeSymbol has already been declared and returned to the pool, this local is reused. Otherwise, a new local is declared. Use this method to obtain a short-lived temporary local. If immediateReturn is false, return the local to the pool of locals available for reuse by calling ReturnTemporaryLocal.
public GetTemporaryLocal ( TypeSymbol type, bool immediateReturn ) : Microsoft.CodeAnalysis.CodeGen.LocalDefinition
type TypeSymbol The requested of the local.
immediateReturn bool True to immediately return the local builder to the pool of locals /// available for reuse (no need to call ).
Résultat Microsoft.CodeAnalysis.CodeGen.LocalDefinition

ReturnTemporaryLocal() public méthode

Returns a LocalDefinition previously obtained from GetTemporaryLocal(TypeSymbol,bool) to the pool of locals available for reuse.
public ReturnTemporaryLocal ( Microsoft.CodeAnalysis.CodeGen.LocalDefinition definition ) : void
definition Microsoft.CodeAnalysis.CodeGen.LocalDefinition The to return to the pool.
Résultat void