summaryrefslogtreecommitdiff
path: root/Test/og/new1.bpl
blob: 6ebb9cf172ab926682e521292eed68bcefa98dc0 (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
function {:builtin "MapConst"} mapconstbool(x:bool): [int]bool;

var g:int;

var {:linear "Perm"} Permissions: [int]bool;

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

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()
modifies g, Permissions;
requires Permissions == mapconstbool(true);
{
  var {:linear "Perm"} permVar_out: [int]bool;

  call permVar_out := Allocate_Perm();

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