Table of Contents

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

TInstruction

The 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

instructions IEnumerable<TInstruction>

The instructions to add to the basic block.

Exceptions

ArgumentNullException

Occurs when instructions is null.

BasicBlock(long)

Creates a new, empty basic block, with the provided offset.

public BasicBlock(long offset)

Parameters

offset long

The 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

offset long

The offset to assign to the basic block.

instructions IEnumerable<TInstruction>

The instructions to add to the basic block.

Exceptions

ArgumentNullException

Occurs when instructions is null.

Properties

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

bool

Offset

Gets or sets the offset (or identifier) of this basic block.

public long Offset { get; set; }

Property Value

long

Methods

AcceptVisitor(IBlockVisitor<TInstruction>)

Visit the current block using the provided visitor.

public void AcceptVisitor(IBlockVisitor<TInstruction> visitor)

Parameters

visitor IBlockVisitor<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

visitor IBlockVisitor<TInstruction, TState, TResult>

The visitor to accept.

state TState

An argument to pass onto the visitor.

Returns

TResult

Type Parameters

TState
TResult

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 null if 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 null if the block contains no basic blocks..

ToString()

public override string ToString()

Returns

string

UpdateOffset(IArchitecture<TInstruction>)

Synchronizes the basic block's offset with the offset of the first instruction.

public void UpdateOffset(IArchitecture<TInstruction> architecture)

Parameters

architecture IArchitecture<TInstruction>

The architecture description of the instructions.