Skip to content

Commit 6df8c3e

Browse files
committed
refactor
1 parent 0d6e7d1 commit 6df8c3e

File tree

8 files changed

+16
-17
lines changed

8 files changed

+16
-17
lines changed

jscomp/core/j.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ and ident = Ident.t
5151
currently we always use quote
5252
*)
5353

54-
and module_id = { id : ident; kind : Js_op.kind ; dynamic_import : bool ; import_attributes : External_ffi_types.import_attributes option }
54+
and module_id = { id : ident; kind : Js_op.kind ; dynamic_import : bool }
5555

5656
and required_modules = module_id list
5757
and vident = Id of ident | Qualified of module_id * string option

jscomp/core/js_dump_program.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ let es6_program ~output_dir fmt f (x : J.deps_program) =
9595
Some ( x.id,
9696
Js_name_of_module_id.string_of_module_id x ~output_dir fmt,
9797
is_default x.kind,
98-
x.import_attributes )))
98+
(match x.kind with | External {import_attributes} -> import_attributes | _ -> None) )))
9999
in
100100
let () = P.at_least_two_lines f in
101101
let cxt = Js_dump.statements true cxt f x.program.block in

jscomp/core/js_exp_make.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ let runtime_var_dot ?comment (x : string) (e1 : string) : J.expression =
7979
{
8080
expression_desc =
8181
Var
82-
(Qualified ({ id = Ident.create_persistent x; kind = Runtime; dynamic_import = false; import_attributes = None }, Some e1));
82+
(Qualified ({ id = Ident.create_persistent x; kind = Runtime; dynamic_import = false }, Some e1));
8383
comment;
8484
}
8585

8686
let ml_var_dot ?comment ?(dynamic_import = false) (id : Ident.t) e : J.expression =
87-
{ expression_desc = Var (Qualified ({ id; kind = Ml; dynamic_import; import_attributes = None }, Some e)); comment }
87+
{ expression_desc = Var (Qualified ({ id; kind = Ml; dynamic_import }, Some e)); comment }
8888

8989
(**
9090
module as a value
@@ -96,7 +96,7 @@ let external_var_field ?import_attributes ?comment ~external_name:name (id : Ide
9696
~default : t =
9797
{
9898
expression_desc =
99-
Var (Qualified ({ id; kind = External { name; default }; dynamic_import = false; import_attributes }, Some field));
99+
Var (Qualified ({ id; kind = External { name; default; import_attributes }; dynamic_import = false }, Some field));
100100
comment;
101101
}
102102

@@ -105,13 +105,13 @@ let external_var ?import_attributes ?comment ~external_name (id : Ident.t) : t =
105105
expression_desc =
106106
Var
107107
(Qualified
108-
( { id; kind = External { name = external_name; default = false }; dynamic_import = false; import_attributes },
108+
( { id; kind = External { name = external_name; default = false; import_attributes }; dynamic_import = false },
109109
None ));
110110
comment;
111111
}
112112

113113
let ml_module_as_var ?comment ?(dynamic_import = false) (id : Ident.t) : t =
114-
{ expression_desc = Var (Qualified ({ id; kind = Ml; dynamic_import; import_attributes = None }, None)); comment }
114+
{ expression_desc = Var (Qualified ({ id; kind = Ml; dynamic_import }, None)); comment }
115115

116116
(* Static_index .....................**)
117117
let runtime_call module_name fn_name args =

jscomp/core/js_op.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ type int_op =
114114
*)
115115
type level = Log | Info | Warn | Error
116116

117-
type kind = Ml | Runtime | External of { name : string; default : bool (* TODO(import-attributes) add here instead? *) }
117+
type kind = Ml | Runtime | External of { name : string; default : bool; import_attributes : External_ffi_types.import_attributes option }
118118

119119
type property = Lam_compat.let_kind = Strict | Alias | StrictOpt | Variable
120120

jscomp/core/js_record_map.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ let label : label fn = unknown
5656
let ident : ident fn = unknown
5757

5858
let module_id : module_id fn =
59-
fun _self { id = _x0; kind = _x1; dynamic_import = _x2; import_attributes = _x3 } ->
59+
fun _self { id = _x0; kind = _x1; dynamic_import = _x2 } ->
6060
let _x0 = _self.ident _self _x0 in
61-
{ id = _x0; kind = _x1; dynamic_import = _x2; import_attributes = _x3 }
61+
{ id = _x0; kind = _x1; dynamic_import = _x2 }
6262

6363
let required_modules : required_modules fn =
6464
fun _self arg -> list _self.module_id _self arg

jscomp/core/lam_compile_env.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ let add_js_module ?import_attributes (hint_name : External_ffi_types.module_bind
7171
| Phint_nothing -> Ext_modulename.js_id_name_of_hint_name module_name)
7272
in
7373
let lam_module_ident : J.module_id =
74-
{ id; kind = External { name = module_name; default }; dynamic_import = false ; import_attributes }
74+
{ id; kind = External { name = module_name; default; import_attributes }; dynamic_import = false }
7575
in
7676
match Lam_module_ident.Hash.find_key_opt cached_tbl lam_module_ident with
7777
| None ->

jscomp/core/lam_module_ident.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@
3131

3232

3333
type t = J.module_id =
34-
{ id : Ident.t ; kind : Js_op.kind ; dynamic_import : bool ; import_attributes : External_ffi_types.import_attributes option }
34+
{ id : Ident.t ; kind : Js_op.kind ; dynamic_import : bool}
3535

3636

3737

3838
let id x = x.id
3939

40-
let of_ml ?(dynamic_import = false) id = { id ; kind = Ml ; dynamic_import ; import_attributes = None }
40+
let of_ml ?(dynamic_import = false) id = { id ; kind = Ml ; dynamic_import }
4141

4242

43-
let of_runtime id = { id ; kind = Runtime ; dynamic_import = false ; import_attributes = None }
43+
let of_runtime id = { id ; kind = Runtime ; dynamic_import = false }
4444

4545
let name (x : t) : string =
4646
match x.kind with
@@ -52,9 +52,9 @@ module Cmp = struct
5252
type nonrec t = t
5353
let equal (x : t) y =
5454
match x.kind with
55-
| External {name = x_kind; default = x_default}->
55+
| External {name = x_kind; default = x_default; _} ->
5656
begin match y.kind with
57-
| External {name = y_kind; default = y_default} ->
57+
| External {name = y_kind; default = y_default; _} ->
5858
x_kind = (y_kind : string) && x_default = y_default
5959
| _ -> false
6060
end

jscomp/core/lam_module_ident.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ type t = J.module_id =
4141
id : Ident.t ;
4242
kind : Js_op.kind ;
4343
dynamic_import : bool ;
44-
import_attributes : External_ffi_types.import_attributes option;
4544
}
4645

4746

0 commit comments

Comments
 (0)