diff --git a/hosts/ocaml/bootstrap_vm.py b/hosts/ocaml/bootstrap_vm.py index 4b4c8c34..5d2f461b 100644 --- a/hosts/ocaml/bootstrap_vm.py +++ b/hosts/ocaml/bootstrap_vm.py @@ -355,7 +355,9 @@ let vm_create_closure vm_val frame_val code_val = let f = unwrap_frame frame_val in let uv_count = match code_val with | Dict d -> (match Hashtbl.find_opt d "upvalue-count" with - | Some (Number n) -> int_of_float n | _ -> 0) + | Some (Integer n) -> n + | Some (Number n) -> int_of_float n + | _ -> 0) | _ -> 0 in let upvalues = Array.init uv_count (fun _ -> diff --git a/hosts/ocaml/browser/sx_browser.ml b/hosts/ocaml/browser/sx_browser.ml index c61cac7f..2abbbf17 100644 --- a/hosts/ocaml/browser/sx_browser.ml +++ b/hosts/ocaml/browser/sx_browser.ml @@ -704,8 +704,10 @@ let () = | List (Symbol "code" :: rest) -> let d = Hashtbl.create 8 in let rec parse_kv = function - | Keyword "arity" :: Number n :: rest -> Hashtbl.replace d "arity" (Number n); parse_kv rest - | Keyword "upvalue-count" :: Number n :: rest -> Hashtbl.replace d "upvalue-count" (Number n); parse_kv rest + | Keyword "arity" :: (Number _ as n) :: rest -> Hashtbl.replace d "arity" n; parse_kv rest + | Keyword "arity" :: (Integer _ as n) :: rest -> Hashtbl.replace d "arity" n; parse_kv rest + | Keyword "upvalue-count" :: (Number _ as n) :: rest -> Hashtbl.replace d "upvalue-count" n; parse_kv rest + | Keyword "upvalue-count" :: (Integer _ as n) :: rest -> Hashtbl.replace d "upvalue-count" n; parse_kv rest | Keyword "bytecode" :: List nums :: rest -> Hashtbl.replace d "bytecode" (List nums); parse_kv rest | Keyword "constants" :: List consts :: rest -> diff --git a/hosts/ocaml/lib/sx_vm.ml b/hosts/ocaml/lib/sx_vm.ml index 4fd09eac..330316e3 100644 --- a/hosts/ocaml/lib/sx_vm.ml +++ b/hosts/ocaml/lib/sx_vm.ml @@ -642,7 +642,9 @@ and run vm = (* Read upvalue descriptors from bytecode *) let uv_count = match code_val with | Dict d -> (match Hashtbl.find_opt d "upvalue-count" with - | Some (Number n) -> int_of_float n | _ -> 0) + | Some (Integer n) -> n + | Some (Number n) -> int_of_float n + | _ -> 0) | _ -> 0 in let upvalues = Array.init uv_count (fun _ -> @@ -1307,7 +1309,9 @@ let trace_run src globals = let code_val2 = frame.closure.vm_code.vc_constants.(idx) in let uv_count = match code_val2 with | Dict d -> (match Hashtbl.find_opt d "upvalue-count" with - | Some (Number n) -> int_of_float n | _ -> 0) + | Some (Integer n) -> n + | Some (Number n) -> int_of_float n + | _ -> 0) | _ -> 0 in let upvalues = Array.init uv_count (fun _ -> let is_local = read_u8 frame in @@ -1428,7 +1432,9 @@ let disassemble (code : vm_code) = if op = 51 && idx < Array.length consts then begin let uv_count = match consts.(idx) with | Dict d -> (match Hashtbl.find_opt d "upvalue-count" with - | Some (Number n) -> int_of_float n | _ -> 0) + | Some (Integer n) -> n + | Some (Number n) -> int_of_float n + | _ -> 0) | _ -> 0 in ip := !ip + uv_count * 2 end diff --git a/hosts/ocaml/lib/sx_vm_ref.ml b/hosts/ocaml/lib/sx_vm_ref.ml index 62e754f1..d8d9b465 100644 --- a/hosts/ocaml/lib/sx_vm_ref.ml +++ b/hosts/ocaml/lib/sx_vm_ref.ml @@ -270,7 +270,9 @@ let vm_create_closure vm_val frame_val code_val = let f = unwrap_frame frame_val in let uv_count = match code_val with | Dict d -> (match Hashtbl.find_opt d "upvalue-count" with - | Some (Number n) -> int_of_float n | _ -> 0) + | Some (Integer n) -> n + | Some (Number n) -> int_of_float n + | _ -> 0) | _ -> 0 in let upvalues = Array.init uv_count (fun _ -> diff --git a/hosts/ocaml/sx_vm_ref.ml b/hosts/ocaml/sx_vm_ref.ml index d7cfd35d..92eedb8f 100644 --- a/hosts/ocaml/sx_vm_ref.ml +++ b/hosts/ocaml/sx_vm_ref.ml @@ -265,7 +265,9 @@ let vm_create_closure vm_val frame_val code_val = let f = unwrap_frame frame_val in let uv_count = match code_val with | Dict d -> (match Hashtbl.find_opt d "upvalue-count" with - | Some (Number n) -> int_of_float n | _ -> 0) + | Some (Integer n) -> n + | Some (Number n) -> int_of_float n + | _ -> 0) | _ -> 0 in let upvalues = Array.init uv_count (fun _ ->