internal virtual ExpressionNode VisitBranchNode(BranchNode node) { node.BaseNode.Accept(this); node.TrueBranch.Accept(this); node.FalseBranch.Accept(this); return node; }
void Start() { BranchNode._debug_prisePrefab = _debug_prisePrefab; _startNode = new BranchNode(transform.position, 10); _startNode.ResetRays(); StartCoroutine(Grow(_startNode)); }
public Label Branch(Code code, Code codeShort) { var branch = new BranchNode(code, codeShort); this.Add(branch); return(branch.Label); }
void DrawBranch(BranchNode branch) { //if node is a branch, draw children and widgets. if (branch != null) { cursor.x += SPACING.x; var top = branch.rect.yMax; var bottom = branch.rect.yMax; for (int i = 0; i < branch.Children.Count; i++) { var c = branch.Children[i]; if (c != null) { Draw(c, branch); bottom = c.rect.center.y; dropZones.Add(new DropZone(branch, c.rect, i)); if (i == branch.Children.Count - 1) { dropZones.Add(new DropZone(branch, c.rect, i + 1, true)); } } } var left = branch.rect.x + (SPACING.x / 2); ReactEditorUtility.DrawLine(new Vector2(left, top), new Vector3(left, bottom), Color.white); cursor.x -= SPACING.x; } }
// Use this for initialization void Start() { //FlowAI生成 Create FlowAI. _flowAI = GetComponent <FlowAIHolder>().flowAI; //ノード生成 Create nodes. var rotNode = new ProcessNode(); var foundBranch = new BranchNode(); var missingBranch = new BranchNode(); var alertNode = new ProcessNode(); var stopAlertNode = new ProcessNode(); var stopRotNode = new ProcessNode(); //ノード初期化 Initialize nodes. rotNode.Initialize(0.1f, foundBranch, () => _isRot = true); stopRotNode.Initialize(0.1f, missingBranch, () => _isRot = false); foundBranch.Initialize(alertNode, 0.1f, foundBranch, 0.1f, () => _isFound); missingBranch.Initialize(stopAlertNode, 0.1f, missingBranch, 0.1f, () => !_isFound); alertNode.Initialize(0.1f, stopRotNode, () => Debug.Log("Alert!")); stopAlertNode.Initialize(0.1f, rotNode, () => Debug.Log("Alert stopped")); //ノード追加 Add nodes at FlowAIBasis. _flowAI.AddNode(rotNode, foundBranch, missingBranch, alertNode, stopAlertNode, stopRotNode); //エントリポイントの次のノードを設定 Setting next node for entry point node. _flowAI.entryPointNode.nextNode = rotNode; //AI開始 Transition entry point. _flowAI.Entry(); }
/// <summary> /// Inserts a new node to the supplied branch, automatically handles undo, dirty flag and save node. /// <param name="branch">The branch to add a new node.</param> /// <param name="index">The index of the new node.</param> /// <param name="nodeType">The type of the new node.</param> /// <returns>The new node.</returns> /// </summary> public static ActionNode InsertNode(BranchNode branch, int index, System.Type nodeType) { // Validate parameters if (branch != null && branch.tree != null && nodeType != null && index >= 0 && index <= branch.children.Length) { // Get the tree var tree = branch.tree; // Register Undo #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2 Undo.RegisterUndo(tree, "Insert New Node"); #else Undo.RecordObject(tree, "Insert New Node"); #endif // Create new node var newNode = tree.AddNode(nodeType); if (newNode != null) { // Insert new node branch.Insert(index, newNode); // Call OnValidate on the parent branch.OnValidate(); // Saves node and sets dirty flag StateUtility.SetDirty(tree); return(newNode); } } return(null); }
/// <summary> /// Adds a new node to the parent, automatically handles undo, dirty flag and save node. /// <param name="parent">The branch to add the child.</param> /// <param name="childType">The type of the new node.</param> /// <returns>The new node.</returns> /// </summary> public static ActionNode AddNode(BranchNode parent, System.Type childType) { // Validate parameters if (parent != null && parent.tree != null && childType != null) { // Register Undo #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2 Undo.RegisterUndo(parent.tree, "Add New Node"); #else Undo.RecordObject(parent.tree, "Add New Node"); #endif var newNode = parent.tree.AddNode(childType); if (newNode != null) { // Adds new node as child of parent parent.Add(newNode); // Call OnValidate on the parent parent.OnValidate(); // Saves node and sets dirty flag StateUtility.SetDirty(parent.tree); return(newNode); } } return(null); }
void Start() { _flowAI = GetComponent <FlowAIHolder>().flowAI; proc1 = new ProcessNode(); proc2 = new ProcessNode(); proc3 = new ProcessNode(); proc4 = new ProcessNode(); proc5 = new ProcessNode(); rand1 = new BranchNode(); proc1.Initialize(1.0f, rand1, () => TFDebug.Log("visualizer", "proc1 finished"), "PROCESS1"); proc2.Initialize(1.0f, proc3, () => TFDebug.Log("visualizer", "proc2 finished"), "PROCESS2"); proc3.Initialize(1.0f, proc1, () => TFDebug.Log("visualizer", "proc3 finished"), "PROCESS3"); proc4.Initialize(1.0f, proc5, () => TFDebug.Log("visualizer", "proc4 finished"), "PROCESS4"); proc5.Initialize(1.0f, proc1, () => TFDebug.Log("visualizer", "proc5 finished"), "PROCESS5"); rand1.Initialize(proc2, 1.0f, proc4, 1.0f, () => { bool result = Random.Range(0, 2) == 0; TFDebug.Log("visualizer", "rand1 {0}", result.ToString()); return(result); }); rand1.summary = "RANDOM"; _flowAI.AddNode(proc1, proc2, proc3, proc4, proc5, rand1); _flowAI.entryPointNode.nextNode = proc1; _flowAI.Entry(); }
// Use this for initialization void Start() { //FlowAI生成 Create FlowAI. _flowAI = GetComponent <FlowAIHolder>().flowAI; //ノード生成 Create nodes. var foundBranch = new BranchNode(); var missingBranch = new BranchNode(); var foundBranch2 = new BranchNode(); var missingBranch2 = new BranchNode(); // 旋回 var rotNode = new ProcessNode(); var stopRotNode = new ProcessNode(); // 攻撃 var ShootingNode = new ProcessNode(); var StopShootingNode = new ProcessNode(); foundBranch.summary = "見てる?"; missingBranch.summary = "見てない"; foundBranch2.summary = "打てる?"; missingBranch2.summary = "打てない"; rotNode.summary = "まわる"; stopRotNode.summary = "回らない"; ShootingNode.summary = "打ちます"; StopShootingNode.summary = "打つのやめます"; //ノード初期化 Initialize nodes. rotNode.Initialize(0.1f, foundBranch, () => _isRot = true); stopRotNode.Initialize(0.1f, ShootingNode, () => _isRot = false); ShootingNode.Initialize(0.1f, foundBranch2, () => _isBullet = true); StopShootingNode.Initialize(0.1f, rotNode, () => _isBullet = false); foundBranch.Initialize(stopRotNode, 0.1f, rotNode, 0.1f, () => _isFound); missingBranch.Initialize(rotNode, 0.1f, stopRotNode, 0.1f, () => !_isFound); foundBranch2.Initialize(ShootingNode, 0.1f, StopShootingNode, 0.1f, () => _isFound); missingBranch2.Initialize(StopShootingNode, 0.1f, ShootingNode, 0.1f, () => !_isFound); //ノード追加 Add nodes at FlowAIBasis. _flowAI.AddNode(rotNode, foundBranch, missingBranch, stopRotNode, ShootingNode, StopShootingNode, foundBranch2, missingBranch2); //エントリポイントの次のノードを設定 Setting next node for entry point node. _flowAI.entryPointNode.nextNode = rotNode; //AI開始 Transition entry point. _flowAI.Entry(); animator = GetComponent <Animator>(); //animator.SetTrigger("Shot"); }
public override ParseResult Apply(Dictionary <int, INodeContainer> containers) { BranchNode <string> branchNode = (BranchNode <string>)Node; try { foreach (string argument in ParseData.Arguments) { string[] pieces = argument.Split(':'); if (pieces.Length != 2) { return(ParseResult.Failure.Derive(ParseData.LineNumber, ParseData.Line, "Invalid argument")); } string value = pieces[0]; int index = Convert.ToInt32(pieces[1]); if (!containers.ContainsKey(index)) { return(ParseResult.Failure.Derive(ParseData.LineNumber, ParseData.Line, String.Format("Invalid index argument \"{0}\"", index))); } branchNode.AddBranch(value, containers[index].Node); } return(ParseResult.Success); } catch (FormatException) { return(ParseResult.Failure.Derive(ParseData.LineNumber, ParseData.Line, "Failed to cast argument to an integer")); } }
public async Task <DocumentElementDto> CreateNewNodeAsync(ObjectId documentElementID, ObjectId branchID, ObjectId userID, string nodeName, string comment) { try { await database.Connect().ConfigureAwait(false); FilterBase getFilter = new EqualityFilter <ObjectId>("_id", documentElementID); var element = (await database.Get(getFilter).ConfigureAwait(false)).FirstOrDefault(); if (element is null) { throw new ArgumentException("No document element was found for id"); } var branch = element.Branches.Find(b => b.BranchID == branchID); if (branch is null) { throw new ArgumentException("No branch found for this id"); } branch.BranchNodes.Add(BranchNode.GetEmptyNode(element.Type, dateService, userID, nodeName, comment)); await database.Update(element).ConfigureAwait(false); var dto = new DocumentElementDto(element); dto.SetBranches(element.Branches, userID); return(dto); } catch (Exception ex) when(ex.GetType() != typeof(ArgumentException)) { exceptionLogger.Log(new ApplicationError(ex), LogLevel.Error, logConfiguration); throw new DatabaseException("Error occurred while creating new node"); } }
private void GenInterface(BranchNode node, CodeNamespace parentInterfaceNamespaceContainer) { var interf = new CodeTypeDeclaration(node.InterfaceName) { IsInterface = true, BaseTypes = { Statics.IResourceProvider }, }; SetAccess(interf); AddAttribute(interf); AddMemberComment(interf, $"Path: {node.ResourcePath}"); parentInterfaceNamespaceContainer.Types.Add(interf); var myContainer = default(CodeNamespace); foreach (var item in node.Childern) { if (item is BranchNode b) { if (myContainer is null) { myContainer = new CodeNamespace(Helper.FormatNamespace($"{node.InterfaceNamespace}.{node.MemberName}")); InterfaceNamespaces.Add(myContainer); } GenInterfaceMember(b, interf); GenInterface(b, myContainer); } else if (item is LeafNode l) { GenInterfaceMember(l, interf); } } }
public void BranchNodeTest() { float elapsed = 0f; var basis = new FlowAIBasis(); var branch = new BranchNode(); var proc1 = new ProcessNode(); var proc2 = new ProcessNode(); branch.Initialize( proc1, 0.2f, proc2, 0.2f, () => { return elapsed < 0.5f; }); proc1.Initialize(0.2f, branch, () => Debug.Log("プロセス1完了")); proc2.Initialize(0.2f, branch, () => Debug.Log("プロセス2完了")); basis.entryPointNode.nextNode = branch; basis.AddNode(branch, proc1, proc2); basis.Entry(); for(int f1=0;f1<50;f1++) { elapsed += 0.1f; Debug.LogFormat("---{0:0.0}sec---", elapsed); basis.Update(0.1f); } }
void PlayNode() { UpdateEvents(); Type nodeType = currentNode.GetType(); if (nodeType == typeof(TextNode)) { TextNode tNode = currentNode as TextNode; UIManager.instance.ShowText(tNode); } if (nodeType == typeof(BranchNode)) { BranchNode bNode = currentNode as BranchNode; currentNode = bNode.GetNextNode(); PlayNode(); } if (nodeType == typeof(ChoiceNode)) { ChoiceNode cNode = currentNode as ChoiceNode; List <Node> availableNodes = cNode.GetValidNodes(); UIManager.instance.ShowPlayerOptions(availableNodes); } if (nodeType == typeof(CustomNode)) { PlayCustomNode(); } }
public IHttpActionResult PutBranchNode(int id, BranchNode branchNode) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != branchNode.GuardId) { return(BadRequest()); } db.Entry(branchNode).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BranchNodeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <inheritdoc/> public override void InsertChild(BranchNode node) { ExpNode lastChild = Children[ChildCount - 1]; Children.RemoveAt(ChildCount - 1); node.AddChild(lastChild); AddChild(node); }
void UpdateChildren() { foreach (Transform childTransform in transform) { BranchNode childController = GetOrAddController(childTransform.gameObject); childController.UpdateRenderers(this); } }
public LeafNode(BranchNode parentNode) { if (parentNode != null) { // Start with already decoded minimum Debug.Assert(parentNode.MinimumOfChildNodeValuesIsFullyDecoded); Value = parentNode.MinimumOfChildNodeValues; } }
public void Dispose() { leafNode.Dispose(); branchNode.Dispose(); leafNode = new LeafNode(); branchNode = new BranchNode(); Parent = null; Name = null; }
private void Branching(BranchNode branchingNode) { /*CG, Update LB of this branch, cut decision*/ /*feasibility test, Update global UB, stop criteria*/ BuildBranchingTree(branchingNode); }
/// <summary> /// 指定ノードに葉ノードを追加する /// </summary> /// <param name="root">追加先ノード</param> /// <param name="leaf">追加する葉ノード</param> private void InsertLeaf(Node root, LeafNode leaf) { if (_Root == null) { // ツリーが空なら追加ノードをルートとする _Root = leaf; leaf.Parent = null; } else { // 兄弟となる葉ノードを探す、境界ボリュームの距離が近い方へ辿っていく LeafNode sibling = root.AsLeaf; BranchNode branch = root.AsBranch; if (branch != null) { var volume = leaf.Volume; while (true) { var c = branch.GetChild(Select(volume, branch.Child1.Volume, branch.Child2.Volume)); sibling = c.AsLeaf; if (sibling != null) { break; } branch = c.AsBranch; } } // 追加ノードと兄弟ノードの親となるノードを作成 var prev = sibling.Parent; branch = new BranchNode(prev, sibling, leaf); if (prev != null) { // 見つかった兄弟ノードに親があるなら、親ノードの子をすり替えて根に向かって境界ボリュームを計算し直す prev.SetChild(sibling.Index, branch); sibling.Parent = branch; leaf.Parent = branch; do { if (prev.Volume.Contains(branch.Volume)) { break; } prev.UpdateVolume(); branch = prev; } while (null != (prev = branch.Parent)); } else { // 見つかった兄弟ノードに親が無いなら、作成した親ノードをルートとする sibling.Parent = branch; leaf.Parent = branch; _Root = branch; } } }
public void PushBranchNode(object node, object source) { BranchNode branchNode = new BranchNode(); branchNode.Node = node; branchNode.Source = source; BranchNodeStack.Push(branchNode); }
void UpdateBranch(BranchNode node) { var parent = segmentJoints[node.AttachedTrunk.Position]; var branchGO = Instantiate(branchPrefab, parent); branchGO.transform.rotation = Quaternion.Euler(0f, 0f, node.AttachedTrunk.BranchLeft == node ? Random.Range(160f, 200f) : Random.Range(-20f, 20f)); StartCoroutine(UpdateBranch(branchGO.transform, Vector3.zero, Vector3.one * Random.Range(0.8f, 1.2f))); branches.Add(node, branchGO); }
private void FindInsertionNode(ExpNode node) { while ((_activeNode.Priority != Priority.OVERRIDE) && node.Priority > _activeNode.Priority && !_activeNode.IsRoot) { _activeNode = _activeNode.Parent; } }
public BranchNodeDto(BranchNode node) { BranchNodeID = node.BranchNodeID; CreatorID = node.CreatorID; UpdatedAt = node.UpdatedAt; CreatedAt = node.CreatedAt; Comment = node.Comment; Title = node.Title; DocumentElement = node.DocumentElement; }
public override bool Equals(object obj) { if (base.Equals(obj)) { BranchNode branchNode = obj as BranchNode; return(branchNode != null && IsActive == branchNode.IsActive); } return(false); }
/// <summary> /// Adds a <see cref="OperNode"/> to the expression tree. /// </summary> /// <param name="node">The <see cref="OperNode"/> to add to the expression tree.</param> public void AddNode(OperNode node) { bool insert = !(node is UOperNode); if (_activeNode == null) { // This is the first Branch Node if (Root != null) { // The first node is often a ValueNode // That is the only time a ValueNode will be the active or root node // Makes node the new active_node node.AddChild(Root); } Root = node; _activeNode = node; return; } FindInsertionNode(node); if (node.Priority > _activeNode.Priority) { // The new node is a lower priority than any node so far // or a parenthesis/function was hit // Add new node to top if (_activeNode.Priority == Priority.OVERRIDE) { InsertOperNode(node, insert); } else if (Root == _activeNode) { // node is new root node.AddChild(Root); Root = node; } } else if (node.Priority == _activeNode.Priority && (node is NOperNode)) { for (int i = 0; i < node.ChildCount; i++) { _activeNode.AddChild(node); } return; } else { InsertOperNode(node, insert); } _activeNode = node; }
public object PopBranchNode() { if (BranchNodeStack.Count == 0) { return(null); } BranchNode branchNode = BranchNodeStack.Pop(); return(branchNode.Node); }
public object PeekBranchSource() { if (BranchNodeStack.Count == 0) { return(null); } BranchNode branchNode = BranchNodeStack.Peek(); return(branchNode.Source); }
private Node CreateNode(BranchNode parentNode, int level) { if (level == LeafNodeLevel) { return(new LeafNode(parentNode)); } else { return(new BranchNode(this, parentNode, level)); } }
public IHttpActionResult GetBranchNode(int id) { BranchNode branchNode = db.BranchNodes.Find(id); if (branchNode == null) { return(NotFound()); } return(Ok(branchNode)); }
IEnumerator Grow(BranchNode node) { BranchNode._debug_currentIteration = 0; float delay = 0.5f; float time = delay; while (BranchNode._debug_currentIteration < BranchNode._debug_maxIteration) { time = Mathf.MoveTowards(time, 0, Time.fixedDeltaTime); if (time <= 0) { time = delay; BranchNode._debug_currentIteration ++; Debug.Log(BranchNode._debug_currentIteration + " : " + BranchNode._debug_maxIteration); node.Grow(); } yield return null; } }
/// <summary>Gets the hierarchical branch tree from the specified list of <paramref name="branches"/>.</summary> public void FillBranchTree(IEnumerable<string> branches) { #region ex // (input) // a-branch // develop/crazy-branch // develop/features/feat-next // develop/features/feat-next2 // develop/issues/iss444 // develop/wild-branch // issues/iss111 // master // // -> // (output) // 0 a-branch // 0 develop/ // 1 features/ // 2 feat-next // 2 feat-next2 // 1 issues/ // 2 iss444 // 1 wild-branch // 1 wilds/ // 2 card // 0 issues/ // 1 iss111 // 0 master #endregion ex Dictionary<string, BaseBranchNode> nodes = new Dictionary<string, BaseBranchNode>(); foreach (string branch in branches) { BranchNode branchNode = new BranchNode(this, branch); BaseBranchNode parent = branchNode.CreateRootNode(nodes); if (parent != null) Nodes.AddNode(parent); } }
internal override ExpressionNode VisitBranchNode(BranchNode node) { return base.VisitBranchNode(node); }
private void BuildBranchNodes(Graph g) { // lay out the dag nodes in order List<Node> Nodes = g.ReversePostOrder(); // Figure out dominance Dictionary<Node, Node> IDOM = g.Dominators(Nodes); for( int i=0; i<Nodes.Count; i++ ) { Node n = Nodes[i]; if (n is LoopNode) { // descend into loop nodes BuildBranchNodes((n as LoopNode).SubGraph); } else { LeafNode leaf = n as LeafNode; BasicBlock bl = leaf.Block; // mark break, branch, and continue nodes as such if (bl.LastInstruction is IBranchInstruction) { IBranchInstruction branch = bl.LastInstruction as IBranchInstruction; if (branch.Category == BranchCategory.BREAK_BRANCH) leaf.NodeType = "break"; else if (branch.Category == BranchCategory.CONTINUE_BRANCH) leaf.NodeType = "continue"; else if (branch.Category == BranchCategory.LOOPSKIP_BRANCH) leaf.NodeType = "node"; else if (branch.Category == BranchCategory.SKIP_BRANCH) leaf.NodeType = "skip"; else leaf.NodeType = "branch"; } else { // mark continue nodes as such if (bl.InnerMostLoop != null && bl.Successors.First() == bl.InnerMostLoop.Header) n.NodeType = "continue"; } } } int k = 0; while( k < Nodes.Count ) { if( Nodes[k] is LeafNode && Nodes[k].NodeType.Equals("branch") ) { BranchNode br = new BranchNode((Nodes[k] as LeafNode)); List<Node> descendents = new List<Node>(g.ChildrenOf(Nodes[k])); Graph[] branchGraphs = new Graph[2]; branchGraphs[0] = br.IfGraph; branchGraphs[1] = br.ElseGraph; for (int k0 = k + 1; k0 < Nodes.Count; k0++) { Node n = Nodes[k0]; for (int j = 0; j < descendents.Count; j++) { if (Algorithms.Dominates(descendents[j], n, IDOM)) branchGraphs[j].AddNode(n); } } br.OwnedNodes.AddRange(branchGraphs[0].Nodes); br.OwnedNodes.AddRange(branchGraphs[1].Nodes); Graph branchGraph = new Graph(); g.CombineNodes(br.OwnedNodes, br, branchGraph); branchGraph.TransferEdgesToSubgraph(branchGraphs[0]); branchGraph.TransferEdgesToSubgraph(branchGraphs[1]); // do this recursively on the if/else branches BuildBranchNodes(br.IfGraph); BuildBranchNodes(br.ElseGraph); // start over k = 0; Nodes = g.ReversePostOrder(); } else if (Nodes[k] is LeafNode && Nodes[k].NodeType.Equals("skip")) { Dictionary<Node, Node> PDOM = g.PostDominators(Nodes); // find nodes to put into the sub-graph // these are all the nodes which are skipped // nodes are skipped if they are post-dominated by the convergence node (which post-dominates the test) Node joinPoint = PDOM[Nodes[k]]; Graph branchGraph = new Graph(); for (int k0 = k + 1; Nodes[k0] != joinPoint; k0++) { Node n = Nodes[k0]; if (Algorithms.Dominates(joinPoint, Nodes[k0], PDOM)) branchGraph.AddNode(Nodes[k0]); } SkipNode sk = new SkipNode((Nodes[k] as LeafNode), branchGraph); // now make a graph containing both test node and all skipped nodes // combine these into one skip node List<Node> ownedNodes = new List<Node>(branchGraph.Nodes); ownedNodes.Add(Nodes[k]); Graph tmpGraph = new Graph(); g.CombineNodes(ownedNodes, sk, tmpGraph); tmpGraph.TransferEdgesToSubgraph(branchGraph); // do this recursively on the skipped nodes BuildBranchNodes(sk.BranchGraph); // start over k = 0; Nodes = g.ReversePostOrder(); } else { k++; } } }
internal override ExpressionNode VisitBranchNode(BranchNode node) { node.BaseNode.Accept(this); graph.Connectors.Add(new MapConnector()); var v = new BranchVertex(); v.Predicate = node.Predicate.ToString(); graph.Nodes.Add(v); v.FirstBranch = new PipeGraph(); graphStack.Push(v.FirstBranch); curVertexStack.Push(null); node.TrueBranch.Accept(this); curVertexStack.Pop(); graphStack.Pop(); v.SecondBranch = new PipeGraph(); graphStack.Push(v.SecondBranch); curVertexStack.Push(null); node.FalseBranch.Accept(this); curVertexStack.Pop(); graphStack.Pop(); curVertex = v; return node; }
public void Add(BranchNode branchNode) { this.parts.Add(branchNode); }
public Label Branch(Code code, Code codeShort) { var branch = new BranchNode(code, codeShort); this.Add(branch); return branch.Label; }
public void Branch(Code code, Code codeShort, Label label) { var branch = new BranchNode(code, codeShort, label); this.Add(branch); }
private void BuildBranchNodes(Graph g) { // lay out the dag nodes in order List<Node> Nodes = g.ReversePostOrder(); // Figure out dominance Dictionary<Node, Node> IDOM = g.Dominators(Nodes); for( int i=0; i<Nodes.Count; i++ ) { Node n = Nodes[i]; if (n is LoopNode) { // descend into loop nodes BuildBranchNodes((n as LoopNode).SubGraph); } else { LeafNode leaf = n as LeafNode; BasicBlock bl = leaf.Block; // mark break, branch, and continue nodes as such if (bl.LastInstruction is IBranchInstruction) { IBranchInstruction branch = bl.LastInstruction as IBranchInstruction; if (branch.Category == BranchCategory.BREAK_BRANCH) leaf.NodeType = "break"; else leaf.NodeType = "branch"; } else { // mark continue nodes as such if (bl.InnerMostLoop != null && bl.Successors.First() == bl.InnerMostLoop.Header) n.NodeType = "continue"; } } } int k = 0; while( k < Nodes.Count ) { if( Nodes[k] is LeafNode && Nodes[k].NodeType.Equals("branch") ) { BranchNode br = new BranchNode((Nodes[k] as LeafNode)); List<Node> descendents = new List<Node>(g.ChildrenOf(Nodes[k])); Graph[] branchGraphs = new Graph[2]; branchGraphs[0] = br.IfGraph; branchGraphs[1] = br.ElseGraph; for (int k0 = k + 1; k0 < Nodes.Count; k0++) { Node n = Nodes[k0]; for (int j = 0; j < descendents.Count; j++) { if (Algorithms.Dominates(descendents[j], n, IDOM)) branchGraphs[j].AddNode(n); } } br.OwnedNodes.AddRange(branchGraphs[0].Nodes); br.OwnedNodes.AddRange(branchGraphs[1].Nodes); Graph branchGraph = new Graph(); g.CombineNodes(br.OwnedNodes, br, branchGraph); branchGraph.TransferEdgesToSubgraph(branchGraphs[0]); branchGraph.TransferEdgesToSubgraph(branchGraphs[1]); // do this recursively on the if/else branches BuildBranchNodes(br.IfGraph); BuildBranchNodes(br.ElseGraph); // start over k = 0; Nodes = g.ReversePostOrder(); } else { k++; } } }