Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
memory.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
open Js_of_ocaml open Js_of_ocaml.Js open Js_of_ocaml.Js.Unsafe type segment = { name : string; passive : bool; offset : Expression.t; size : int; } (** Module, initial size, maximum size, export name, segments, shared. *) let set_memory wasm_mod initial maximum export_name (segments : segment list) = let segs = List.map (fun { name; passive; offset; _ } -> let data = meth_call Typed_array.uint8Array "from" [| inject (string name) |] in obj [| ("data", data); ("passive", inject passive); ("offset", inject offset); |]) segments in ignore (meth_call wasm_mod "setMemory" [| inject initial; inject maximum; inject (string export_name); inject (array (Array.of_list segs)); inject (if shared then _true else _false); |]) let unlimited = -1