CompositeLocation constraint) {
ClassDescriptor cd = md.getClassDesc();
- MethodDescriptor calleeMD = min.getMethod();
+ MethodDescriptor calleeMethodDesc = min.getMethod();
NameDescriptor baseName = min.getBaseName();
boolean isSystemout = false;
isSystemout = baseName.getSymbol().equals("System.out");
}
- if (!ssjava.isSSJavaUtil(calleeMD.getClassDesc()) && !ssjava.isTrustMethod(calleeMD)
- && !calleeMD.getModifiers().isNative() && !isSystemout) {
+ if (!ssjava.isSSJavaUtil(calleeMethodDesc.getClassDesc())
+ && !ssjava.isTrustMethod(calleeMethodDesc) && !calleeMethodDesc.getModifiers().isNative()
+ && !isSystemout) {
CompositeLocation baseLocation = null;
if (min.getExpression() != null) {
// setup the location list of caller's arguments
List<CompositeLocation> callerArgList = new ArrayList<CompositeLocation>();
+ // setup the location list of callee's parameters
+ MethodLattice<String> calleeLattice = ssjava.getMethodLattice(calleeMethodDesc);
+ List<CompositeLocation> calleeParamList = new ArrayList<CompositeLocation>();
+
if (min.numArgs() > 0) {
- // setup caller args set
- // first, add caller's base(this) location
- callerArgList.add(baseLocation);
- // second, add caller's arguments
+ if (!calleeMethodDesc.isStatic()) {
+ callerArgList.add(baseLocation);
+ }
for (int i = 0; i < min.numArgs(); i++) {
ExpressionNode en = min.getArg(i);
CompositeLocation callerArgLoc =
constraint, false);
callerArgList.add(callerArgLoc);
}
- }
- // setup the location list of callee's parameters
- MethodDescriptor calleemd = min.getMethod();
- MethodLattice<String> calleeLattice = ssjava.getMethodLattice(calleemd);
- CompositeLocation calleeThisLoc =
- new CompositeLocation(new Location(calleemd, calleeLattice.getThisLoc()));
- List<CompositeLocation> calleeParamList = new ArrayList<CompositeLocation>();
- // first, add callee's this location
- calleeParamList.add(calleeThisLoc);
- // second, add callee's parameters
- for (int i = 0; i < calleemd.numParameters(); i++) {
- VarDescriptor calleevd = (VarDescriptor) calleemd.getParameter(i);
- CompositeLocation calleeLoc = d2loc.get(calleevd);
- calleeParamList.add(calleeLoc);
+ if (!calleeMethodDesc.isStatic()) {
+ CompositeLocation calleeThisLoc =
+ new CompositeLocation(new Location(calleeMethodDesc, calleeLattice.getThisLoc()));
+ calleeParamList.add(calleeThisLoc);
+ }
+
+ for (int i = 0; i < calleeMethodDesc.numParameters(); i++) {
+ VarDescriptor calleevd = (VarDescriptor) calleeMethodDesc.getParameter(i);
+ CompositeLocation calleeLoc = d2loc.get(calleevd);
+ calleeParamList.add(calleeLoc);
+ }
}
if (constraint != null) {
// annotation that declares the program counter that is higher than
// corresponding parameter
- CompositeLocation calleePCLOC = ssjava.getPCLocation(calleemd);
+ CompositeLocation calleePCLOC = ssjava.getPCLocation(calleeMethodDesc);
for (int idx = 0; idx < callerArgList.size(); idx++) {
CompositeLocation argLocation = callerArgList.get(idx);
- int compareResult =
- CompositeLattice
- .compare(argLocation, constraint, true, generateErrorMessage(cd, min));
-
// need to check that param is higher than PCLOC
- if (compareResult == ComparisonResult.GREATER) {
+ if (!argLocation.get(0).isTop()
+ && CompositeLattice.compare(argLocation, constraint, true,
+ generateErrorMessage(cd, min)) == ComparisonResult.GREATER) {
CompositeLocation paramLocation = calleeParamList.get(idx);
+ argLocation
+ ". Need to specify that the initial PC location of the callee, which is currently set to "
+ calleePCLOC + ", is lower than " + paramLocation + " in the method "
- + calleeMD.getSymbol() + ":" + min.getNumLine());
+ + calleeMethodDesc.getSymbol() + ":" + min.getNumLine());
}
}
private void checkCalleeConstraints(MethodDescriptor md, SymbolTable nametable,
MethodInvokeNode min, CompositeLocation callerBaseLoc, CompositeLocation constraint) {
- // System.out.println("checkCalleeConstraints=" + min.printNode(0));
-
MethodDescriptor calleemd = min.getMethod();
MethodLattice<String> calleeLattice = ssjava.getMethodLattice(calleemd);
+
CompositeLocation calleeThisLoc =
new CompositeLocation(new Location(calleemd, calleeLattice.getThisLoc()));
// setup caller args set
// first, add caller's base(this) location
- callerArgList.add(callerBaseLoc);
+ if (!calleemd.isStatic())
+ callerArgList.add(callerBaseLoc);
// second, add caller's arguments
for (int i = 0; i < min.numArgs(); i++) {
ExpressionNode en = min.getArg(i);
// setup callee params set
// first, add callee's this location
- calleeParamList.add(calleeThisLoc);
+ if (!calleemd.isStatic())
+ calleeParamList.add(calleeThisLoc);
// second, add callee's parameters
for (int i = 0; i < calleemd.numParameters(); i++) {
VarDescriptor calleevd = (VarDescriptor) calleemd.getParameter(i);
}
}
+ Set<CompositeLocation> inputGLB = new HashSet<CompositeLocation>();
if (left instanceof ArrayAccessNode) {
ArrayAccessNode aan = (ArrayAccessNode) left;
- left = aan.getExpression();
+ CompositeLocation indexLoc =
+ checkLocationFromExpressionNode(md, nametable, aan.getIndex(), loc, constraint, false);
+ inputGLB.add(indexLoc);
}
loc = checkLocationFromExpressionNode(md, nametable, left, loc, constraint, false);
- // System.out.println("### checkLocationFromFieldAccessNode=" +
- // fan.printNode(0));
- // System.out.println("### left=" + left.printNode(0));
if (!left.getType().isPrimitive()) {
- if (fd.getSymbol().equals("length")) {
+ if (!fd.getSymbol().equals("length")) {
// array.length access, return the location of the array
- return loc;
+ Location fieldLoc = getFieldLocation(fd);
+ loc.addLocation(fieldLoc);
}
- Location fieldLoc = getFieldLocation(fd);
- loc.addLocation(fieldLoc);
}
+
+ inputGLB.add(loc);
+ loc = CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(md.getClassDesc(), fan));
return loc;
}
private CompositeLocation checkLocationFromAssignmentNode(MethodDescriptor md,
SymbolTable nametable, AssignmentNode an, CompositeLocation loc, CompositeLocation constraint) {
- // System.out.println("\n# ASSIGNMENTNODE=" + an.printNode(0));
-
ClassDescriptor cd = md.getClassDesc();
Set<CompositeLocation> inputGLBSet = new HashSet<CompositeLocation>();
checkLocationFromExpressionNode(md, nametable, an.getSrc(), new CompositeLocation(),
constraint, false);
- srcLocation = rhsLocation;
+ if (an.getOperation().getOp() >= 2 && an.getOperation().getOp() <= 12) {
+ // if assignment contains OP+EQ operator, need to merge location types
+ // of LHS & RHS into the RHS
+ Set<CompositeLocation> srcGLBSet = new HashSet<CompositeLocation>();
+ srcGLBSet.add(rhsLocation);
+ srcGLBSet.add(destLocation);
+ srcLocation = CompositeLattice.calculateGLB(srcGLBSet, generateErrorMessage(cd, an));
+ } else {
+ srcLocation = rhsLocation;
+ }
- // if (!rhsLocation.get(rhsLocation.getSize() - 1).isTop()) {
if (constraint != null) {
- inputGLBSet.add(rhsLocation);
+ inputGLBSet.add(srcLocation);
inputGLBSet.add(constraint);
srcLocation = CompositeLattice.calculateGLB(inputGLBSet, generateErrorMessage(cd, an));
}
- // }
-
- // System.out.println("dstLocation=" + destLocation);
- // System.out.println("rhsLocation=" + rhsLocation);
- // System.out.println("srcLocation=" + srcLocation);
- // System.out.println("constraint=" + constraint);
if (!CompositeLattice.isGreaterThan(srcLocation, destLocation, generateErrorMessage(cd, an))) {
srcLocation = rhsLocation;
}
- // System.out.println("srcLocation=" + srcLocation);
- // System.out.println("rhsLocation=" + rhsLocation);
- // System.out.println("constraint=" + constraint);
-
if (!CompositeLattice.isGreaterThan(srcLocation, destLocation, generateErrorMessage(cd, an))) {
if (srcLocation.equals(destLocation)) {