Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        internal EnterFlowNode(FlowGraph graph, FlowNodeId id, FlowNodeFlags flags, IEnumerable <FlowVariable> parameters)
            : base(graph, id, flags)
        {
            Contract.Requires(parameters != null);

            this.Parameters = parameters.ToImmutableArray();
        }
Ejemplo n.º 3
0
        internal InnerFlowNode(FlowGraph graph, FlowNodeId id, FlowNodeFlags flags, IEnumerable <Operation> operations)
            : base(graph, id, flags)
        {
            Contract.Requires(operations != null);

            this.Operations = operations.ToImmutableArray();
        }
Ejemplo n.º 4
0
        internal ReturnFlowNode(FlowGraph graph, FlowNodeId id, FlowNodeFlags flags, IEnumerable <Expression> returnValues)
            : base(graph, id, flags)
        {
            Contract.Requires(returnValues != null);

            this.ReturnValues = returnValues.ToImmutableArray();
        }
Ejemplo n.º 5
0
        public NodeConfig(FlowNodeFilter cat, string desc, FlowNodeFlags nodeFlags, FlowNodeType nodeType, InputPortConfig[] inputPorts, OutputPortConfig[] outputPorts)
            : this()
        {
            flags = nodeFlags;
            filter = cat;
            description = desc;
            type = nodeType;

            inputs = inputPorts.Cast<object>().ToArray();
            outputs = outputPorts.Cast<object>().ToArray();
        }
Ejemplo n.º 6
0
        public NodeConfig(FlowNodeFilter cat, string desc, FlowNodeFlags nodeFlags, FlowNodeType nodeType, InputPortConfig[] inputPorts, OutputPortConfig[] outputPorts)
            : this()
        {
            flags       = nodeFlags;
            filter      = cat;
            description = desc;
            type        = nodeType;

            inputs  = inputPorts.Cast <object>().ToArray();
            outputs = outputPorts.Cast <object>().ToArray();
        }
Ejemplo n.º 7
0
        internal FlowNode(FlowGraph graph, FlowNodeId id, FlowNodeFlags flags)
        {
            Contract.Requires(graph != null);
            Contract.Requires(id.IsValid);

            this.Graph         = graph;
            this.Id            = id;
            this.Flags         = flags;
            this.IngoingEdges  = this.MutableIngoingEdges;
            this.OutgoingEdges = this.MutableOutgoingEdges;
        }
Ejemplo n.º 8
0
        // TODO: Add even more overloads (for example, consider directly using immutable array) and optimize their calls
        public InnerFlowNode AddInnerNode(IEnumerable <Operation> operations = null, FlowNodeFlags flags = FlowNodeFlags.None)
        {
            Contract.Requires <InvalidOperationException>(this.Graph != null);

            var nodeId = this.nodeIdProvider.GenerateNewId();
            var node   = new InnerFlowNode(this.Graph, nodeId, flags, operations ?? Enumerable.Empty <Operation>());

            this.Graph.MutableNodes.Add(node);
            Contract.Assert(nodeId.Value == this.Graph.MutableNodes.IndexOf(node));

            return(node);
        }
        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();
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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;
        }
Ejemplo n.º 12
0
 public NodeConfig(FlowNodeCategory cat, string desc, FlowNodeFlags nodeFlags = 0)
     : this()
 {
     flags = nodeFlags;
     category = cat;
     description = desc;
 }