start of new file
[IRC.git] / Robust / src / IR / Flat / FlatNode.java
index b53eb4331c337c67a9fa9bdd42da75116049b948..714b894bfad3ba57e37519aab8c23afa324e2109 100644 (file)
@@ -2,13 +2,56 @@ package IR.Flat;
 import java.util.Vector;
 
 public class FlatNode {
-    Vector next;
+    protected Vector next;
+    protected Vector prev;
 
+    public FlatNode() {
+       next=new Vector();
+       prev=new Vector();
+    }
 
     public String toString() {
-       throw new Error();
+       throw new Error(this.getClass().getName() + "does not implement toString!");
+    }
+    public int numNext() {
+       return next.size();
     }
+    public FlatNode getNext(int i) {
+       return (FlatNode) next.get(i);
+    }
+
+    public int numPrev() {
+       return prev.size();
+    }
+    public FlatNode getPrev(int i) {
+       return (FlatNode) prev.get(i);
+    }
+    
     public void addNext(FlatNode n) {
        next.add(n);
+       n.addPrev(this);
+    }
+
+    /** This function modifies the graph */
+    public void setNext(int i, FlatNode n) {
+       FlatNode old=getNext(i);
+       next.set(i, n);
+       old.prev.remove(this);
+       n.addPrev(this);
+    }
+
+    protected void addPrev(FlatNode p) {
+       prev.add(p);
+    }
+    public int kind() {
+       throw new Error();
+    }
+
+    public TempDescriptor [] readsTemps() {
+       return new TempDescriptor[0];
+    }
+
+    public TempDescriptor [] writesTemps() {
+       return new TempDescriptor[0];
     }
 }