standalone exapunks vm in ocaml
at main 37 lines 860 B view raw
1(* This Source Code Form is subject to the terms of the Mozilla Public 2 License, v. 2.0. If a copy of the MPL was not distributed with this 3 file, You can obtain one at https://mozilla.org/MPL/2.0/. *) 4 5type register = Common.register 6 7let show (r : register) : string = 8 match r with 9 | X -> "X" 10 | T -> "T" 11 | F -> "F" 12 | M -> "M" 13 14let pp ppf t = Format.fprintf ppf "%s" (show t) 15 16let equal (r1 : register) (r2 : register) = 17 match (r1, r2) with 18 | X, X -> true 19 | T, T -> true 20 | F, F -> true 21 | M, M -> true 22 | _ -> false 23 24type r_n = Common.r_n 25 26let show_r_n (rn : r_n) : string = 27 match rn with 28 | R t -> show t 29 | N i -> string_of_int i 30 31let pp_r_n ppf rn = Format.fprintf ppf "%s" (show rn) 32 33let equal_r_n (rn1 : r_n) (rn2 : r_n) = 34 match (rn1, rn2) with 35 | R r1, R r2 -> equal r1 r2 36 | N n1, N n2 -> Int.equal n1 n2 37 | _ -> false