C# Class PERWAPI.CILInstructions

The IL instructions for a method
Afficher le fichier Open project: xored/f4 Class Usage Examples

Méthodes publiques

Свойство Type Description
blockStack System.Collections.Stack

Méthodes publiques

Méthode Description
AddTryBlock ( TryBlock tryBlock ) : void
BindConstant ( string name, object value, Type type ) : ConstantBinding

Bind a constant to the CIL instructions.

BindLocal ( Local local ) : LocalBinding

Bind a local to the CIL instructions.

BindLocal ( string name, int index ) : LocalBinding

Bind a local to the CIL instructions.

Branch ( BranchOp inst, CILLabel lab ) : void

Add a branch instruction

CloseScope ( ) : void

Close the current scope.

CodeLabel ( CILLabel lab ) : void

Add a label to the CIL instructions

EndCatchBlock ( Class exceptType, TryBlock tryBlock ) : void

Mark this position as the end of the last started block and make it a catch block. This catch block is associated with the specified try block.

EndFaultBlock ( TryBlock tryBlock ) : void

Mark this position as the end of the last started block and make it a fault block. This fault block is associated with the specified try block.

EndFilterBlock ( CILLabel filterLab, TryBlock tryBlock ) : void

Mark this position as the end of the last started block and make it a filter block. This filter block is associated with the specified try block. The format is: filterLab: ... ... filterHandler : ... ...

EndFinallyBlock ( TryBlock tryBlock ) : void

Mark this position as the end of the last started block and make it a finally block. This finally block is associated with the specified try block.

EndInsert ( ) : void

Stop inserting instructions into the buffer. Any instructions added after this call will go at the end of the instruction buffer. To be used with StartInsert(). This method cannot be called if not in "insert" mode.

EndInstCounter ( ) : void

Reset the counter for GetNextInstuction to the first instruction. This method cannot be called when in "insert" mode.

EndTryBlock ( ) : TryBlock

Mark this position as the end of the last started block and make it a try block. This try block is added to the current instructions (ie do not need to call AddTryBlock)

FieldInst ( FieldOp inst, Field f ) : void

Add an instruction with a field parameter

GetInstructions ( ) : PERWAPI.CILInstruction[]

Get all the IL instructions. This method cannot be called when in "insert" mode.

GetMaxStackDepthRequired ( ) : int

Returns the maximum stack depth required by these CIL instructions.

GetNextInstruction ( ) : CILInstruction

Get the next instruction in the instruction buffer in sequence. An internal index is kept to keep track of which instruction was the last retrieved by this method. On the first call, the first instruction in the buffer is retrieved. The instruction index may be zeroed using ResetInstCounter(). This method cannot be called when in "insert" mode.

GetPrevInstruction ( ) : CILInstruction

Get the previous instruction in the instruction buffer in sequence. An internal index is kept to keep track of which instruction was the last retrieved by this method. This method cannot be called when in "insert" mode.

InInsertMode ( ) : bool

Check if the buffer is ready for insertion of extra instructions. The buffer only needs to be in insert mode when instructions need to be added to existing instructions, not for addition of instructions to the end of the buffer.

Inst ( Op inst ) : void

Add a simple IL instruction

IntInst ( IntOp inst, int val ) : void

Add an IL instruction with an integer parameter

IntLine ( int num ) : void
IntLine ( int sLin, int sCol, int eLin, int eCol ) : void

CLS compliant version of Line()

Line ( uint num, uint startCol ) : void

Create a new line instruction.

Line ( uint num, uint startCol, uint endCol ) : void

Create a new line instruction.

Line ( uint startNum, uint startCol, uint endNum, uint endCol ) : void

Create a new line instruction.

Line ( uint startNum, uint startCol, uint endNum, uint endCol, SourceFile sFile ) : void

Create a new line instruction.

LoadArg ( int argNo ) : void

Add the instruction to load an argument on TOS. This method selects the correct instruction based on the value of argNo

LoadArgAdr ( int argNo ) : void

Add the instruction to load the address of an argument on TOS. This method selects the correct instruction based on the value of argNo.

LoadLocal ( int locNo ) : void

Add the instruction to load a local on TOS. This method selects the correct instruction based on the value of locNo.

LoadLocalAdr ( int locNo ) : void

Add the instruction to load the address of a local on TOS. This method selects the correct instruction based on the value of locNo.

