Table of Contents

Class NodeCollection<TInstruction>

Namespace
Echo.ControlFlow.Collections
Assembly
Echo.ControlFlow.dll

Represents a mutable collection of nodes present in a graph.

public class NodeCollection<TInstruction> : ICollection<ControlFlowNode<TInstruction>>, IEnumerable<ControlFlowNode<TInstruction>>, IEnumerable where TInstruction : notnull

Type Parameters

TInstruction

The type of data that is stored in each node.

Inheritance
NodeCollection<TInstruction>
Implements
Inherited Members

Properties

Count

public int Count { get; }

Property Value

int

IsReadOnly

public bool IsReadOnly { get; }

Property Value

bool

Methods

Add(BasicBlock<TInstruction>)

Wraps a basic block into a node and adds it to the graph.

public ControlFlowNode<TInstruction> Add(BasicBlock<TInstruction> item)

Parameters

item BasicBlock<TInstruction>

The block.

Returns

ControlFlowNode<TInstruction>

The created node.

Add(ControlFlowNode<TInstruction>)

public void Add(ControlFlowNode<TInstruction> item)

Parameters

item ControlFlowNode<TInstruction>

AddRange(IEnumerable<ControlFlowNode<TInstruction>>)

Adds a collection of nodes to the graph.

public void AddRange(IEnumerable<ControlFlowNode<TInstruction>> items)

Parameters

items IEnumerable<ControlFlowNode<TInstruction>>

The nodes to add.

Exceptions

ArgumentException

Occurs when at least one node in the provided collection is already added to another graph.

Clear()

public void Clear()

Contains(ControlFlowNode<TInstruction>)

public bool Contains(ControlFlowNode<TInstruction> item)

Parameters

item ControlFlowNode<TInstruction>

Returns

bool

CopyTo(ControlFlowNode<TInstruction>[], int)

public void CopyTo(ControlFlowNode<TInstruction>[] array, int arrayIndex)

Parameters

array ControlFlowNode<TInstruction>[]
arrayIndex int

CreateOffsetMap()

Constructs a mapping from basic block header offsets to their respective nodes.

public IDictionary<long, ControlFlowNode<TInstruction>> CreateOffsetMap()

Returns

IDictionary<long, ControlFlowNode<TInstruction>>

The mapping

Exceptions

ArgumentException

The control flow graph contains nodes with duplicated offsets.

GetByOffset(long)

Finds a node by its basic block header offset.

public ControlFlowNode<TInstruction>? GetByOffset(long offset)

Parameters

offset long

The offset.

Returns

ControlFlowNode<TInstruction>

The node, or null if no node was found with the provided offset.

Remarks

This is a linear lookup. For many lookups by offset, consider first creating an offset map using CreateOffsetMap().

GetEnumerator()

public IEnumerator<ControlFlowNode<TInstruction>> GetEnumerator()

Returns

IEnumerator<ControlFlowNode<TInstruction>>

Remove(ControlFlowNode<TInstruction>)

public bool Remove(ControlFlowNode<TInstruction> item)

Parameters

item ControlFlowNode<TInstruction>

Returns

bool

UpdateOffsets()

Synchronizes all offsets of each node and basic blocks with the underlying instructions.

public void UpdateOffsets()