- }
- }
-
- }
-
- private void propagateFlowsToCaller(MethodInvokeNode min, MethodDescriptor mdCaller,
- MethodDescriptor mdCallee) {
-
- System.out.println("\n##PROPAGATE callee=" + mdCallee + "TO caller=" + mdCaller);
-
- // if the parameter A reaches to the parameter B
- // then, add an edge the argument A -> the argument B to the caller's flow
- // graph
-
- // TODO
- // also if a parameter is a composite location and is started with "this"
- // reference,
- // need to make sure that the corresponding argument is higher than the
- // translated location of
- // the parameter.
-
- FlowGraph calleeFlowGraph = getFlowGraph(mdCallee);
- FlowGraph callerFlowGraph = getFlowGraph(mdCaller);
- int numParam = calleeFlowGraph.getNumParameters();
-
- for (int i = 0; i < numParam; i++) {
- for (int k = 0; k < numParam; k++) {
-
- if (i != k) {
-
- FlowNode paramNode1 = calleeFlowGraph.getParamFlowNode(i);
- FlowNode paramNode2 = calleeFlowGraph.getParamFlowNode(k);
-
- System.out.println("param1=" + paramNode1 + " curDescTuple="
- + paramNode1.getCurrentDescTuple());
- System.out.println("param2=" + paramNode2 + " curDescTuple="
- + paramNode2.getCurrentDescTuple());
-
- // 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();
-
- for (Iterator<NTuple<Descriptor>> iter2 = tupleSetArg2.iterator(); iter2.hasNext();) {
- NTuple<Descriptor> arg2Tuple = iter2.next();
-
- // check if the callee propagates an ordering constraints through
- // parameters
-
- Set<FlowNode> localReachSet =
- calleeFlowGraph.getLocalReachFlowNodeSetFrom(paramNode1);
-
- 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);
-
- if (!min.getMethod().isStatic()) {
- // check if this is the case that values flow to/from the
- // current object reference 'this'
-
- NTuple<Descriptor> baseTuple = mapMethodInvokeNodeToBaseTuple.get(min);
- Descriptor baseRef = baseTuple.get(baseTuple.size() - 1);
-
- System.out.println("paramNode1.getCurrentDescTuple()="
- + paramNode1.getCurrentDescTuple());
- // calculate the prefix of the argument
-
- if (arg2Tuple.size() == 1 && arg2Tuple.get(0).equals(baseRef)) {
- // in this case, the callee flow causes a caller flow to the
- // object whose method
- // is invoked.
-
- if (!paramNode1.getCurrentDescTuple().startsWith(mdCallee.getThis())) {
- // check whether ???
-
- NTuple<Descriptor> param1Prefix =
- calculatePrefixForParam(callerFlowGraph, calleeFlowGraph, min, arg1Tuple,
- paramNode1);
-
- if (param1Prefix != null && param1Prefix.startsWith(mdCallee.getThis())) {
- // in this case, we need to create a new edge
- // 'this.FIELD'->'this'
- // but we couldn't... instead we assign a new composite
- // location started
- // with 'this' reference to the corresponding parameter
-
- CompositeLocation compLocForParam1 =
- generateCompositeLocation(mdCallee, param1Prefix);
-
- System.out
- .println("set comp loc=" + compLocForParam1 + " to " + paramNode1);
- paramNode1.setCompositeLocation(compLocForParam1);