Skip to content

Commit ef6ac2b

Browse files
committed
fixed nix, formatted
1 parent 2abc942 commit ef6ac2b

38 files changed

+495
-505
lines changed

compiler/bin-js_of_ocaml/check_runtime.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +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-
(
6766
let ic = open_in_bin f in
6867
let prims =
69-
Fun.protect (fun () ->
70-
(* CR jvanburen: fix this once by reading .cmj files. *)
71-
failwith "Unimplemented")
68+
Fun.protect
69+
(fun () ->
70+
(* CR jvanburen: fix this once by reading .cmj files. *)
71+
failwith "Unimplemented")
7272
~finally:(fun () -> close_in ic)
7373
in
74-
List.map ~f:(fun p -> p, f) prims))
74+
List.map ~f:(fun p -> p, f) prims)
7575
in
7676
let _percent_prim, needed =
7777
List.partition all_prims ~f:(fun (x, _) -> Char.equal (String.get x 0) '%')

compiler/bin-js_of_ocaml/cmd_arg.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ let options =
115115
Arg.(value & opt (some string) None & info [ "o" ] ~docv:"FILE" ~doc)
116116
in
117117
let input_file =
118-
let doc =
119-
"Compile the JSOO file (.cmj) or archive (.cmja) [$(docv)]."
120-
in
118+
let doc = "Compile the JSOO file (.cmj) or archive (.cmja) [$(docv)]." in
121119
Arg.(required & pos ~rev:true 0 (some string) None & info [] ~docv:"PROGRAM" ~doc)
122120
in
123121
let keep_unit_names =

compiler/bin-js_of_ocaml/compile.ml

