package js_of_ocaml-compiler
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Compiler from OCaml bytecode to JavaScript
Install
dune-project
Dependency
Authors
Maintainers
Sources
js_of_ocaml-6.4.0.tbz
sha256=7ae22a7e5a6c6aa14a8e2695fa62c66f32cb20db17f1b45dc21e97009342151f
sha512=6cea398d61d4be8e38e912ba7e4bad4f7b81b10d946cdf29026274b5a4b2cc2709fb75e23f7cbe2db335cc65679c262a8aa1b9148effc987d6e79665a7538286
doc/src/js_of_ocaml-compiler.dynlink/js_of_ocaml_compiler_dynlink.ml.html
Source file js_of_ocaml_compiler_dynlink.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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65open Js_of_ocaml_compiler.Stdlib open Js_of_ocaml_compiler module J = Jsoo_runtime.Js external get_bytecode_sections : unit -> Parse_bytecode.bytesections = "jsoo_get_bytecode_sections" external get_runtime_aliases : unit -> (string * string) list = "jsoo_get_runtime_aliases" external toplevel_init_compile : (string -> Instruct.debug_event list array -> unit -> J.t) -> unit = "jsoo_toplevel_init_compile" external toplevel_init_reloc : (Global_name.t -> int) -> unit = "jsoo_toplevel_init_reloc" let eval_ref = ref (fun (_ : string) -> failwith "toplevel: eval not initialized") let () = (match Sys.backend_type with | Sys.Other "js_of_ocaml" -> Config.set_target `JavaScript | Sys.(Native | Bytecode | Other _) -> failwith "Expected backend `js_of_ocaml`"); let aliases = get_runtime_aliases () in let global = J.pure_js_expr "globalThis" in Build_info.set_values (Build_info.config_keys `JavaScript) (Build_info.parse_config_string (Jsoo_runtime.Sys.Config.build_config ())); Linker.reset (); List.iter aliases ~f:(fun (a, b) -> Primitive.alias a b); (* this needs to stay synchronized with toplevel.js *) let toplevel_compile (s : string) (debug : Instruct.debug_event list array) : unit -> J.t = let s = Parse_bytecode.normalize_bytecode s in let prims = Array.of_list (Ocaml_compiler.Symtable.all_primitives ()) in let b = Buffer.create 100 in let fmt = Pretty_print.to_buffer b in Driver.configure fmt; Driver.from_string ~prims ~debug s fmt; Format.(pp_print_flush std_formatter ()); Format.(pp_print_flush err_formatter ()); flush stdout; flush stderr; let js = Buffer.contents b in !eval_ref js in let toplevel_eval (x : string) : unit -> J.t = let f : J.t = J.eval_string x in fun () -> let res = J.fun_call f [| global |] in Format.(pp_print_flush std_formatter ()); Format.(pp_print_flush err_formatter ()); flush stdout; flush stderr; res in let toc = get_bytecode_sections () in let sym : Ocaml_compiler.Symtable.GlobalMap.t = toc.symb in let toplevel_reloc (gn : Global_name.t) : int = match Ocaml_compiler.Symtable.GlobalMap.find gn sym with | i -> i | exception Not_found -> Ocaml_compiler.Symtable.reloc_ident (Global_name.to_string gn) in eval_ref := toplevel_eval; toplevel_init_compile toplevel_compile; toplevel_init_reloc toplevel_reloc
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>