changes + bring up uncommited previous changes.
[IRC.git] / Robust / src / Analysis / SSJava / FlowNode.java
index 45de718a042fc73c862620be6ee2be93256ea145..a4125c0d9a2017aaf6381a7d96c9dd0c28537be9 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
@@ -28,6 +28,10 @@ public class FlowNode {
 
   private boolean isSkeleton;
 
+  private boolean isFormHolder = false;
+
+  private NTuple<Descriptor> baseTuple;
+
   public boolean isIntermediate() {
     return isIntermediate;
   }
@@ -36,30 +40,46 @@ public class FlowNode {
     this.isIntermediate = isIntermediate;
   }
 
+  public void setFormHolder(boolean in) {
+    isFormHolder = in;
+  }
+
+  public boolean isFromHolder() {
+    return isFormHolder;
+  }
+
+  public void setBaseTuple(NTuple<Descriptor> in) {
+    baseTuple = in;
+  }
+
+  public NTuple<Descriptor> getBaseTuple() {
+    return baseTuple;
+  }
+
   public Set<FlowNode> getFieldNodeSet() {
     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);
     }
 
   }
@@ -76,16 +96,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 +119,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 +142,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 +151,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 +186,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 +208,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;
-  }
-
 }