示例#1
0
        internal static ILabel ConcatTrees(this IEnumerable <Node> trees, ILabelFactory labelFactory, ControlFlowInstruction next)
        {
            var treesReversed = trees.Reverse().ToList();
            var resultTree    = treesReversed
                                .Skip(1)
                                .Aggregate(
                new Tree(treesReversed.First(), next),
                (tree, node) => new Tree(node, new UnconditionalJump(labelFactory.GetLabel(tree))));

            return(labelFactory.GetLabel(resultTree));
        }
示例#2
0
        public static ILabel MakeTreeChain(
            this IEnumerable <Node> nodes, ILabelFactory labelFactory, ControlFlowInstruction controlFlow)
        {
            var nodesList = nodes.Reverse().ToList();

            return(MakeTreeChain(nodesList.Skip(1).Reverse(), labelFactory, labelFactory.GetLabel(new Tree(nodesList.First(), controlFlow))));
        }
示例#3
0
 public static ILabel MakeTreeChain(this IEnumerable <Node> nodes, ILabelFactory labelFactory, ILabel after)
 {
     return(nodes
            .Reverse()
            .Aggregate(after, (next, node) =>
     {
         var controlFlow = new UnconditionalJump(next);
         var tree = new Tree(node, controlFlow);
         return labelFactory.GetLabel(tree);
     }));
 }