66
77package viper .silicon .rules
88
9+ import viper .silicon
910import viper .silicon .debugger .DebugExp
1011import viper .silicon .Config .JoinMode
1112import viper .silver .ast
@@ -316,7 +317,7 @@ object evaluator extends EvaluationRules {
316317 val smLookup = Lookup (fa.field.name, smDef1.sm, tRcvr)
317318 val fr2 =
318319 s2.functionRecorder.recordSnapshot(fa, v1.decider.pcs.branchConditions, smLookup)
319- .recordFvfAndDomain(smDef1)
320+ .recordFvfAndDomain(smDef1).recordPermMap(pmDef1)
320321 val s3 = s2.copy(functionRecorder = fr2)
321322 Q (s3, smLookup, newFa, v1)
322323 }
@@ -578,7 +579,8 @@ object evaluator extends EvaluationRules {
578579 quantifiedChunkSupporter.summarisingPermissionMap(
579580 s1, wand, formalVars, relevantChunks, null , v1)
580581
581- (s1.copy(pmCache = pmCache), pmDef)
582+ val newFr = s1.functionRecorder.recordPermMap(pmDef)
583+ (s1.copy(pmCache = pmCache, functionRecorder = newFr), pmDef)
582584 }
583585 (s2, PredicatePermLookup (identifier.toString, pmDef.pm, args))
584586
@@ -594,8 +596,8 @@ object evaluator extends EvaluationRules {
594596 val (pmDef, pmCache) =
595597 quantifiedChunkSupporter.summarisingPermissionMap(
596598 s1, field, Seq (`?r`), relevantChunks, null , v1)
597-
598- (s1.copy(pmCache = pmCache), pmDef)
599+ val newFr = s1.functionRecorder.recordPermMap(pmDef)
600+ (s1.copy(pmCache = pmCache, functionRecorder = newFr ), pmDef)
599601 }
600602 val currentPermAmount = PermLookup (field.name, pmDef.pm, args.head)
601603 v1.decider.prover.comment(s " perm( $resacc) ~~> assume upper permission bound " )
@@ -1029,16 +1031,33 @@ object evaluator extends EvaluationRules {
10291031 val argsPairs : List [(Term , Option [ast.Exp ])] = if (withExp) tArgs zip eArgsNew.get.map(Some (_)) else tArgs zip Seq .fill(tArgs.size)(None )
10301032 val insg = s7.g + Store (predicate.formalArgs map (_.localVar) zip argsPairs)
10311033 val s7a = s7.copy(g = insg).setConstrainable(s7.constrainableARPs, false )
1032- produce(s7a, toSf(snap.get), body, pve, v4)((s8, v5) => {
1033- val s9 = s8.copy(g = s7.g,
1034- functionRecorder = s8.functionRecorder.changeDepthBy(- 1 ),
1035- recordVisited = s3.recordVisited,
1036- permissionScalingFactor = s6.permissionScalingFactor,
1037- permissionScalingFactorExp = s6.permissionScalingFactorExp,
1038- constrainableARPs = s1.constrainableARPs)
1039- .decCycleCounter(predicate)
1040- val s10 = v5.stateConsolidator(s9).consolidateOptionally(s9, v5)
1041- eval(s10, eIn, pve, v5)((s9, t9, e9, v9) => QB (s9, (t9, e9), v9))})})
1034+
1035+ if (s7a.predicateData(predicate).predContents.isDefined) {
1036+ val toReplace : silicon.Map [Term , Term ] = silicon.Map .from(s7a.predicateData(predicate).params.get.zip(Seq (snap.get) ++ tArgs))
1037+ predicateSupporter.producePredicateContents(s7a, s7a.predicateData(predicate).predContents.get, toReplace, v4, true )((s8, v5) => {
1038+ val s9 = s8.copy(g = s7.g,
1039+ functionRecorder = s8.functionRecorder.changeDepthBy(- 1 ),
1040+ recordVisited = s3.recordVisited,
1041+ permissionScalingFactor = s6.permissionScalingFactor,
1042+ permissionScalingFactorExp = s6.permissionScalingFactorExp,
1043+ constrainableARPs = s1.constrainableARPs)
1044+ .decCycleCounter(predicate)
1045+ val s10 = v5.stateConsolidator(s9).consolidateOptionally(s9, v5)
1046+ eval(s10, eIn, pve, v5)((s9, t9, e9, v9) => QB (s9, (t9, e9), v9))
1047+ })
1048+ } else {
1049+ produce(s7a, toSf(snap.get), body, pve, v4)((s8, v5) => {
1050+ val s9 = s8.copy(g = s7.g,
1051+ functionRecorder = s8.functionRecorder.changeDepthBy(- 1 ),
1052+ recordVisited = s3.recordVisited,
1053+ permissionScalingFactor = s6.permissionScalingFactor,
1054+ permissionScalingFactorExp = s6.permissionScalingFactorExp,
1055+ constrainableARPs = s1.constrainableARPs)
1056+ .decCycleCounter(predicate)
1057+ val s10 = v5.stateConsolidator(s9).consolidateOptionally(s9, v5)
1058+ eval(s10, eIn, pve, v5)((s9, t9, e9, v9) => QB (s9, (t9, e9), v9))})
1059+ }
1060+ })
10421061 })(join(eIn.typ, " joined_unfolding" , s2.relevantQuantifiedVariables.map(_._1),
10431062 Option .when(withExp)(s2.relevantQuantifiedVariables.map(_._2.get)), v2))((s12, r12, v7)
10441063 => {
@@ -1049,7 +1068,8 @@ object evaluator extends EvaluationRules {
10491068 createFailure(pve dueTo NonPositivePermission (ePerm.get), v2, s2, IsPositive (tPerm), ePermNew.map(p => ast.PermGtCmp (p, ast.NoPerm ()())(p.pos, p.info, p.errT)))}))
10501069 } else {
10511070 val unknownValue = v.decider.appliedFresh(" recunf" , v.symbolConverter.toSort(eIn.typ), s.relevantQuantifiedVariables.map(_._1))
1052- Q (s, unknownValue, Option .when(withExp)(ast.LocalVarWithVersion (" unknownValue" , eIn.typ)(eIn.pos, eIn.info, eIn.errT)), v)
1071+ val newFuncRec = s.functionRecorder.recordFreshSnapshot(unknownValue.applicable.asInstanceOf [Function ])
1072+ Q (s.copy(functionRecorder = newFuncRec), unknownValue, Option .when(withExp)(ast.LocalVarWithVersion (" unknownValue" , eIn.typ)(eIn.pos, eIn.info, eIn.errT)), v)
10531073 }
10541074
10551075 case ast.Applying (wand, eIn) =>
0 commit comments