Exemplo n.º 1
0
        /// <summary>
        /// Applies a function to a copy of this control-flow graph and
        /// either incorporates those changes into this control-flow graph
        /// or discards them, depending on the Boolean value returned by the
        /// transforming function.
        /// </summary>
        /// <param name="transform">
        /// A function that takes a copy of this control-flow graph and modifies it.
        /// If the function returns <c>true</c>, then this control-flow graph is
        /// set to the modified version created by the function; otherwise, this
        /// control-flow graph is left unchanged.
        /// </param>
        /// <returns>
        /// <paramref name="transform"/>'s return value.
        /// </returns>
        public bool TryForkAndMerge(Func <FlowGraphBuilder, bool> transform)
        {
            var copy = new FlowGraphBuilder(ImmutableGraph);

            if (transform(copy))
            {
                ImmutableGraph = copy.ImmutableGraph;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a basic block builder from a graph and a tag.
 /// </summary>
 /// <param name="graph">The basic block builder's defining graph.</param>
 /// <param name="tag">The basic block's tag.</param>
 internal BasicBlockBuilder(FlowGraphBuilder graph, BasicBlockTag tag)
 {
     this.Graph = graph;
     this.Tag   = tag;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Zips this branch's arguments with their corresponding
 /// parameters.
 /// </summary>
 /// <param name="graph">
 /// The graph that defines the branch.
 /// </param>
 /// <returns>
 /// A sequence of key-value pairs where the keys are basic
 /// block parameters and the values are branch arguments.
 /// </returns>
 public IEnumerable <KeyValuePair <ValueTag, BranchArgument> > ZipArgumentsWithParameters(
     FlowGraphBuilder graph)
 {
     return(ZipArgumentsWithParameters(graph.ImmutableGraph));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a named instruction builder from a graph and a tag.
 /// </summary>
 /// <param name="graph">The instruction builder's defining graph.</param>
 /// <param name="tag">The instruction's tag.</param>
 internal NamedInstructionBuilder(FlowGraphBuilder graph, ValueTag tag)
 {
     this.graph = graph;
     this.Tag   = tag;
 }