| 1 |
open import Pervasives_extra |
| 2 |
(* https://raw.githubusercontent.com/rems-project/lem/master/examples/ppcmem-model/machineDefFreshIds.lem *) |
| 3 |
|
| 4 |
(*========================================================================*) |
| 5 |
(* *) |
| 6 |
(* ppcmem executable model *) |
| 7 |
(* *) |
| 8 |
(* Susmit Sarkar, University of Cambridge *) |
| 9 |
(* Peter Sewell, University of Cambridge *) |
| 10 |
(* Jade Alglave, Oxford University *) |
| 11 |
(* Luc Maranget, INRIA Rocquencourt *) |
| 12 |
(* *) |
| 13 |
(* This file is copyright 2010,2011 Institut National de Recherche en *) |
| 14 |
(* Informatique et en Automatique (INRIA), and Susmit Sarkar, Peter *) |
| 15 |
(* Sewell, and Jade Alglave. *) |
| 16 |
(* *) |
| 17 |
(* All rights reserved. *) |
| 18 |
(* *) |
| 19 |
(* *) |
| 20 |
(* *) |
| 21 |
(* *) |
| 22 |
(* *) |
| 23 |
(*========================================================================*) |
| 24 |
|
| 25 |
(* emacs fontification -*-caml-*- *) |
| 26 |
|
| 27 |
(*: \section{Fresh Identifiers} :*) |
| 28 |
|
| 29 |
(*: Generation of fresh ids, for flexible unification variables, events, and instruction instances. :*) |
| 30 |
|
| 31 |
open import MachineDefUtils |
| 32 |
|
| 33 |
type flexsym = nat |
| 34 |
type ioid = nat |
| 35 |
|
| 36 |
let compare_flexsym = compare_num |
| 37 |
|
| 38 |
type id_state = |
| 39 |
<| flexsym_state : flexsym; |
| 40 |
ioid_state : ioid; |
| 41 |
|> |
| 42 |
|
| 43 |
let initial_id_state = |
| 44 |
<| flexsym_state = 0; ioid_state = 0 |> |
| 45 |
|
| 46 |
let gen_ioid ist = |
| 47 |
(ist.ioid_state, <| ist with ioid_state = ist.ioid_state + 1 |>) |
| 48 |
|
| 49 |
let gen_flexsym ist = |
| 50 |
(ist.flexsym_state, <| ist with flexsym_state = ist.flexsym_state + 1 |>) |