public CallFlowNode AddCallNode( IRoutineLocation location, IEnumerable <Expression> arguments = null, IEnumerable <FlowVariable> returnAssignments = null, CallKind kind = CallKind.Static, FlowNodeFlags flags = FlowNodeFlags.None) { Contract.Requires <InvalidOperationException>(this.Graph != null); Contract.Requires <ArgumentNullException>(location != null, nameof(location)); Contract.Requires <ArgumentException>(kind != CallKind.ObjectCreation || location.IsConstructor, nameof(kind)); var nodeId = this.nodeIdProvider.GenerateNewId(); var node = new CallFlowNode( this.Graph, nodeId, flags, location, arguments ?? Enumerable.Empty <Expression>(), returnAssignments ?? Enumerable.Empty <FlowVariable>(), kind); this.Graph.MutableNodes.Add(node); Contract.Assert(nodeId.Value == this.Graph.MutableNodes.IndexOf(node)); return(node); }
private static bool VerifyConstructorUsage( IRoutineLocation location, IEnumerable <FlowVariable> returnAssignments) { return(location.IsConstructor && returnAssignments.Count() == 1 && returnAssignments.Single().Sort == References.Sort); }
public async Task <DisplayGraph> GetDisplayGraphAsync(IRoutineLocation location) { Contract.Requires <ArgumentException>(location is MethodLocation, nameof(location)); var graphs = await this.LazyGenerateGraphsAsync((MethodLocation)location); return(graphs.DisplayGraph); }
internal ThrowExceptionFlowNode( FlowGraph graph, FlowNodeId id, FlowNodeFlags flags, IRoutineLocation constructorLocation, IEnumerable <Expression> arguments) : base(graph, id, flags) { Contract.Requires(constructorLocation != null); Contract.Requires(arguments != null); this.ConstructorLocation = constructorLocation; this.Arguments = arguments.ToImmutableArray(); }
internal static void CheckThrowExceptionNode( ThrowExceptionFlowNode node, FlowGraph graph, int ingoingCount, int outgoingCount, IRoutineLocation constructorLocation, int argumentsCount) { CheckNode(node, graph, ingoingCount, outgoingCount); Assert.AreEqual(constructorLocation, node.ConstructorLocation); Assert.AreNotEqual(null, node.Arguments); Assert.AreEqual(argumentsCount, node.Arguments.Count); }
internal static void CheckCallNode( CallFlowNode node, FlowGraph graph, int ingoingCount, int outgoingCount, IRoutineLocation location, int argumentsCount, int returnAssignmentsCount) { CheckNode(node, graph, ingoingCount, outgoingCount); Assert.AreEqual(location, node.Location); Assert.AreNotEqual(null, node.Arguments); Assert.AreEqual(argumentsCount, node.Arguments.Count); Assert.AreNotEqual(null, node.ReturnAssignments); Assert.AreEqual(returnAssignmentsCount, node.ReturnAssignments.Count); }
public ThrowExceptionFlowNode AddThrowExceptionNode( IRoutineLocation constructorLocation, IEnumerable <Expression> arguments = null, FlowNodeFlags flags = FlowNodeFlags.None) { Contract.Requires <InvalidOperationException>(this.Graph != null); Contract.Requires <ArgumentNullException>(constructorLocation != null, nameof(constructorLocation)); var nodeId = this.nodeIdProvider.GenerateNewId(); var node = new ThrowExceptionFlowNode( this.Graph, nodeId, flags, constructorLocation, arguments ?? Enumerable.Empty <Expression>()); this.Graph.MutableNodes.Add(node); Contract.Assert(nodeId.Value == this.Graph.MutableNodes.IndexOf(node)); return(node); }
internal CallFlowNode( FlowGraph graph, FlowNodeId id, FlowNodeFlags flags, IRoutineLocation location, IEnumerable <Expression> arguments, IEnumerable <FlowVariable> returnAssignments, CallKind kind) : base(graph, id, flags) { Contract.Requires(location != null); Contract.Requires(arguments != null); Contract.Requires(returnAssignments != null); Contract.Requires( kind != CallKind.ObjectCreation || VerifyConstructorUsage(location, returnAssignments), nameof(kind)); this.Location = location; this.Arguments = arguments.ToImmutableArray(); this.ReturnAssignments = returnAssignments.ToImmutableArray(); this.Kind = kind; }
public Task <FlowGraph> GetFlowGraphAsync(IRoutineLocation location) { return(Task.FromResult(this.generatorToGraphMap[((TestRoutineLocation)location).Generator])); }