// invoked by the method descriptor
private Map<MethodDescriptor, Set<MethodInvokeNode>> mapMethodDescriptorToMethodInvokeNodeSet;
- private Map<MethodInvokeNode, Map<Integer, NodeTupleSet>> mapMethodInvokeNodeToArgIdxMap;
+ private Map<MethodInvokeNode, Map<Integer, NTuple<Descriptor>>> mapMethodInvokeNodeToArgIdxMap;
private Map<MethodInvokeNode, NTuple<Descriptor>> mapMethodInvokeNodeToBaseTuple;
this.mapMethodDescriptorToMethodInvokeNodeSet =
new HashMap<MethodDescriptor, Set<MethodInvokeNode>>();
this.mapMethodInvokeNodeToArgIdxMap =
- new HashMap<MethodInvokeNode, Map<Integer, NodeTupleSet>>();
+ new HashMap<MethodInvokeNode, Map<Integer, NTuple<Descriptor>>>();
this.mapMethodDescToMethodLocationInfo = new HashMap<MethodDescriptor, MethodLocationInfo>();
this.mapMethodToCalleeSet = new HashMap<MethodDescriptor, Set<MethodDescriptor>>();
this.mapClassToLocationInfo = new HashMap<ClassDescriptor, LocationInfo>();
// FlowGraph fg = new FlowGraph(md, mapParamDescToIdx);
// mapMethodDescriptorToFlowGraph.put(md, fg);
// analyzeMethodBody(md.getClassDesc(), md);
-
}
+
+ }
+
+ // DEBUG: write a global flow graph
+ MethodDescriptor mdContainingSSJavaLoop = ssjava.getMethodContainingSSJavaLoop();
+ FlowGraph globalFlowGraph = getSubGlobalFlowGraph(mdContainingSSJavaLoop);
+ // System.out.println("GLOBAL NODE SET=" + globalFlowGraph.getNodeSet());
+ assignCompositeLocation(globalFlowGraph);
+ try {
+ globalFlowGraph.writeGraph("_GLOBAL");
+ } catch (IOException e) {
+ e.printStackTrace();
}
// _debug_printGraph();
}
+ private void assignCompositeLocation(FlowGraph globalFlowGraph) {
+ Set<FlowNode> nodeSet = globalFlowGraph.getNodeSet();
+
+ for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) {
+ FlowNode flowNode = (FlowNode) iterator.next();
+ Set<FlowNode> inNodeSet = globalFlowGraph.getIncomingFlowNodeSet(flowNode);
+ Set<FlowNode> reachableNodeSet = globalFlowGraph.getReachFlowNodeSetFrom(flowNode);
+
+ // System.out.println("flowNode=" + flowNode + " incoming=" + inNodeSet);
+ // System.out.println("reachableNodeSet=" + reachableNodeSet);
+
+ Map<NTuple<Location>, Set<NTuple<Descriptor>>> mapPrefixToIncomingLocTupleSet =
+ new HashMap<NTuple<Location>, Set<NTuple<Descriptor>>>();
+
+ List<NTuple<Descriptor>> prefixList = new ArrayList<NTuple<Descriptor>>();
+
+ for (Iterator iterator2 = inNodeSet.iterator(); iterator2.hasNext();) {
+ FlowNode inNode = (FlowNode) iterator2.next();
+
+ NTuple<Descriptor> inNodeTuple = inNode.getCurrentDescTuple();
+
+ // CompositeLocation inNodeInferredLoc =
+ // generateInferredCompositeLocation(methodInfo, inNodeTuple);
+ // NTuple<Location> inNodeInferredLocTuple = inNodeInferredLoc.getTuple();
+
+ for (int i = 1; i < inNodeTuple.size(); i++) {
+ NTuple<Descriptor> prefix = inNodeTuple.subList(0, i);
+ if (!prefixList.contains(prefix)) {
+ prefixList.add(prefix);
+ }
+ }
+ }
+
+ Collections.sort(prefixList, new Comparator<NTuple<Descriptor>>() {
+ public int compare(NTuple<Descriptor> arg0, NTuple<Descriptor> arg1) {
+ int s0 = arg0.size();
+ int s1 = arg1.size();
+ if (s0 > s1) {
+ return -1;
+ } else if (s0 == s1) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ });
+
+ // find out reachable nodes that have the longest common prefix
+ for (int i = 0; i < prefixList.size(); i++) {
+ NTuple<Descriptor> curPrefix = prefixList.get(i);
+ Set<NTuple<Descriptor>> reachableCommonPrefixSet = new HashSet<NTuple<Descriptor>>();
+
+ for (Iterator iterator2 = reachableNodeSet.iterator(); iterator2.hasNext();) {
+ FlowNode reachableNode = (FlowNode) iterator2.next();
+ NTuple<Descriptor> reachLocTuple = reachableNode.getCurrentDescTuple();
+ if (reachLocTuple.startsWith(curPrefix)) {
+ reachableCommonPrefixSet.add(reachLocTuple);
+ }
+ }
+
+ if (!reachableCommonPrefixSet.isEmpty()) {
+ // found reachable nodes that start with the prefix curPrefix
+ // need to assign a composite location
+ // System.out.println("-prefixList=" + prefixList);
+ // System.out.println("-reachableCommonPrefixSet=" + reachableCommonPrefixSet);
+ // System.out.println("-curPrefix=" + curPrefix);
+
+ // first, check if there are more than one the set of locations that has
+ // the same length of the longest reachable prefix, no way to assign
+ // a composite location to the input local var
+ prefixSanityCheck(prefixList, i, globalFlowGraph, reachableNodeSet);
+
+ MethodDescriptor topMethodDesc = globalFlowGraph.getMethodDescriptor();
+ CompositeLocation newCompLoc = generateCompositeLocation(curPrefix, topMethodDesc);
+
+ System.out.println("SET COMPOSITE LOCATION=" + newCompLoc + " to " + flowNode);
+ flowNode.setCompositeLocation(newCompLoc);
+ }
+ }
+
+ }
+
+ }
+
+ private CompositeLocation generateCompositeLocation(NTuple<Descriptor> curPrefix,
+ MethodDescriptor md) {
+ CompositeLocation newCompLoc = new CompositeLocation();
+
+ Descriptor enclosingDesc = md;
+ for (int i = 0; i < curPrefix.size(); i++) {
+ Descriptor curDesc = curPrefix.get(i);
+ Location loc = new Location(enclosingDesc, curDesc.getSymbol());
+ newCompLoc.addLocation(loc);
+ if (i == 0) {
+ VarDescriptor varDesc = (VarDescriptor) curDesc;
+ enclosingDesc = varDesc.getType().getClassDesc();
+ } else {
+ FieldDescriptor fieldDesc = (FieldDescriptor) curDesc;
+ enclosingDesc = fieldDesc.getType().getClassDesc();
+ }
+ }
+
+ LocationDescriptor newLocDescriptor = generateNewLocationDescriptor();
+ newLocDescriptor.setEnclosingClassDesc((ClassDescriptor) enclosingDesc);
+
+ Location newLoc = new Location(enclosingDesc, newLocDescriptor.getSymbol());
+ newLoc.setLocDescriptor(newLocDescriptor);
+ newCompLoc.addLocation(newLoc);
+
+ return newCompLoc;
+ }
+
+ private void prefixSanityCheck(List<NTuple<Descriptor>> prefixList, int curIdx,
+ FlowGraph globalFlowGraph, Set<FlowNode> reachableNodeSet) {
+
+ NTuple<Descriptor> curPrefix = prefixList.get(curIdx);
+
+ for (int i = curIdx + 1; i < prefixList.size(); i++) {
+ NTuple<Descriptor> prefixTuple = prefixList.get(i);
+
+ if (curPrefix.startsWith(prefixTuple)) {
+ continue;
+ }
+
+ for (Iterator iterator2 = reachableNodeSet.iterator(); iterator2.hasNext();) {
+ FlowNode reachableNode = (FlowNode) iterator2.next();
+ NTuple<Descriptor> reachLocTuple = reachableNode.getCurrentDescTuple();
+ if (reachLocTuple.startsWith(prefixTuple)) {
+ throw new Error(
+ "Failed to generate a composite location because there is more than one prefix which is reach to the current node.");
+ }
+ }
+ }
+
+ }
+
private void addValueFlowsFromCalleeSubGlobalFlowGraph(MethodDescriptor mdCaller,
FlowGraph subGlobalFlowGraph) {
int numParam = calleeSubGlobalGraph.getNumParameters();
for (int idx = 0; idx < numParam; idx++) {
FlowNode paramNode = calleeSubGlobalGraph.getParamFlowNode(idx);
- NodeTupleSet argTupleSet = mapMethodInvokeNodeToArgIdxMap.get(min).get(idx);
- System.out.println("argTupleSet=" + argTupleSet + " param=" + paramNode);
- for (Iterator<NTuple<Descriptor>> iter = argTupleSet.iterator(); iter.hasNext();) {
- NTuple<Descriptor> argTuple = iter.next();
- addValueFlowsFromCalleeParam(calleeSubGlobalGraph, paramNode, callerSubGlobalGraph,
- argTuple, baseTuple);
- }
+ NTuple<Descriptor> argTuple = mapMethodInvokeNodeToArgIdxMap.get(min).get(idx);
+ System.out.println("argTupleSet=" + argTuple + " param=" + paramNode);
+ // here, it adds all value flows reachable from the paramNode in the callee's flow graph
+ addValueFlowsFromCalleeParam(min, calleeSubGlobalGraph, paramNode, callerSubGlobalGraph,
+ argTuple, baseTuple);
}
}
- private void addValueFlowsFromCalleeParam(FlowGraph calleeSubGlobalGraph, FlowNode paramNode,
- FlowGraph callerSubGlobalGraph, NTuple<Descriptor> argTuple, NTuple<Descriptor> baseTuple) {
+ private void addValueFlowsFromCalleeParam(MethodInvokeNode min, FlowGraph calleeSubGlobalGraph,
+ FlowNode paramNode, FlowGraph callerSubGlobalGraph, NTuple<Descriptor> argTuple,
+ NTuple<Descriptor> baseTuple) {
Set<FlowNode> visited = new HashSet<FlowNode>();
visited.add(paramNode);
- recurAddValueFlowsFromCalleeParam(calleeSubGlobalGraph, paramNode, callerSubGlobalGraph,
+ recurAddValueFlowsFromCalleeParam(min, calleeSubGlobalGraph, paramNode, callerSubGlobalGraph,
argTuple, visited, baseTuple);
}
- private void recurAddValueFlowsFromCalleeParam(FlowGraph calleeSubGlobalGraph,
- FlowNode calleeSrcNode, FlowGraph callerSubGlobalGraph, NTuple<Descriptor> callerSrcTuple,
- Set<FlowNode> visited, NTuple<Descriptor> baseTuple) {
+ private void recurAddValueFlowsFromCalleeParam(MethodInvokeNode min,
+ FlowGraph calleeSubGlobalGraph, FlowNode calleeSrcNode, FlowGraph callerSubGlobalGraph,
+ NTuple<Descriptor> callerSrcTuple, Set<FlowNode> visited, NTuple<Descriptor> baseTuple) {
MethodDescriptor mdCallee = calleeSubGlobalGraph.getMethodDescriptor();
- Set<FlowEdge> edgeSet = calleeSubGlobalGraph.getOutEdgeSet(calleeSrcNode);
+ // Set<FlowEdge> edgeSet = calleeSubGlobalGraph.getOutEdgeSet(calleeSrcNode);
+ Set<FlowEdge> edgeSet = calleeSubGlobalGraph.getOutEdgeSetStartingFrom(calleeSrcNode);
for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
FlowEdge flowEdge = (FlowEdge) iterator.next();
- FlowNode dstNode = flowEdge.getDst();
- NTuple<Descriptor> dstDescTuple = dstNode.getCurrentDescTuple();
- if (dstDescTuple.get(0).equals(mdCallee.getThis())) {
- // destination node is started with 'this' variable
- // need to translate it in terms of the caller's base node
- dstDescTuple = translateToCaller(dstDescTuple, baseTuple);
+ NTuple<Descriptor> srcDescTuple = flowEdge.getInitTuple();
+ NTuple<Descriptor> dstDescTuple = flowEdge.getEndTuple();
+
+ FlowNode dstNode = calleeSubGlobalGraph.getFlowNode(dstDescTuple);
+
+ if (calleeSubGlobalGraph.isParameter(srcDescTuple)) {
+ // destination node is started with 'parameter'
+ // need to translate it in terms of the caller's a node
+ srcDescTuple =
+ translateToCaller(min, calleeSubGlobalGraph.getParamIdx(srcDescTuple), srcDescTuple);
}
- callerSubGlobalGraph.addValueFlowEdge(callerSrcTuple, dstDescTuple);
+ if (calleeSubGlobalGraph.isParameter(dstDescTuple)) {
+ // destination node is started with 'parameter'
+ // need to translate it in terms of the caller's a node
+ dstDescTuple =
+ translateToCaller(min, calleeSubGlobalGraph.getParamIdx(dstDescTuple), dstDescTuple);
+ }
+
+ callerSubGlobalGraph.addValueFlowEdge(srcDescTuple, dstDescTuple);
if (!visited.contains(dstNode)) {
visited.add(dstNode);
- recurAddValueFlowsFromCalleeParam(calleeSubGlobalGraph, dstNode, callerSubGlobalGraph,
+ recurAddValueFlowsFromCalleeParam(min, calleeSubGlobalGraph, dstNode, callerSubGlobalGraph,
dstDescTuple, visited, baseTuple);
}
}
+ private NTuple<Descriptor> translateToCaller(MethodInvokeNode min, int paramIdx,
+ NTuple<Descriptor> srcDescTuple) {
+
+ NTuple<Descriptor> callerTuple = new NTuple<Descriptor>();
+
+ NTuple<Descriptor> argTuple = mapMethodInvokeNodeToArgIdxMap.get(min).get(paramIdx);
+
+ for (int i = 0; i < argTuple.size(); i++) {
+ callerTuple.add(argTuple.get(i));
+ }
+
+ for (int i = 1; i < srcDescTuple.size(); i++) {
+ callerTuple.add(srcDescTuple.get(i));
+ }
+
+ return callerTuple;
+ }
+
private NTuple<Descriptor> translateToCaller(NTuple<Descriptor> dstDescTuple,
NTuple<Descriptor> baseTuple) {
NTuple<Descriptor> callerDescTuple = new NTuple<Descriptor>();
for (int paramIdx = 0; paramIdx < flowGraph.getNumParameters(); paramIdx++) {
FlowNode flowNode = flowGraph.getParamFlowNode(paramIdx);
- NTuple<Descriptor> descTuple = flowNode.getDescTuple();
+ NTuple<Location> locTuple = flowNode.getLocTuple();
CompositeLocation assignedCompLoc = flowNode.getCompositeLocation();
CompositeLocation inferredCompLoc;
if (assignedCompLoc != null) {
inferredCompLoc = translateCompositeLocation(assignedCompLoc);
} else {
- Descriptor locDesc = descTuple.get(0);
- Location loc = new Location(md, locDesc.getSymbol());
- loc.setLocDescriptor(locDesc);
+ Location loc = locTuple.get(0);
inferredCompLoc = new CompositeLocation(loc);
}
System.out.println("-paramIdx=" + paramIdx + " infer=" + inferredCompLoc);
Set<FlowNode> nodeSet = fg.getNodeSet();
for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) {
FlowNode flowNode = (FlowNode) iterator.next();
- if (flowNode.getDescTuple().get(0).equals(md.getThis())) {
+ if (flowNode.getLocTuple().get(0).equals(md.getThis())) {
return true;
}
}
FlowNode paramNode1 = calleeFlowGraph.getParamFlowNode(i);
FlowNode paramNode2 = calleeFlowGraph.getParamFlowNode(k);
- NodeTupleSet tupleSetArg1 = getNodeTupleSetByArgIdx(min, i);
- NodeTupleSet tupleSetArg2 = getNodeTupleSetByArgIdx(min, k);
-
- for (Iterator<NTuple<Descriptor>> iter1 = tupleSetArg1.iterator(); iter1.hasNext();) {
- NTuple<Descriptor> arg1Tuple = iter1.next();
-
- for (Iterator<NTuple<Descriptor>> iter2 = tupleSetArg2.iterator(); iter2.hasNext();) {
- NTuple<Descriptor> arg2Tuple = iter2.next();
-
- // check if the callee propagates an ordering constraints through
- // parameters
+ NTuple<Descriptor> arg1Tuple = getNodeTupleByArgIdx(min, i);
+ NTuple<Descriptor> arg2Tuple = getNodeTupleByArgIdx(min, k);
- Set<FlowNode> localReachSet =
- calleeFlowGraph.getLocalReachFlowNodeSetFrom(paramNode1);
+ // check if the callee propagates an ordering constraints through
+ // parameters
- if (localReachSet.contains(paramNode2)) {
- // need to propagate an ordering relation s.t. arg1 is higher
- // than arg2
-
- System.out
- .println("-param1=" + paramNode1 + " is higher than param2=" + paramNode2);
- System.out.println("-arg1Tuple=" + arg1Tuple + " is higher than arg2Tuple="
- + arg2Tuple);
+ Set<FlowNode> localReachSet = calleeFlowGraph.getLocalReachFlowNodeSetFrom(paramNode1);
- // otherwise, flows between method/field locations...
- callerFlowGraph.addValueFlowEdge(arg1Tuple, arg2Tuple);
- System.out.println("arg1=" + arg1Tuple + " arg2=" + arg2Tuple);
+ if (localReachSet.contains(paramNode2)) {
+ // need to propagate an ordering relation s.t. arg1 is higher
+ // than arg2
- }
+ System.out.println("-param1=" + paramNode1 + " is higher than param2=" + paramNode2);
+ System.out
+ .println("-arg1Tuple=" + arg1Tuple + " is higher than arg2Tuple=" + arg2Tuple);
- }
+ // otherwise, flows between method/field locations...
+ callerFlowGraph.addValueFlowEdge(arg1Tuple, arg2Tuple);
+ System.out.println("arg1=" + arg1Tuple + " arg2=" + arg2Tuple);
}
+
System.out.println();
}
}
System.out.println("param2=" + paramNode2 + " curDescTuple="
+ paramNode2.getCurrentDescTuple());
- NodeTupleSet tupleSetArg1 = getNodeTupleSetByArgIdx(min, i);
- NodeTupleSet tupleSetArg2 = getNodeTupleSetByArgIdx(min, k);
+ // TODO: deprecated method
+ // NodeTupleSet tupleSetArg1 = getNodeTupleSetByArgIdx(min, i);
+ // NodeTupleSet tupleSetArg2 = getNodeTupleSetByArgIdx(min, k);
+ NodeTupleSet tupleSetArg1 = null;
+ NodeTupleSet tupleSetArg2 = null;
for (Iterator<NTuple<Descriptor>> iter1 = tupleSetArg1.iterator(); iter1.hasNext();) {
NTuple<Descriptor> arg1Tuple = iter1.next();
CompositeLocation param2 = calleeLocInfo.getParamCompositeLocation(k);
if (isGreaterThan(getLattice(possibleMdCallee), param1, param2)) {
- NodeTupleSet argDescTupleSet1 = getNodeTupleSetByArgIdx(min, i);
- NodeTupleSet argDescTupleSet2 = getNodeTupleSetByArgIdx(min, k);
+ // NodeTupleSet argDescTupleSet1 = getNodeTupleSetByArgIdx(min, i);
+ // NodeTupleSet argDescTupleSet2 = getNodeTupleSetByArgIdx(min, k);
+ NodeTupleSet argDescTupleSet1 = null;
+ NodeTupleSet argDescTupleSet2 = null;
// the callee has the relation in which param1 is higher than param2
// therefore, the caller has to have the relation in which arg1 is
CompositeLocation inferSrcLoc;
CompositeLocation inferDstLoc = methodInfo.getInferLocation(dstDesc);
- if (srcNode.getDescTuple().size() > 1) {
+ if (srcNode.getLocTuple().size() > 1) {
// field access
inferSrcLoc = new CompositeLocation();
inferSrcLoc = methodInfo.getInferLocation(srcDesc);
}
- if (dstNode.getDescTuple().size() > 1) {
+ if (dstNode.getLocTuple().size() > 1) {
// field access
inferDstLoc = new CompositeLocation();
// first, check if there are more than one the set of locations that has
// the same length of the longest reachable prefix, no way to assign
// a composite location to the input local var
- prefixSanityCheck(prefixList, i, flowGraph, reachableNodeSet);
+ // prefixSanityCheck(prefixList, i, flowGraph, reachableNodeSet);
Set<NTuple<Location>> incomingCommonPrefixSet =
mapPrefixToIncomingLocTupleSet.get(curPrefix);
methodInfo.removeMaplocalVarToLocSet(srcLocalVar);
// add the field/var descriptor to the set of the location symbol
- int lastIdx = srcNode.getDescTuple().size() - 1;
+ int lastIdx = srcNode.getLocTuple().size() - 1;
Descriptor lastFlowNodeDesc = srcNode.getDescTuple().get(lastIdx);
NTuple<Location> srcNodelocTuple = flowGraph.getLocationTuple(srcNode);
Descriptor enclosinglastLastFlowNodeDesc = srcNodelocTuple.get(lastIdx).getDescriptor();
methodInfo.removeMaplocalVarToLocSet(localVarDesc);
// add the field/var descriptor to the set of the location symbol
- int lastIdx = flowNode.getDescTuple().size() - 1;
+ int lastIdx = flowNode.getLocTuple().size() - 1;
Descriptor lastFlowNodeDesc = flowNode.getDescTuple().get(lastIdx);
Descriptor enclosinglastLastFlowNodeDesc = flowNodelocTuple.get(lastIdx).getDescriptor();
}
- private void prefixSanityCheck(List<NTuple<Location>> prefixList, int curIdx,
- FlowGraph flowGraph, Set<FlowNode> reachableNodeSet) {
-
- NTuple<Location> curPrefix = prefixList.get(curIdx);
-
- for (int i = curIdx + 1; i < prefixList.size(); i++) {
- NTuple<Location> prefixTuple = prefixList.get(i);
-
- if (curPrefix.startsWith(prefixTuple)) {
- continue;
- }
-
- for (Iterator iterator2 = reachableNodeSet.iterator(); iterator2.hasNext();) {
- FlowNode reachableNode = (FlowNode) iterator2.next();
- NTuple<Location> reachLocTuple = flowGraph.getLocationTuple(reachableNode);
- if (reachLocTuple.startsWith(prefixTuple)) {
- // TODO
- throw new Error("Failed to generate a composite location");
- }
- }
- }
- }
-
public boolean isPrimitiveLocalVariable(FlowNode node) {
VarDescriptor varDesc = (VarDescriptor) node.getDescTuple().get(0);
return varDesc.getType().isPrimitive();
private void extractRelationFromFieldFlows(ClassDescriptor cd, FlowNode srcNode,
FlowNode dstNode, int idx) throws CyclicFlowException {
- if (srcNode.getDescTuple().get(idx).equals(dstNode.getDescTuple().get(idx))
- && srcNode.getDescTuple().size() > (idx + 1) && dstNode.getDescTuple().size() > (idx + 1)) {
+ if (srcNode.getLocTuple().get(idx).equals(dstNode.getLocTuple().get(idx))
+ && srcNode.getLocTuple().size() > (idx + 1) && dstNode.getLocTuple().size() > (idx + 1)) {
// value flow between fields: we don't need to add a binary relation
// for this case
if (newImplicitTupleSet.size() > 1) {
// need to create an intermediate node for the GLB of conditional locations & implicit flows
- NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
+ NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode(md).getDescTuple();
for (Iterator<NTuple<Descriptor>> idxIter = newImplicitTupleSet.iterator(); idxIter.hasNext();) {
NTuple<Descriptor> tuple = idxIter.next();
addFlowGraphEdge(md, tuple, interTuple);
currentFlowTupleSet.addTupleSet(implicitFlowTupleSet);
if (currentFlowTupleSet.size() > 1) {
- FlowNode meetNode = fg.createIntermediateNode();
+ FlowNode meetNode = fg.createIntermediateNode(md);
for (Iterator iterator = currentFlowTupleSet.iterator(); iterator.hasNext();) {
NTuple<Descriptor> currentFlowTuple = (NTuple<Descriptor>) iterator.next();
fg.addValueFlowEdge(currentFlowTuple, meetNode.getDescTuple());
if (newImplicitTupleSet.size() > 1) {
// need to create an intermediate node for the GLB of conditional locations & implicit flows
- NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
+ NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode(md).getDescTuple();
for (Iterator<NTuple<Descriptor>> idxIter = newImplicitTupleSet.iterator(); idxIter
.hasNext();) {
NTuple<Descriptor> tuple = idxIter.next();
implicitFlowTupleSet, false);
// ///////////
- NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
+ NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode(md).getDescTuple();
for (Iterator<NTuple<Descriptor>> idxIter = condTupleNode.iterator(); idxIter.hasNext();) {
NTuple<Descriptor> tuple = idxIter.next();
if (newImplicitTupleSet.size() > 1) {
// need to create an intermediate node for the GLB of conditional locations & implicit flows
- NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
+ NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode(md).getDescTuple();
for (Iterator<NTuple<Descriptor>> idxIter = newImplicitTupleSet.iterator(); idxIter.hasNext();) {
NTuple<Descriptor> tuple = idxIter.next();
addFlowGraphEdge(md, tuple, interTuple);
// creates edges from RHS to LHS
NTuple<Descriptor> interTuple = null;
if (nodeSetRHS.size() > 1) {
- interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
+ interTuple = getFlowGraph(md).createIntermediateNode(md).getDescTuple();
}
for (Iterator<NTuple<Descriptor>> iter = nodeSetRHS.iterator(); iter.hasNext();) {
implicitFlowTupleSet, false);
assert (baseNodeSet.size() == 1);
- mapMethodInvokeNodeToBaseTuple.put(min, baseNodeSet.iterator().next());
+ NTuple<Descriptor> baseTuple = baseNodeSet.iterator().next();
+ mapMethodInvokeNodeToBaseTuple.put(min, baseTuple);
if (!min.getMethod().isStatic()) {
- addArgIdxMap(min, 0, baseNodeSet);
+ addArgIdxMap(min, 0, baseTuple);
for (Iterator iterator = calleeReturnSet.iterator(); iterator.hasNext();) {
FlowNode returnNode = (FlowNode) iterator.next();
if (returnDescTuple.startsWith(calleeMethodDesc.getThis())) {
// the location type of the return value is started with 'this'
// reference
- for (Iterator<NTuple<Descriptor>> baseIter = baseNodeSet.iterator(); baseIter
- .hasNext();) {
- NTuple<Descriptor> baseTuple = baseIter.next();
- NTuple<Descriptor> inFlowTuple = new NTuple<Descriptor>(baseTuple.getList());
- inFlowTuple.addAll(returnDescTuple.subList(1, returnDescTuple.size()));
- nodeSet.addTuple(inFlowTuple);
- }
+ NTuple<Descriptor> inFlowTuple = new NTuple<Descriptor>(baseTuple.getList());
+ inFlowTuple.addAll(returnDescTuple.subList(1, returnDescTuple.size()));
+ nodeSet.addTuple(inFlowTuple);
} else {
+ // TODO
Set<FlowNode> inFlowSet = calleeFlowGraph.getIncomingFlowNodeSet(returnNode);
for (Iterator iterator2 = inFlowSet.iterator(); iterator2.hasNext();) {
FlowNode inFlowNode = (FlowNode) iterator2.next();
NodeTupleSet argTupleSet = new NodeTupleSet();
analyzeFlowExpressionNode(md, nametable, en, argTupleSet, false);
// if argument is liternal node, argTuple is set to NULL.
- addArgIdxMap(min, idx, argTupleSet);
+
+ NTuple<Descriptor> argTuple = new NTuple<Descriptor>();
+ if (argTupleSet.size() > 1) {
+ NTuple<Descriptor> interTuple =
+ getFlowGraph(md).createIntermediateNode(md).getDescTuple();
+ for (Iterator<NTuple<Descriptor>> idxIter = argTupleSet.iterator(); idxIter.hasNext();) {
+ NTuple<Descriptor> tuple = idxIter.next();
+ addFlowGraphEdge(md, tuple, interTuple);
+ }
+ argTuple = interTuple;
+ } else {
+ argTuple = argTupleSet.iterator().next();
+ }
+
+ addArgIdxMap(min, idx, argTuple);
FlowNode paramNode = calleeFlowGraph.getParamFlowNode(idx);
if (hasInFlowTo(calleeFlowGraph, paramNode, calleeReturnSet)
|| calleeMethodDesc.getModifiers().isNative()) {
return false;
}
- private NodeTupleSet getNodeTupleSetByArgIdx(MethodInvokeNode min, int idx) {
+ private NTuple<Descriptor> getNodeTupleByArgIdx(MethodInvokeNode min, int idx) {
return mapMethodInvokeNodeToArgIdxMap.get(min).get(new Integer(idx));
}
- private void addArgIdxMap(MethodInvokeNode min, int idx, NodeTupleSet tupleSet) {
- Map<Integer, NodeTupleSet> mapIdxToTupleSet = mapMethodInvokeNodeToArgIdxMap.get(min);
- if (mapIdxToTupleSet == null) {
- mapIdxToTupleSet = new HashMap<Integer, NodeTupleSet>();
- mapMethodInvokeNodeToArgIdxMap.put(min, mapIdxToTupleSet);
+ private void addArgIdxMap(MethodInvokeNode min, int idx, NTuple<Descriptor> argTuple /*
+ * NodeTupleSet
+ * tupleSet
+ */) {
+ Map<Integer, NTuple<Descriptor>> mapIdxToTuple = mapMethodInvokeNodeToArgIdxMap.get(min);
+ if (mapIdxToTuple == null) {
+ mapIdxToTuple = new HashMap<Integer, NTuple<Descriptor>>();
+ mapMethodInvokeNodeToArgIdxMap.put(min, mapIdxToTuple);
}
- mapIdxToTupleSet.put(new Integer(idx), tupleSet);
- }
-
- private void analyzeFlowMethodParameters(MethodDescriptor callermd, SymbolTable nametable,
- MethodInvokeNode min, NodeTupleSet nodeSet) {
-
- if (min.numArgs() > 0) {
-
- int offset;
- if (min.getMethod().isStatic()) {
- offset = 0;
- } else {
- offset = 1;
- // NTuple<Descriptor> thisArgTuple = new NTuple<Descriptor>();
- // thisArgTuple.add(callermd.getThis());
- // NodeTupleSet argTupleSet = new NodeTupleSet();
- // argTupleSet.addTuple(thisArgTuple);
- // addArgIdxMap(min, 0, argTupleSet);
- // nodeSet.addTuple(thisArgTuple);
- }
-
- for (int i = 0; i < min.numArgs(); i++) {
- ExpressionNode en = min.getArg(i);
- NodeTupleSet argTupleSet = new NodeTupleSet();
- analyzeFlowExpressionNode(callermd, nametable, en, argTupleSet, false);
- // if argument is liternal node, argTuple is set to NULL.
- addArgIdxMap(min, i + offset, argTupleSet);
- nodeSet.addTupleSet(argTupleSet);
- }
-
- }
-
+ mapIdxToTuple.put(new Integer(idx), argTuple);
}
private void analyzeLiteralNode(MethodDescriptor md, SymbolTable nametable, LiteralNode en) {
// creates edges from RHS to LHS
NTuple<Descriptor> interTuple = null;
if (nodeSetRHS.size() > 1) {
- interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
+ interTuple = getFlowGraph(md).createIntermediateNode(md).getDescTuple();
}
for (Iterator<NTuple<Descriptor>> iter = nodeSetRHS.iterator(); iter.hasNext();) {