Skip to content

Commit c519912

Browse files
committed
more cleanup
1 parent 91cdffc commit c519912

File tree

5 files changed

+71
-111
lines changed

5 files changed

+71
-111
lines changed

jscomp/core/lam_compile_primitive.ml

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,8 @@ let ensure_value_unit (st : Lam_compile_context.continuation) e : E.t =
3636
| EffectCall Not_tail -> e
3737
(* NeedValue should return a meaningful expression*)
3838

39-
let rec module_of_expression = function
39+
let module_of_expression = function
4040
| J.Var (J.Qualified (module_id, value)) -> [ (module_id, value) ]
41-
| J.Caml_block (exprs, _, _, _) ->
42-
exprs
43-
|> List.map (fun (e : J.expression) ->
44-
module_of_expression e.expression_desc)
45-
|> List.concat
4641
| _ -> []
4742

4843
let get_module_system () =
@@ -75,7 +70,7 @@ let wrap_then import value =
7570
];
7671
]
7772

78-
let translate ?output_prefix loc (cxt : Lam_compile_context.t)
73+
let translate ~output_prefix loc (cxt : Lam_compile_context.t)
7974
(prim : Lam_primitive.t) (args : J.expression list) : J.expression =
8075
match prim with
8176
| Pis_not_none -> Js_of_lam_option.is_not_none (Ext_list.singleton_exn args)
@@ -120,28 +115,23 @@ let translate ?output_prefix loc (cxt : Lam_compile_context.t)
120115
| Pimport -> (
121116
match args with
122117
| [ e ] -> (
123-
match e.expression_desc with
124-
| _ -> (
125-
match output_prefix with
126-
| Some output_prefix -> (
127-
let output_dir = Filename.dirname output_prefix in
118+
let output_dir = Filename.dirname output_prefix in
128119

129-
let module_id, module_value =
130-
match module_of_expression e.expression_desc with
131-
| [ module_ ] -> module_
132-
| _ -> assert false
133-
(* TODO: graceful error message here *)
134-
in
120+
let module_id, module_value =
121+
match module_of_expression e.expression_desc with
122+
| [ module_ ] -> module_
123+
| _ -> assert false
124+
(* TODO: graceful error message here *)
125+
in
135126

136-
let path =
137-
Js_name_of_module_id.string_of_module_id module_id
138-
~output_dir (get_module_system ())
139-
in
127+
let path =
128+
Js_name_of_module_id.string_of_module_id module_id ~output_dir
129+
(get_module_system ())
130+
in
140131

141-
match module_value with
142-
| Some value -> wrap_then (import_of_path path) value
143-
| None -> import_of_path path)
144-
| None -> assert false))
132+
match module_value with
133+
| Some value -> wrap_then (import_of_path path) value
134+
| None -> import_of_path path)
145135
| _ -> assert false)
146136
| Pjs_function_length -> E.function_length (Ext_list.singleton_exn args)
147137
| Pcaml_obj_length -> E.obj_length (Ext_list.singleton_exn args)

jscomp/core/lam_compile_primitive.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*)
3030

3131
val translate :
32-
?output_prefix:string ->
32+
output_prefix:string ->
3333
Location.t ->
3434
Lam_compile_context.t ->
3535
Lam_primitive.t ->

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -96601,7 +96601,7 @@ module Lam_compile_primitive : sig
9660196601
*)
9660296602

9660396603
val translate :
96604-
?output_prefix:string ->
96604+
output_prefix:string ->
9660596605
Location.t ->
9660696606
Lam_compile_context.t ->
9660796607
Lam_primitive.t ->
@@ -96648,13 +96648,8 @@ let ensure_value_unit (st : Lam_compile_context.continuation) e : E.t =
9664896648
| EffectCall Not_tail -> e
9664996649
(* NeedValue should return a meaningful expression*)
9665096650

96651-
let rec module_of_expression = function
96651+
let module_of_expression = function
9665296652
| J.Var (J.Qualified (module_id, value)) -> [ (module_id, value) ]
96653-
| J.Caml_block (exprs, _, _, _) ->
96654-
exprs
96655-
|> List.map (fun (e : J.expression) ->
96656-
module_of_expression e.expression_desc)
96657-
|> List.concat
9665896653
| _ -> []
9665996654

9666096655
let get_module_system () =
@@ -96687,7 +96682,7 @@ let wrap_then import value =
9668796682
];
9668896683
]
9668996684

