Пример #1
0
        // statement.id, node.id(direct), node.id(continue)
        // node.id(source), statement.id(destination), edge type
        // node.id(exit), [node.id(source), statement.id(destination)]
        // node.id(exit), [node.id(source), statement.id(destination)]
        // positive if branches
        public virtual DirectGraph BuildDirectGraph(RootStatement root)
        {
            this.root = root;
            graph     = new DirectGraph();
            FlattenStatement();
            // dummy exit node
            Statement  dummyexit = root.GetDummyExit();
            DirectNode node      = new DirectNode(DirectNode.Node_Direct, dummyexit, dummyexit.id.
                                                  ToString());

            node.exprents = new List <Exprent>();
            graph.nodes.AddWithKey(node, node.id);
            Sharpen.Collections.Put(mapDestinationNodes, dummyexit.id, new string[] { node.id
                                                                                      , null });
            SetEdges();
            graph.first = graph.nodes.GetWithKey(mapDestinationNodes.GetOrNull(root.id)[0]);
            graph.SortReversePostOrder();
            return(graph);
        }