finite-wasm 0.6.1

Guarantee deterministic limits on execution time and space resources made available to the WebAssembly programs in a runtime-agnostic way.
open Types
open Values

type global = {ty : global_type; mutable content : value}
type t = global

exception Type
exception NotMutable

let alloc (GlobalType (t, _) as ty) v =
  if type_of_value v <> t then raise Type;
  {ty; content = v}

let type_of glob =
  glob.ty

let load glob =
  glob.content

let store glob v =
  let GlobalType (t, mut) = glob.ty in
  if mut <> Mutable then raise NotMutable;
  if type_of_value v <> t then raise Type;
  glob.content <- v