private void CreateEdge(PapyrusControlFlowNode fromNode, PapyrusControlFlowNode toNode) { var edge = new PapyrusControlFlowEdge(fromNode, toNode); fromNode.Outgoing.Add(edge); toNode.Incoming.Add(edge); }
public PapyrusControlFlowGraphBuilder(PapyrusMethodDefinition method) { this.method = method; entryPoint = new PapyrusControlFlowNode(0, 0, PapyrusControlFlowNodeType.EntryPoint); nodes.Add(entryPoint); regularExit = new PapyrusControlFlowNode(1, -1, PapyrusControlFlowNodeType.RegularExit); nodes.Add(regularExit); }
/// <summary> /// Gets whether <c>this</c> dominates <paramref name="node" />. /// </summary> public bool Dominates(PapyrusControlFlowNode node) { // TODO: this can be made O(1) by numbering the dominator tree var tmp = node; while (tmp != null) { if (tmp == this) { return(true); } tmp = tmp.ImmediateDominator; } return(false); }
private static PapyrusControlFlowNode FindCommonDominator(PapyrusControlFlowNode b1, PapyrusControlFlowNode b2) { // Here we could use the postorder numbers to get rid of the hashset, see "A Simple, Fast Dominance Algorithm" var path1 = new HashSet <PapyrusControlFlowNode>(); while (b1 != null && path1.Add(b1)) { b1 = b1.ImmediateDominator; } while (b2 != null) { if (path1.Contains(b2)) { return(b2); } b2 = b2.ImmediateDominator; } throw new Exception("No common dominator found!"); }
private void CreateEdge(PapyrusControlFlowNode fromNode, PapyrusInstruction toInstruction) { CreateEdge(fromNode, nodes.Single(n => n.Start == toInstruction)); }