X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=blobdiff_plain;f=Robust%2Fsrc%2FAnalysis%2FSSJava%2FFlowNode.java;h=d170494f8a3c32ee9aef5f696f446760af5ab24d;hp=eb9c2a7e9a7a5fa581183e50e8a2fcd643812eca;hb=d45bb251bdc1196d7848094fa2ccd566b39e021c;hpb=031636263ce6e4b6f35f3d9162460eb0ef536c2a diff --git a/Robust/src/Analysis/SSJava/FlowNode.java b/Robust/src/Analysis/SSJava/FlowNode.java index eb9c2a7e..d170494f 100644 --- a/Robust/src/Analysis/SSJava/FlowNode.java +++ b/Robust/src/Analysis/SSJava/FlowNode.java @@ -1,35 +1,69 @@ 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; public class FlowNode { // descriptor tuple is a unique identifier of the flow node - private NTuple descTuple; + protected NTuple descTuple; // if the infer node represents the base type of field access, // this set contains fields of the base type private Set 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; + + private boolean isFormHolder = false; + + private NTuple baseTuple; + + public boolean isIntermediate() { + return isIntermediate; + } + + public void setIntermediate(boolean isIntermediate) { + this.isIntermediate = isIntermediate; + } + + public void setFormHolder(boolean in) { + isFormHolder = in; + } + + public boolean isFromHolder() { + return isFormHolder; + } + + public void setBaseTuple(NTuple in) { + baseTuple = in; + } + + public NTuple getBaseTuple() { + return baseTuple; + } + public Set getFieldNodeSet() { return fieldNodeSet; } - private Set outEdgeSet; + public FlowNode(NTuple tuple) { - public FlowNode(NTuple tuple, boolean isParam) { - - this.isParameter = isParam; + this.isSkeleton = false; + this.isIntermediate = false; NTuple base = null; Descriptor desc = null; @@ -47,15 +81,20 @@ public class FlowNode { if (desc != null) { descTuple.add(desc); } - outEdgeSet = new HashSet(); + } - public void addFieldNode(FlowNode node) { - fieldNodeSet.add(node); + public void setCompositeLocation(CompositeLocation in) { + System.out.println("$$$set compLoc=" + in); + compLoc = in; } - public boolean isParameter() { - return isParameter; + public CompositeLocation getCompositeLocation() { + return compLoc; + } + + public void addFieldNode(FlowNode node) { + fieldNodeSet.add(node); } public NTuple getDescTuple() { @@ -66,35 +105,25 @@ public class FlowNode { return descTuple.get(descTuple.size() - 1); } - public boolean isReturn() { - return isReturn; - } - - 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() { String rtr = "[FlowNode]:"; - if (isParameter()) { - rtr += "param:"; + if (isSkeleton()) { + rtr += "SKELETON:"; } rtr += ":" + descTuple; return rtr; } - public Iterator iteratorOfOutEdges() { - return outEdgeSet.iterator(); - } - - public void addOutEdge(FlowEdge out) { - outEdgeSet.add(out); - } - - public Set getOutEdgeSet() { - return outEdgeSet; - } - public int hashCode() { return 7 + descTuple.hashCode(); } @@ -122,6 +151,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 +159,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 getCurrentDescTuple() { + + if (compLoc == null) { + return descTuple; + } + + NTuple curDescTuple = new NTuple(); + 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; + } + }