PostSharp SDK 6.10 / / Class Reference / Post­Sharp.​Sdk.​Code­Model Namespace / Instruction­Reader Class

InstructionReader Class

Reads a stream of binary IL instructions and debugging sequence points.
Inheritance Hierarchy
System.Object
  PostSharp.Sdk.CodeModel.InstructionReader

Namespace:  PostSharp.Sdk.CodeModel
Assembly:  PostSharp.Compiler.Engine (in PostSharp.Compiler.Engine.dll) Version: 6.10.14.0 (6.10.14.0)
Syntax
C#
public sealed class InstructionReader : IDisposable

The InstructionReader type exposes the following members.

Properties
  NameDescription
Public propertyCurrentInstruction
Gets the current instruction.
Public propertyCurrentInstructionBlock
Gets the InstructionBlock on which the current InstructionReader is positioned.
Public propertyCurrentInstructionSequence
Gets the InstructionSequence on which the current InstructionReader is positioned.
Public propertyIsAtEnfOfSequence
Determines whether the current instruction is the last of the sequence.
Public propertyIsSymbolResolutionEnabled
Determines whether resolution of local variable symbols is enabled for the current reader.
Public propertyMethodBody
Gets the MethodBodyDeclaration to which the current InstructionReader is assigned.
Public propertyModule
Gets the module to which this InstructionReader is associates.
Methods
  NameDescription
Public methodCreateBookmark
Creates a bookmark, thanks to which the current InstructionReader can move forward and then return to the current location.
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public methodEnterInstructionBlock
Enters an InstructionBlock.
Public methodEnterInstructionSequence
Enters an InstructionSequence.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize (Overrides Object.Finalize().)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetLocalVariableSymbol(Int32)
Gets the LocalVariableSymbol associated to a given ordinal in the current context.
Public methodGetLocalVariableSymbol(Int32, Boolean)
Gets the LocalVariableSymbol of a local variable given its ordinal and optionally creates default symbol if no symbol is associated to the given ordinal in the current context.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGoToBookmark
Moves the current InstructionReader to a given bookmark.
Public methodJumpToInstructionBlock
Prepares the current InstructionReader so that it can read a specific block, without assumption on the current state of the InstructionReader.
Public methodLeaveInstructionBlock
Leaves the active InstructionBlock, and sets the position of the current InstructionReader to the parent block of the active block.
Public methodLeaveInstructionSequence
Leaves the active InstructionSequence, and sets the position of the current InstructionReader to the parent block of the active sequence.
Public methodReadInstruction
Reads the next instruction of the active InstructionSequence.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Remarks

Each InstructionReader instance is assigned to a single method. Developers must use the CreateInstructionReader() method to get an InstructionReader instance.

When you want to read an instruction block, you first need to enter it using the EnterInstructionBlock(InstructionBlock) method. The EnterInstructionBlock(InstructionBlock) method expect that the active block of the InstructionReader is the parent of the block you want to enter, so you have to enter all ascendant blocks, from the root to the leave, like in a stack model. Then you attach the reader to a sequence using EnterInstructionSequence(InstructionSequence). To read another sequence, you need first to use LeaveInstructionSequence(), then again EnterInstructionSequence(InstructionSequence). Use LeaveInstructionBlock() to leave a block.

If you want to enter a specific block without entering all its ancestors, use the JumpToInstructionBlock(InstructionBlock) method, which will make the proper calls to LeaveInstructionBlock() and EnterInstructionBlock(InstructionBlock) automatically.

When the InstructionReader has entered an InstructionSequence, you can use it as a classic reader. The ReadInstruction() reads the next instruction and you can read it on the instance properties of the InstructionReader.

See Also