MethInst ( MethodOp inst, Method m ) : void

Add an instruction with a method parameter

NewCodedLabel ( ) : CILLabel

Create a new label at this position in the code buffer

NewLabel ( ) : CILLabel

Create a new CIL label. To place the label in the CIL instruction stream use CodeLabel.

NumInstructions ( ) : int

The number of instructions currently in the buffer.

OpenScope ( ) : void

Open a new scope.

PushFalse ( ) : void

Add an instruction to push the boolean value false on TOS

PushInt ( int i ) : void

Add an instruction which puts an integer on TOS. This method selects the correct instruction based on the value of the integer.

PushLong ( long l ) : void

Add the instruction to load a long on TOS

PushTrue ( ) : void

Add an instruction to push the boolean value true on TOS

RemoveInstruction ( int pos ) : void

Remove the instruction at a specified position from the buffer. If you remove the "current" instruction (from GetNext or GetPrev) then the "current" instruction becomes the instruction before that in the buffer.

RemoveInstructions ( int startRange, int endRange ) : void

Remove the instructions from position "startRange" to (and including) position "endRange" from the buffer. If the range removed contains the "current" instruction (from GetNext or GetPrev) then the "current" instruction becomes the instruction before startRange in the buffer.

ReplaceInstruction ( int pos ) : void

Replace a single IL instruction at position pos in the buffer with some new instruction(s). This removes the instruction and puts the instruction buffer into "insert" mode at the position of the removed instruction. EndInsert must be called to insert the new instructions. This method cannot be called when in "insert" mode.

ReplaceInstruction ( int from, int to ) : void

Replace a number of IL instructions beginning at position pos in the buffer with some new instruction(s). This removes the instructions and puts the instruction buffer into "insert" mode at the position of the removed instructions. EndInsert must be called to insert the new instructions. The instructions from index "from" up to and including index "to" will be replaced by the new instructions entered. This method cannot be called when in "insert" mode.

ResetInstCounter ( ) : void

Reset the counter for GetNextInstuction to the first instruction. This method cannot be called when in "insert" mode.

SetInstructions ( CILInstruction insts ) : void

Set the instruction to be the new array of instructions, this will replace any existing instructions. This method cannot be called when in "insert" mode.

StartBlock ( ) : void

Mark this position as the start of a new block (try, catch, filter, finally or fault)

StartInsert ( ) : void

This method should only be used to insert instructions into a buffer which already contains some instructions. Start inserting instructions into the instruction buffer ie. set the buffer to "insert" mode. The position of the insertion will be directly after the "current instruction" as used be GetNextInstruction(). The instructions to be inserted are any calls to the instruction specific methods - Inst, TypeInst, MethodInst, etc. This method cannot be called if already in "insert" mode.

StoreArg ( int argNo ) : void

Add the instruction to store to an argument. This method selects the correct instruction based on the value of argNo.

StoreLocal ( int locNo ) : void

Add the instruction to store to a local. This method selects the correct instruction based on the value of locNo.

Switch ( CILLabel labs ) : void

Add a switch instruction

TypeInst ( TypeOp inst, Type aType ) : void

Add an instruction with a type parameter

calli ( CalliSig sig ) : void

Add the calli instruction

emitbyte ( byte bVal ) : void

Add a byte to the CIL instructions (.emitbyte)

ldc_i8 ( long cVal ) : void

Add the load long instruction

ldc_r4 ( float cVal ) : void

Add the load float32 instruction

ldc_r8 ( double cVal ) : void

Add the load float64 instruction

ldstr ( string str ) : void

Add the load string instruction

Private Methods

Méthode Description
AddEHClause ( EHClause ehc ) : void
AddToBuffer ( CILInstruction inst ) : void
AddToLines ( Line line ) : void
BuildCILInfo ( CILWriter output ) : void
BuildTables ( MetaDataOut md ) : void
CILInstructions ( MethodDef meth ) : System
ChangeRefsToDefs ( ClassDef newType, ClassDef oldTypes ) : void
CheckCode ( uint locSigIx, bool initLocals, int maxStack, MetaDataOut metaData ) : void
GetCodeSize ( ) : uint
GetLabel ( ArrayList labs, uint targetOffset ) : CILLabel
InsertInstructions ( int ix, CILInstruction newInsts, int numNew ) : void
IsEmpty ( ) : bool
IsTerminatingInstruction ( CILInstruction cilInstr ) : bool
SetAndResolveInstructions ( CILInstruction insts ) : void
TraverseMaxDepth ( CodeBlock entryBlock ) : int
UpdateIndexesFrom ( int ix ) : void
Write ( CILWriter output ) : void
Write ( PEWriter output ) : void

