C# Class System.Xml.Xsl.IlGen.GenerateHelper

Contains helper methods used during the code generation phase.
Mostra file Open project: dotnet/corefx Class Usage Examples

Public Methods

Method Description
AddSortKey ( XmlQueryType keyType ) : void
BranchAndMark ( Label lblBranch, Label lblMark ) : void

Branch to lblBranch and anchor lblMark. If lblBranch = lblMark, then no need to generate a "br" to the next instruction.

Call ( MethodInfo meth ) : void
CallArithmeticOp ( QilNodeType opType, XmlTypeCode code ) : void
CallCacheCount ( Type itemStorageType ) : void
CallCacheItem ( Type itemStorageType ) : void
CallCompare ( XmlTypeCode code ) : void
CallCompareEquals ( XmlTypeCode code ) : void
CallConcatStrings ( int cStrings ) : void
CallEndRtfConstruction ( ) : void
CallEndSequenceConstruction ( ) : void
CallEndTree ( ) : void
CallGetAtomizedName ( int idxName ) : void
CallGetCollation ( int idxName ) : void
CallGetEarlyBoundObject ( int idxObj, Type clrType ) : void
CallGetGlobalValue ( int idxValue, Type clrType ) : void
CallGetNameFilter ( int idxFilter ) : void
CallGetParameter ( string localName, string namespaceUri ) : void
CallGetTypeFilter ( XPathNodeType nodeType ) : void
CallParseTagName ( GenerateNameType nameType ) : void
CallSetGlobalValue ( Type clrType ) : void
CallStartElementContent ( ) : void
CallStartRtfConstruction ( string baseUri ) : void
CallStartSequenceConstruction ( ) : void
CallStartTree ( XPathNodeType rootType ) : void
CallSyncToNavigator ( ) : void

Call a static method which attempts to reuse a navigator.

CallToken ( MethodInfo meth ) : void
CallValueAs ( Type clrType ) : void
CallWriteEndAttribute ( bool callChk ) : void
CallWriteEndComment ( ) : void
CallWriteEndElement ( GenerateNameType nameType, bool callChk ) : void
CallWriteEndPI ( ) : void
CallWriteEndRoot ( ) : void
CallWriteNamespaceDecl ( bool callChk ) : void
CallWriteStartAttribute ( GenerateNameType nameType, bool callChk ) : void
CallWriteStartComment ( ) : void
CallWriteStartElement ( GenerateNameType nameType, bool callChk ) : void
CallWriteStartPI ( ) : void
CallWriteStartRoot ( ) : void
CallWriteString ( bool disableOutputEscaping, bool callChk ) : void
Construct ( ConstructorInfo constr ) : void
ConstructLiteralDecimal ( decimal dec ) : void
ConstructLiteralQName ( string localName, string namespaceName ) : void
ConvBranchToBool ( Label lblBranch, bool isTrueBranch ) : void

Assume a branch instruction has already been issued. If isTrueBranch is true, then the true path is linked to lblBranch. Otherwise, the false path is linked to lblBranch. Convert this "branching" boolean logic into an explicit push of 1 or 0 onto the stack.

DebugEndScope ( ) : void

End a new debugging scope.

DebugSequencePoint ( ISourceLineInfo sourceInfo ) : void

Correlate the current IL generation position with the current source position.

DebugStartScope ( ) : void

Begin a new variable debugging scope.

DeclareLocal ( string name, Type type ) : LocalBuilder

Generate a new local variable. Add a numeric suffix to name that ensures that all local variable names will be unique (for readability).

