Created
April 6, 2023 09:36
-
-
Save ebresafegaga/9963892ff0430bfc831f5a8ceabf6eea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type stack = int array | |
type machine = { ip : int; sp : int; mutable stack : stack } | |
(* Machine stack *) | |
module type S = sig | |
type t | |
type index | |
type elem | |
val alignment : int | |
val index : | |
t -> | |
index -> | |
offset:int -> | |
(elem, [ `Invalid_memory | `Stack_overflow ]) Either.t | |
val store : | |
t -> | |
index -> | |
offset:int -> | |
elem -> | |
(t, [ `Invalid_memory | `Stack_overflow ]) Either.t | |
end | |
(* Instruction list *) | |
module type I = sig | |
type t | |
val next : t -> Ast.instr option * t | |
end | |
(* Machine *) | |
module type M = sig | |
type t | |
type error | |
val step : t -> Ast.instr -> (t, error) Result.t | |
val exec : t -> Ast.program -> (t, error) Result.t | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment