public void DisconnectNodeShouldRemoveEdge(ControlFlowEdgeType edgeType, bool removeSourceNode) { var graph = new ControlFlowGraph <int>(IntArchitecture.Instance); var n1 = new ControlFlowNode <int>(0, 0); var n2 = new ControlFlowNode <int>(1, 1); graph.Nodes.AddRange(new[] { n1, n2 }); n1.ConnectWith(n2, edgeType); if (removeSourceNode) { n1.Disconnect(); } else { n2.Disconnect(); } Assert.Empty(n1.GetOutgoingEdges()); Assert.Empty(n2.GetIncomingEdges()); }
/// <summary> /// Creates a new instance of the <see cref="RemoveEdgeAction{TInstruction}"/> class. /// </summary> /// <param name="originOffset">The offset to the branching instruction that is the origin of the edge to remove.</param> /// <param name="targetOffset">The offset to the neighbour that the edge to remove targets.</param> /// <param name="edgeType">The type of edge.</param> /// <exception cref="NotSupportedException"> /// Occurs when <paramref name="edgeType"/> equals <see cref="ControlFlowEdgeType.FallThrough"/> /// </exception> public RemoveEdgeAction(long originOffset, long targetOffset, ControlFlowEdgeType edgeType) : base(originOffset, targetOffset, edgeType) { if (edgeType == ControlFlowEdgeType.FallThrough) { throw new NotSupportedException("Fallthrough edges are not supported."); } }
public ControlFlowEdge(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type) { if (from == null) throw new ArgumentNullException("from"); if (to == null) throw new ArgumentNullException("to"); this.From = from; this.To = to; this.Type = type; }
internal static void AssertEdgeValidity(ControlFlowNode <TContents> owner, ControlFlowEdgeType type, ControlFlowEdge <TContents> item) { if (item.Type != type) { throw new ArgumentException( $"Cannot add an edge of type {item.Type} to a collection of type {type}."); } if (item.Origin != owner) { throw new ArgumentException("Cannot add an edge originating from a different node."); } }
public ControlFlowEdge(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type) { if (from == null) { throw new ArgumentNullException("from"); } if (to == null) { throw new ArgumentNullException("to"); } this.From = from; this.To = to; this.Type = type; }
internal ControlFlowEdge Connect(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type = ControlFlowEdgeType.Normal) { if (from == null || to == null) { return(null); } ControlFlowEdge edge = builder.CreateEdge(from, to, type); from.Outgoing.Add(edge); to.Incoming.Add(edge); return(edge); }
protected virtual ControlFlowEdge CreateEdge(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type) { cancellationToken.ThrowIfCancellationRequested(); return(new ControlFlowEdge(from, to, type)); }
/// <summary> /// Initializes the <see cref="UpdateAdjacencyAction{TInstruction}"/> base class. /// </summary> /// <param name="originOffset">The offset of the branch instruction representing the origin of the edge.</param> /// <param name="targetOffset">The offset of the neighbour that the edge targets.</param> /// <param name="edgeType">The type of edge.</param> protected UpdateAdjacencyAction(long originOffset, long targetOffset, ControlFlowEdgeType edgeType) { OriginOffset = originOffset; TargetOffset = targetOffset; EdgeType = edgeType; }
protected virtual ControlFlowEdge CreateEdge(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type) { return(new ControlFlowEdge(from, to, type)); }
/// <summary> /// Creates a new program state transition. /// </summary> /// <param name="nextState">The new program state.</param> /// <param name="edgeType">The type of edge that was taken.</param> public StateTransition(SymbolicProgramState <TInstruction> nextState, ControlFlowEdgeType edgeType) { NextState = nextState; EdgeType = edgeType; }
/// <summary> /// Creates a new program state transition. /// </summary> /// <param name="nextState">The new program state.</param> /// <param name="edgeType">The type of edge that was taken.</param> public StateTransition(SymbolicProgramState <TInstruction> nextState, ControlFlowEdgeType edgeType) { NextState = nextState ?? throw new ArgumentNullException(nameof(nextState)); EdgeType = edgeType; }
internal AdjacencyCollection(ControlFlowNode <TContents> owner, ControlFlowEdgeType edgeType) { EdgeType = edgeType; Owner = owner ?? throw new ArgumentNullException(nameof(owner)); }
/// <summary> /// Creates a new edge between two nodes. /// </summary> /// <param name="origin">The node to start the edge at.</param> /// <param name="target">The node to use as destination for the edge.</param> /// <param name="edgeType">The type of the edge to create.</param> public ControlFlowEdge(ControlFlowNode <TContents> origin, ControlFlowNode <TContents> target, ControlFlowEdgeType edgeType) { Origin = origin; Target = target; Type = edgeType; }
/// <summary> /// Creates a new successor reference. /// </summary> /// <param name="destinationAddress">The address of the successor instruction.</param> /// <param name="edgeType">The type of control flow transfer that has to be made to go to this successor.</param> public SuccessorInfo(long destinationAddress, ControlFlowEdgeType edgeType) { DestinationAddress = destinationAddress; EdgeType = edgeType; }
internal ControlFlowEdge Connect(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type = ControlFlowEdgeType.Normal) { if (from == null || to == null) return null; ControlFlowEdge edge = builder.CreateEdge(from, to, type); from.Outgoing.Add(edge); to.Incoming.Add(edge); return edge; }
protected virtual ControlFlowEdge CreateEdge(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type) { cancellationToken.ThrowIfCancellationRequested(); return new ControlFlowEdge(from, to, type); }