+ private void bindLocationPathCallerArgWithCalleeParam(MethodDescriptor mdCaller, FlatCall fc) {
+
+ if (ssjava.isSSJavaUtil(fc.getMethod().getClassDesc())) {
+ // ssjava util case!
+ // have write effects on the first argument
+ TempDescriptor arg = fc.getArg(0);
+ NTuple<String> argLocationStrPath = deriveLocationTuple(mdCaller, arg);
+ NTuple<Descriptor> argHeapPath = computePath(arg);
+ mapLocationPathToMayWrittenSet.put(argLocationStrPath, null,
+ argHeapPath.get(argHeapPath.size() - 1));
+
+ } else {
+
+ // if arg is not primitive type, we need to propagate maywritten set to
+ // the caller's location path
+
+ MethodDescriptor mdCallee = fc.getMethod();
+ Set<MethodDescriptor> setPossibleCallees = new HashSet<MethodDescriptor>();
+ setPossibleCallees.addAll(callGraph.getMethods(mdCallee));
+
+ // create mapping from arg idx to its heap paths
+ Hashtable<Integer, NTuple<String>> mapArgIdx2CallerAgLocationStrPath =
+ new Hashtable<Integer, NTuple<String>>();
+
+ // arg idx is starting from 'this' arg
+ if (fc.getThis() != null) {
+ NTuple<String> thisLocationStrPath = deriveLocationTuple(mdCaller, fc.getThis());
+ mapArgIdx2CallerAgLocationStrPath.put(Integer.valueOf(0), thisLocationStrPath);
+ }
+
+ for (int i = 0; i < fc.numArgs(); i++) {
+ TempDescriptor arg = fc.getArg(i);
+ NTuple<String> argLocationStrPath = deriveLocationTuple(mdCaller, arg);
+ mapArgIdx2CallerAgLocationStrPath.put(Integer.valueOf(i + 1), argLocationStrPath);
+ }
+
+ for (Iterator iterator = setPossibleCallees.iterator(); iterator.hasNext();) {
+ MethodDescriptor callee = (MethodDescriptor) iterator.next();
+ FlatMethod calleeFlatMethod = state.getMethodFlat(callee);
+
+ // binding caller's args and callee's params
+
+ Hashtable<Integer, TempDescriptor> mapParamIdx2ParamTempDesc =
+ new Hashtable<Integer, TempDescriptor>();
+ int offset = 0;
+ if (calleeFlatMethod.getMethod().isStatic()) {
+ // static method does not have implicit 'this' arg
+ offset = 1;
+ }
+ for (int i = 0; i < calleeFlatMethod.numParameters(); i++) {
+ TempDescriptor param = calleeFlatMethod.getParameter(i);
+ mapParamIdx2ParamTempDesc.put(Integer.valueOf(i + offset), param);
+ }
+
+ Set<Integer> keySet = mapArgIdx2CallerAgLocationStrPath.keySet();
+ for (Iterator iterator2 = keySet.iterator(); iterator2.hasNext();) {
+ Integer idx = (Integer) iterator2.next();
+ NTuple<String> callerArgLocationStrPath = mapArgIdx2CallerAgLocationStrPath.get(idx);
+
+ TempDescriptor calleeParam = mapParamIdx2ParamTempDesc.get(idx);
+ NTuple<String> calleeLocationStrPath = deriveLocationTuple(mdCallee, calleeParam);
+
+ createNewMappingOfMayWrittenSet(callerArgLocationStrPath, calleeLocationStrPath);
+
+ }
+
+ }
+
+ }
+
+ }
+
+ private void createNewMappingOfMayWrittenSet(NTuple<String> callerPath,
+ NTuple<String> calleeParamPath) {
+
+ // propagate may-written-set associated with the key that is started with
+ // calleepath to the caller
+ // 1) makes a new key by combining caller path and callee path(except local
+ // loc element of param)
+ // 2) create new mapping of may-written-set of callee path to caller path
+
+ // extract all may written effect accessed through callee param path
+ Hashtable<NTuple<String>, Set<Descriptor>> mapping =
+ mapLocationPathToMayWrittenSet.getMappingByStartedWith(calleeParamPath);
+ System.out.println("CALLEE MAPPING=" + mapping);
+
+ Set<NTuple<String>> calleeKeySet = mapping.keySet();
+ for (Iterator iterator = calleeKeySet.iterator(); iterator.hasNext();) {
+ NTuple<String> calleeKey = (NTuple<String>) iterator.next();
+ Set<Descriptor> calleeMayWriteSet = mapLocationPathToMayWrittenSet.get(calleeKey);
+
+ NTuple<String> newKey = new NTuple<String>();
+ newKey.addAll(callerPath);
+ // need to replace the local location with the caller's path so skip the
+ // local location of the parameter
+ for (int i = 1; i < calleeKey.size(); i++) {
+ newKey.add(calleeKey.get(i));
+ }
+
+ System.out.println("calleeParamPath=" + calleeParamPath + " newKey=" + newKey
+ + " maywriteSet=" + calleeMayWriteSet);
+ mapLocationPathToMayWrittenSet.put(newKey, calleeKey, calleeMayWriteSet);