changes.
[IRC.git] / Robust / src / Analysis / SSJava / FlowNode.java
index eb9c2a7e9a7a5fa581183e50e8a2fcd643812eca..cdd9bd472a939e1d53b3da0a1e2546805b1deb44 100644 (file)
@@ -5,6 +5,8 @@ import java.util.Iterator;
 import java.util.Set;
 
 import IR.Descriptor;
+import IR.FieldDescriptor;
+import IR.VarDescriptor;
 
 public class FlowNode {
 
@@ -15,21 +17,33 @@ public class FlowNode {
   // this set contains fields of the base type
   private Set<FlowNode> fieldNodeSet;
 
-  // set true if this node is driven from a paramter
-  private boolean isParameter;
-
   // set true if this node stores a return value
   private boolean isReturn;
 
+  private boolean isDeclarationNode = false;
+
+  private boolean isIntermediate;
+
+  private CompositeLocation compLoc;
+
+  private boolean isSkeleton;
+
+  public boolean isIntermediate() {
+    return isIntermediate;
+  }
+
+  public void setIntermediate(boolean isIntermediate) {
+    this.isIntermediate = isIntermediate;
+  }
+
   public Set<FlowNode> getFieldNodeSet() {
     return fieldNodeSet;
   }
 
-  private Set<FlowEdge> outEdgeSet;
+  public FlowNode(NTuple<Descriptor> tuple) {
 
-  public FlowNode(NTuple<Descriptor> tuple, boolean isParam) {
-
-    this.isParameter = isParam;
+    this.isSkeleton = false;
+    this.isIntermediate = false;
 
     NTuple<Descriptor> base = null;
     Descriptor desc = null;
@@ -47,15 +61,19 @@ public class FlowNode {
     if (desc != null) {
       descTuple.add(desc);
     }
-    outEdgeSet = new HashSet<FlowEdge>();
+
   }
 
-  public void addFieldNode(FlowNode node) {
-    fieldNodeSet.add(node);
+  public void setCompositeLocation(CompositeLocation in) {
+    compLoc = in;
+  }
+
+  public CompositeLocation getCompositeLocation() {
+    return compLoc;
   }
 
-  public boolean isParameter() {
-    return isParameter;
+  public void addFieldNode(FlowNode node) {
+    fieldNodeSet.add(node);
   }
 
   public NTuple<Descriptor> getDescTuple() {
@@ -74,26 +92,25 @@ public class FlowNode {
     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() {
     String rtr = "[FlowNode]:";
-    if (isParameter()) {
-      rtr += "param:";
+    if (isSkeleton()) {
+      rtr += "SKELETON:";
     }
     rtr += ":" + descTuple;
     return rtr;
   }
 
-  public Iterator<FlowEdge> iteratorOfOutEdges() {
-    return outEdgeSet.iterator();
-  }
-
-  public void addOutEdge(FlowEdge out) {
-    outEdgeSet.add(out);
-  }
-
-  public Set<FlowEdge> getOutEdgeSet() {
-    return outEdgeSet;
-  }
 
   public int hashCode() {
     return 7 + descTuple.hashCode();
@@ -122,6 +139,7 @@ public class FlowNode {
 
   public String getPrettyID() {
     String id = "<";
+    String property = "";
     for (int i = 0; i < descTuple.size(); i++) {
       if (i != 0) {
         id += ",";
@@ -129,6 +147,54 @@ public class FlowNode {
       id += descTuple.get(i).getSymbol();
     }
     id += ">";
-    return id;
+
+    if (compLoc != null) {
+      id += " " + compLoc;
+    }
+
+    // if (isReturn()) {
+    // property += "R";
+    // }
+    //
+    // if (isSkeleton()) {
+    // property += "S";
+    // }
+
+    if (property.length() > 0) {
+      property = " [" + property + "]";
+    }
+
+    return id + property;
+  }
+
+  public void setDeclarationNode() {
+    isDeclarationNode = true;
+  }
+
+  public boolean isDeclaratonNode() {
+    return isDeclarationNode;
+  }
+
+  public NTuple<Descriptor> getCurrentDescTuple() {
+
+    if (compLoc == null) {
+      return descTuple;
+    }
+
+    NTuple<Descriptor> curDescTuple = new NTuple<Descriptor>();
+    for (int i = 0; i < compLoc.getSize(); i++) {
+      Location locElement = compLoc.get(i);
+      curDescTuple.add(locElement.getLocDescriptor());
+    }
+    return curDescTuple;
+  }
+
+  public boolean isSkeleton() {
+    return isSkeleton;
   }
+
+  public void setSkeleton(boolean isSkeleton) {
+    this.isSkeleton = isSkeleton;
+  }
+
 }