Skip to content

Commit e2bd459

Browse files
authored
Merge pull request #684 from viperproject/meilers_issue_205
Fixing issue #205
2 parents 3c0a9d9 + 726f707 commit e2bd459

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/main/scala/rules/ChunkSupporter.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,16 @@ object chunkSupporter extends ChunkSupportRules {
116116
} else {
117117
consumeGreedy(s1, s1.h, id, args, perms, v1) match {
118118
case (Complete(), s2, h2, optCh2) =>
119-
QS(s2.copy(h = s.h), h2, optCh2.map(_.snap), v1)
119+
val snap = optCh2 match {
120+
case None => None
121+
case Some(ch) =>
122+
if (v1.decider.check(Greater(perms, NoPerm()), Verifier.config.checkTimeout())) {
123+
Some(ch.snap)
124+
} else {
125+
Some(Ite(Greater(perms, NoPerm()), ch.snap.convert(sorts.Snap), Unit))
126+
}
127+
}
128+
QS(s2.copy(h = s.h), h2, snap, v1)
120129
case _ if v1.decider.checkSmoke() =>
121130
Success() // TODO: Mark branch as dead?
122131
case _ =>

src/main/scala/state/Terms.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ class Less(val p0: Term, val p1: Term) extends ComparisonTerm
947947
object Less extends /* OptimisingBinaryArithmeticOperation with */ ((Term, Term) => Term) {
948948
def apply(e0: Term, e1: Term) = (e0, e1) match {
949949
case (IntLiteral(n0), IntLiteral(n1)) => if (n0 < n1) True() else False()
950+
case (pl0: PermLiteral, pl1: PermLiteral) => if (pl0.literal < pl1.literal) True() else False()
950951
case (t0, t1) if t0 == t1 => False()
951952
case _ => new Less(e0, e1)
952953
}
@@ -963,6 +964,7 @@ class AtMost(val p0: Term, val p1: Term) extends ComparisonTerm
963964
object AtMost extends /* OptimisingBinaryArithmeticOperation with */ ((Term, Term) => Term) {
964965
def apply(e0: Term, e1: Term) = (e0, e1) match {
965966
case (IntLiteral(n0), IntLiteral(n1)) => if (n0 <= n1) True() else False()
967+
case (pl0: PermLiteral, pl1: PermLiteral) => if (pl0.literal <= pl1.literal) True() else False()
966968
case (t0, t1) if t0 == t1 => True()
967969
case _ => new AtMost(e0, e1)
968970
}
@@ -979,6 +981,7 @@ class Greater(val p0: Term, val p1: Term) extends ComparisonTerm
979981
object Greater extends /* OptimisingBinaryArithmeticOperation with */ ((Term, Term) => Term) {
980982
def apply(e0: Term, e1: Term) = (e0, e1) match {
981983
case (IntLiteral(n0), IntLiteral(n1)) => if (n0 > n1) True() else False()
984+
case (pl0: PermLiteral, pl1: PermLiteral) => if (pl0.literal > pl1.literal) True() else False()
982985
case (t0, t1) if t0 == t1 => False()
983986
case _ => new Greater(e0, e1)
984987
}
@@ -995,6 +998,7 @@ class AtLeast(val p0: Term, val p1: Term) extends ComparisonTerm
995998
object AtLeast extends /* OptimisingBinaryArithmeticOperation with */ ((Term, Term) => Term) {
996999
def apply(e0: Term, e1: Term) = (e0, e1) match {
9971000
case (IntLiteral(n0), IntLiteral(n1)) => if (n0 >= n1) True() else False()
1001+
case (pl0: PermLiteral, pl1: PermLiteral) => if (pl0.literal >= pl1.literal) True() else False()
9981002
case (t0, t1) if t0 == t1 => True()
9991003
case _ => new AtLeast(e0, e1)
10001004
}

0 commit comments

Comments
 (0)