Method Details

AddTryBlock() public méthode

public AddTryBlock ( TryBlock tryBlock ) : void
tryBlock TryBlock
Résultat void

BindConstant() public méthode

Bind a constant to the CIL instructions.
public BindConstant ( string name, object value, Type type ) : ConstantBinding
name string The name of the constant.
value object The value of the constant.
type Type The type of the constant.
Résultat ConstantBinding

BindLocal() public méthode

Bind a local to the CIL instructions.
public BindLocal ( Local local ) : LocalBinding
local Local The local variable to load.
Résultat LocalBinding

BindLocal() public méthode

Bind a local to the CIL instructions.
public BindLocal ( string name, int index ) : LocalBinding
name string The name of the local variable..
index int The index of the local variable.
Résultat LocalBinding

Branch() public méthode

Add a branch instruction
public Branch ( BranchOp inst, CILLabel lab ) : void
inst BranchOp the branch instruction
lab CILLabel the label that is the target of the branch
Résultat void

CloseScope() public méthode

Close the current scope.
public CloseScope ( ) : void
Résultat void

CodeLabel() public méthode

Add a label to the CIL instructions
public CodeLabel ( CILLabel lab ) : void
lab CILLabel the label to be added
Résultat void

EndCatchBlock() public méthode

Mark this position as the end of the last started block and make it a catch block. This catch block is associated with the specified try block.
public EndCatchBlock ( Class exceptType, TryBlock tryBlock ) : void
exceptType Class the exception type to be caught
tryBlock TryBlock the try block associated with this catch block
Résultat void

EndFaultBlock() public méthode

Mark this position as the end of the last started block and make it a fault block. This fault block is associated with the specified try block.
public EndFaultBlock ( TryBlock tryBlock ) : void
tryBlock TryBlock the try block associated with this fault block
Résultat void

EndFilterBlock() public méthode

Mark this position as the end of the last started block and make it a filter block. This filter block is associated with the specified try block. The format is: filterLab: ... ... filterHandler : ... ...
public EndFilterBlock ( CILLabel filterLab, TryBlock tryBlock ) : void
filterLab CILLabel the label where the filter code is
tryBlock TryBlock the try block associated with this filter block
Résultat void

EndFinallyBlock() public méthode

Mark this position as the end of the last started block and make it a finally block. This finally block is associated with the specified try block.
public EndFinallyBlock ( TryBlock tryBlock ) : void
tryBlock TryBlock the try block associated with this finally block
Résultat void

EndInsert() public méthode

Stop inserting instructions into the buffer. Any instructions added after this call will go at the end of the instruction buffer. To be used with StartInsert(). This method cannot be called if not in "insert" mode.
public EndInsert ( ) : void
Résultat void

EndInstCounter() public méthode

Reset the counter for GetNextInstuction to the first instruction. This method cannot be called when in "insert" mode.
public EndInstCounter ( ) : void
Résultat void

EndTryBlock() public méthode

Mark this position as the end of the last started block and make it a try block. This try block is added to the current instructions (ie do not need to call AddTryBlock)
public EndTryBlock ( ) : TryBlock
Résultat TryBlock

FieldInst() public méthode

Add an instruction with a field parameter
public FieldInst ( FieldOp inst, Field f ) : void
inst FieldOp the CIL instruction
f Field the field parameter
Résultat void

GetInstructions() public méthode

Get all the IL instructions. This method cannot be called when in "insert" mode.
public GetInstructions ( ) : PERWAPI.CILInstruction[]
Résultat PERWAPI.CILInstruction[]

GetMaxStackDepthRequired() public méthode

Returns the maximum stack depth required by these CIL instructions.
public GetMaxStackDepthRequired ( ) : int
Résultat int

GetNextInstruction() public méthode

Get the next instruction in the instruction buffer in sequence. An internal index is kept to keep track of which instruction was the last retrieved by this method. On the first call, the first instruction in the buffer is retrieved. The instruction index may be zeroed using ResetInstCounter(). This method cannot be called when in "insert" mode.
public GetNextInstruction ( ) : CILInstruction
Résultat CILInstruction

