int classDefLine = mapDescToDefinitionLine.get(cd);
Vector<String> sourceVec = mapFileNameToLineVector.get(sourceFileName);
-
if (locInfo == null) {
locInfo = getLocationInfo(cd);
ssjava.init();
LinkedList<MethodDescriptor> descriptorListToAnalyze = ssjava.getSortedDescriptors();
- Collections.sort(descriptorListToAnalyze, new Comparator<MethodDescriptor>() {
- public int compare(MethodDescriptor o1, MethodDescriptor o2) {
- return o1.getSymbol().compareToIgnoreCase(o2.getSymbol());
- }
- });
+ // Collections.sort(descriptorListToAnalyze, new
+ // Comparator<MethodDescriptor>() {
+ // public int compare(MethodDescriptor o1, MethodDescriptor o2) {
+ // return o1.getSymbol().compareToIgnoreCase(o2.getSymbol());
+ // }
+ // });
// current descriptors to visit in fixed-point interprocedural analysis,
// prioritized by
}
}
+ // create mapping from param idx to inferred composite location
+
+ int offset;
+ if (!md.isStatic()) {
+ // add 'this' reference location
+ offset = 1;
+ methodInfo.addMapParamIdxToInferLoc(0, methodInfo.getInferLocation(md.getThis()));
+ } else {
+ offset = 0;
+ }
+
+ for (int idx = 0; idx < md.numParameters(); idx++) {
+ Descriptor paramDesc = md.getParameter(idx);
+ CompositeLocation inferParamLoc = methodInfo.getInferLocation(paramDesc);
+ methodInfo.addMapParamIdxToInferLoc(idx + offset, inferParamLoc);
+ }
+
}
private void calculateExtraLocations(MethodDescriptor md) {
// calcualte pcloc, returnloc,...
- System.out.println("#calculateExtraLocations=" + md);
SSJavaLattice<String> methodLattice = getMethodLattice(md);
MethodLocationInfo methodInfo = getMethodLocationInfo(md);
FlowGraph fg = getFlowGraph(md);
}
}
- // create mapping from param idx to inferred composite location
-
- int offset;
- if (!md.isStatic()) {
- // add 'this' reference location
- offset = 1;
- methodInfo.addMapParamIdxToInferLoc(0, methodInfo.getInferLocation(md.getThis()));
- } else {
- offset = 0;
- }
-
- for (int idx = 0; idx < md.numParameters(); idx++) {
- Descriptor paramDesc = md.getParameter(idx);
- CompositeLocation inferParamLoc = methodInfo.getInferLocation(paramDesc);
- methodInfo.addMapParamIdxToInferLoc(idx + offset, inferParamLoc);
- }
-
Map<Integer, CompositeLocation> mapParamToLoc = methodInfo.getMapParamIdxToInferLoc();
Set<Integer> keySet = mapParamToLoc.keySet();
// calculate the initial program counter location
// PC location is higher than location types of all parameters
String pcLocSymbol = "PCLOC";
+
for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
Integer paramIdx = (Integer) iterator.next();
CompositeLocation inferLoc = mapParamToLoc.get(paramIdx);
}
}
}
+
+ Set<String> locElementSet = methodLattice.getElementSet();
+ locElementSet.remove(pcLocSymbol);
+ for (Iterator iterator = locElementSet.iterator(); iterator.hasNext();) {
+ String loc = (String) iterator.next();
+ if (!methodLattice.isGreaterThan(pcLocSymbol, loc)) {
+ addRelationHigherToLower(methodLattice, methodInfo, pcLocSymbol, loc);
+ }
+ }
+
}
// calculate a return location
// types
// of return values
if (!md.getReturnType().isVoid()) {
- System.out.println("@@@@@ RETURN md=" + md);
// first, generate the set of return value location types that starts
// with
// 'this' reference
MethodDescriptor possibleMdCallee, SSJavaLattice<String> methodLattice,
MethodLocationInfo methodInfo) throws CyclicFlowException {
+
SSJavaLattice<String> calleeLattice = getMethodLattice(possibleMdCallee);
MethodLocationInfo calleeLocInfo = getMethodLocationInfo(possibleMdCallee);
FlowGraph calleeFlowGraph = getFlowGraph(possibleMdCallee);
for (int k = 0; k < numParam; k++) {
if (i != k) {
CompositeLocation param2 = calleeLocInfo.getParamCompositeLocation(k);
+
if (isGreaterThan(getLattice(possibleMdCallee), param1, param2)) {
NodeTupleSet argDescTupleSet1 = getNodeTupleSetByArgIdx(min, i);
NodeTupleSet argDescTupleSet2 = getNodeTupleSetByArgIdx(min, k);
LinkedList<MethodDescriptor> methodDescList = computeMethodList();
-
while (!methodDescList.isEmpty()) {
MethodDescriptor md = methodDescList.removeLast();
if (state.SSJAVADEBUG) {
private void analyzeFlowMethodInvokeNode(MethodDescriptor md, SymbolTable nametable,
MethodInvokeNode min, NodeTupleSet nodeSet, NodeTupleSet implicitFlowTupleSet) {
+
if (nodeSet == null) {
nodeSet = new NodeTupleSet();
}
}
if (!ssjava.isSSJavaUtil(calleeMethodDesc.getClassDesc())
- && !ssjava.isTrustMethod(calleeMethodDesc) && !calleeMethodDesc.getModifiers().isNative()
- && !isSystemout) {
+ && !ssjava.isTrustMethod(calleeMethodDesc) && !isSystemout) {
FlowGraph calleeFlowGraph = getFlowGraph(calleeMethodDesc);
Set<FlowNode> calleeReturnSet = calleeFlowGraph.getReturnNodeSet();
analyzeFlowExpressionNode(md, nametable, min.getExpression(), baseNodeSet, null,
implicitFlowTupleSet, false);
+
if (!min.getMethod().isStatic()) {
addArgIdxMap(min, 0, baseNodeSet);
+
for (Iterator iterator = calleeReturnSet.iterator(); iterator.hasNext();) {
FlowNode returnNode = (FlowNode) iterator.next();
NTuple<Descriptor> returnDescTuple = returnNode.getDescTuple();
ExpressionNode en = min.getArg(i);
int idx = i + offset;
NodeTupleSet argTupleSet = new NodeTupleSet();
- analyzeFlowExpressionNode(md, nametable, en, argTupleSet, false);
+ analyzeFlowExpressionNode(md, nametable, en, argTupleSet, true);
// if argument is liternal node, argTuple is set to NULL.
addArgIdxMap(min, idx, argTupleSet);
FlowNode paramNode = calleeFlowGraph.getParamFlowNode(idx);
- if (hasInFlowTo(calleeFlowGraph, paramNode, calleeReturnSet)) {
+ if (hasInFlowTo(calleeFlowGraph, paramNode, calleeReturnSet)
+ || calleeMethodDesc.getModifiers().isNative()) {
addParamNodeFlowingToReturnValue(calleeMethodDesc, paramNode);
nodeSet.addTupleSet(argTupleSet);
}