96690-
let translate ?output_prefix loc (cxt : Lam_compile_context.t)
96685+
let translate ~output_prefix loc (cxt : Lam_compile_context.t)
9669196686
(prim : Lam_primitive.t) (args : J.expression list) : J.expression =
9669296687
match prim with
9669396688
| Pis_not_none -> Js_of_lam_option.is_not_none (Ext_list.singleton_exn args)
@@ -96732,28 +96727,23 @@ let translate ?output_prefix loc (cxt : Lam_compile_context.t)
9673296727
| Pimport -> (
9673396728
match args with
9673496729
| [ e ] -> (
96735-
match e.expression_desc with
96736-
| _ -> (
96737-
match output_prefix with
96738-
| Some output_prefix -> (
96739-
let output_dir = Filename.dirname output_prefix in
96740-
96741-
let module_id, module_value =
96742-
match module_of_expression e.expression_desc with
96743-
| [ module_ ] -> module_
96744-
| _ -> assert false
96745-
(* TODO: graceful error message here *)
96746-
in
96730+
let output_dir = Filename.dirname output_prefix in
9674796731

96748-
let path =
96749-
Js_name_of_module_id.string_of_module_id module_id
96750-
~output_dir (get_module_system ())
96751-
in
96732+
let module_id, module_value =
96733+
match module_of_expression e.expression_desc with
96734+
| [ module_ ] -> module_
96735+
| _ -> assert false
96736+
(* TODO: graceful error message here *)
96737+
in
96738+
96739+
let path =
96740+
Js_name_of_module_id.string_of_module_id module_id ~output_dir
96741+
(get_module_system ())
96742+
in
9675296743

96753-
match module_value with
96754-
| Some value -> wrap_then (import_of_path path) value
96755-
| None -> import_of_path path)
96756-
| None -> assert false))
96744+
match module_value with
96745+
| Some value -> wrap_then (import_of_path path) value
96746+
| None -> import_of_path path)
9675796747
| _ -> assert false)
9675896748
| Pjs_function_length -> E.function_length (Ext_list.singleton_exn args)
9675996749
| Pcaml_obj_length -> E.obj_length (Ext_list.singleton_exn args)

lib/4.06.1/unstable/js_playground_compiler.ml

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -96601,7 +96601,7 @@ module Lam_compile_primitive : sig
9660196601
*)
9660296602

9660396603
val translate :
96604-
?output_prefix:string ->
96604+
output_prefix:string ->
9660596605
Location.t ->
9660696606
Lam_compile_context.t ->
9660796607
Lam_primitive.t ->
@@ -96648,13 +96648,8 @@ let ensure_value_unit (st : Lam_compile_context.continuation) e : E.t =
9664896648
| EffectCall Not_tail -> e
9664996649
(* NeedValue should return a meaningful expression*)
9665096650

96651-
let rec module_of_expression = function
96651+
let module_of_expression = function
9665296652
| J.Var (J.Qualified (module_id, value)) -> [ (module_id, value) ]
96653-
| J.Caml_block (exprs, _, _, _) ->
96654-
exprs
96655-
|> List.map (fun (e : J.expression) ->
96656-
module_of_expression e.expression_desc)
96657-
|> List.concat
9665896653
| _ -> []
9665996654

9666096655
let get_module_system () =
@@ -96687,7 +96682,7 @@ let wrap_then import value =
9668796682
];
9668896683
]
9668996684

96690-
let translate ?output_prefix loc (cxt : Lam_compile_context.t)
96685+
let translate ~output_prefix loc (cxt : Lam_compile_context.t)
9669196686
(prim : Lam_primitive.t) (args : J.expression list) : J.expression =
9669296687
match prim with
9669396688
| Pis_not_none -> Js_of_lam_option.is_not_none (Ext_list.singleton_exn args)
@@ -96732,28 +96727,23 @@ let translate ?output_prefix loc (cxt : Lam_compile_context.t)
9673296727
| Pimport -> (
9673396728
match args with
9673496729
| [ e ] -> (
96735-
match e.expression_desc with
96736-
| _ -> (
96737-
match output_prefix with
96738-
| Some output_prefix -> (
96739-
let output_dir = Filename.dirname output_prefix in
96740-
96741-
let module_id, module_value =
96742-
match module_of_expression e.expression_desc with
96743-
| [ module_ ] -> module_
96744-
| _ -> assert false
96745-
(* TODO: graceful error message here *)
96746-
in
96730+
let output_dir = Filename.dirname output_prefix in
9674796731

96748-
let path =
96749-
Js_name_of_module_id.string_of_module_id module_id
96750-
~output_dir (get_module_system ())
96751-
in
96732+
let module_id, module_value =
96733+
match module_of_expression e.expression_desc with
96734+
| [ module_ ] -> module_
96735+
| _ -> assert false
96736+
(* TODO: graceful error message here *)
96737+
in
96738+
96739+
let path =
96740+
Js_name_of_module_id.string_of_module_id module_id ~output_dir
96741+
(get_module_system ())
96742+
in
9675296743

96753-
match module_value with
96754-
| Some value -> wrap_then (import_of_path path) value
96755-
| None -> import_of_path path)
96756-
| None -> assert false))
96744+
match module_value with
96745+
| Some value -> wrap_then (import_of_path path) value
96746+
| None -> import_of_path path)
9675796747
| _ -> assert false)
9675896748
| Pjs_function_length -> E.function_length (Ext_list.singleton_exn args)
9675996749
| Pcaml_obj_length -> E.obj_length (Ext_list.singleton_exn args)

