Skip to content

Commit

Permalink
sliceconstruct termination measure
Browse files Browse the repository at this point in the history
  • Loading branch information
Dspil committed Sep 14, 2023
1 parent b3d4f15 commit 4d73949
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class SliceEncoding(arrayEmb : SharedArrayEmbedding) extends LeafTypeEncoding {
* ensures soffset(result) == offset
* ensures slen(result) == len
* ensures scap(result) == cap
* dereases _
* }}}
*/
private val constructGenerator : FunctionGenerator[vpr.Type] = new FunctionGenerator[vpr.Type] {
Expand All @@ -357,6 +358,7 @@ class SliceEncoding(arrayEmb : SharedArrayEmbedding) extends LeafTypeEncoding {
val pre2 = synthesized(vpr.LeCmp(vpr.IntLit(0)(), lenDecl.localVar))("Slice length might be negative")
val pre3 = synthesized(vpr.LeCmp(lenDecl.localVar, capDecl.localVar))("Slice length might exceed capacity")
val pre4 = synthesized(vpr.LeCmp(vpr.Add(offsetDecl.localVar, capDecl.localVar)(), ctx.array.len(aDecl.localVar)()))("Slice capacity might exceed the capacity of the underlying array")
val pre5 = synthesized(termination.DecreasesWildcard(None))("This function is assumed to terminate")

// postconditions
val result = vpr.Result(ctx.slice.typ(typ))()
Expand All @@ -369,7 +371,7 @@ class SliceEncoding(arrayEmb : SharedArrayEmbedding) extends LeafTypeEncoding {
s"${Names.sliceConstruct}_${Names.serializeType(typ)}",
Seq(aDecl, offsetDecl, lenDecl, capDecl),
ctx.slice.typ(typ),
Seq(pre1, pre2, pre3, pre4),
Seq(pre1, pre2, pre3, pre4, pre5),
Seq(post1, post2, post3, post4),
None
)()
Expand Down

0 comments on commit 4d73949

Please sign in to comment.