Lines changed: 64 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ let run
205205
if Option.is_some source_map && Parse_bytecode.Debug.is_empty one.debug
206206
then
207207
warn
208-
"Warning: '--source-map' is enabled but the program was compiled with \
209-
no debugging information.\n\
208+
"Warning: '--source-map' is enabled but the program was compiled with no \
209+
debugging information.\n\
210210
%!"
211211
in
212212
let pseudo_fs_instr prim debug cmis =
@@ -290,7 +290,7 @@ let run
290290
sm
291291
in
292292
let output_partial
293-
({name = _ ; info= uinfo ; contents }: Parse_bytecode.compilation_unit)
293+
({ name = _; info = uinfo; contents } : Parse_bytecode.compilation_unit)
294294
~standalone
295295
~source_map
296296
((_, fmt) as output_file) =
@@ -364,81 +364,82 @@ let run
364364
~link:`All
365365
output_file
366366
|> sourcemap_of_info ~base:source_map_base)
367-
| `Filename filename ->
367+
| `Filename filename -> (
368368
match
369369
Parse_bytecode.load
370370
~filename
371371
~include_dirs
372372
~include_cmis
373373
~debug:need_debug
374-
~log_times:(times())
374+
~log_times:(times ())
375375
with
376376
| `Cmj cmj ->
377-
output_gen
378-
~standalone:false
379-
~custom_header
380-
~build_info:(Build_info.create `Cmj)
381-
~source_map
382-
(fst output_file)
383-
(fun ~standalone ~source_map output ->
384-
if include_runtime then
385-
(let sm1 = output_partial_runtime ~standalone ~source_map output in
386-
let sm2 = output_partial cmj ~standalone ~source_map output in
387-
sourcemap_of_infos ~base:source_map_base [sm1; sm2])
388-
else
389-
output_partial cmj ~standalone ~source_map output
390-
|> sourcemap_of_info ~base:source_map_base)
377+
output_gen
378+
~standalone:false
379+
~custom_header
380+
~build_info:(Build_info.create `Cmj)
381+
~source_map
382+
(fst output_file)
383+
(fun ~standalone ~source_map output ->
384+
if include_runtime
385+
then
386+
let sm1 = output_partial_runtime ~standalone ~source_map output in
387+
let sm2 = output_partial cmj ~standalone ~source_map output in
388+
sourcemap_of_infos ~base:source_map_base [ sm1; sm2 ]
389+
else
390+
output_partial cmj ~standalone ~source_map output
391+
|> sourcemap_of_info ~base:source_map_base)
391392
| `Cmja units ->
392-
if keep_unit_names then (
393-
let output_dir =
394-
match output_file with
395-
| `Stdout, false -> Filename.current_dir_name
396-
| `Name x, false -> Filename.dirname x
397-
| `Name x, true when String.ends_with x ~suffix:"/" -> x
398-
| `Stdout, true | `Name _, true ->
399-
failwith "use [-o dirname/] or remove [--keep-unit-names]"
400-
in
401-
if include_runtime then (
402-
output_gen
403-
~standalone:false
404-
~custom_header
405-
~build_info:(Build_info.create `Runtime)
406-
~source_map
407-
(`Name (Filename.concat output_dir "runtime.js"))
408-
(fun ~standalone ~source_map output ->
409-
output_partial_runtime ~standalone ~source_map output
410-
|> sourcemap_of_info ~base:source_map_base));
411-
List.iter units ~f:(fun (cmj : Parse_bytecode.compilation_unit) ->
393+
if keep_unit_names
394+
then (
395+
let output_dir =
396+
match output_file with
397+
| `Stdout, false -> Filename.current_dir_name
398+
| `Name x, false -> Filename.dirname x
399+
| `Name x, true when String.ends_with x ~suffix:"/" -> x
400+
| `Stdout, true | `Name _, true ->
401+
failwith "use [-o dirname/] or remove [--keep-unit-names]"
402+
in
403+
if include_runtime
404+
then
405+
output_gen
406+
~standalone:false
407+
~custom_header
408+
~build_info:(Build_info.create `Runtime)
409+
~source_map
410+
(`Name (Filename.concat output_dir "runtime.js"))
411+
(fun ~standalone ~source_map output ->
412+
output_partial_runtime ~standalone ~source_map output
413+
|> sourcemap_of_info ~base:source_map_base);
414+
List.iter units ~f:(fun (cmj : Parse_bytecode.compilation_unit) ->
415+
output_gen
416+
~standalone:false
417+
~custom_header
418+
~build_info:(Build_info.create `Cmja)
419+
~source_map
420+
(`Name (Filename.concat output_dir (cmj.name ^ ".js")))
421+
(fun ~standalone ~source_map output ->
422+
output_partial ~standalone ~source_map cmj output
423+
|> sourcemap_of_info ~base:source_map_base)))
424+
else
412425
output_gen
413426
~standalone:false
414427
~custom_header
415428
~build_info:(Build_info.create `Cmja)
416429
~source_map
417-
(`Name (Filename.concat output_dir (cmj.name ^ ".js")))
430+
(fst output_file)
418431
(fun ~standalone ~source_map output ->
419-
output_partial ~standalone ~source_map cmj output
420-
|> sourcemap_of_info ~base:source_map_base))
421-
) else (
422-
output_gen
423-
~standalone:false
424-
~custom_header
425-
~build_info:(Build_info.create `Cmja)
426-
~source_map
427-
(fst output_file)
428-
(fun ~standalone ~source_map output ->
429-
let source_map_runtime =
430-
if not include_runtime
431-
then []
432-
else [ output_partial_runtime ~standalone ~source_map output ]
433-
in
434-
let source_map_units =
435-
List.map units ~f:(fun cmj ->
436-
output_partial cmj ~standalone ~source_map output)
437-
in
438-
let source_maps = source_map_runtime @ source_map_units in
439-
sourcemap_of_infos ~base:source_map_base source_maps)
440-
)
441-
);
432+
let source_map_runtime =
433+
if not include_runtime
434+
then []
435+
else [ output_partial_runtime ~standalone ~source_map output ]
436+
in
437+
let source_map_units =
438+
List.map units ~f:(fun cmj ->
439+
output_partial cmj ~standalone ~source_map output)
440+
in
441+
let source_maps = source_map_runtime @ source_map_units in
442+
sourcemap_of_infos ~base:source_map_base source_maps)));
442443
Debug.stop_profiling ()
443444

444445
let info name =

