// maps a paramter descriptor to its index
Map<Descriptor, Integer> mapParamDescToIdx;
+
+ Map<Integer, FlowNode> mapIdxToFlowNode;
+
boolean debug = true;
public FlowGraph(MethodDescriptor md, Map<Descriptor, Integer> mapParamDescToIdx) {
this.mapParamDescToIdx = new HashMap<Descriptor, Integer>();
this.mapParamDescToIdx.putAll(mapParamDescToIdx);
this.returnNodeSet = new HashSet<FlowNode>();
+ this.mapIdxToFlowNode = new HashMap<Integer, FlowNode>();
if (!md.isStatic()) {
// create a node for 'this' varialbe
thisVarNode = thisNode;
}
+ setupMapIdxToDesc();
+
+ }
+
+ private void setupMapIdxToDesc() {
+
+ Set<Descriptor> descSet = mapParamDescToIdx.keySet();
+ for (Iterator iterator = descSet.iterator(); iterator.hasNext();) {
+ Descriptor paramDesc = (Descriptor) iterator.next();
+ int idx = mapParamDescToIdx.get(paramDesc);
+ NTuple<Descriptor> descTuple = new NTuple<Descriptor>();
+ descTuple.add(paramDesc);
+ mapIdxToFlowNode.put(idx, getFlowNode(descTuple));
+ }
+
+ }
+
+ public FlowNode getParamFlowNode(int idx) {
+ return mapIdxToFlowNode.get(idx);
}
public Set<FlowNode> getNodeSet() {
}
public boolean isParamDesc(Descriptor desc) {
- return mapParamDescToIdx.containsKey(desc);
+
+ if (mapParamDescToIdx.containsKey(desc)) {
+ int idx = mapParamDescToIdx.get(desc);
+ if (!md.isStatic() && idx == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ return false;
}
public boolean hasEdge(NTuple<Descriptor> fromDescTuple, NTuple<Descriptor> toDescTuple) {
}
- public void setReturnFlowNode(NTuple<Descriptor> tuple) {
+ public void addReturnFlowNode(NTuple<Descriptor> tuple) {
if (!mapDescTupleToInferNode.containsKey(tuple)) {
createNewFlowNode(tuple);