Table of Contents

Class NodeCollection<TInstruction>

Namespace
Echo.DataFlow.Collections
Assembly
Echo.DataFlow.dll

Represents a mutable collection of nodes present in a data flow graph.

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

Type Parameters

TInstruction

The type of instruction that is stored in each node.

Inheritance
NodeCollection<TInstruction>
Implements
ICollection<DataFlowNode<TInstruction>>
IEnumerable<DataFlowNode<TInstruction>>
Inherited Members

Properties

Count

public int Count { get; }

Property Value

int

IsReadOnly

public bool IsReadOnly { get; }

Property Value

bool

Methods

Add(DataFlowNode<TInstruction>)

public void Add(DataFlowNode<TInstruction> item)

Parameters

item DataFlowNode<TInstruction>

Add(TInstruction)

Creates and adds a new node to the collection of data flow nodes.

public DataFlowNode<TInstruction> Add(TInstruction contents)

Parameters

contents TInstruction

The contents of the node.

Returns

DataFlowNode<TInstruction>

The created node.

AddRange(IEnumerable<DataFlowNode<TInstruction>>)

Adds a collection of nodes to the graph.

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

Parameters

items IEnumerable<DataFlowNode<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(DataFlowNode<TInstruction>)

public bool Contains(DataFlowNode<TInstruction> item)

Parameters

item DataFlowNode<TInstruction>

Returns

bool

CopyTo(DataFlowNode<TInstruction>[], int)

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

Parameters

array DataFlowNode<TInstruction>[]
arrayIndex int

CreateOffsetMap()

Constructs a mapping from instruction offsets to their respective nodes.

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

Returns

IDictionary<long, DataFlowNode<TInstruction>>

The mapping

Exceptions

ArgumentException

The control flow graph contains nodes with duplicated offsets.

GetByOffset(long)

Finds a node by its instruction offset.

public DataFlowNode<TInstruction>? GetByOffset(long offset)

Parameters

offset long

The offset.

Returns

DataFlowNode<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<DataFlowNode<TInstruction>> GetEnumerator()

Returns

IEnumerator<DataFlowNode<TInstruction>>

Remove(DataFlowNode<TInstruction>)

public bool Remove(DataFlowNode<TInstruction> item)

Parameters

item DataFlowNode<TInstruction>

Returns

bool

UpdateOffsets()

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

public void UpdateOffsets()