compiler/bin-js_of_ocaml/js_of_ocaml.ml

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,30 @@ let () =
4343
| _ -> argv
4444
in
4545
try
46-
(
47-
match
48-
Cmdliner.Cmd.eval_value
49-
~catch:false
50-
~argv
51-
(Cmdliner.Cmd.group
52-
~default:Compile.term
53-
(Compile.info "js_of_ocaml")
54-
[ Link.command
55-
; Build_fs.command
56-
; Build_runtime.command
57-
; Print_runtime.command
58-
; Check_runtime.command
59-
; Compile.command
60-
])
61-
with
62-
| Ok (`Ok () | `Help | `Version) ->
63-
if !warnings > 0 && !werror
64-
then (
65-
Format.eprintf "%s: all warnings being treated as errors@." Sys.argv.(0);
66-
exit 1)
67-
else exit 0
68-
| Error `Term -> exit 1
69-
| Error `Parse -> exit Cmdliner.Cmd.Exit.cli_error
70-
| Error `Exn -> ()
71-
(* should not happen *))
46+
match
47+
Cmdliner.Cmd.eval_value
48+
~catch:false
49+
~argv
50+
(Cmdliner.Cmd.group
51+
~default:Compile.term
52+
(Compile.info "js_of_ocaml")
53+
[ Link.command
54+
; Build_fs.command
55+
; Build_runtime.command
56+
; Print_runtime.command
57+
; Check_runtime.command
58+
; Compile.command
59+
])
60+
with
61+
| Ok (`Ok () | `Help | `Version) ->
62+
if !warnings > 0 && !werror
63+
then (
64+
Format.eprintf "%s: all warnings being treated as errors@." Sys.argv.(0);
65+
exit 1)
66+
else exit 0
67+
| Error `Term -> exit 1
68+
| Error `Parse -> exit Cmdliner.Cmd.Exit.cli_error
69+
| Error `Exn -> () (* should not happen *)
7270
with
7371
| (Match_failure _ | Assert_failure _ | Not_found) as exc ->
7472
let backtrace = Printexc.get_backtrace () in
@@ -96,8 +94,8 @@ let () =
9694
else "a newer"
9795
in
9896
Format.eprintf
99-
"%s: Error: Your JSIR file and the js_of_ocaml compiler have to be compiled \
100-
for the same version of ocaml.@."
97+
"%s: Error: Your JSIR file and the js_of_ocaml compiler have to be compiled for \
98+
the same version of ocaml.@."
10199
Sys.argv.(0);
102100
Format.eprintf
103101
"%s: Error: Its seems that your ocaml bytecode has been compiled with %s version \

compiler/bin-jsoo_minify/jsoo_minify.ml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,10 @@ let main =
9393

9494
let (_ : int) =
9595
try
96-
(
97-
Cmdliner.Cmd.eval
98-
~catch:false
99-
~argv:(Jsoo_cmdline.normalize_argv ~warn:(warn "%s") Sys.argv)
100-
main)
96+
Cmdliner.Cmd.eval
97+
~catch:false
98+
~argv:(Jsoo_cmdline.normalize_argv ~warn:(warn "%s") Sys.argv)
99+
main
101100
with
102101
| (Match_failure _ | Assert_failure _ | Not_found) as exc ->
103102
let backtrace = Printexc.get_backtrace () in

compiler/lib-wasm/gc_target.ml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,12 +1076,10 @@ module Constant = struct
10761076
let* e = Memory.make_int32 ~kind:`Nativeint (return (W.Const (I32 i))) in
10771077
return (Const, e)
10781078
| Null ->
1079-
let* var =
1080-
register_import
1081-
~name:"null"
1082-
(Global { mut = false; typ = Type.value })
1083-
in
1084-
return (Const, W.GlobalGet var)
1079+
let* var =
1080+
register_import ~name:"null" (Global { mut = false; typ = Type.value })
1081+
in
1082+
return (Const, W.GlobalGet var)
10851083

10861084
let translate c =
10871085
let* const, c = translate_rec c in

0 commit comments

Comments
 (0)