Skip to content

Commit a2275df

Browse files
committed
refactoring
1 parent 1242b31 commit a2275df

File tree

4 files changed

+212
-207
lines changed

4 files changed

+212
-207
lines changed

compiler/bin-js_of_ocaml/cmd_arg.ml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ type t =
4646
; source_map : (string option * Source_map.t) option
4747
; runtime_files : string list
4848
; no_runtime : bool
49-
; include_partial_runtime : bool
50-
; runtime_only : bool
49+
; include_runtime : bool
5150
; output_file : [ `Name of string | `Stdout ] * bool
52-
; input_file : string option
51+
; bytecode : [ `File of string | `Stdin | `None ]
5352
; params : (string * string) list
5453
; static_env : (string * string) list
5554
; wrap_with_fun : [ `Iife | `Named of string | `Anonymous ]
@@ -123,11 +122,11 @@ let options =
123122
let doc = "Do not include the standard runtime." in
124123
Arg.(value & flag & info [ "noruntime"; "no-runtime" ] ~doc)
125124
in
126-
let include_partial_runtime =
125+
let include_runtime =
127126
let doc =
128127
"Include (partial) runtime when compiling cmo and cma files to JavaScript."
129128
in
130-
Arg.(value & flag & info [ "include-partial-runtime" ] ~doc)
129+
Arg.(value & flag & info [ "include-runtime" ] ~doc)
131130
in
132131
let no_sourcemap =
133132
let doc =
@@ -270,7 +269,7 @@ let options =
270269
no_cmis
271270
profile
272271
no_runtime
273-
include_partial_runtime
272+
include_runtime
274273
no_sourcemap
275274
sourcemap
276275
sourcemap_inline_in_js
@@ -284,19 +283,19 @@ let options =
284283
let chop_extension s = try Filename.chop_extension s with Invalid_argument _ -> s in
285284
let runtime_files = js_files in
286285
let fs_external = fs_external || (toplevel && no_cmis) in
287-
let input_file =
286+
let bytecode =
288287
match input_file with
289-
| "-" -> None
290-
| x -> Some x
288+
| "-" -> `Stdin
289+
| x -> `File x
291290
in
292291
let output_file =
293292
match output_file with
294293
| Some "-" -> `Stdout, true
295294
| Some s -> `Name s, true
296295
| None -> (
297-
match input_file with
298-
| Some s -> `Name (chop_extension s ^ ".js"), false
299-
| None -> `Stdout, false)
296+
match bytecode with
297+
| `File s -> `Name (chop_extension s ^ ".js"), false
298+
| `Stdin -> `Stdout, false)
300299
in
301300
let source_map =
302301
if (not no_sourcemap) && (sourcemap || sourcemap_inline_in_js)
@@ -346,14 +345,13 @@ let options =
346345
; include_dirs
347346
; runtime_files
348347
; no_runtime
349-
; include_partial_runtime
350-
; runtime_only = false
348+
; include_runtime
351349
; fs_files
352350
; fs_output
353351
; fs_external
354352
; no_cmis
355353
; output_file
356-
; input_file
354+
; bytecode
357355
; source_map
358356
; keep_unit_names
359357
}
@@ -376,7 +374,7 @@ let options =
376374
$ no_cmis
377375
$ profile
378376
$ noruntime
379-
$ include_partial_runtime
377+
$ include_runtime
380378
$ no_sourcemap
381379
$ sourcemap
382380
$ sourcemap_inline_in_js
@@ -586,14 +584,13 @@ let options_runtime_only =
586584
; include_dirs
587585
; runtime_files
588586
; no_runtime
589-
; include_partial_runtime = false
590-
; runtime_only = true
587+
; include_runtime = false
591588
; fs_files
592589
; fs_output
593590
; fs_external
594591
; no_cmis
595592
; output_file
596-
; input_file = None
593+
; bytecode = `None
597594
; source_map
598595
; keep_unit_names = false
599596
}

compiler/bin-js_of_ocaml/cmd_arg.mli

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ type t =
2626
; source_map : (string option * Source_map.t) option
2727
; runtime_files : string list
2828
; no_runtime : bool
29-
; include_partial_runtime : bool
30-
; runtime_only : bool
29+
; include_runtime : bool
3130
; output_file : [ `Name of string | `Stdout ] * bool
32-
; input_file : string option
31+
; bytecode : [ `File of string | `Stdin | `None ]
3332
; params : (string * string) list
3433
; static_env : (string * string) list
3534
; wrap_with_fun :

0 commit comments

Comments
 (0)