CompositeLocation thisLoc = new CompositeLocation(new Location(md, thisLocId));
paramList.add(0, thisLoc);
- md2ReturnLocGen.put(md, new ReturnLocGenerator(md2ReturnLoc.get(md), md, paramList, md
- + " of " + cd.getSourceFileName()));
+
}
+ md2ReturnLocGen.put(md, new ReturnLocGenerator(md2ReturnLoc.get(md), md, paramList, md
+ + " of " + cd.getSourceFileName()));
+
}
// fourth, check declarations inside of method
private CompositeLocation checkLocationFromReturnNode(MethodDescriptor md, SymbolTable nametable,
ReturnNode rn, CompositeLocation constraint) {
+ if (ssjava.getMethodContainingSSJavaLoop().equals(md)) {
+ return new CompositeLocation();
+ }
+
ExpressionNode returnExp = rn.getReturnExpression();
CompositeLocation declaredReturnLoc = md2ReturnLoc.get(md);
private CompositeLocation checkLocationFromIfStatementNode(MethodDescriptor md,
SymbolTable nametable, IfStatementNode isn, CompositeLocation constraint) {
- System.out.println("checkLocationFromIfStatementNode="+isn);
+ System.out.println("\n\ncheckLocationFromIfStatementNode=" + isn.printNode(0));
CompositeLocation condLoc =
checkLocationFromExpressionNode(md, nametable, isn.getCondition(), new CompositeLocation(),
constraint, false);
- System.out.println("-######old constraint="+constraint);
+ System.out.println("-######old constraint=" + constraint);
constraint = generateNewConstraint(constraint, condLoc);
- System.out.println("-######new constraint="+constraint);
+ System.out.println("-######new constraint=" + constraint);
checkLocationFromBlockNode(md, nametable, isn.getTrueBlock(), constraint);
if (isn.getFalseBlock() != null) {
// System.out.println("# false=" + tn.getFalseExpr().printNode(0) + " Loc="
// + falseLoc);
- // check if condLoc is higher than trueLoc & falseLoc
- if (!trueLoc.get(0).isTop()
- && !CompositeLattice.isGreaterThan(condLoc, trueLoc, generateErrorMessage(cd, tn))) {
- throw new Error(
- "The location of the condition expression is lower than the true expression at "
- + cd.getSourceFileName() + ":" + tn.getCond().getNumLine());
- }
-
- if (!falseLoc.get(0).isTop()
- && !CompositeLattice.isGreaterThan(condLoc, falseLoc,
- generateErrorMessage(cd, tn.getCond()))) {
- throw new Error(
- "The location of the condition expression is lower than the false expression at "
- + cd.getSourceFileName() + ":" + tn.getCond().getNumLine());
- }
+ // we don't need to check that condLoc is higher than trueLoc & falseLoc
+ // if (!trueLoc.get(0).isTop()
+ // && !CompositeLattice.isGreaterThan(condLoc, trueLoc, generateErrorMessage(cd, tn))) {
+ // throw new Error(
+ // "The location of the condition expression is lower than the true expression at "
+ // + cd.getSourceFileName() + ":" + tn.getCond().getNumLine());
+ // }
+ //
+ // if (!falseLoc.get(0).isTop()
+ // && !CompositeLattice.isGreaterThan(condLoc, falseLoc,
+ // generateErrorMessage(cd, tn.getCond()))) {
+ // throw new Error(
+ // "The location of the condition expression is lower than the false expression at "
+ // + cd.getSourceFileName() + ":" + tn.getCond().getNumLine());
+ // }
// then, return glb of trueLoc & falseLoc
Set<CompositeLocation> glbInputSet = new HashSet<CompositeLocation>();
+ glbInputSet.add(condLoc);
glbInputSet.add(trueLoc);
glbInputSet.add(falseLoc);
System.out.println("---PARAM LOC=" + paramLocation + " calleePCLOC=" + calleePCLOC
+ " paramCompareResult=" + paramCompareResult);
- if (paramCompareResult != ComparisonResult.GREATER) {
+ if (!(paramLocation.get(0).equals(calleePCLOC.get(0)) && calleePCLOC.getSize() > 1)
+ && paramCompareResult == ComparisonResult.LESS) {
throw new Error(
- "The program counter location "
- + constraint
- + " is lower than the argument(idx="
+ "The argument(idx="
+ idx
+ ") location "
+ argLocation
+ + "is higher than the caller program counter location "
+ + constraint
+ ". Need to specify that the initial PC location of the callee, which is currently set to "
- + calleePCLOC + ", is lower than " + paramLocation + " in the method "
+ + calleePCLOC + ", is not higher than " + paramLocation + " in the method "
+ calleeMethodDesc.getSymbol() + ":" + min.getNumLine());
}
checkCalleeConstraints(md, nametable, min, baseLocation, constraint);
- // checkCallerArgumentLocationConstraints(md, nametable, min,
- // baseLocation, constraint);
+ checkCallerArgumentLocationConstraints(md, nametable, min, baseLocation, constraint);
if (!min.getMethod().getReturnType().isVoid()) {
// If method has a return value, compute the highest possible return
MethodDescriptor calleemd = min.getMethod();
+ if (calleemd.isStatic()) {
+ return;
+ }
+
List<CompositeLocation> callerArgList = new ArrayList<CompositeLocation>();
List<CompositeLocation> calleeParamList = new ArrayList<CompositeLocation>();
generateErrorMessage(md.getClassDesc(), min));
}
- if (!CompositeLattice.isGreaterThan(callerArgLoc, paramLocation, errorMsg)) {
+ Location argLastLoc = callerArgLoc.get(callerArgLoc.getSize() - 1);
+ Location paramLastLoc = paramLocation.get(paramLocation.getSize() - 1);
+
+ if (argLastLoc.equals(paramLastLoc) && ssjava.isSharedLocation(argLastLoc)
+ && ssjava.isSharedLocation(paramLastLoc)) {
+ continue;
+ }
+
+ // if (!CompositeLattice.isGreaterThan(callerArgLoc, paramLocation, errorMsg)) {
+ if (CompositeLattice.compare(callerArgLoc, paramLocation, true, errorMsg) == ComparisonResult.LESS) {
throw new Error("Caller argument '" + min.getArg(i).printNode(0) + " : " + callerArgLoc
+ "' should be higher than corresponding callee's parameter : " + paramLocation
+ " at " + errorMsg);
String paramName1, paramName2;
- if (i == 0) {
- paramName1 = "'THIS'";
+ if (!calleemd.isStatic()) {
+ if (i == 0) {
+ paramName1 = "'THIS'";
+ } else {
+ paramName1 = "'parameter " + calleemd.getParamName(i - 1) + "'";
+ }
} else {
- paramName1 = "'parameter " + calleemd.getParamName(i - 1) + "'";
+ paramName1 = "'parameter " + calleemd.getParamName(i) + "'";
}
- if (j == 0) {
- paramName2 = "'THIS'";
+ if (!calleemd.isStatic()) {
+ if (j == 0 && !calleemd.isStatic()) {
+ paramName2 = "'THIS'";
+ } else {
+ paramName2 = "'parameter " + calleemd.getParamName(j - 1) + "'";
+ }
} else {
- paramName2 = "'parameter " + calleemd.getParamName(j - 1) + "'";
+ paramName2 = "'parameter " + calleemd.getParamName(j) + "'";
}
throw new Error(
private CompositeLocation checkLocationFromArrayAccessNode(MethodDescriptor md,
SymbolTable nametable, ArrayAccessNode aan, CompositeLocation constraint, boolean isLHS) {
- // System.out.println("aan=" + aan.printNode(0) + " line#=" + aan.getNumLine());
+ System.out.println("aan=" + aan.printNode(0) + " line#=" + aan.getNumLine());
ClassDescriptor cd = md.getClassDesc();
-
+ System.out.println("aan.getExpression()=" + aan.getExpression().getClass());
CompositeLocation arrayLoc =
checkLocationFromExpressionNode(md, nametable, aan.getExpression(),
new CompositeLocation(), constraint, isLHS);
-
+ System.out.println("HERE?");
// addTypeLocation(aan.getExpression().getType(), arrayLoc);
CompositeLocation indexLoc =
checkLocationFromExpressionNode(md, nametable, aan.getIndex(), new CompositeLocation(),
constraint, isLHS);
// addTypeLocation(aan.getIndex().getType(), indexLoc);
+ System.out.println("HERE2?");
if (isLHS) {
if (!CompositeLattice.isGreaterThan(indexLoc, arrayLoc, generateErrorMessage(cd, aan))) {
Set<CompositeLocation> inputGLB = new HashSet<CompositeLocation>();
inputGLB.add(arrayLoc);
inputGLB.add(indexLoc);
- return CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(cd, aan));
+ System.out.println("arrayLoc=" + arrayLoc + " indexLoc=" + indexLoc);
+ CompositeLocation comp =
+ CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(cd, aan));
+ System.out.println("---aan=" + aan.printNode(0) + " compLoc=" + comp);
+ return comp;
}
}
// addTypeLocation(on.getRight().getType(), rightLoc);
}
- // System.out.println("\n# OP NODE=" + on.printNode(0));
+ System.out.println("\n# OP NODE=" + on.printNode(0));
// System.out.println("# left loc=" + leftLoc + " from " +
// on.getLeft().getClass());
// if (on.getRight() != null) {
private CompositeLocation checkLocationFromNameNode(MethodDescriptor md, SymbolTable nametable,
NameNode nn, CompositeLocation loc, CompositeLocation constraint) {
+ // System.out.println("checkLocationFromNameNode nn=" + nn.printNode(0));
NameDescriptor nd = nn.getName();
if (nd.getBase() != null) {
loc =
} else if (d instanceof FieldDescriptor) {
// the type of field descriptor has a location!
FieldDescriptor fd = (FieldDescriptor) d;
+ // System.out.println("fd=" + fd);
if (fd.isStatic()) {
if (fd.isFinal()) {
// if it is 'static final', the location has TOP since no one can
loc.addLocation(Location.createTopLocation(md));
return loc;
} else {
+
// if 'static', the location has pre-assigned global loc
MethodLattice<String> localLattice = ssjava.getMethodLattice(md);
String globalLocId = localLattice.getGlobalLoc();
throw new Error("Global location element is not defined in the method " + md);
}
Location globalLoc = new Location(md, globalLocId);
-
+ System.out.println("static=" + globalLoc);
loc.addLocation(globalLoc);
}
} else {
SymbolTable nametable, FieldAccessNode fan, CompositeLocation loc,
CompositeLocation constraint) {
-
ExpressionNode left = fan.getExpression();
TypeDescriptor ltd = left.getType();
private CompositeLocation checkLocationFromAssignmentNode(MethodDescriptor md,
SymbolTable nametable, AssignmentNode an, CompositeLocation loc, CompositeLocation constraint) {
+ System.out.println("\n\ncheckLocationFromAssignmentNode=" + an.printNode(0));
ClassDescriptor cd = md.getClassDesc();
checkLocationFromExpressionNode(md, nametable, an.getSrc(), new CompositeLocation(),
constraint, false);
-
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
// generateErrorMessage(cd, an));
}
- // System.out.println("src=" + srcLocation + " dest=" + destLocation + " const=" +
- // constraint);
+ System.out.println("src=" + srcLocation + " dest=" + destLocation + " const=" + constraint);
if (!CompositeLattice.isGreaterThan(srcLocation, destLocation, generateErrorMessage(cd, an))) {
} else if (lattice.isGreaterThan(loc1.getLocIdentifier(), loc2.getLocIdentifier())) {
return ComparisonResult.GREATER;
} else {
- return ComparisonResult.LESS;
+ if (lattice.isComparable(loc1.getLocIdentifier(), loc2.getLocIdentifier())) {
+ return ComparisonResult.LESS;
+ } else {
+ return ComparisonResult.INCOMPARABLE;
+ }
}
}
}
if (innerGLBInput.size() > 0) {
+ // System.out.println("######innerGLBInput=" + innerGLBInput);
CompositeLocation innerGLB = CompositeLattice.calculateGLB(innerGLBInput, errMsg);
for (int idx = 0; idx < innerGLB.getSize(); idx++) {
glbCompLoc.addLocation(innerGLB.get(idx));
}
}
- System.out.println("GLB=" + glbCompLoc + "\n");
+ System.out.println("GLB=" + glbCompLoc);
return glbCompLoc;
}