DefineLabel ( ) : Label
Emit ( OpCode opcode ) : void
Emit ( OpCode opcode, ConstructorInfo constrInfo ) : void
Emit ( OpCode opcode, FieldInfo fldInfo ) : void
Emit ( OpCode opcode, Label lblVal ) : void
Emit ( OpCode opcode, LocalBuilder locBldr ) : void
Emit ( OpCode opcode, MethodInfo methInfo ) : void
Emit ( OpCode opcode, Type typVal ) : void
Emit ( OpCode opcode, byte byteVal ) : void
Emit ( OpCode opcode, double dblVal ) : void
Emit ( OpCode opcode, float fltVal ) : void
Emit ( OpCode opcode, int intVal ) : void
Emit ( OpCode opcode, long longVal ) : void
Emit ( OpCode opcode, sbyte sbyteVal ) : void
Emit ( OpCode opcode, short shrtVal ) : void
Emit ( OpCode opcode, string strVal ) : void
EmitUnconditionalBranch ( OpCode opcode, Label lblTarget ) : void

Unconditional branch opcodes (OpCode.Br, OpCode.Br_S) can lead to unverifiable code in the following cases: # DEAD CODE CASE ldc_i4 1 # Stack depth == 1 br Label2 Label1: nop # Dead code, so IL rules assume stack depth == 0. This causes a verification error, # since next instruction has depth == 1 Label2: pop # Stack depth == 1 ret # LATE BRANCH CASE ldc_i4 1 # Stack depth == 1 br Label2 Label1: nop # Not dead code, but since branch comes from below, IL rules assume stack depth = 0. # This causes a verification error, since next instruction has depth == 1 Label2: pop # Stack depth == 1 ret Label3: br Label1 # Stack depth == 1 This method works around the above limitations by using Brtrue or Brfalse in the following way: ldc_i4 1 # Since this test is always true, this is a way of creating a path to the code that brtrue Label # follows the brtrue instruction. ldc_i4 1 # Since this test is always false, this is a way of creating a path to the code that brfalse Label # starts at Label. 1. If opcode == Brtrue or Brtrue_S, then 1 will be pushed and brtrue instruction will be generated. 2. If opcode == Brfalse or Brfalse_S, then 1 will be pushed and brfalse instruction will be generated. 3. If opcode == Br or Br_S, then a br instruction will be generated.

GenerateHelper ( XmlILModule module, bool isDebug ) : System

Cache metadata used during code-generation phase.

LoadBoolean ( bool boolVal ) : void
LoadInteger ( int intVal ) : void

Generate the optimal Ldc_I4 instruction based on intVal.

LoadParameter ( int paramPos ) : void
LoadQueryContext ( ) : void
LoadQueryOutput ( ) : void
LoadQueryRuntime ( ) : void
LoadType ( Type clrTyp ) : void
LoadXsltLibrary ( ) : void
MarkLabel ( Label lbl ) : void
MethodBegin ( MethodBase methInfo, ISourceLineInfo sourceInfo, bool initWriters ) : void

Begin generating code within a new method.

MethodEnd ( ) : void

Generate "ret" instruction and branch fixup jump table.

SetParameter ( object paramId ) : void
TailCall ( MethodInfo meth ) : void
TestAndBranch ( int i4, Label lblBranch, OpCode opcodeBranch ) : void

Compare the top value on the stack with the specified i4 using the specified relational comparison opcode, and branch to lblBranch if the result is true.

TreatAs ( Type clrTypeSrc, Type clrTypeDst ) : void

Assume that an object reference is on the IL stack. Change the static Clr type from "clrTypeSrc" to "clrTypeDst"

Private Methods

Method Description
EnsureWriter ( ) : void
GetFileName ( ISourceLineInfo sourceInfo ) : string
MarkSequencePoint ( ISourceLineInfo sourceInfo ) : void
TraceCall ( OpCode opcode, MethodInfo meth ) : void

Method Details

AddSortKey() public method

public AddSortKey ( XmlQueryType keyType ) : void
keyType XmlQueryType
return void

BranchAndMark() public method

Branch to lblBranch and anchor lblMark. If lblBranch = lblMark, then no need to generate a "br" to the next instruction.
public BranchAndMark ( Label lblBranch, Label lblMark ) : void
lblBranch System.Reflection.Emit.Label
lblMark System.Reflection.Emit.Label
return void

