コード例 #1
0
        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());
        }
コード例 #2
0
 /// <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.");
     }
 }
コード例 #3
0
 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;
 }
コード例 #4
0
        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.");
            }
        }
コード例 #5
0
ファイル: ControlFlow.cs プロジェクト: xiaotie/NRefactory
 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;
 }
コード例 #6
0
ファイル: ControlFlow.cs プロジェクト: xiaotie/NRefactory
            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);
            }
コード例 #7
0
ファイル: ControlFlow.cs プロジェクト: xiaotie/NRefactory
 protected virtual ControlFlowEdge CreateEdge(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type)
 {
     cancellationToken.ThrowIfCancellationRequested();
     return(new ControlFlowEdge(from, to, type));
 }
コード例 #8
0
 /// <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;
 }
コード例 #9
0
 protected virtual ControlFlowEdge CreateEdge(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type)
 {
     return(new ControlFlowEdge(from, to, type));
 }
コード例 #10
0
ファイル: StateTransition.cs プロジェクト: lanicon/Echo
 /// <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;
 }
コード例 #11
0
ファイル: StateTransition.cs プロジェクト: mirec12590/Echo
 /// <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;
 }
コード例 #12
0
 internal AdjacencyCollection(ControlFlowNode <TContents> owner, ControlFlowEdgeType edgeType)
 {
     EdgeType = edgeType;
     Owner    = owner ?? throw new ArgumentNullException(nameof(owner));
 }
コード例 #13
0
 /// <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;
 }
コード例 #14
0
 /// <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;
 }
コード例 #15
0
 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;
 }
コード例 #16
0
 protected virtual ControlFlowEdge CreateEdge(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type)
 {
     cancellationToken.ThrowIfCancellationRequested();
     return new ControlFlowEdge(from, to, type);
 }