@@ -63,7 +63,7 @@ class DefaultStateModule(val verifier: Verifier) extends StateModule {
6363
6464 // initialize the state of all components and assume that afterwards the
6565 // whole state is good
66- val firstStmt = components map (_.initBoogieState)
66+ val firstStmt = components map (_.initBoogieState)
6767 // note: this code should come afterwards, to allow the components to reset their state variables
6868 for (c <- components) {
6969 curState.put(c, c.currentStateVars)
@@ -85,12 +85,9 @@ class DefaultStateModule(val verifier: Verifier) extends StateModule {
8585 }
8686
8787 def initOldState : Stmt = {
88- curOldState = new StateComponentMapping ()
89- for (c <- components) yield {
90- val exps = curState.get(c)
91- curOldState.put(c, exps) // Logic: whenever we *get* on the old state, we should wrap in "Old"
92- exps map (e => Assume (e === Old (e))): Stmt
93- }
88+ val freshSnapshot = freshTempStateKeepCurrentAux(" old" , true )
89+ curOldState = freshSnapshot._1
90+ initToCurrentStmt(freshSnapshot)
9491 }
9592
9693
@@ -104,7 +101,7 @@ class DefaultStateModule(val verifier: Verifier) extends StateModule {
104101 res ++= hashMap.get(c)
105102 }
106103 }
107- if (usingOldState) ( res map (v => Old (v))) else res // ALEX: I think this conditional should be on the element of the StateSnapshot
104+ res
108105 }
109106
110107
@@ -130,6 +127,8 @@ class DefaultStateModule(val verifier: Verifier) extends StateModule {
130127 override def stateRepositoryGet (name: String ) : Option [StateSnapshot ] = stateRepository.get(name)
131128
132129 override def freshTempState (name : String , discardCurrent : Boolean = false , initialise : Boolean = false ): (Stmt , StateSnapshot ) = {
130+ assert(name != " old" )
131+
133132 val previousState = new StateSnapshot (new StateComponentMapping (), usingOldState, usingPureState)
134133
135134 curState = new StateComponentMapping () // essentially, the code below "clones" what curState should represent anyway. But, if we omit this line, we inadvertently alias the previous hash map.
@@ -149,6 +148,12 @@ class DefaultStateModule(val verifier: Verifier) extends StateModule {
149148 }
150149
151150 override def freshTempStateKeepCurrent (name : String ) : StateSnapshot = {
151+ freshTempStateKeepCurrentAux(name, false )
152+ }
153+
154+ private def freshTempStateKeepCurrentAux (name : String , usedForOldState : Boolean ) : StateSnapshot = {
155+ assert(usedForOldState || name != " old" )
156+
152157 val freshState = new StateComponentMapping ()
153158
154159 for (c <- components) yield {
0 commit comments