From 890c448e14fd7e016be47cb82859402b4211b013 Mon Sep 17 00:00:00 2001 From: yeom Date: Tue, 20 Sep 2011 21:11:08 +0000 Subject: [PATCH] passes the flow down rule --- Robust/src/Analysis/SSJava/FlowDownCheck.java | 50 +++++++++---------- .../SSJava/EyeTracking/Classifier.java | 6 +-- .../SSJava/EyeTracking/ClassifierTree.java | 39 ++++++++------- .../SSJava/EyeTracking/DeviationScanner.java | 43 +++++++++------- .../SSJava/EyeTracking/EyeDetector.java | 9 ++-- .../Benchmarks/SSJava/EyeTracking/LEA.java | 2 +- .../SSJava/EyeTracking/LEAImplementation.java | 10 ++-- Robust/src/ClassLibrary/SSJava/Math.java | 4 +- Robust/src/ClassLibrary/SSJava/Object.java | 1 + Robust/src/ClassLibrary/SSJava/SSJAVA.java | 13 ++++- 10 files changed, 98 insertions(+), 79 deletions(-) diff --git a/Robust/src/Analysis/SSJava/FlowDownCheck.java b/Robust/src/Analysis/SSJava/FlowDownCheck.java index 76a9d7fa..78d82df1 100644 --- a/Robust/src/Analysis/SSJava/FlowDownCheck.java +++ b/Robust/src/Analysis/SSJava/FlowDownCheck.java @@ -544,15 +544,20 @@ public class FlowDownCheck { checkLocationFromExpressionNode(md, nametable, returnExp, new CompositeLocation(), constraint, false); + // System.out.println("# RETURN VALUE LOC=" + returnValueLoc + + // " with constraint=" + constraint); + + // TODO: do we need to check here? // if this return statement is inside branch, return value has an implicit // flow from conditional location - if (constraint != null) { - Set inputGLB = new HashSet(); - inputGLB.add(returnValueLoc); - inputGLB.add(constraint); - returnValueLoc = - CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(md.getClassDesc(), rn)); - } + // if (constraint != null) { + // Set inputGLB = new HashSet(); + // inputGLB.add(returnValueLoc); + // inputGLB.add(constraint); + // returnValueLoc = + // CompositeLattice.calculateGLB(inputGLB, + // generateErrorMessage(md.getClassDesc(), rn)); + // } // check if return value is equal or higher than RETRUNLOC of method // declaration annotation @@ -841,9 +846,12 @@ public class FlowDownCheck { // values // in this case, we don't need to check flow down rule! - System.out.println("\n#tertiary cond=" + tn.getCond().printNode(0) + " Loc=" + condLoc); - System.out.println("# true=" + tn.getTrueExpr().printNode(0) + " Loc=" + trueLoc); - System.out.println("# false=" + tn.getFalseExpr().printNode(0) + " Loc=" + falseLoc); + // System.out.println("\n#tertiary cond=" + tn.getCond().printNode(0) + + // " Loc=" + condLoc); + // System.out.println("# true=" + tn.getTrueExpr().printNode(0) + " Loc=" + + // trueLoc); + // System.out.println("# false=" + tn.getFalseExpr().printNode(0) + " Loc=" + // + falseLoc); // check if condLoc is higher than trueLoc & falseLoc if (!trueLoc.get(0).isTop() @@ -896,7 +904,6 @@ public class FlowDownCheck { checkLocationFromExpressionNode(md, nametable, min.getExpression(), new CompositeLocation(), constraint, false); } else { - System.out.println("min=" + min.getMethod()); if (min.getMethod().isStatic()) { String globalLocId = ssjava.getMethodLattice(md).getGlobalLoc(); if (globalLocId == null) { @@ -908,11 +915,11 @@ public class FlowDownCheck { String thisLocId = ssjava.getMethodLattice(md).getThisLoc(); baseLocation = new CompositeLocation(new Location(md, thisLocId)); } - } - System.out.println("\n#checkLocationFromMethodInvokeNode=" + min.printNode(0) - + " baseLocation=" + baseLocation + " constraint=" + constraint); + // System.out.println("\n#checkLocationFromMethodInvokeNode=" + + // min.printNode(0) + // + " baseLocation=" + baseLocation + " constraint=" + constraint); if (constraint != null) { int compareResult = @@ -1141,11 +1148,11 @@ public class FlowDownCheck { int callerResult = CompositeLattice.compare(callerLoc1, callerLoc2, true, generateErrorMessage(md.getClassDesc(), min)); - System.out.println("callerResult=" + callerResult); + // System.out.println("callerResult=" + callerResult); int calleeResult = CompositeLattice.compare(calleeLoc1, calleeLoc2, true, generateErrorMessage(md.getClassDesc(), min)); - System.out.println("calleeResult=" + calleeResult); + // System.out.println("calleeResult=" + calleeResult); if (callerResult == ComparisonResult.EQUAL) { if (ssjava.isSharedLocation(callerLoc1.get(callerLoc1.getSize() - 1)) @@ -1156,15 +1163,6 @@ public class FlowDownCheck { } } - if (calleeResult == ComparisonResult.EQUAL) { - if (ssjava.isSharedLocation(calleeLoc1.get(calleeLoc1.getSize() - 1)) - && ssjava.isSharedLocation(calleeLoc2.get(calleeLoc2.getSize() - 1))) { - // if both of them are shared locations, promote them to - // "GREATER relation" - calleeResult = ComparisonResult.GREATER; - } - } - if (calleeResult == ComparisonResult.GREATER && callerResult != ComparisonResult.GREATER) { // If calleeLoc1 is higher than calleeLoc2 @@ -1821,7 +1819,7 @@ public class FlowDownCheck { public static int compare(CompositeLocation loc1, CompositeLocation loc2, boolean ignore, String msg) { - System.out.println("compare=" + loc1 + " " + loc2); + // System.out.println("compare=" + loc1 + " " + loc2); int baseCompareResult = compareBaseLocationSet(loc1, loc2, false, ignore, msg); if (baseCompareResult == ComparisonResult.EQUAL) { diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/Classifier.java b/Robust/src/Benchmarks/SSJava/EyeTracking/Classifier.java index 53e26e23..87ada5b5 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/Classifier.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/Classifier.java @@ -76,8 +76,8 @@ public class Classifier { */ @LATTICE("OUT 0 ? +1 : 1)); } diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/DeviationScanner.java b/Robust/src/Benchmarks/SSJava/EyeTracking/DeviationScanner.java index b5308f50..052c7f4b 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/DeviationScanner.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/DeviationScanner.java @@ -22,11 +22,11 @@ * * @author Florian Frankenberger */ -@LATTICE("SIZE= 3) { - @LOC("DEV") double deviationX = 0; - @LOC("DEV") double deviationY = 0; + @LOC("THIS,DeviationScanner.DEV") double deviationX = 0; + @LOC("THIS,DeviationScanner.DEV") double deviationY = 0; - @LOC("DEV") int lastIdx = -1; - for (@LOC("C") int i = 0; i < 3; ++i) { + @LOC("THIS,DeviationScanner.DEV") int lastIdx = -1; + for (@LOC("THIS,DeviationScanner.DEV") int i = 0; i < 3; ++i) { if (lastIdx != -1) { deviationX += (eyePositions[i].getX() - eyePositions[lastIdx].getX()); deviationY += (eyePositions[i].getY() - eyePositions[lastIdx].getY()); @@ -85,14 +91,14 @@ public class DeviationScanner { lastIdx = i; } - @LOC("DEV") final double deviationPercentX = 0.04; - @LOC("DEV") final double deviationPercentY = 0.04; + @LOC("THIS,DeviationScanner.DEV") final double deviationPercentX = 0.04; + @LOC("THIS,DeviationScanner.DEV") final double deviationPercentY = 0.04; deviationX /= faceRect.getWidth(); deviationY /= faceRect.getWidth(); - @LOC("DEV") int deviationAbsoluteX = 0; - @LOC("DEV") int deviationAbsoluteY = 0; + @LOC("THIS,DeviationScanner.DEV") int deviationAbsoluteX = 0; + @LOC("THIS,DeviationScanner.DEV") int deviationAbsoluteY = 0; if (deviationX > deviationPercentX) deviationAbsoluteX = 1; if (deviationX < -deviationPercentX) @@ -117,6 +123,7 @@ public class DeviationScanner { return deviation; } + @LATTICE("OUT