// check if return value is equal or higher than RETRUNLOC of method
// declaration annotation
CompositeLocation returnLocAt = md2ReturnLoc.get(md);
-
- if (CompositeLattice.isGreaterThan(returnLocAt, expLoc,
- generateErrorMessage(md.getClassDesc(), rn))) {
+
+ if (CompositeLattice.compare(returnLocAt, expLoc,
+ generateErrorMessage(md.getClassDesc(), rn))!=ComparisonResult.LESS) {
throw new Error(
"Return value location is not equal or higher than the declaraed return location at "
+ md.getClassDesc().getSourceFileName() + "::" + rn.getNumLine());
private CompositeLocation checkLocationFromDeclarationNode(MethodDescriptor md,
SymbolTable nametable, DeclarationNode dn) {
- System.out.println("DeclarationNode=" + dn.printNode(0));
+ System.out.println("DeclarationNode=" + dn.printNode(0) + " "
+ + generateErrorMessage(md.getClassDesc(), dn));
VarDescriptor vd = dn.getVarDescriptor();
checkLocationFromExpressionNode(md, nametable, tn.getFalseExpr(), new CompositeLocation());
addLocationType(tn.getFalseExpr().getType(), falseLoc);
- // locations from true/false branches can be TOP when there are only literal values
+ // locations from true/false branches can be TOP when there are only literal
+ // values
// in this case, we don't need to check flow down rule!
-
+
// check if condLoc is higher than trueLoc & falseLoc
- if (!trueLoc.get(0).isTop() && !CompositeLattice.isGreaterThan(condLoc, trueLoc, generateErrorMessage(cd, tn))) {
+ 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()))) {
+ 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 true expression at "
+ cd.getSourceFileName() + ":" + tn.getCond().getNumLine());
// addTypeLocation(on.getRight().getType(), rightLoc);
}
- // System.out.println("checking op node=" + on.printNode(0));
- // System.out.println("left loc=" + leftLoc + " from " +
- // on.getLeft().getClass());
- // System.out.println("right loc=" + rightLoc + " from " +
- // on.getRight().getClass());
-
+ System.out.println("checking op node=" + on.printNode(0)
+ + generateErrorMessage(md.getClassDesc(), on));
+ System.out.println("left loc=" + leftLoc + " from " + on.getLeft().getClass());
+ if (on.getRight() != null) {
+ System.out.println("right loc=" + rightLoc + " from " + on.getRight().kind());
+ }
+
Operation op = on.getOp();
switch (op.getOp()) {
private CompositeLocation checkLocationFromNameNode(MethodDescriptor md, SymbolTable nametable,
NameNode nn, CompositeLocation loc) {
+
NameDescriptor nd = nn.getName();
if (nd.getBase() != null) {
-
loc = checkLocationFromExpressionNode(md, nametable, nn.getExpression(), loc);
// addTypeLocation(nn.getExpression().getType(), loc);
} else {
String varname = nd.toString();
-
if (varname.equals("this")) {
// 'this' itself!
MethodLattice<String> methodLattice = ssjava.getMethodLattice(md);
} else if (d instanceof FieldDescriptor) {
// the type of field descriptor has a location!
FieldDescriptor fd = (FieldDescriptor) d;
-
if (fd.isStatic()) {
if (fd.isFinal()) {
// if it is 'static final', the location has TOP since no one can
return destLocation;
}
srcLocation = new CompositeLocation();
- System.out.println("checkLocationFromExpressionNode=" + an.getSrc().printNode(0));
srcLocation = checkLocationFromExpressionNode(md, nametable, an.getSrc(), srcLocation);
// System.out.println(" an= " + an.printNode(0) + " an.getSrc()=" +
// an.getSrc().getClass()
int idx = decl.indexOf(".");
String className = decl.substring(0, idx);
String fieldName = decl.substring(idx + 1);
-
+
className.replaceAll(" ", "");
fieldName.replaceAll(" ", "");
Descriptor d = state.getClassSymbolTable().get(className);
if (d == null) {
- System.out.println("className="+className+" to d="+d);
throw new Error("The class in the location declaration '" + decl + "' does not exist at "
+ msg);
}
SSJavaLattice<String> lattice = ssjava.getClassLattice((ClassDescriptor) d);
if (!lattice.containsKey(fieldName)) {
throw new Error("The location " + fieldName + " is not defined in the field lattice of '"
- + className + "' at "+msg);
+ + className + "' at " + msg);
}
return new Location(d, fieldName);
if (!(fd.isFinal() && fd.isStatic())) {
checkFieldDeclaration(cd, fd);
+ } else {
+ // for static final, assign top location by default
+ Location loc = Location.createTopLocation(cd);
+ addLocationType(fd.getType(), loc);
}
}
}
public static boolean isGreaterThan(CompositeLocation loc1, CompositeLocation loc2, String msg) {
- System.out.println("isGreaterThan="+loc1+" "+loc2+" msg="+msg);
+ System.out.println("isGreaterThan=" + loc1 + " " + loc2 + " msg=" + msg);
int baseCompareResult = compareBaseLocationSet(loc1, loc2, true, msg);
if (baseCompareResult == ComparisonResult.EQUAL) {
if (compareDelta(loc1, loc2) == ComparisonResult.GREATER) {
if (!loc1.getDescriptor().equals(loc2.getDescriptor())) {
throw new Error("Failed to compare two locations of " + compLoc1 + " and " + compLoc2
- + " because they are not comparable at "+msg);
+ + " because they are not comparable at " + msg);
}
Descriptor d1 = loc1.getDescriptor();
if (numOfTie != compLoc2.getSize()) {
throw new Error("Failed to compare two locations of " + compLoc1 + " and " + compLoc2
- + " because they are not comparable at "+msg);
+ + " because they are not comparable at " + msg);
}
return ComparisonResult.EQUAL;
public static CompositeLocation calculateGLB(Set<CompositeLocation> inputSet) {
- System.out.println("calculateGLB="+inputSet);
// System.out.println("Calculating GLB=" + inputSet);
CompositeLocation glbCompLoc = new CompositeLocation();
glbCompLoc.addLocation(new Location(priorityDescriptor, glbOfPriorityLoc));
Set<CompositeLocation> compSet = locId2CompLocSet.get(glbOfPriorityLoc);
- // here find out composite location that has a maximum length tuple
- // if we have three input set: [A], [A,B], [A,B,C]
- // maximum length tuple will be [A,B,C]
- int max = 0;
- CompositeLocation maxFromCompSet = null;
- for (Iterator iterator = compSet.iterator(); iterator.hasNext();) {
- CompositeLocation c = (CompositeLocation) iterator.next();
- if (c.getSize() > max) {
- max = c.getSize();
- maxFromCompSet = c;
- }
- }
-
if (compSet == null) {
// when GLB(x1,x2)!=x1 and !=x2 : GLB case 4
// mean that the result is already lower than <x1,y1> and <x2,y2>
// in this case, do not take care about delta
// CompositeLocation inputComp = inputSet.iterator().next();
- CompositeLocation inputComp = maxCompLoc;
- for (int i = 1; i < inputComp.getSize(); i++) {
- glbCompLoc.addLocation(Location.createTopLocation(inputComp.get(i).getDescriptor()));
+ for (int i = 1; i < maxTupleSize; i++) {
+ glbCompLoc.addLocation(Location.createTopLocation(maxCompLoc.get(i).getDescriptor()));
}
} else {
+
+ // here find out composite location that has a maximum length tuple
+ // if we have three input set: [A], [A,B], [A,B,C]
+ // maximum length tuple will be [A,B,C]
+ int max = 0;
+ CompositeLocation maxFromCompSet = null;
+ for (Iterator iterator = compSet.iterator(); iterator.hasNext();) {
+ CompositeLocation c = (CompositeLocation) iterator.next();
+ if (c.getSize() > max) {
+ max = c.getSize();
+ maxFromCompSet = c;
+ }
+ }
+
if (compSet.size() == 1) {
// if GLB(x1,x2)==x1 or x2 : GLB case 2,3
}\r
*/\r
\r
- @LOC("IN,SynthesisFilter.L4") float new_v0;\r
- @LOC("IN,SynthesisFilter.L2") float new_v1;\r
- @LOC("IN,SynthesisFilter.L4") float new_v2;\r
- @LOC("IN,SynthesisFilter.L2") float new_v3;\r
- @LOC("IN,SynthesisFilter.L3") float new_v4;\r
- @LOC("IN,SynthesisFilter.L4") float new_v5;\r
- @LOC("IN,SynthesisFilter.L2") float new_v6;\r
- @LOC("IN,SynthesisFilter.L3") float new_v7;\r
- @LOC("IN,SynthesisFilter.L4") float new_v8;\r
- @LOC("IN,SynthesisFilter.L4") float new_v9;\r
- @LOC("IN,SynthesisFilter.L3") float new_v10;\r
- @LOC("IN,SynthesisFilter.L2") float new_v11;\r
- @LOC("IN,SynthesisFilter.L4") float new_v12;\r
- @LOC("IN,SynthesisFilter.L3") float new_v13;\r
- @LOC("IN,SynthesisFilter.L4") float new_v14;\r
- @LOC("IN,SynthesisFilter.L4") float new_v15;\r
- @LOC("IN,SynthesisFilter.L1") float new_v16;\r
- @LOC("IN,SynthesisFilter.L3") float new_v17;\r
- @LOC("IN,SynthesisFilter.L1") float new_v18;\r
- @LOC("IN,SynthesisFilter.L2") float new_v19;\r
- @LOC("IN,SynthesisFilter.L2") float new_v20;\r
- @LOC("IN,SynthesisFilter.L2") float new_v21;\r
- @LOC("IN,SynthesisFilter.L2") float new_v22;\r
- @LOC("IN,SynthesisFilter.L3") float new_v23;\r
- @LOC("IN,SynthesisFilter.L2") float new_v24;\r
- @LOC("IN,SynthesisFilter.L2") float new_v25;\r
- @LOC("IN,SynthesisFilter.L2") float new_v26;\r
- @LOC("IN,SynthesisFilter.L4") float new_v27;\r
- @LOC("IN,SynthesisFilter.L2") float new_v28;\r
- @LOC("IN,SynthesisFilter.L4") float new_v29;\r
- @LOC("IN,SynthesisFilter.L2") float new_v30;\r
- @LOC("IN,SynthesisFilter.L4") float new_v31;\r
-\r
- new_v0 = new_v1 = new_v2 = new_v3 = new_v4 = new_v5 = new_v6 = new_v7 = new_v8 = new_v9 = \r
- new_v10 = new_v11 = new_v12 = new_v13 = new_v14 = new_v15 = new_v16 = new_v17 = new_v18 = new_v19 = \r
- new_v20 = new_v21 = new_v22 = new_v23 = new_v24 = new_v25 = new_v26 = new_v27 = new_v28 = new_v29 = \r
- new_v30 = new_v31 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L4") float new_v0 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v1 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L4") float new_v2 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v3 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L3") float new_v4 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L4") float new_v5 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v6 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L3") float new_v7 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L4") float new_v8 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L4") float new_v9 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L3") float new_v10 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v11 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L4") float new_v12 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L3") float new_v13 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L4") float new_v14 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L4") float new_v15 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L1") float new_v16 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L3") float new_v17 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L1") float new_v18 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v19 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v20 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v21 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v22 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L3") float new_v23 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v24 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v25 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v26 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L4") float new_v27 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v28 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L4") float new_v29 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L2") float new_v30 = 0.0f;\r
+ @LOC("IN,SynthesisFilter.L4") float new_v31 = 0.0f;\r
+\r
+// new_v0 = new_v1 = new_v2 = new_v3 = new_v4 = new_v5 = new_v6 = new_v7 = new_v8 = new_v9 = \r
+// new_v10 = new_v11 = new_v12 = new_v13 = new_v14 = new_v15 = new_v16 = new_v17 = new_v18 = new_v19 = \r
+// new_v20 = new_v21 = new_v22 = new_v23 = new_v24 = new_v25 = new_v26 = new_v27 = new_v28 = new_v29 = \r
+// new_v30 = new_v31 = 0.0f;\r
\r
\r
// float[] new_v = new float[32]; // new V[0-15] and V[33-48] of Figure 3-A.2 in ISO DIS 11172-3\r