@@ -228,36 +228,63 @@ object evaluator extends EvaluationRules {
228228 Q (s2, fvfLookup, v1)}
229229 }
230230 case _ =>
231- val (s2, smDef1, pmDef1) =
232- quantifiedChunkSupporter.heapSummarisingMaps(
233- s = s1,
234- resource = fa.field,
235- codomainQVars = Seq (`?r`),
236- relevantChunks = relevantChunks,
237- optSmDomainDefinitionCondition = None ,
238- optQVarsInstantiations = None ,
239- v = v1)
240- if (s2.heapDependentTriggers.contains(fa.field)){
241- val trigger = FieldTrigger (fa.field.name, smDef1.sm, tRcvr)
242- v1.decider.assume(trigger)
243- }
244- val permCheck =
245- if (s2.triggerExp) {
246- True
247- } else {
248- val totalPermissions = PermLookup (fa.field.name, pmDef1.pm, tRcvr)
249- IsPositive (totalPermissions)
231+ if (relevantChunks.size == 1 ) {
232+ // No need to create a summary since there is only one chunk to look at.
233+ if (s1.heapDependentTriggers.contains(fa.field)) {
234+ val trigger = FieldTrigger (fa.field.name, relevantChunks.head.fvf, tRcvr)
235+ v1.decider.assume(trigger)
250236 }
251- v1.decider.assert(permCheck) {
252- case false =>
253- createFailure(pve dueTo InsufficientPermission (fa), v1, s2)
254- case true =>
255- val smLookup = Lookup (fa.field.name, smDef1.sm, tRcvr)
256- val fr2 =
257- s2.functionRecorder.recordSnapshot(fa, v1.decider.pcs.branchConditions, smLookup)
258- .recordFvfAndDomain(smDef1)
259- val s3 = s2.copy(functionRecorder = fr2)
260- Q (s3, smLookup, v1)}
237+ val permCheck =
238+ if (s1.triggerExp) {
239+ True
240+ } else {
241+ val permVal = relevantChunks.head.perm
242+ val totalPermissions = permVal.replace(relevantChunks.head.quantifiedVars, Seq (tRcvr))
243+ IsPositive (totalPermissions)
244+ }
245+ v1.decider.assert(permCheck) {
246+ case false =>
247+ createFailure(pve dueTo InsufficientPermission (fa), v1, s1)
248+ case true =>
249+ val smLookup = Lookup (fa.field.name, relevantChunks.head.fvf, tRcvr)
250+ val fr2 =
251+ s1.functionRecorder.recordSnapshot(fa, v1.decider.pcs.branchConditions, smLookup)
252+ val s2 = s1.copy(functionRecorder = fr2)
253+ Q (s2, smLookup, v1)
254+ }
255+ } else {
256+ val (s2, smDef1, pmDef1) =
257+ quantifiedChunkSupporter.heapSummarisingMaps(
258+ s = s1,
259+ resource = fa.field,
260+ codomainQVars = Seq (`?r`),
261+ relevantChunks = relevantChunks,
262+ optSmDomainDefinitionCondition = None ,
263+ optQVarsInstantiations = None ,
264+ v = v1)
265+ if (s2.heapDependentTriggers.contains(fa.field)) {
266+ val trigger = FieldTrigger (fa.field.name, smDef1.sm, tRcvr)
267+ v1.decider.assume(trigger)
268+ }
269+ val permCheck =
270+ if (s2.triggerExp) {
271+ True
272+ } else {
273+ val totalPermissions = PermLookup (fa.field.name, pmDef1.pm, tRcvr)
274+ IsPositive (totalPermissions)
275+ }
276+ v1.decider.assert(permCheck) {
277+ case false =>
278+ createFailure(pve dueTo InsufficientPermission (fa), v1, s2)
279+ case true =>
280+ val smLookup = Lookup (fa.field.name, smDef1.sm, tRcvr)
281+ val fr2 =
282+ s2.functionRecorder.recordSnapshot(fa, v1.decider.pcs.branchConditions, smLookup)
283+ .recordFvfAndDomain(smDef1)
284+ val s3 = s2.copy(functionRecorder = fr2)
285+ Q (s3, smLookup, v1)
286+ }
287+ }
261288 }})
262289
263290 case fa : ast.FieldAccess =>
0 commit comments