Call() public method

public Call ( MethodInfo meth ) : void
meth System.Reflection.MethodInfo
return void

CallArithmeticOp() public method

public CallArithmeticOp ( QilNodeType opType, XmlTypeCode code ) : void
opType QilNodeType
code XmlTypeCode
return void

CallCacheCount() public method

public CallCacheCount ( Type itemStorageType ) : void
itemStorageType System.Type
return void

CallCacheItem() public method

public CallCacheItem ( Type itemStorageType ) : void
itemStorageType System.Type
return void

CallCompare() public method

public CallCompare ( XmlTypeCode code ) : void
code XmlTypeCode
return void

CallCompareEquals() public method

public CallCompareEquals ( XmlTypeCode code ) : void
code XmlTypeCode
return void

CallConcatStrings() public method

public CallConcatStrings ( int cStrings ) : void
cStrings int
return void

CallEndRtfConstruction() public method

public CallEndRtfConstruction ( ) : void
return void

CallEndSequenceConstruction() public method

public CallEndSequenceConstruction ( ) : void
return void

CallEndTree() public method

public CallEndTree ( ) : void
return void

CallGetAtomizedName() public method

public CallGetAtomizedName ( int idxName ) : void
idxName int
return void

CallGetCollation() public method

public CallGetCollation ( int idxName ) : void
idxName int
return void

CallGetEarlyBoundObject() public method

public CallGetEarlyBoundObject ( int idxObj, Type clrType ) : void
idxObj int
clrType System.Type
return void

CallGetGlobalValue() public method

public CallGetGlobalValue ( int idxValue, Type clrType ) : void
idxValue int
clrType System.Type
return void

CallGetNameFilter() public method

public CallGetNameFilter ( int idxFilter ) : void
idxFilter int
return void

CallGetParameter() public method

public CallGetParameter ( string localName, string namespaceUri ) : void
localName string
namespaceUri string
return void

CallGetTypeFilter() public method

public CallGetTypeFilter ( XPathNodeType nodeType ) : void
nodeType XPathNodeType
return void

CallParseTagName() public method

public CallParseTagName ( GenerateNameType nameType ) : void
nameType GenerateNameType
return void

CallSetGlobalValue() public method

public CallSetGlobalValue ( Type clrType ) : void
clrType System.Type
return void

CallStartElementContent() public method

public CallStartElementContent ( ) : void
return void

CallStartRtfConstruction() public method

public CallStartRtfConstruction ( string baseUri ) : void
baseUri string
return void

CallStartSequenceConstruction() public method

public CallStartSequenceConstruction ( ) : void
return void

CallStartTree() public method

public CallStartTree ( XPathNodeType rootType ) : void
rootType XPathNodeType
return void

CallSyncToNavigator() public method

Call a static method which attempts to reuse a navigator.
public CallSyncToNavigator ( ) : void
return void

CallToken() public method

public CallToken ( MethodInfo meth ) : void
meth System.Reflection.MethodInfo
return void

CallValueAs() public method

public CallValueAs ( Type clrType ) : void
clrType System.Type
return void

CallWriteEndAttribute() public method

public CallWriteEndAttribute ( bool callChk ) : void
callChk bool
return void

CallWriteEndComment() public method

public CallWriteEndComment ( ) : void
return void

CallWriteEndElement() public method

public CallWriteEndElement ( GenerateNameType nameType, bool callChk ) : void
nameType GenerateNameType
callChk bool
return void

CallWriteEndPI() public method

public CallWriteEndPI ( ) : void
return void

CallWriteEndRoot() public method

public CallWriteEndRoot ( ) : void
return void

CallWriteNamespaceDecl() public method

public CallWriteNamespaceDecl ( bool callChk ) : void
callChk bool
return void

CallWriteStartAttribute() public method

