Skip to content

Commit 2abc942

Browse files
committed
import Oxcaml JSOO changes
1 parent 246df64 commit 2abc942

File tree

163 files changed

+4595
-6687
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+4595
-6687
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@ toplevel/examples/lwt_toplevel_bin/toplevel.js
5656
toplevel/examples/lwt_toplevel_bin/eval.js
5757

5858
janestreet
59+
.local-merlin-binaries
60+
.local-ocaml-lib
61+
_install
62+
*.orig
63+
*.rej

compiler/bin-js_of_ocaml/build_fs.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ let f { files; output_file; include_dirs } =
5151
{|
5252
//Provides: jsoo_create_file_extern
5353
function jsoo_create_file_extern(name,content){
54-
if(globalThis.jsoo_create_file)
54+
if (globalThis.jsoo_create_file) {
5555
globalThis.jsoo_create_file(name,content);
56-
else {
56+
} else if (globalThis.caml_create_file) {
57+
globalThis.caml_create_file(name,content);
58+
} else {
5759
if(!globalThis.jsoo_fs_tmp) globalThis.jsoo_fs_tmp = [];
5860
globalThis.jsoo_fs_tmp.push({name:name,content:content});
5961
}

compiler/bin-js_of_ocaml/check_runtime.ml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,15 @@ let f (runtime_files, bytecode, target_env) =
6363
Linker.check_deps ();
6464
let all_prims =
6565
List.concat_map bytecode ~f:(fun f ->
66+
(
6667
let ic = open_in_bin f in
6768
let prims =
68-
match Parse_bytecode.from_channel ic with
69-
| `Cmo x -> x.Cmo_format.cu_primitives
70-
| `Cma x ->
71-
List.concat_map
72-
~f:(fun x -> x.Cmo_format.cu_primitives)
73-
x.Cmo_format.lib_units
74-
| `Exe ->
75-
let toc = Parse_bytecode.Toc.read ic in
76-
Parse_bytecode.read_primitives toc ic
69+
Fun.protect (fun () ->
70+
(* CR jvanburen: fix this once by reading .cmj files. *)
71+
failwith "Unimplemented")
72+
~finally:(fun () -> close_in ic)
7773
in
78-
close_in ic;
79-
List.map ~f:(fun p -> p, f) prims)
74+
List.map ~f:(fun p -> p, f) prims))
8075
in
8176
let _percent_prim, needed =
8277
List.partition all_prims ~f:(fun (x, _) -> Char.equal (String.get x 0) '%')

compiler/bin-js_of_ocaml/cmd_arg.ml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type t =
5959
; no_runtime : bool
6060
; include_runtime : bool
6161
; output_file : [ `Name of string | `Stdout ] * bool
62-
; bytecode : [ `File of string | `Stdin | `None ]
62+
; input : [ `Filename of string | `None ]
6363
; params : (string * string) list
6464
; static_env : (string * string) list
6565
; wrap_with_fun : [ `Iife | `Named of string | `Anonymous ]
@@ -116,8 +116,7 @@ let options =
116116
in
117117
let input_file =
118118
let doc =
119-
"Compile the bytecode program [$(docv)]. "
120-
^ "Use '-' to read from the standard input instead."
119+
"Compile the JSOO file (.cmj) or archive (.cmja) [$(docv)]."
121120
in
122121
Arg.(required & pos ~rev:true 0 (some string) None & info [] ~docv:"PROGRAM" ~doc)
123122
in
@@ -314,19 +313,12 @@ let options =
314313
let chop_extension s = try Filename.chop_extension s with Invalid_argument _ -> s in
315314
let runtime_files = js_files in
316315
let fs_external = fs_external || (toplevel && no_cmis) in
317-
let bytecode =
318-
match input_file with
319-
| "-" -> `Stdin
320-
| x -> `File x
321-
in
316+
let input = `Filename input_file in
322317
let output_file =
323318
match output_file with
324319
| Some "-" -> `Stdout, true
325320
| Some s -> `Name s, true
326-
| None -> (
327-
match bytecode with
328-
| `File s -> `Name (chop_extension s ^ ".js"), false
329-
| `Stdin -> `Stdout, false)
321+
| None -> `Name (chop_extension input_file ^ ".js"), false
330322
in
331323
let source_map =
332324
if (not no_sourcemap) && (sourcemap || sourcemap_inline_in_js)
@@ -376,7 +368,7 @@ let options =
376368
; fs_external
377369
; no_cmis
378370
; output_file
379-
; bytecode
371+
; input
380372
; source_map
381373
; keep_unit_names
382374
; effects
@@ -629,7 +621,7 @@ let options_runtime_only =
629621
; fs_external
630622
; no_cmis
631623
; output_file
632-
; bytecode = `None
624+
; input = `None
633625
; source_map
634626
; keep_unit_names = false
635627
; effects

compiler/bin-js_of_ocaml/cmd_arg.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type t =
2828
; no_runtime : bool
2929
; include_runtime : bool
3030
; output_file : [ `Name of string | `Stdout ] * bool
31-
; bytecode : [ `File of string | `Stdin | `None ]
31+
; input : [ `Filename of string | `None ]
3232
; params : (string * string) list
3333
; static_env : (string * string) list
3434
; wrap_with_fun :

0 commit comments

Comments
 (0)