lib/4.06.1/whole_compiler.ml

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -265795,7 +265795,7 @@ module Lam_compile_primitive : sig
265795265795
*)
265796265796

265797265797
val translate :
265798-
?output_prefix:string ->
265798+
output_prefix:string ->
265799265799
Location.t ->
265800265800
Lam_compile_context.t ->
265801265801
Lam_primitive.t ->
@@ -265842,13 +265842,8 @@ let ensure_value_unit (st : Lam_compile_context.continuation) e : E.t =
265842265842
| EffectCall Not_tail -> e
265843265843
(* NeedValue should return a meaningful expression*)
265844265844

265845-
let rec module_of_expression = function
265845+
let module_of_expression = function
265846265846
| J.Var (J.Qualified (module_id, value)) -> [ (module_id, value) ]
265847-
| J.Caml_block (exprs, _, _, _) ->
265848-
exprs
265849-
|> List.map (fun (e : J.expression) ->
265850-
module_of_expression e.expression_desc)
265851-
|> List.concat
265852265847
| _ -> []
265853265848

265854265849
let get_module_system () =
@@ -265881,7 +265876,7 @@ let wrap_then import value =
265881265876
];
265882265877
]
265883265878

265884-
let translate ?output_prefix loc (cxt : Lam_compile_context.t)
265879+
let translate ~output_prefix loc (cxt : Lam_compile_context.t)
265885265880
(prim : Lam_primitive.t) (args : J.expression list) : J.expression =
265886265881
match prim with
265887265882
| Pis_not_none -> Js_of_lam_option.is_not_none (Ext_list.singleton_exn args)
@@ -265926,28 +265921,23 @@ let translate ?output_prefix loc (cxt : Lam_compile_context.t)
265926265921
| Pimport -> (
265927265922
match args with
265928265923
| [ e ] -> (
265929-
match e.expression_desc with
265930-
| _ -> (
265931-
match output_prefix with
265932-
| Some output_prefix -> (
265933-
let output_dir = Filename.dirname output_prefix in
265934-
265935-
let module_id, module_value =
265936-
match module_of_expression e.expression_desc with
265937-
| [ module_ ] -> module_
265938-
| _ -> assert false
265939-
(* TODO: graceful error message here *)
265940-
in
265924+
let output_dir = Filename.dirname output_prefix in
265941265925

265942-
let path =
265943-
Js_name_of_module_id.string_of_module_id module_id
265944-
~output_dir (get_module_system ())
265945-
in
265926+
let module_id, module_value =
265927+
match module_of_expression e.expression_desc with
265928+
| [ module_ ] -> module_
265929+
| _ -> assert false
265930+
(* TODO: graceful error message here *)
265931+
in
265932+
265933+
let path =
265934+
Js_name_of_module_id.string_of_module_id module_id ~output_dir
265935+
(get_module_system ())
265936+
in
265946265937

265947-
match module_value with
265948-
| Some value -> wrap_then (import_of_path path) value
265949-
| None -> import_of_path path)
265950-
| None -> assert false))
265938+
match module_value with
265939+
| Some value -> wrap_then (import_of_path path) value
265940+
| None -> import_of_path path)
265951265941
| _ -> assert false)
265952265942
| Pjs_function_length -> E.function_length (Ext_list.singleton_exn args)
265953265943
| Pcaml_obj_length -> E.obj_length (Ext_list.singleton_exn args)

0 commit comments

Comments
 (0)