public CallWriteStartAttribute ( GenerateNameType nameType, bool callChk ) : void
nameType GenerateNameType
callChk bool
return void

CallWriteStartComment() public method

public CallWriteStartComment ( ) : void
return void

CallWriteStartElement() public method

public CallWriteStartElement ( GenerateNameType nameType, bool callChk ) : void
nameType GenerateNameType
callChk bool
return void

CallWriteStartPI() public method

public CallWriteStartPI ( ) : void
return void

CallWriteStartRoot() public method

public CallWriteStartRoot ( ) : void
return void

CallWriteString() public method

public CallWriteString ( bool disableOutputEscaping, bool callChk ) : void
disableOutputEscaping bool
callChk bool
return void

Construct() public method

public Construct ( ConstructorInfo constr ) : void
constr ConstructorInfo
return void

ConstructLiteralDecimal() public method

public ConstructLiteralDecimal ( decimal dec ) : void
dec decimal
return void

ConstructLiteralQName() public method

public ConstructLiteralQName ( string localName, string namespaceName ) : void
localName string
namespaceName string
return void

ConvBranchToBool() public method

Assume a branch instruction has already been issued. If isTrueBranch is true, then the true path is linked to lblBranch. Otherwise, the false path is linked to lblBranch. Convert this "branching" boolean logic into an explicit push of 1 or 0 onto the stack.
public ConvBranchToBool ( Label lblBranch, bool isTrueBranch ) : void
lblBranch Label
isTrueBranch bool
return void

DebugEndScope() public method

End a new debugging scope.
public DebugEndScope ( ) : void
return void

DebugSequencePoint() public method

Correlate the current IL generation position with the current source position.
public DebugSequencePoint ( ISourceLineInfo sourceInfo ) : void
sourceInfo ISourceLineInfo
return void

DebugStartScope() public method

Begin a new variable debugging scope.
public DebugStartScope ( ) : void
return void

DeclareLocal() public method

Generate a new local variable. Add a numeric suffix to name that ensures that all local variable names will be unique (for readability).
public DeclareLocal ( string name, Type type ) : LocalBuilder
name string
type Type
return LocalBuilder

DefineLabel() public method

public DefineLabel ( ) : Label
return Label

Emit() public method

public Emit ( OpCode opcode ) : void
opcode OpCode
return void

Emit() public method

public Emit ( OpCode opcode, ConstructorInfo constrInfo ) : void
opcode OpCode
constrInfo ConstructorInfo
return void

Emit() public method

public Emit ( OpCode opcode, FieldInfo fldInfo ) : void
opcode OpCode
fldInfo FieldInfo
return void

Emit() public method

public Emit ( OpCode opcode, Label lblVal ) : void
opcode OpCode
lblVal Label
return void

Emit() public method

public Emit ( OpCode opcode, LocalBuilder locBldr ) : void
opcode OpCode
locBldr LocalBuilder
return void

Emit() public method

public Emit ( OpCode opcode, MethodInfo methInfo ) : void
opcode OpCode
methInfo MethodInfo
return void

Emit() public method

public Emit ( OpCode opcode, Type typVal ) : void
opcode OpCode
typVal Type
return void

Emit() public method

public Emit ( OpCode opcode, byte byteVal ) : void
opcode OpCode
byteVal byte
return void

Emit() public method

public Emit ( OpCode opcode, double dblVal ) : void
opcode OpCode
dblVal double
return void

Emit() public method

public Emit ( OpCode opcode, float fltVal ) : void
opcode OpCode
fltVal float
return void

Emit() public method

public Emit ( OpCode opcode, int intVal ) : void
opcode OpCode
intVal int
return void

Emit() public method

public Emit ( OpCode opcode, long longVal ) : void
opcode OpCode
longVal long
return void

Emit() public method

public Emit ( OpCode opcode, sbyte sbyteVal ) : void
opcode OpCode
sbyteVal sbyte
return void

Emit() public method