GetPrevInstruction() public méthode

Get the previous instruction in the instruction buffer in sequence. An internal index is kept to keep track of which instruction was the last retrieved by this method. This method cannot be called when in "insert" mode.
public GetPrevInstruction ( ) : CILInstruction
Résultat CILInstruction

InInsertMode() public méthode

Check if the buffer is ready for insertion of extra instructions. The buffer only needs to be in insert mode when instructions need to be added to existing instructions, not for addition of instructions to the end of the buffer.
public InInsertMode ( ) : bool
Résultat bool

Inst() public méthode

Add a simple IL instruction
public Inst ( Op inst ) : void
inst Op the IL instruction
Résultat void

IntInst() public méthode

Add an IL instruction with an integer parameter
public IntInst ( IntOp inst, int val ) : void
inst IntOp the IL instruction
val int the integer parameter value
Résultat void

IntLine() public méthode

public IntLine ( int num ) : void
num int
Résultat void

IntLine() public méthode

CLS compliant version of Line()
public IntLine ( int sLin, int sCol, int eLin, int eCol ) : void
sLin int The start line
sCol int The start column
eLin int The end line
eCol int The end column
Résultat void

Line() public méthode

Create a new line instruction.
public Line ( uint num, uint startCol ) : void
num uint The line for the given code segment.
startCol uint The starting column for the code segment.
Résultat void

Line() public méthode

Create a new line instruction.
public Line ( uint num, uint startCol, uint endCol ) : void
num uint The line for the given code segment.
startCol uint The starting column for the code segment.
endCol uint The ending column for the code segment.
Résultat void

Line() public méthode

Create a new line instruction.
public Line ( uint startNum, uint startCol, uint endNum, uint endCol ) : void
startNum uint The starting line for the code segment.
startCol uint The starting column for the code segment.
endNum uint The ending line for the code segment.
endCol uint The ending column for the code segment.
Résultat void

Line() public méthode

Create a new line instruction.
public Line ( uint startNum, uint startCol, uint endNum, uint endCol, SourceFile sFile ) : void
startNum uint The starting line for the code segment.
startCol uint The starting column for the code segment.
endNum uint The ending line for the code segment.
endCol uint The ending column for the code segment.
sFile SourceFile The source file for the given code segment.
Résultat void

LoadArg() public méthode

Add the instruction to load an argument on TOS. This method selects the correct instruction based on the value of argNo
public LoadArg ( int argNo ) : void
argNo int the number of the argument
Résultat void

LoadArgAdr() public méthode

Add the instruction to load the address of an argument on TOS. This method selects the correct instruction based on the value of argNo.
public LoadArgAdr ( int argNo ) : void
argNo int the number of the argument
Résultat void

LoadLocal() public méthode

Add the instruction to load a local on TOS. This method selects the correct instruction based on the value of locNo.
public LoadLocal ( int locNo ) : void
locNo int the number of the local to load
Résultat void

LoadLocalAdr() public méthode

Add the instruction to load the address of a local on TOS. This method selects the correct instruction based on the value of locNo.
public LoadLocalAdr ( int locNo ) : void
locNo int the number of the local
Résultat void

MethInst() public méthode

Add an instruction with a method parameter
public MethInst ( MethodOp inst, Method m ) : void
inst MethodOp the CIL instruction
m Method the method parameter
Résultat void

NewCodedLabel() public méthode

Create a new label at this position in the code buffer
public NewCodedLabel ( ) : CILLabel
Résultat CILLabel

NewLabel() public méthode

Create a new CIL label. To place the label in the CIL instruction stream use CodeLabel.
public NewLabel ( ) : CILLabel
Résultat CILLabel

NumInstructions() public méthode

The number of instructions currently in the buffer.
public NumInstructions ( ) : int
Résultat int

OpenScope() public méthode

Open a new scope.
public OpenScope ( ) : void
Résultat void

PushFalse() public méthode

Add an instruction to push the boolean value false on TOS
public PushFalse ( ) : void
Résultat void

PushInt() public méthode

Add an instruction which puts an integer on TOS. This method selects the correct instruction based on the value of the integer.
public PushInt ( int i ) : void
i int the integer value
Résultat void

PushLong() public méthode

Add the instruction to load a long on TOS
public PushLong ( long l ) : void
l long the long value
Résultat void

PushTrue() public méthode

