summaryrefslogtreecommitdiff
path: root/Test/og/new1.bpl
blob: 3ba0840dd28fb7cef6e8115645d3fe4948b1fbce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function {:builtin "MapConst"} mapconstbool(x:bool): [int]bool;

var g:int;

function {:inline} {:linear "Perm"} SetCollectorPerm(x: [int]bool) : [int]bool
{
  x
}

procedure Allocate_Perm({:linear "Perm"} Permissions: [int]bool) returns ({:linear "Perm"} xls: [int]bool);
requires Permissions == mapconstbool(true);
ensures xls == mapconstbool(true);

procedure {:yields} {:stable} PB({:linear "Perm"} permVar_in:[int]bool)
requires permVar_in[0] && g == 0;
{
  var {:linear "Perm"} permVar_out: [int]bool;
  permVar_out := permVar_in;

  yield;
  assert permVar_out[0];
  assert g == 0;

  g := g + 1;

  yield;
  assert permVar_out[0];
  assert g == 1;
}

procedure{:entrypoint} {:yields} Main({:linear "Perm"} Permissions: [int]bool)
requires Permissions == mapconstbool(true);
{
  var {:linear "Perm"} permVar_out: [int]bool;

  call permVar_out := Allocate_Perm(Permissions);

  g := 0;
  async call PB(permVar_out);
}