File: issue232.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 (35 lines) | stat: -rw-r--r-- 758 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
default Order dec
$include <prelude.sail>

enum E = EA | EB

mapping e_pair_bits : (E,E) <-> bits(2) =
  { (EA, EA) <-> 0b00
  , (EA, EB) <-> 0b01
  , (EB, EB) <-> 0b11
  }

struct eful =
  { e1 : E
  , e2 : E
  }

val eful_unpack : eful <-> (E,E)
mapping eful_unpack = { struct { e1, e2 } <-> (e1, e2) }
/*
function eful_unpack_backwards_matches(x) = true
function eful_unpack_forwards(s) = (s.e1, s.e2)
function eful_unpack_forwards_matches(x) = true
function eful_unpack_backwards(e1,e2) = struct { e1 = e1, e2 = e2 }
*/

union F = { FE : eful }

val f_bits : F <-> bits(2)
mapping f_bits = { FE(eful_unpack(e1,e2)) <-> e_pair_bits(e1,e2) }

val main : unit -> unit

function main() = {
  print_bits("EA, EB = ", f_bits(FE(struct { e1 = EA, e2 = EB })))
}