Add an instruction to push the boolean value true on TOS
public PushTrue ( ) : void
Résultat void

RemoveInstruction() public méthode

Remove the instruction at a specified position from the buffer. If you remove the "current" instruction (from GetNext or GetPrev) then the "current" instruction becomes the instruction before that in the buffer.
public RemoveInstruction ( int pos ) : void
pos int position of the instruction to be removed
Résultat void

RemoveInstructions() public méthode

Remove the instructions from position "startRange" to (and including) position "endRange" from the buffer. If the range removed contains the "current" instruction (from GetNext or GetPrev) then the "current" instruction becomes the instruction before startRange in the buffer.
public RemoveInstructions ( int startRange, int endRange ) : void
startRange int
endRange int
Résultat void

ReplaceInstruction() public méthode

Replace a single IL instruction at position pos in the buffer with some new instruction(s). This removes the instruction and puts the instruction buffer into "insert" mode at the position of the removed instruction. EndInsert must be called to insert the new instructions. This method cannot be called when in "insert" mode.
public ReplaceInstruction ( int pos ) : void
pos int position of the instruction to be replaced
Résultat void

ReplaceInstruction() public méthode

Replace a number of IL instructions beginning at position pos in the buffer with some new instruction(s). This removes the instructions and puts the instruction buffer into "insert" mode at the position of the removed instructions. EndInsert must be called to insert the new instructions. The instructions from index "from" up to and including index "to" will be replaced by the new instructions entered. This method cannot be called when in "insert" mode.
public ReplaceInstruction ( int from, int to ) : void
from int the index to start replacing instruction from
to int the last index of the instructions to be replaced
Résultat void

ResetInstCounter() public méthode

Reset the counter for GetNextInstuction to the first instruction. This method cannot be called when in "insert" mode.
public ResetInstCounter ( ) : void
Résultat void

SetInstructions() public méthode

Set the instruction to be the new array of instructions, this will replace any existing instructions. This method cannot be called when in "insert" mode.
public SetInstructions ( CILInstruction insts ) : void
insts CILInstruction The new instructions
Résultat void

StartBlock() public méthode

Mark this position as the start of a new block (try, catch, filter, finally or fault)
public StartBlock ( ) : void
Résultat void

StartInsert() public méthode

This method should only be used to insert instructions into a buffer which already contains some instructions. Start inserting instructions into the instruction buffer ie. set the buffer to "insert" mode. The position of the insertion will be directly after the "current instruction" as used be GetNextInstruction(). The instructions to be inserted are any calls to the instruction specific methods - Inst, TypeInst, MethodInst, etc. This method cannot be called if already in "insert" mode.
public StartInsert ( ) : void
Résultat void

StoreArg() public méthode

Add the instruction to store to an argument. This method selects the correct instruction based on the value of argNo.
public StoreArg ( int argNo ) : void
argNo int the argument to be stored to
Résultat void

StoreLocal() public méthode

Add the instruction to store to a local. This method selects the correct instruction based on the value of locNo.
public StoreLocal ( int locNo ) : void
locNo int the local to be stored to
Résultat void

Switch() public méthode

Add a switch instruction
public Switch ( CILLabel labs ) : void
labs CILLabel the target labels for the switch
Résultat void

TypeInst() public méthode

Add an instruction with a type parameter
public TypeInst ( TypeOp inst, Type aType ) : void
inst TypeOp the CIL instruction
aType Type the type argument for the CIL instruction
Résultat void

calli() public méthode

Add the calli instruction
public calli ( CalliSig sig ) : void
sig CalliSig the signature for the calli
Résultat void

emitbyte() public méthode

Add a byte to the CIL instructions (.emitbyte)
public emitbyte ( byte bVal ) : void
bVal byte
Résultat void

ldc_i8() public méthode

Add the load long instruction
public ldc_i8 ( long cVal ) : void
cVal long the long value
Résultat void

ldc_r4() public méthode

Add the load float32 instruction
public ldc_r4 ( float cVal ) : void
cVal float the float value
Résultat void

ldc_r8() public méthode

Add the load float64 instruction
public ldc_r8 ( double cVal ) : void
cVal double the float value
Résultat void

ldstr() public méthode

Add the load string instruction
public ldstr ( string str ) : void
str string the string value
Résultat void

Property Details

blockStack public_oe property

public Stack,System.Collections blockStack
Résultat System.Collections.Stack