示例#1
0
        public OuterFlowEdge GetCallEdge(CallFlowNode callNode, EnterFlowNode enterNode)
        {
            // TODO: Perform the proper comparison
            ////Contract.Requires(callNode.Location.Equals(this.GetLocation(enterNode.Graph.Id)));

            // TODO: Store outer edges instead of recreating them every time
            return(OuterFlowEdge.CreateMethodCall(new OuterFlowEdgeId(-1), callNode, enterNode));
        }
示例#2
0
        public async Task <IReadOnlyList <OuterFlowEdge> > GetReturnEdgesToAsync(CallFlowNode callNode)
        {
            // TODO: Store outer edges instead of recreating them every time
            var graph = (await this.LazyGenerateGraphsAsync((MethodLocation)callNode.Location)).FlowGraph;

            return(graph.Nodes
                   .OfType <ReturnFlowNode>()
                   .Select(returnNode => OuterFlowEdge.CreateReturn(new OuterFlowEdgeId(-1), returnNode, callNode))
                   .ToArray());
        }
示例#3
0
        public Task <IReadOnlyList <OuterFlowEdge> > GetCallEdgesToAsync(EnterFlowNode enterNode)
        {
            // TODO: Store outer edges instead of recreating them every time
            ImmutableArray <CallFlowNode> callSites = this.graphCallSites[enterNode.Graph.Id.Value];
            var result = callSites
                         .Select(callNode => OuterFlowEdge.CreateMethodCall(new OuterFlowEdgeId(-1), callNode, enterNode))
                         .ToArray();

            return(Task.FromResult <IReadOnlyList <OuterFlowEdge> >(result));
        }
示例#4
0
        public Task <IReadOnlyList <OuterFlowEdge> > GetReturnEdgesToAsync(CallFlowNode callNode)
        {
            // TODO: Store outer edges instead of recreating them every time
            var generator = ((TestRoutineLocation)callNode.Location).Generator;
            var graph     = this.generatorToGraphMap[generator];
            var result    =
                graph.Nodes
                .OfType <ReturnFlowNode>()
                .Select(returnNode => OuterFlowEdge.CreateReturn(new OuterFlowEdgeId(-1), returnNode, callNode))
                .ToArray();

            return(Task.FromResult <IReadOnlyList <OuterFlowEdge> >(result));
        }
示例#5
0
        public async Task <IReadOnlyList <OuterFlowEdge> > GetCallEdgesToAsync(EnterFlowNode enterNode)
        {
            var results = new List <OuterFlowEdge>();

            var calledMethodLocation = this.GetLocation(enterNode.Graph.Id);
            var references           = await SymbolFinder.FindCallersAsync(calledMethodLocation.Method, this.Solution);

            foreach (var reference in references)
            {
                Contract.Assert(reference.CalledSymbol.Equals(calledMethodLocation.Method));
                var callingMethod = reference.CallingSymbol as IMethodSymbol;
                if (callingMethod == null)
                {
                    continue;
                }

                var callingMethodLocation = new MethodLocation(callingMethod);
                if (!callingMethodLocation.CanBeExplored)
                {
                    continue;
                }

                var graphs = await this.LazyGenerateGraphsAsync(callingMethodLocation);

                foreach (var callNode in graphs.FlowGraph.Nodes.OfType <CallFlowNode>())
                {
                    if (((MethodLocation)callNode.Location).Equals(calledMethodLocation))
                    {
                        // TODO: Store outer edges instead of recreating them every time
                        var callEdge = OuterFlowEdge.CreateMethodCall(new OuterFlowEdgeId(-1), callNode, enterNode);
                        results.Add(callEdge);
                    }
                }
            }

            return(results.ToArray());
        }
示例#6
0
 public OuterFlowEdge GetCallEdge(CallFlowNode callNode, EnterFlowNode enterNode)
 {
     // TODO: Store outer edges instead of recreating them every time
     return(OuterFlowEdge.CreateMethodCall(new OuterFlowEdgeId(-1), callNode, enterNode));
 }