X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FAnalysis%2FSSJava%2FFlowNode.java;h=7ce39ed50055c8c9b4be6140ee22259a3d83ff88;hb=dfaefc442488f69bf9f33038ddafb7ff47a67d8d;hp=cc7d4ee1654c6f16ef97a482947e0c5432f6f61f;hpb=28876fc6038265b38688ea04cd0f5d8241604bd6;p=IRC.git diff --git a/Robust/src/Analysis/SSJava/FlowNode.java b/Robust/src/Analysis/SSJava/FlowNode.java index cc7d4ee1..7ce39ed5 100644 --- a/Robust/src/Analysis/SSJava/FlowNode.java +++ b/Robust/src/Analysis/SSJava/FlowNode.java @@ -1,8 +1,12 @@ package Analysis.SSJava; +import java.util.HashSet; +import java.util.Iterator; import java.util.Set; import IR.Descriptor; +import IR.FieldDescriptor; +import IR.VarDescriptor; public class FlowNode { @@ -13,15 +17,31 @@ public class FlowNode { // this set contains fields of the base type private Set fieldNodeSet; - public FlowNode(Descriptor desc) { - this(null, desc); - } + // 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; - public FlowNode(NTuple base) { - this(base, null); + public Set getFieldNodeSet() { + return fieldNodeSet; } - public FlowNode(NTuple base, Descriptor desc) { + private Set outEdgeSet; + + public FlowNode(NTuple tuple, boolean isParam) { + + this.isParameter = isParam; + + NTuple base = null; + Descriptor desc = null; + if (tuple.size() > 1) { + base = tuple.subList(0, tuple.size() - 1); + desc = tuple.get(tuple.size() - 1); + } else { + base = tuple; + } + fieldNodeSet = new HashSet(); descTuple = new NTuple(); if (base != null) { descTuple.addAll(base); @@ -29,6 +49,15 @@ public class FlowNode { if (desc != null) { descTuple.add(desc); } + outEdgeSet = new HashSet(); + } + + public void addFieldNode(FlowNode node) { + fieldNodeSet.add(node); + } + + public boolean isParameter() { + return isParameter; } public NTuple getDescTuple() { @@ -39,8 +68,79 @@ 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() { - return "[FlowNode]::" + descTuple; + String rtr = "[FlowNode]:"; + if (isParameter()) { + rtr += "param:"; + } + 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(); + } + + public boolean equals(Object obj) { + + if (obj instanceof FlowNode) { + FlowNode in = (FlowNode) obj; + if (descTuple.equals(in.getDescTuple())) { + return true; + } + } + + return false; + + } + + public String getID() { + String id = ""; + for (int i = 0; i < descTuple.size(); i++) { + id += descTuple.get(i).getSymbol(); + } + return id; + } + + public String getPrettyID() { + String id = "<"; + for (int i = 0; i < descTuple.size(); i++) { + if (i != 0) { + id += ","; + } + id += descTuple.get(i).getSymbol(); + } + id += ">"; + return id; + } }