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
TInstructionThe type of data that is stored in each node.
- Inheritance
-
NodeCollection<TInstruction>
- Implements
-
ICollection<ControlFlowNode<TInstruction>>IEnumerable<ControlFlowNode<TInstruction>>
- Inherited Members
Properties
Count
public int Count { get; }
Property Value
IsReadOnly
public bool IsReadOnly { get; }
Property Value
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
itemBasicBlock<TInstruction>The block.
Returns
- ControlFlowNode<TInstruction>
The created node.
Add(ControlFlowNode<TInstruction>)
public void Add(ControlFlowNode<TInstruction> item)
Parameters
itemControlFlowNode<TInstruction>
AddRange(IEnumerable<ControlFlowNode<TInstruction>>)
Adds a collection of nodes to the graph.
public void AddRange(IEnumerable<ControlFlowNode<TInstruction>> items)
Parameters
itemsIEnumerable<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
itemControlFlowNode<TInstruction>
Returns
CopyTo(ControlFlowNode<TInstruction>[], int)
public void CopyTo(ControlFlowNode<TInstruction>[] array, int arrayIndex)
Parameters
arrayControlFlowNode<TInstruction>[]arrayIndexint
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
offsetlongThe offset.
Returns
- ControlFlowNode<TInstruction>
The node, or
nullif 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
itemControlFlowNode<TInstruction>
Returns
UpdateOffsets()
Synchronizes all offsets of each node and basic blocks with the underlying instructions.
public void UpdateOffsets()