public Emit ( OpCode opcode, short shrtVal ) : void
opcode OpCode
shrtVal short
return void

Emit() public method

public Emit ( OpCode opcode, string strVal ) : void
opcode OpCode
strVal string
return void

EmitUnconditionalBranch() public method

Unconditional branch opcodes (OpCode.Br, OpCode.Br_S) can lead to unverifiable code in the following cases: # DEAD CODE CASE ldc_i4 1 # Stack depth == 1 br Label2 Label1: nop # Dead code, so IL rules assume stack depth == 0. This causes a verification error, # since next instruction has depth == 1 Label2: pop # Stack depth == 1 ret # LATE BRANCH CASE ldc_i4 1 # Stack depth == 1 br Label2 Label1: nop # Not dead code, but since branch comes from below, IL rules assume stack depth = 0. # This causes a verification error, since next instruction has depth == 1 Label2: pop # Stack depth == 1 ret Label3: br Label1 # Stack depth == 1 This method works around the above limitations by using Brtrue or Brfalse in the following way: ldc_i4 1 # Since this test is always true, this is a way of creating a path to the code that brtrue Label # follows the brtrue instruction. ldc_i4 1 # Since this test is always false, this is a way of creating a path to the code that brfalse Label # starts at Label. 1. If opcode == Brtrue or Brtrue_S, then 1 will be pushed and brtrue instruction will be generated. 2. If opcode == Brfalse or Brfalse_S, then 1 will be pushed and brfalse instruction will be generated. 3. If opcode == Br or Br_S, then a br instruction will be generated.
public EmitUnconditionalBranch ( OpCode opcode, Label lblTarget ) : void
opcode OpCode
lblTarget Label
return void

GenerateHelper() public method

Cache metadata used during code-generation phase.
public GenerateHelper ( XmlILModule module, bool isDebug ) : System
module XmlILModule
isDebug bool
return System

LoadBoolean() public method

public LoadBoolean ( bool boolVal ) : void
boolVal bool
return void

LoadInteger() public method

Generate the optimal Ldc_I4 instruction based on intVal.
public LoadInteger ( int intVal ) : void
intVal int
return void

LoadParameter() public method

public LoadParameter ( int paramPos ) : void
paramPos int
return void

LoadQueryContext() public method

public LoadQueryContext ( ) : void
return void

LoadQueryOutput() public method

public LoadQueryOutput ( ) : void
return void

LoadQueryRuntime() public method

public LoadQueryRuntime ( ) : void
return void

LoadType() public method

public LoadType ( Type clrTyp ) : void
clrTyp Type
return void

LoadXsltLibrary() public method

public LoadXsltLibrary ( ) : void
return void

MarkLabel() public method

public MarkLabel ( Label lbl ) : void
lbl Label
return void

MethodBegin() public method

Begin generating code within a new method.
public MethodBegin ( MethodBase methInfo, ISourceLineInfo sourceInfo, bool initWriters ) : void
methInfo MethodBase
sourceInfo ISourceLineInfo
initWriters bool
return void

MethodEnd() public method

Generate "ret" instruction and branch fixup jump table.
public MethodEnd ( ) : void
return void

SetParameter() public method

public SetParameter ( object paramId ) : void
paramId object
return void

TailCall() public method

public TailCall ( MethodInfo meth ) : void
meth MethodInfo
return void

TestAndBranch() public method

Compare the top value on the stack with the specified i4 using the specified relational comparison opcode, and branch to lblBranch if the result is true.
public TestAndBranch ( int i4, Label lblBranch, OpCode opcodeBranch ) : void
i4 int
lblBranch Label
opcodeBranch OpCode
return void

TreatAs() public method

Assume that an object reference is on the IL stack. Change the static Clr type from "clrTypeSrc" to "clrTypeDst"
public TreatAs ( Type clrTypeSrc, Type clrTypeDst ) : void
clrTypeSrc Type
clrTypeDst Type
return void