From 0d4ca9d9d1d0a4c32bc613e56115477c38ff5838 Mon Sep 17 00:00:00 2001 From: jjenista Date: Fri, 19 Feb 2010 19:54:49 +0000 Subject: [PATCH] squashing bugs --- Robust/src/Analysis/Disjoint/Canonical.java | 56 ++++++++++++------- Robust/src/Analysis/Disjoint/ChangeSet.java | 2 +- Robust/src/Analysis/Disjoint/ChangeTuple.java | 4 +- Robust/src/Analysis/Disjoint/ExistPred.java | 18 +++--- .../src/Analysis/Disjoint/ExistPredSet.java | 2 +- Robust/src/Analysis/Disjoint/ReachSet.java | 2 +- Robust/src/Analysis/Disjoint/ReachState.java | 2 +- Robust/src/Analysis/Disjoint/ReachTuple.java | 6 +- .../critical-regression-testing/test.java | 31 ++++++++-- 9 files changed, 81 insertions(+), 42 deletions(-) diff --git a/Robust/src/Analysis/Disjoint/Canonical.java b/Robust/src/Analysis/Disjoint/Canonical.java index 887a95f6..6465366a 100644 --- a/Robust/src/Analysis/Disjoint/Canonical.java +++ b/Robust/src/Analysis/Disjoint/Canonical.java @@ -5,6 +5,24 @@ import IR.Flat.*; import java.util.*; import java.io.*; + +//////////////////////////////////////////////// +// +// important note! The static operations in this class that take +// canonicals and produce a canonical result sometimes need a +// "working copy" that IS NOT CANONICAL. So, even though it isn't +// perfectly clean, Canonical constructors have been changed from +// private to protected and they may be used in this file--however, +// only use a constructor for an object that will mutate during the +// calculation--use the factory method to obtain everything else! +// This is CRITICAL! +// +// What this boils down to is that the only normally constructed +// object in a canonical operation should be the result out. +// +//////////////////////////////////////////////// + + abstract public class Canonical { // for generating unique canonical values @@ -131,8 +149,8 @@ abstract public class Canonical { } - public ReachState union( ReachState rs1, - ReachState rs2 ) { + public static ReachState union( ReachState rs1, + ReachState rs2 ) { assert rs1 != null; assert rs2 != null; assert rs1.isCanonical(); @@ -149,7 +167,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ReachState out = ReachState.factory(); + ReachState out = new ReachState(); out.reachTuples.addAll( rs1.reachTuples ); out.reachTuples.addAll( rs2.reachTuples ); @@ -175,7 +193,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ReachState out = ReachState.factory(); + ReachState out = new ReachState(); out.reachTuples.addAll( rs.reachTuples ); out.reachTuples.add( rt ); @@ -203,7 +221,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ReachState out = ReachState.factory(); + ReachState out = new ReachState(); Iterator rtItr = rs1.iterator(); while( rtItr.hasNext() ) { @@ -251,7 +269,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ReachState out = ReachState.factory(); + ReachState out = new ReachState(); out.reachTuples.addAll( rs.reachTuples ); out.reachTuples.remove( rt ); @@ -279,7 +297,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ReachState out = ReachState.factory(); + ReachState out = new ReachState(); ReachTuple rtSummary = null; ReachTuple rtOldest = null; @@ -373,7 +391,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ReachSet out = ReachSet.factory(); + ReachSet out = new ReachSet(); out.reachStates.addAll( rs1.reachStates ); out.reachStates.addAll( rs2.reachStates ); @@ -401,7 +419,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ReachSet out = ReachSet.factory(); + ReachSet out = new ReachSet(); out.reachStates.addAll( rs.reachStates ); out.reachStates.add( state ); @@ -428,7 +446,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ReachSet out = ReachSet.factory(); + ReachSet out = new ReachSet(); Iterator itr = rs1.iterator(); while( itr.hasNext() ) { ReachState state = (ReachState) itr.next(); @@ -466,7 +484,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ReachSet out = ReachSet.factory(); + ReachSet out = new ReachSet(); out.reachStates.addAll( rs.reachStates ); out.reachStates.remove( state ); @@ -505,7 +523,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ReachSet out = ReachSet.factory(); + ReachSet out = new ReachSet(); Iterator stateItr = rs.iterator(); while( stateItr.hasNext() ) { @@ -552,7 +570,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ChangeSet out = ChangeSet.factory(); + ChangeSet out = new ChangeSet(); Iterator itrO = rsO.iterator(); while( itrO.hasNext() ) { @@ -629,7 +647,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ReachSet out = ReachSet.factory(); + ReachSet out = new ReachSet(); Iterator itrS = rs.iterator(); while( itrS.hasNext() ) { @@ -661,7 +679,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ReachSet out = ReachSet.factory(); + ReachSet out = new ReachSet(); Iterator itrO = rsO.iterator(); while( itrO.hasNext() ) { @@ -707,7 +725,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ChangeSet out = ChangeSet.factory(); + ChangeSet out = new ChangeSet(); out.changeTuples.addAll( cs1.changeTuples ); out.changeTuples.addAll( cs2.changeTuples ); @@ -734,7 +752,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ChangeSet out = ChangeSet.factory(); + ChangeSet out = new ChangeSet(); out.changeTuples.addAll( cs.changeTuples ); out.changeTuples.add( ct ); @@ -764,7 +782,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ExistPredSet out = ExistPredSet.factory(); + ExistPredSet out = new ExistPredSet(); out.preds.addAll( eps1.preds ); out.preds.addAll( eps2.preds ); @@ -793,7 +811,7 @@ abstract public class Canonical { } // otherwise, no cached result... - ExistPredSet out = ExistPredSet.factory(); + ExistPredSet out = new ExistPredSet(); out.preds.addAll( eps.preds ); out.preds.add( ep ); diff --git a/Robust/src/Analysis/Disjoint/ChangeSet.java b/Robust/src/Analysis/Disjoint/ChangeSet.java index a9f36e82..ecd551de 100644 --- a/Robust/src/Analysis/Disjoint/ChangeSet.java +++ b/Robust/src/Analysis/Disjoint/ChangeSet.java @@ -42,7 +42,7 @@ public class ChangeSet extends Canonical { return out; } - private ChangeSet() { + protected ChangeSet() { changeTuples = new HashSet(); } diff --git a/Robust/src/Analysis/Disjoint/ChangeTuple.java b/Robust/src/Analysis/Disjoint/ChangeTuple.java index b579c16a..d192d217 100644 --- a/Robust/src/Analysis/Disjoint/ChangeTuple.java +++ b/Robust/src/Analysis/Disjoint/ChangeTuple.java @@ -40,8 +40,8 @@ public class ChangeTuple extends Canonical return out; } - private ChangeTuple( ReachState toMatch, - ReachState toAdd ) { + protected ChangeTuple( ReachState toMatch, + ReachState toAdd ) { this.toMatch = toMatch; this.toAdd = toAdd; } diff --git a/Robust/src/Analysis/Disjoint/ExistPred.java b/Robust/src/Analysis/Disjoint/ExistPred.java index 2c1f56b7..404632f7 100644 --- a/Robust/src/Analysis/Disjoint/ExistPred.java +++ b/Robust/src/Analysis/Disjoint/ExistPred.java @@ -76,7 +76,7 @@ public class ExistPred extends Canonical { return out; } - private ExistPred() { + protected ExistPred() { this.predType = TYPE_TRUE; } @@ -88,8 +88,8 @@ public class ExistPred extends Canonical { return out; } - private ExistPred( Integer hrnID, - ReachState state ) { + protected ExistPred( Integer hrnID, + ReachState state ) { assert hrnID != null; this.n_hrnID = hrnID; this.ne_state = state; @@ -113,12 +113,12 @@ public class ExistPred extends Canonical { return out; } - private ExistPred( TempDescriptor tdSrc, - Integer hrnSrcID, - Integer hrnDstID, - TypeDescriptor type, - String field, - ReachState state ) { + protected ExistPred( TempDescriptor tdSrc, + Integer hrnSrcID, + Integer hrnDstID, + TypeDescriptor type, + String field, + ReachState state ) { assert (tdSrc == null) || (hrnSrcID == null); assert hrnDstID != null; diff --git a/Robust/src/Analysis/Disjoint/ExistPredSet.java b/Robust/src/Analysis/Disjoint/ExistPredSet.java index 9f2fc31b..50c7edd6 100644 --- a/Robust/src/Analysis/Disjoint/ExistPredSet.java +++ b/Robust/src/Analysis/Disjoint/ExistPredSet.java @@ -45,7 +45,7 @@ public class ExistPredSet extends Canonical { return out; } - private ExistPredSet() { + protected ExistPredSet() { preds = new HashSet(); } diff --git a/Robust/src/Analysis/Disjoint/ReachSet.java b/Robust/src/Analysis/Disjoint/ReachSet.java index 0c40a3f1..0af32efa 100644 --- a/Robust/src/Analysis/Disjoint/ReachSet.java +++ b/Robust/src/Analysis/Disjoint/ReachSet.java @@ -45,7 +45,7 @@ public class ReachSet extends Canonical { return out; } - private ReachSet() { + protected ReachSet() { reachStates = new HashSet(); } diff --git a/Robust/src/Analysis/Disjoint/ReachState.java b/Robust/src/Analysis/Disjoint/ReachState.java index b1d96659..e5052028 100644 --- a/Robust/src/Analysis/Disjoint/ReachState.java +++ b/Robust/src/Analysis/Disjoint/ReachState.java @@ -47,7 +47,7 @@ public class ReachState extends Canonical { return out; } - private ReachState() { + protected ReachState() { reachTuples = new HashSet(); } diff --git a/Robust/src/Analysis/Disjoint/ReachTuple.java b/Robust/src/Analysis/Disjoint/ReachTuple.java index bfa3e1ab..4a472cfa 100644 --- a/Robust/src/Analysis/Disjoint/ReachTuple.java +++ b/Robust/src/Analysis/Disjoint/ReachTuple.java @@ -58,9 +58,9 @@ public class ReachTuple extends Canonical { return out; } - private ReachTuple( Integer hrnID, - boolean isMultiObject, - int arity ) { + protected ReachTuple( Integer hrnID, + boolean isMultiObject, + int arity ) { assert hrnID != null; this.hrnID = hrnID; diff --git a/Robust/src/Tests/disjoint/critical-regression-testing/test.java b/Robust/src/Tests/disjoint/critical-regression-testing/test.java index e8b6c217..d0c9838b 100644 --- a/Robust/src/Tests/disjoint/critical-regression-testing/test.java +++ b/Robust/src/Tests/disjoint/critical-regression-testing/test.java @@ -20,10 +20,10 @@ public class test { } void t1() { - ReachTuple rt11a = ReachTuple.factory( 11, true, ReachTuple.ARITY_ONE ); - ReachTuple rt11b = ReachTuple.factory( 11, true, ReachTuple.ARITY_ONE ); - ReachTuple rt12 = ReachTuple.factory( 12, true, ReachTuple.ARITY_ONE ); - ReachTuple rt12z = ReachTuple.factory( 12, true, ReachTuple.ARITY_ZEROORMORE ); + ReachTuple rt11a = ReachTuple.factory( 11, true, ReachTuple.ARITY_ONE ); + ReachTuple rt11b = ReachTuple.factory( 11, true, ReachTuple.ARITY_ONE ); + ReachTuple rt12 = ReachTuple.factory( 12, true, ReachTuple.ARITY_ONE ); + ReachTuple rt12z = ReachTuple.factory( 12, true, ReachTuple.ARITY_ZEROORMORE ); ReachTuple rt13 = ReachTuple.factory( 13, false, ReachTuple.ARITY_ONE ); assert rt11a.equals( rt11b ); @@ -43,7 +43,28 @@ public class test { } void t2() { - + ReachTuple rt14 = ReachTuple.factory( 14, false, ReachTuple.ARITY_ONE ); + ReachTuple rt15 = ReachTuple.factory( 15, true, ReachTuple.ARITY_ZEROORMORE ); + + ReachState s1 = ReachState.factory(); + ReachState s2 = Canonical.union( s1, rt14 ); + + ReachState s3 = ReachState.factory(); + ReachState s4 = Canonical.union( s3, rt15 ); + + ReachState s5 = ReachState.factory( rt14 ); + + ReachState s6 = ReachState.factory( rt15 ); + + ReachState s7 = Canonical.union( s2, s4 ); + ReachState s8 = Canonical.union( s5, s6 ); + + assert s1 == s3; + assert s2 == s5; + assert s4 == s6; + assert s7 == s8; + assert !s1.equals( s7 ); + assert !s8.equals( s5 ); } } -- 2.34.1