changes: generated annotated code but it still causes type errors + re-formatting...
[IRC.git] / Robust / src / Analysis / SSJava / FlowNode.java
index 45de718a042fc73c862620be6ee2be93256ea145..31a9ded33afec455c64623cadbdbd9e3b80ed1bf 100644 (file)
@@ -1,9 +1,9 @@
 package Analysis.SSJava;
 
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 
+import IR.ClassDescriptor;
 import IR.Descriptor;
 import IR.FieldDescriptor;
 import IR.VarDescriptor;
@@ -11,7 +11,7 @@ import IR.VarDescriptor;
 public class FlowNode {
 
   // descriptor tuple is a unique identifier of the flow node
-  private NTuple<Location> locTuple;
+  protected NTuple<Descriptor> descTuple;
 
   // if the infer node represents the base type of field access,
   // this set contains fields of the base type
@@ -40,31 +40,32 @@ public class FlowNode {
     return fieldNodeSet;
   }
 
-  public FlowNode(NTuple<Location> tuple) {
+  public FlowNode(NTuple<Descriptor> tuple) {
 
     this.isSkeleton = false;
     this.isIntermediate = false;
 
-    NTuple<Location> base = null;
-    Location loc = null;
+    NTuple<Descriptor> base = null;
+    Descriptor desc = null;
     if (tuple.size() > 1) {
       base = tuple.subList(0, tuple.size() - 1);
-      loc = tuple.get(tuple.size() - 1);
+      desc = tuple.get(tuple.size() - 1);
     } else {
       base = tuple;
     }
     fieldNodeSet = new HashSet<FlowNode>();
-    locTuple = new NTuple<Location>();
+    descTuple = new NTuple<Descriptor>();
     if (base != null) {
-      locTuple.addAll(base);
+      descTuple.addAll(base);
     }
-    if (loc != null) {
-      locTuple.add(loc);
+    if (desc != null) {
+      descTuple.add(desc);
     }
 
   }
 
   public void setCompositeLocation(CompositeLocation in) {
+    System.out.println("$$$set compLoc=" + in);
     compLoc = in;
   }
 
@@ -76,16 +77,22 @@ public class FlowNode {
     fieldNodeSet.add(node);
   }
 
-  public NTuple<Location> getLocTuple() {
-    return locTuple;
+  public NTuple<Descriptor> getDescTuple() {
+    return descTuple;
   }
 
-  public boolean isReturn() {
-    return isReturn;
+  public Descriptor getOwnDescriptor() {
+    return descTuple.get(descTuple.size() - 1);
   }
 
-  public void setReturn(boolean isReturn) {
-    this.isReturn = isReturn;
+  public boolean isPrimitiveType() {
+    Descriptor desc = descTuple.get(descTuple.size() - 1);
+    if (desc instanceof VarDescriptor) {
+      return ((VarDescriptor) desc).getType().isPrimitive();
+    } else if (desc instanceof FieldDescriptor) {
+      return ((FieldDescriptor) desc).getType().isPrimitive();
+    }
+    return false;
   }
 
   public String toString() {
@@ -93,19 +100,19 @@ public class FlowNode {
     if (isSkeleton()) {
       rtr += "SKELETON:";
     }
-    rtr += ":" + locTuple;
+    rtr += ":" + descTuple;
     return rtr;
   }
 
   public int hashCode() {
-    return 7 + locTuple.hashCode();
+    return 7 + descTuple.hashCode();
   }
 
   public boolean equals(Object obj) {
 
     if (obj instanceof FlowNode) {
       FlowNode in = (FlowNode) obj;
-      if (locTuple.equals(in.getLocTuple())) {
+      if (descTuple.equals(in.getDescTuple())) {
         return true;
       }
     }
@@ -116,8 +123,8 @@ public class FlowNode {
 
   public String getID() {
     String id = "";
-    for (int i = 0; i < locTuple.size(); i++) {
-      id += locTuple.get(i).getSymbol();
+    for (int i = 0; i < descTuple.size(); i++) {
+      id += descTuple.get(i).getSymbol();
     }
     return id;
   }
@@ -125,11 +132,11 @@ public class FlowNode {
   public String getPrettyID() {
     String id = "<";
     String property = "";
-    for (int i = 0; i < locTuple.size(); i++) {
+    for (int i = 0; i < descTuple.size(); i++) {
       if (i != 0) {
         id += ",";
       }
-      id += locTuple.get(i).getSymbol();
+      id += descTuple.get(i).getSymbol();
     }
     id += ">";
 
@@ -160,22 +167,10 @@ public class FlowNode {
     return isDeclarationNode;
   }
 
-  public NTuple<Location> getCurrentLocTuple() {
-    if (compLoc == null) {
-      return locTuple;
-    }
-    NTuple<Location> curLocTuple = new NTuple<Location>();
-    for (int i = 0; i < compLoc.getSize(); i++) {
-      Location locElement = compLoc.get(i);
-      curLocTuple.add(locElement);
-    }
-    return curLocTuple;
-  }
-
   public NTuple<Descriptor> getCurrentDescTuple() {
 
     if (compLoc == null) {
-      return getDescTuple();
+      return descTuple;
     }
 
     NTuple<Descriptor> curDescTuple = new NTuple<Descriptor>();
@@ -194,12 +189,4 @@ public class FlowNode {
     this.isSkeleton = isSkeleton;
   }
 
-  public NTuple<Descriptor> getDescTuple() {
-    NTuple<Descriptor> descTuple = new NTuple<Descriptor>();
-    for (int i = 0; i < locTuple.size(); i++) {
-      descTuple.add(locTuple.get(i).getLocDescriptor());
-    }
-    return descTuple;
-  }
-
 }