File: existentials2.sail

package info (click to toggle)
sail-ocaml 0.19.1%2Bdfsg5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,008 kB
  • sloc: ml: 75,941; ansic: 8,848; python: 1,342; exp: 560; sh: 474; makefile: 218; cpp: 36
file content (38 lines) | stat: -rw-r--r-- 866 bytes parent folder | download
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
default Order dec
$include <prelude.sail>
$include <generic_equality.sail>

union ast = {
  Foo : {'n, 'n in {16,32}. (int, int, int('n), bits('n))},
  Bar : (int, int, {'n, 'n in {16,32}. (int('n), bits('n))}),
}

struct st = {
  One : (int, int),
  Two : {'n, 'n in {16, 32}. (int('n), bits('n))},
  Three : (int, {'n, 'n in {16, 32}. (int('n), bits('n))}),
}

function test_struct1(i : int, v : bits(16)) -> st = struct {
  One = (i,i),
  Two = (16, v),
  Three = (i, (16, v)),
}

function test_struct2(i : int, v : bits(16), st0 : st) -> st = {
  var st1 = st0;
  st1.Two = (16, v);
  st1.Three = (i, (16, v));
  st1
}

union ast2 = {
  Foo2 : {'n, 'n in {16,32}. (int, (int('n), bits('n)))},
}

function test11(x : ast2) -> int =
  match x {
  Foo2 (y, z) => match z { (_,v) => unsigned(v) }
  }

function test12(i : int, v : bits(16)) -> ast2 = Foo2(i,(16,v))