public static HashSet<Node> NewAdd(this HashSet<Node> set, Node item)
 {
     if (item == null)
         return set;
     set = new HashSet<Node>(set);
     set.Add(item);
     return set;
 }
Exemple #2
0
 /// <summary>
 /// Finds the common dominator of two nodes
 /// </summary>
 public static Node CommonDominator(Node lhs, Node rhs)
 {
     if (lhs == null)
         return rhs;
     if (rhs == null)
         return lhs;
     while ((lhs != null) && (rhs != null) && (lhs != rhs)) {
         if (lhs.DfsIndex < rhs.DfsIndex) {
             rhs = rhs.ImmediateDominator;
         }
         else {
             lhs = lhs.ImmediateDominator;
         }
     }
     return lhs;
 }
 public Context NewUntil(Node node)
 {
     return new Context(this.loop, this.until.NewAdd(node), this.tryContext);
 }
 public bool IsUntil(Node node)
 {
     return this.until.Contains(node);
 }
Exemple #5
0
 public void ReplacePredecessorsWith(Node search, Node replace)
 {
     for (int i = 0; i < this.Predecessors.Count; i++) {
         if (this.Predecessors[i] == search) {
             this.Predecessors[i] = replace;
             break;
         }
     }
 }
Exemple #6
0
 public void AddNode(Node node)
 {
     node.Id = ++nextId;
     if (this.Root == null)
         this.Root = node;
     this.Nodes.Add(node);
 }
Exemple #7
0
 public void CreateIntervalFromHeader(Node header, List<Interval> intervals)
 {
     var interval = new Interval();
     this.AddNode(interval);
     interval.BuildFromHeader(this.Parent.Nodes, header);
     intervals.Add(interval);
 }
Exemple #8
0
 public void Connect(Node predecessor, Node successor)
 {
     predecessor.Successors.AddUnique(successor);
     successor.Predecessors.AddUnique(predecessor);
 }