Class BasicBlock<TInstruction>
- Namespace
- Echo.ControlFlow.Blocks
- Assembly
- Echo.ControlFlow.dll
Represents one basic block in a control flow graph, consisting of a list of instructions (or statements).
public class BasicBlock<TInstruction> : IBlock<TInstruction> where TInstruction : notnull
Type Parameters
TInstructionThe type of instructions that the basic block contains.
- Inheritance
-
BasicBlock<TInstruction>
- Implements
-
IBlock<TInstruction>
- Inherited Members
Constructors
BasicBlock()
Creates a new, empty basic block.
public BasicBlock()
BasicBlock(IEnumerable<TInstruction>)
Creates a new basic block with the provided instructions.
public BasicBlock(IEnumerable<TInstruction> instructions)
Parameters
instructionsIEnumerable<TInstruction>The instructions to add to the basic block.
Exceptions
- ArgumentNullException
Occurs when
instructionsisnull.
BasicBlock(long)
Creates a new, empty basic block, with the provided offset.
public BasicBlock(long offset)
Parameters
offsetlongThe offset to assign to the basic block.
BasicBlock(long, IEnumerable<TInstruction>)
Creates a new basic block with the provided offset and list of instructions.
public BasicBlock(long offset, IEnumerable<TInstruction> instructions)
Parameters
offsetlongThe offset to assign to the basic block.
instructionsIEnumerable<TInstruction>The instructions to add to the basic block.
Exceptions
- ArgumentNullException
Occurs when
instructionsisnull.
Properties
Footer
Gets the last instruction that is evaluated when this basic block is executed.
public TInstruction? Footer { get; }
Property Value
- TInstruction
Header
Gets the first instruction that is evaluated when this basic block is executed.
public TInstruction? Header { get; }
Property Value
- TInstruction
Instructions
Gets a collection of instructions that are executed in sequence when this basic block is executed.
public IList<TInstruction> Instructions { get; }
Property Value
- IList<TInstruction>
IsEmpty
Gets a value indicating whether the basic block contains any instruction.
public bool IsEmpty { get; }
Property Value
Offset
Gets or sets the offset (or identifier) of this basic block.
public long Offset { get; set; }
Property Value
Methods
AcceptVisitor(IBlockVisitor<TInstruction>)
Visit the current block using the provided visitor.
public void AcceptVisitor(IBlockVisitor<TInstruction> visitor)
Parameters
visitorIBlockVisitor<TInstruction>The visitor to accept.
AcceptVisitor<TState, TResult>(IBlockVisitor<TInstruction, TState, TResult>, TState)
Visit the current block using the provided visitor.
public TResult AcceptVisitor<TState, TResult>(IBlockVisitor<TInstruction, TState, TResult> visitor, TState state)
Parameters
visitorIBlockVisitor<TInstruction, TState, TResult>The visitor to accept.
stateTStateAn argument to pass onto the visitor.
Returns
- TResult
Type Parameters
TStateTResult
GetFirstBlock()
Gets the first basic block that appears in the ordered list of blocks.
public BasicBlock<TInstruction> GetFirstBlock()
Returns
- BasicBlock<TInstruction>
The first basic block, or
nullif the block contains no basic blocks..
GetLastBlock()
Gets the last basic block that appears in the ordered list of blocks.
public BasicBlock<TInstruction> GetLastBlock()
Returns
- BasicBlock<TInstruction>
The last basic block, or
nullif the block contains no basic blocks..
ToString()
public override string ToString()
Returns
UpdateOffset(IArchitecture<TInstruction>)
Synchronizes the basic block's offset with the offset of the first instruction.
public void UpdateOffset(IArchitecture<TInstruction> architecture)
Parameters
architectureIArchitecture<TInstruction>The architecture description of the instructions.