From 1f9c5813bee457d629e35ac51495d61ab03fd9d6 Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Sun, 20 Nov 2022 12:15:30 +0900 Subject: [PATCH] dynamic import --- jscomp/core/js_packages_info.ml | 2 + jscomp/core/js_packages_info.mli | 2 + jscomp/core/lam_analysis.ml | 6 +- jscomp/core/lam_compile.ml | 255 ++--- jscomp/core/lam_compile.mli | 4 +- jscomp/core/lam_compile_main.ml | 10 +- jscomp/core/lam_compile_primitive.ml | 63 +- jscomp/core/lam_compile_primitive.mli | 1 + jscomp/core/lam_convert.ml | 1 + jscomp/core/lam_primitive.ml | 2 + jscomp/core/lam_primitive.mli | 1 + jscomp/core/lam_print.ml | 1 + jscomp/frontend/ast_await.ml | 24 + jscomp/frontend/bs_builtin_ppx.ml | 44 +- jscomp/others/js.ml | 1 + jscomp/runtime/js.ml | 2 + jscomp/test/Import.js | 58 ++ jscomp/test/Import.res | 17 + jscomp/test/build.ninja | 3 +- jscomp/test/flow_parser_reg_test.js | 1288 ++++++++++++------------- lib/es6/belt_internalBuckets.js | 26 +- lib/js/belt_internalBuckets.js | 26 +- 22 files changed, 1024 insertions(+), 813 deletions(-) create mode 100644 jscomp/test/Import.js create mode 100644 jscomp/test/Import.res diff --git a/jscomp/core/js_packages_info.ml b/jscomp/core/js_packages_info.ml index 0dc4b52f495..eb37cfcce0e 100644 --- a/jscomp/core/js_packages_info.ml +++ b/jscomp/core/js_packages_info.ml @@ -84,6 +84,8 @@ let is_runtime_package (x : t) = x.name = Pkg_runtime let iter (x : t) cb = Ext_list.iter x.module_systems cb +let map (x : t) cb = Ext_list.map x.module_systems cb + (* let equal (x : t) ({name; module_systems}) = x.name = name && Ext_list.for_all2_no_exn diff --git a/jscomp/core/js_packages_info.mli b/jscomp/core/js_packages_info.mli index b5c8caefb5d..943c231bae4 100644 --- a/jscomp/core/js_packages_info.mli +++ b/jscomp/core/js_packages_info.mli @@ -46,6 +46,8 @@ val same_package_by_name : t -> t -> bool val iter : t -> (package_info -> unit) -> unit +val map : t -> (package_info -> 'a) -> 'a list + val empty : t val from_name : string -> t diff --git a/jscomp/core/lam_analysis.ml b/jscomp/core/lam_analysis.ml index 1280a17dc88..a810b9cc300 100644 --- a/jscomp/core/lam_analysis.ml +++ b/jscomp/core/lam_analysis.ml @@ -58,9 +58,9 @@ let rec no_side_effects (lam : Lam.t) : bool = | [ _; Lconst cst ] -> not_zero_constant cst | _ -> false) | Pcreate_extension _ | Pjs_typeof | Pis_null | Pis_not_none | Psome - | Psome_not_nest | Pis_undefined | Pis_null_undefined | Pnull_to_opt - | Pundefined_to_opt | Pnull_undefined_to_opt | Pjs_fn_make _ - | Pjs_object_create _ + | Psome_not_nest | Pis_undefined | Pis_null_undefined | Pimport + | Pnull_to_opt | Pundefined_to_opt | Pnull_undefined_to_opt + | Pjs_fn_make _ | Pjs_object_create _ (* TODO: check *) | Pbytes_to_string | Pmakeblock _ (* whether it's mutable or not *) diff --git a/jscomp/core/lam_compile.ml b/jscomp/core/lam_compile.ml index a4e925e63b3..69c47c0dfc3 100644 --- a/jscomp/core/lam_compile.ml +++ b/jscomp/core/lam_compile.ml @@ -179,10 +179,10 @@ type initialization = J.block non-toplevel, it will explode code very quickly *) let rec compile_external_field (* Like [List.empty]*) - (lamba_cxt : Lam_compile_context.t) (id : Ident.t) name : Js_output.t = + output_prefix (lamba_cxt : Lam_compile_context.t) (id : Ident.t) name : Js_output.t = match Lam_compile_env.query_external_id_info id name with | { persistent_closed_lambda = Some lam } when Lam_util.not_function lam -> - compile_lambda lamba_cxt lam + compile_lambda output_prefix lamba_cxt lam | _ -> Js_output.output_of_expression lamba_cxt.continuation ~no_effects:no_effects_const (E.ml_var_dot id name) @@ -214,7 +214,7 @@ let rec compile_external_field (* Like [List.empty]*) for the function, generative module or functor can be a function, however it can not be global -- global can only module *) -and compile_external_field_apply (appinfo : Lam.apply) (module_id : Ident.t) +and compile_external_field_apply output_prefix (appinfo : Lam.apply) (module_id : Ident.t) (field_name : string) (lambda_cxt : Lam_compile_context.t) : Js_output.t = let ident_info = Lam_compile_env.query_external_id_info module_id field_name @@ -227,7 +227,7 @@ and compile_external_field_apply (appinfo : Lam.apply) (module_id : Ident.t) let _, param_map = Lam_closure.is_closed_with_map Set_ident.empty params body in - compile_lambda lambda_cxt + compile_lambda output_prefix lambda_cxt (Lam_beta_reduce.propagate_beta_reduce_with_map lambda_cxt.meta param_map params body ap_args) | _ -> @@ -237,7 +237,7 @@ and compile_external_field_apply (appinfo : Lam.apply) (module_id : Ident.t) else let arg_cxt = { lambda_cxt with continuation = NeedValue Not_tail } in Ext_list.fold_right ap_args dummy (fun arg_lambda (args_code, args) -> - match compile_lambda arg_cxt arg_lambda with + match compile_lambda output_prefix arg_cxt arg_lambda with | { block; value = Some b } -> (Ext_list.append block args_code, b :: args) | _ -> assert false) @@ -266,7 +266,7 @@ and compile_external_field_apply (appinfo : Lam.apply) (module_id : Ident.t) here we share env *) -and compile_recursive_let ~all_bindings (cxt : Lam_compile_context.t) +and compile_recursive_let output_prefix ~all_bindings (cxt : Lam_compile_context.t) (id : Ident.t) (arg : Lam.t) : Js_output.t * initialization = match arg with | Lfunction { params; body; attr = { return_unit; async } } -> @@ -290,6 +290,7 @@ and compile_recursive_let ~all_bindings (cxt : Lam_compile_context.t) in let output = compile_lambda + output_prefix { cxt with continuation = @@ -329,7 +330,7 @@ and compile_recursive_let ~all_bindings (cxt : Lam_compile_context.t) [] ) | Lprim { primitive = Pmakeblock (_, _, _); args } when args_either_function_or_const args -> - (compile_lambda { cxt with continuation = Declare (Alias, id) } arg, []) + (compile_lambda output_prefix { cxt with continuation = Declare (Alias, id) } arg, []) (* case of lazy blocks, treat it as usual *) | Lprim { @@ -387,7 +388,7 @@ and compile_recursive_let ~all_bindings (cxt : Lam_compile_context.t) however it would affect scope issues, we have to declare it first *) match - compile_lambda { cxt with continuation = NeedValue Not_tail } arg + compile_lambda output_prefix { cxt with continuation = NeedValue Not_tail } arg with | { block = b; value = Some v } -> (* TODO: check recursive value .. @@ -424,15 +425,15 @@ and compile_recursive_let ~all_bindings (cxt : Lam_compile_context.t) fun _-> print_endline "hey"; v () ]} *) - (compile_lambda { cxt with continuation = Declare (Alias, id) } arg, []) + (compile_lambda output_prefix { cxt with continuation = Declare (Alias, id) } arg, []) -and compile_recursive_lets_aux cxt (id_args : Lam_scc.bindings) : Js_output.t = +and compile_recursive_lets_aux output_prefix cxt (id_args : Lam_scc.bindings) : Js_output.t = (* #1716 *) let output_code, ids = Ext_list.fold_right id_args (Js_output.dummy, []) (fun (ident, arg) (acc, ids) -> let code, declare_ids = - compile_recursive_let ~all_bindings:id_args cxt ident arg + compile_recursive_let output_prefix ~all_bindings:id_args cxt ident arg in (Js_output.append_output code acc, Ext_list.append declare_ids ids)) in @@ -440,7 +441,7 @@ and compile_recursive_lets_aux cxt (id_args : Lam_scc.bindings) : Js_output.t = | [] -> output_code | _ -> Js_output.append_output (Js_output.make ids) output_code -and compile_recursive_lets cxt id_args : Js_output.t = +and compile_recursive_lets output_prefix cxt id_args : Js_output.t = match id_args with | [] -> Js_output.dummy | _ -> ( @@ -448,12 +449,13 @@ and compile_recursive_lets cxt id_args : Js_output.t = match id_args_group with | [] -> assert false | first :: rest -> - let acc = compile_recursive_lets_aux cxt first in + let acc = compile_recursive_lets_aux output_prefix cxt first in Ext_list.fold_left rest acc (fun acc x -> - Js_output.append_output acc (compile_recursive_lets_aux cxt x))) + Js_output.append_output acc (compile_recursive_lets_aux output_prefix cxt x))) and compile_general_cases : 'a. + string -> ('a -> string option) -> ('a -> J.expression) -> (J.expression -> J.expression -> J.expression) -> @@ -467,7 +469,7 @@ and compile_general_cases : ('a * Lam.t) list -> default_case -> J.block = - fun (make_comment : _ -> string option) (make_exp : _ -> J.expression) + fun (output_prefix: string) (make_comment : _ -> string option) (make_exp : _ -> J.expression) (eq_exp : J.expression -> J.expression -> J.expression) (cxt : Lam_compile_context.t) (switch : @@ -478,7 +480,7 @@ and compile_general_cases : J.statement) (switch_exp : J.expression) (cases : (_ * Lam.t) list) (default : default_case) -> match (cases, default) with - | [], Default lam -> Js_output.output_as_block (compile_lambda cxt lam) + | [], Default lam -> Js_output.output_as_block (compile_lambda output_prefix cxt lam) | [], (Complete | NonComplete) -> [] | [ (_, lam) ], Complete -> (* To take advantage of such optimizations, @@ -487,18 +489,18 @@ and compile_general_cases : otherwise the compiler engine would think that it's also complete *) - Js_output.output_as_block (compile_lambda cxt lam) + Js_output.output_as_block (compile_lambda output_prefix cxt lam) | [ (id, lam) ], NonComplete -> morph_declare_to_assign cxt (fun cxt define -> [ S.if_ ?declaration:define (eq_exp switch_exp (make_exp id)) - (Js_output.output_as_block (compile_lambda cxt lam)); + (Js_output.output_as_block (compile_lambda output_prefix cxt lam)); ]) | [ (id, lam) ], Default x | [ (id, lam); (_, x) ], Complete -> morph_declare_to_assign cxt (fun cxt define -> - let else_block = Js_output.output_as_block (compile_lambda cxt x) in - let then_block = Js_output.output_as_block (compile_lambda cxt lam) in + let else_block = Js_output.output_as_block (compile_lambda output_prefix cxt x) in + let then_block = Js_output.output_as_block (compile_lambda output_prefix cxt lam) in [ S.if_ ?declaration:define (eq_exp switch_exp (make_exp id)) @@ -529,14 +531,14 @@ and compile_general_cases : | Complete -> None | NonComplete -> None | Default lam -> - Some (Js_output.output_as_block (compile_lambda cxt lam)) + Some (Js_output.output_as_block (compile_lambda output_prefix cxt lam)) in let body = group_apply cases (fun last (switch_case, lam) -> if last then (* merge and shared *) let switch_body, should_break = - Js_output.to_break_block (compile_lambda cxt lam) + Js_output.to_break_block (compile_lambda output_prefix cxt lam) in let should_break = if @@ -567,15 +569,15 @@ and compile_general_cases : [ switch ?default ?declaration switch_exp body ]) -and compile_cases cxt (switch_exp : E.t) table default get_name = - compile_general_cases get_name +and compile_cases output_prefix cxt (switch_exp : E.t) table default get_name = + compile_general_cases output_prefix get_name (fun i -> { (E.small_int i) with comment = get_name i }) E.int_equal cxt (fun ?default ?declaration e clauses -> S.int_switch ?default ?declaration e clauses) switch_exp table default -and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch) +and compile_switch output_prefix (switch_arg : Lam.t) (sw : Lam.lambda_switch) (lambda_cxt : Lam_compile_context.t) = (* TODO: if default is None, we can do some optimizations Use switch vs if/then/else @@ -603,24 +605,24 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch) let get_block_name i = get_block_name i sw_names in let compile_whole (cxt : Lam_compile_context.t) = match - compile_lambda { cxt with continuation = NeedValue Not_tail } switch_arg + compile_lambda output_prefix { cxt with continuation = NeedValue Not_tail } switch_arg with | { value = None; _ } -> assert false | { block; value = Some e } -> ( block @ if sw_consts_full && sw_consts = [] then - compile_cases cxt (E.tag e) sw_blocks sw_blocks_default get_block_name + compile_cases output_prefix cxt (E.tag e) sw_blocks sw_blocks_default get_block_name else if sw_blocks_full && sw_blocks = [] then - compile_cases cxt e sw_consts sw_num_default get_const_name + compile_cases output_prefix cxt e sw_consts sw_num_default get_const_name else (* [e] will be used twice *) let dispatch e = S.if_ (E.is_type_number e) - (compile_cases cxt e sw_consts sw_num_default get_const_name) + (compile_cases output_prefix cxt e sw_consts sw_num_default get_const_name) (* default still needed, could simplified*) ~else_: - (compile_cases cxt (E.tag e) sw_blocks sw_blocks_default + (compile_cases output_prefix cxt (E.tag e) sw_blocks sw_blocks_default get_block_name) in match e.expression_desc with @@ -648,8 +650,9 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch) :: compile_whole { lambda_cxt with continuation = Assign id }) | EffectCall _ | Assign _ -> Js_output.make (compile_whole lambda_cxt) -and compile_string_cases cxt switch_exp table default = +and compile_string_cases output_prefix cxt switch_exp table default = compile_general_cases + output_prefix (fun _ -> None) E.str E.string_equal cxt (fun ?default ?declaration e clauses -> @@ -658,13 +661,13 @@ and compile_string_cases cxt switch_exp table default = (* TODO: optional arguments are not good for high order currying *) -and compile_stringswitch l cases default (lambda_cxt : Lam_compile_context.t) = +and compile_stringswitch output_prefix l cases default (lambda_cxt : Lam_compile_context.t) = (* TODO might better optimization according to the number of cases Be careful: we should avoid multiple evaluation of l, The [gen] can be elimiated when number of [cases] is less than 3 *) match - compile_lambda { lambda_cxt with continuation = NeedValue Not_tail } l + compile_lambda output_prefix { lambda_cxt with continuation = NeedValue Not_tail } l with | { value = None } -> assert false | { block; value = Some e } -> ( @@ -679,14 +682,14 @@ and compile_stringswitch l cases default (lambda_cxt : Lam_compile_context.t) = let v = Ext_ident.create_tmp () in Js_output.make (Ext_list.append block - (compile_string_cases + (compile_string_cases output_prefix { lambda_cxt with continuation = Declare (Variable, v) } e cases default)) ~value:(E.var v) | _ -> Js_output.make (Ext_list.append block - (compile_string_cases lambda_cxt e cases default))) + (compile_string_cases output_prefix lambda_cxt e cases default))) (* This should be optimized in lambda layer @@ -698,7 +701,7 @@ and compile_stringswitch l cases default (lambda_cxt : Lam_compile_context.t) = default: (exit 1)) with (1) 2)) *) -and compile_staticraise i (largs : Lam.t list) +and compile_staticraise output_prefix i (largs : Lam.t list) (lambda_cxt : Lam_compile_context.t) = (* [i] is the jump table, [largs] is the arguments passed to [Lstaticcatch]*) match Lam_compile_context.find_exn lambda_cxt i with @@ -713,7 +716,7 @@ and compile_staticraise i (largs : Lam.t list) | Lvar id -> Js_output.make [ S.assign bind (E.var id) ] | _ -> (* TODO: should be Assign -- Assign is an optimization *) - compile_lambda + compile_lambda output_prefix { lambda_cxt with continuation = Assign bind } larg in @@ -748,7 +751,7 @@ and compile_staticraise i (largs : Lam.t list) ]} *) -and compile_staticcatch (lam : Lam.t) (lambda_cxt : Lam_compile_context.t) = +and compile_staticcatch output_prefix (lam : Lam.t) (lambda_cxt : Lam_compile_context.t) = let code_table, body = flatten_nested_caches lam in let exit_id = Ext_ident.create_tmp ~name:"exit" () in match (lambda_cxt.continuation, code_table) with @@ -770,13 +773,13 @@ and compile_staticcatch (lam : Lam.t) (lambda_cxt : Lam_compile_context.t) = } in - let lbody = compile_lambda new_cxt body in + let lbody = compile_lambda output_prefix new_cxt body in let declares = Ext_list.map code_table.bindings (fun x -> S.declare_variable ~kind:Variable x) in Js_output.append_output (Js_output.make declares) - (Js_output.append_output lbody (compile_lambda lambda_cxt handler)) + (Js_output.append_output lbody (compile_lambda output_prefix lambda_cxt handler)) | _ -> ( let exit_expr = E.var exit_id in let jmp_table, handlers = @@ -798,12 +801,12 @@ and compile_staticcatch (lam : Lam.t) (lambda_cxt : Lam_compile_context.t) = let new_cxt = { lambda_cxt with jmp_table; continuation = Assign v } in - let lbody = compile_lambda new_cxt body in + let lbody = compile_lambda output_prefix new_cxt body in Js_output.append_output (Js_output.make (S.declare_variable ~kind:Variable v :: declares)) (Js_output.append_output lbody (Js_output.make - (compile_cases new_cxt exit_expr handlers NonComplete + (compile_cases output_prefix new_cxt exit_expr handlers NonComplete (fun _ -> None)) ~value:(E.var v))) | Declare (kind, id) (* declare first this we will do branching*) -> @@ -811,11 +814,11 @@ and compile_staticcatch (lam : Lam.t) (lambda_cxt : Lam_compile_context.t) = let new_cxt = { lambda_cxt with jmp_table; continuation = Assign id } in - let lbody = compile_lambda new_cxt body in + let lbody = compile_lambda output_prefix new_cxt body in Js_output.append_output (Js_output.make declares) (Js_output.append_output lbody (Js_output.make - (compile_cases new_cxt exit_expr handlers NonComplete + (compile_cases output_prefix new_cxt exit_expr handlers NonComplete (fun _ -> None)))) (* place holder -- tell the compiler that we don't know if it's complete @@ -827,31 +830,31 @@ and compile_staticcatch (lam : Lam.t) (lambda_cxt : Lam_compile_context.t) = else EffectCall new_tail_type in let new_cxt = { lambda_cxt with jmp_table; continuation } in - let lbody = compile_lambda new_cxt body in + let lbody = compile_lambda output_prefix new_cxt body in Js_output.append_output (Js_output.make declares) (Js_output.append_output lbody (Js_output.make - (compile_cases new_cxt exit_expr handlers NonComplete + (compile_cases output_prefix new_cxt exit_expr handlers NonComplete (fun _ -> None)))) | Assign _ -> let new_cxt = { lambda_cxt with jmp_table } in - let lbody = compile_lambda new_cxt body in + let lbody = compile_lambda output_prefix new_cxt body in Js_output.append_output (Js_output.make declares) (Js_output.append_output lbody (Js_output.make - (compile_cases new_cxt exit_expr handlers NonComplete + (compile_cases output_prefix new_cxt exit_expr handlers NonComplete (fun _ -> None))))) -and compile_sequand (l : Lam.t) (r : Lam.t) (lambda_cxt : Lam_compile_context.t) +and compile_sequand output_prefix (l : Lam.t) (r : Lam.t) (lambda_cxt : Lam_compile_context.t) = if Lam_compile_context.continuation_is_return lambda_cxt.continuation then - compile_lambda lambda_cxt (Lam.sequand l r) + compile_lambda output_prefix lambda_cxt (Lam.sequand l r) else let new_cxt = { lambda_cxt with continuation = NeedValue Not_tail } in - match compile_lambda new_cxt l with + match compile_lambda output_prefix new_cxt l with | { value = None } -> assert false | { block = l_block; value = Some l_expr } -> ( - match compile_lambda new_cxt r with + match compile_lambda output_prefix new_cxt r with | { value = None } -> assert false | { block = []; value = Some r_expr } -> Js_output.output_of_block_and_expression lambda_cxt.continuation @@ -882,16 +885,16 @@ and compile_sequand (l : Lam.t) (r : Lam.t) (lambda_cxt : Lam_compile_context.t) @ [ S.if_ l_expr (r_block @ [ S.assign v r_expr ]) ]) ~value:(E.var v))) -and compile_sequor (l : Lam.t) (r : Lam.t) (lambda_cxt : Lam_compile_context.t) +and compile_sequor output_prefix (l : Lam.t) (r : Lam.t) (lambda_cxt : Lam_compile_context.t) = if Lam_compile_context.continuation_is_return lambda_cxt.continuation then - compile_lambda lambda_cxt (Lam.sequor l r) + compile_lambda output_prefix lambda_cxt (Lam.sequor l r) else let new_cxt = { lambda_cxt with continuation = NeedValue Not_tail } in - match compile_lambda new_cxt l with + match compile_lambda output_prefix new_cxt l with | { value = None } -> assert false | { block = l_block; value = Some l_expr } -> ( - match compile_lambda new_cxt r with + match compile_lambda output_prefix new_cxt r with | { value = None } -> assert false | { block = []; value = Some r_expr } -> let exp = E.or_ l_expr r_expr in @@ -930,10 +933,10 @@ and compile_sequor (l : Lam.t) (r : Lam.t) (lambda_cxt : Lam_compile_context.t) while expression, here we generate for statement, leave optimization later. (Sine OCaml expression can be really complex..) *) -and compile_while (predicate : Lam.t) (body : Lam.t) +and compile_while output_prefix (predicate : Lam.t) (body : Lam.t) (lambda_cxt : Lam_compile_context.t) = match - compile_lambda + compile_lambda output_prefix { lambda_cxt with continuation = NeedValue Not_tail } predicate with @@ -945,7 +948,7 @@ and compile_while (predicate : Lam.t) (body : Lam.t) [ S.while_ e (Js_output.output_as_block - @@ compile_lambda + @@ compile_lambda output_prefix { lambda_cxt with continuation = EffectCall Not_tail } body); ] @@ -965,12 +968,12 @@ and compile_while (predicate : Lam.t) (body : Lam.t) print i each time, so they are different semantics... *) -and compile_for (id : J.for_ident) (start : Lam.t) (finish : Lam.t) +and compile_for output_prefix (id : J.for_ident) (start : Lam.t) (finish : Lam.t) (direction : Js_op.direction_flag) (body : Lam.t) (lambda_cxt : Lam_compile_context.t) = let new_cxt = { lambda_cxt with continuation = NeedValue Not_tail } in let block = - match (compile_lambda new_cxt start, compile_lambda new_cxt finish) with + match (compile_lambda output_prefix new_cxt start, compile_lambda output_prefix new_cxt finish) with | { value = None }, _ | _, { value = None } -> assert false | { block = b1; value = Some e1 }, { block = b2; value = Some e2 } -> ( (* order b1 -- (e1 -- b2 -- e2) @@ -983,7 +986,7 @@ and compile_for (id : J.for_ident) (start : Lam.t) (finish : Lam.t) *) let block_body = Js_output.output_as_block - (compile_lambda + (compile_lambda output_prefix { lambda_cxt with continuation = EffectCall Not_tail } body) in @@ -1009,7 +1012,7 @@ and compile_for (id : J.for_ident) (start : Lam.t) (finish : Lam.t) in Js_output.output_of_block_and_expression lambda_cxt.continuation block E.unit -and compile_assign id (lambda : Lam.t) (lambda_cxt : Lam_compile_context.t) = +and compile_assign output_prefix id (lambda : Lam.t) (lambda_cxt : Lam_compile_context.t) = let block = match lambda with | Lprim { primitive = Poffsetint v; args = [ Lvar bid ] } @@ -1017,7 +1020,7 @@ and compile_assign id (lambda : Lam.t) (lambda_cxt : Lam_compile_context.t) = [ S.exp (E.assign (E.var id) (E.int32_add (E.var id) (E.small_int v))) ] | _ -> ( match - compile_lambda + compile_lambda output_prefix { lambda_cxt with continuation = NeedValue Not_tail } lambda with @@ -1040,16 +1043,16 @@ and compile_assign id (lambda : Lam.t) (lambda_cxt : Lam_compile_context.t) = } ]} *) -and compile_trywith lam id catch (lambda_cxt : Lam_compile_context.t) = +and compile_trywith output_prefix lam id catch (lambda_cxt : Lam_compile_context.t) = let aux (with_context : Lam_compile_context.t) (body_context : Lam_compile_context.t) = (* should_return is passed down #1701, try should prevent tailcall *) [ S.try_ - (Js_output.output_as_block (compile_lambda body_context lam)) + (Js_output.output_as_block (compile_lambda output_prefix body_context lam)) ~with_: - (id, Js_output.output_as_block (compile_lambda with_context catch)); + (id, Js_output.output_as_block (compile_lambda output_prefix with_context catch)); ] in match lambda_cxt.continuation with @@ -1116,10 +1119,10 @@ and compile_trywith lam id catch (lambda_cxt : Lam_compile_context.t) = mutable initializers: (obj -> unit) list } ]} *) -and compile_ifthenelse (predicate : Lam.t) (t_branch : Lam.t) (f_branch : Lam.t) +and compile_ifthenelse output_prefix (predicate : Lam.t) (t_branch : Lam.t) (f_branch : Lam.t) (lambda_cxt : Lam_compile_context.t) = match - compile_lambda + compile_lambda output_prefix { lambda_cxt with continuation = NeedValue Not_tail } predicate with @@ -1128,8 +1131,8 @@ and compile_ifthenelse (predicate : Lam.t) (t_branch : Lam.t) (f_branch : Lam.t) match lambda_cxt.continuation with | NeedValue _ -> ( match - ( compile_lambda lambda_cxt t_branch, - compile_lambda lambda_cxt f_branch ) + ( compile_lambda output_prefix lambda_cxt t_branch, + compile_lambda output_prefix lambda_cxt f_branch ) with | { block = []; value = Some out1 }, { block = []; value = Some out2 } -> @@ -1141,8 +1144,8 @@ and compile_ifthenelse (predicate : Lam.t) (t_branch : Lam.t) (f_branch : Lam.t) let id = Ext_ident.create_tmp () in let assign_cxt = { lambda_cxt with continuation = Assign id } in match - ( compile_lambda assign_cxt t_branch, - compile_lambda assign_cxt f_branch ) + ( compile_lambda output_prefix assign_cxt t_branch, + compile_lambda output_prefix assign_cxt f_branch ) with | out1, out2 -> Js_output.make @@ -1159,8 +1162,8 @@ and compile_ifthenelse (predicate : Lam.t) (t_branch : Lam.t) (f_branch : Lam.t) { lambda_cxt with continuation = NeedValue Not_tail } in match - ( compile_lambda declare_cxt t_branch, - compile_lambda declare_cxt f_branch ) + ( compile_lambda output_prefix declare_cxt t_branch, + compile_lambda output_prefix declare_cxt f_branch ) with | { block = []; value = Some out1 }, { block = []; value = Some out2 } -> @@ -1173,20 +1176,20 @@ and compile_ifthenelse (predicate : Lam.t) (t_branch : Lam.t) (f_branch : Lam.t) (Ext_list.append_one b (S.if_ ~declaration:(kind, id) e (Js_output.output_as_block - @@ compile_lambda + @@ compile_lambda output_prefix { lambda_cxt with continuation = Assign id } t_branch) ~else_: (Js_output.output_as_block - @@ compile_lambda + @@ compile_lambda output_prefix { lambda_cxt with continuation = Assign id } f_branch)))) | Assign _ -> let then_output = - Js_output.output_as_block (compile_lambda lambda_cxt t_branch) + Js_output.output_as_block (compile_lambda output_prefix lambda_cxt t_branch) in let else_output = - Js_output.output_as_block (compile_lambda lambda_cxt f_branch) + Js_output.output_as_block (compile_lambda output_prefix lambda_cxt f_branch) in Js_output.make (Ext_list.append_one b (S.if_ e then_output ~else_:else_output)) @@ -1196,8 +1199,8 @@ and compile_ifthenelse (predicate : Lam.t) (t_branch : Lam.t) (f_branch : Lam.t) in match ( should_return, - compile_lambda context1 t_branch, - compile_lambda context1 f_branch ) + compile_lambda output_prefix context1 t_branch, + compile_lambda output_prefix context1 f_branch ) with (* see PR#83 *) | ( Not_tail, @@ -1228,7 +1231,7 @@ and compile_ifthenelse (predicate : Lam.t) (t_branch : Lam.t) (f_branch : Lam.t) [ S.if_ (E.not e) (Js_output.output_as_block - @@ compile_lambda lambda_cxt f_branch); + @@ compile_lambda output_prefix lambda_cxt f_branch); ]) else Js_output.make @@ -1236,10 +1239,10 @@ and compile_ifthenelse (predicate : Lam.t) (t_branch : Lam.t) (f_branch : Lam.t) [ S.if_ e (Js_output.output_as_block - @@ compile_lambda lambda_cxt t_branch) + @@ compile_lambda output_prefix lambda_cxt t_branch) ~else_: (Js_output.output_as_block - @@ compile_lambda lambda_cxt f_branch); + @@ compile_lambda output_prefix lambda_cxt f_branch); ]) | Not_tail, _, { block = []; value = Some out2 } -> let else_ = @@ -1247,13 +1250,13 @@ and compile_ifthenelse (predicate : Lam.t) (t_branch : Lam.t) (f_branch : Lam.t) else Some (Js_output.output_as_block - (compile_lambda lambda_cxt f_branch)) + (compile_lambda output_prefix lambda_cxt f_branch)) in Js_output.make (Ext_list.append_one b (S.if_ e (Js_output.output_as_block - (compile_lambda lambda_cxt t_branch)) + (compile_lambda output_prefix lambda_cxt t_branch)) ?else_)) | ( Maybe_tail_is_return _, { block = []; value = Some out1 }, @@ -1263,16 +1266,16 @@ and compile_ifthenelse (predicate : Lam.t) (t_branch : Lam.t) (f_branch : Lam.t) ~output_finished:True | _, _, _ -> let then_output = - Js_output.output_as_block (compile_lambda lambda_cxt t_branch) + Js_output.output_as_block (compile_lambda output_prefix lambda_cxt t_branch) in let else_output = - Js_output.output_as_block (compile_lambda lambda_cxt f_branch) + Js_output.output_as_block (compile_lambda output_prefix lambda_cxt f_branch) in Js_output.make (Ext_list.append_one b (S.if_ e then_output ~else_:else_output)) )) -and compile_apply (appinfo : Lam.apply) (lambda_cxt : Lam_compile_context.t) = +and compile_apply output_prefix (appinfo : Lam.apply) (lambda_cxt : Lam_compile_context.t) = match appinfo with | { ap_func = @@ -1284,7 +1287,7 @@ and compile_apply (appinfo : Lam.apply) (lambda_cxt : Lam_compile_context.t) = if outer_ap_info.ap_inlined = ap_inlined then outer_ap_info else { outer_ap_info with ap_inlined } in - compile_lambda lambda_cxt + compile_lambda output_prefix lambda_cxt (Lam.apply ap_func (Ext_list.append ap_args appinfo.ap_args) ap_info) (* External function call: it can not be tailcall in this case*) | { @@ -1293,7 +1296,7 @@ and compile_apply (appinfo : Lam.apply) (lambda_cxt : Lam_compile_context.t) = } -> ( match fld_info with | Fld_module { name } -> - compile_external_field_apply appinfo id name lambda_cxt + compile_external_field_apply output_prefix appinfo id name lambda_cxt | _ -> assert false) | _ -> ( (* TODO: --- @@ -1306,7 +1309,7 @@ and compile_apply (appinfo : Lam.apply) (lambda_cxt : Lam_compile_context.t) = = Ext_list.fold_right (ap_func :: appinfo.ap_args) ([], []) (fun x (args_code, fn_code) -> - match compile_lambda new_cxt x with + match compile_lambda output_prefix new_cxt x with | { block; value = Some b } -> (Ext_list.append block args_code, b :: fn_code) | { value = None } -> assert false) @@ -1366,18 +1369,18 @@ and compile_apply (appinfo : Lam.apply) (lambda_cxt : Lam_compile_context.t) = ~info:(call_info_of_ap_status appinfo.ap_info.ap_status) fn_code args)) -and compile_prim (prim_info : Lam.prim_info) +and compile_prim output_prefix (prim_info : Lam.prim_info) (lambda_cxt : Lam_compile_context.t) = match prim_info with | { primitive = Pfield (_, fld_info); args = [ Lglobal_module id ]; _ } -> ( (* should be before Lglobal_global *) match fld_info with | Fld_module { name = field } -> - compile_external_field lambda_cxt id field + compile_external_field output_prefix lambda_cxt id field | _ -> assert false) | { primitive = Praise; args = [ e ]; _ } -> ( match - compile_lambda { lambda_cxt with continuation = NeedValue Not_tail } e + compile_lambda output_prefix { lambda_cxt with continuation = NeedValue Not_tail } e with | { block; value = Some v } -> Js_output.make @@ -1388,8 +1391,8 @@ and compile_prim (prim_info : Lam.prim_info) *) | { value = None } -> assert false) | { primitive = Psequand; args = [ l; r ]; _ } -> - compile_sequand l r lambda_cxt - | { primitive = Psequor; args = [ l; r ] } -> compile_sequor l r lambda_cxt + compile_sequand output_prefix l r lambda_cxt + | { primitive = Psequor; args = [ l; r ] } -> compile_sequor output_prefix l r lambda_cxt | { primitive = Pdebugger; _ } -> (* [%bs.debugger] guarantees that the expression does not matter TODO: make it even safer *) @@ -1409,7 +1412,7 @@ and compile_prim (prim_info : Lam.prim_info) assert (not setter); match - compile_lambda { lambda_cxt with continuation = NeedValue Not_tail } obj + compile_lambda output_prefix { lambda_cxt with continuation = NeedValue Not_tail } obj with | { value = None } -> assert false | { block; value = Some b } -> @@ -1438,8 +1441,8 @@ and compile_prim (prim_info : Lam.prim_info) let need_value_no_return_cxt = { lambda_cxt with continuation = NeedValue Not_tail } in - let obj_output = compile_lambda need_value_no_return_cxt obj in - let arg_output = compile_lambda need_value_no_return_cxt setter_val in + let obj_output = compile_lambda output_prefix need_value_no_return_cxt obj in + let arg_output = compile_lambda output_prefix need_value_no_return_cxt setter_val in let cont obj_block arg_block obj_code = Js_output.output_of_block_and_expression lambda_cxt.continuation (match obj_code with @@ -1471,7 +1474,7 @@ and compile_prim (prim_info : Lam.prim_info) *) match args with | fn :: rest -> - compile_lambda lambda_cxt + compile_lambda output_prefix lambda_cxt (Lam.apply fn rest { ap_loc = loc; @@ -1489,7 +1492,7 @@ and compile_prim (prim_info : Lam.prim_info) here we share env *) (Js_output.output_as_block - (compile_lambda + (compile_lambda output_prefix { lambda_cxt with continuation = @@ -1502,7 +1505,7 @@ and compile_prim (prim_info : Lam.prim_info) body))) | _ -> assert false) | { primitive = Pjs_fn_make arity; args = [ fn ]; loc } -> - compile_lambda lambda_cxt + compile_lambda output_prefix lambda_cxt (Lam_eta_conversion.unsafe_adjust_to_arity loc ~to_:arity ?from:None fn) | { primitive = Pjs_fn_make _; args = [] | _ :: _ :: _ } -> assert false | { primitive = Pjs_object_create labels; args } -> @@ -1511,7 +1514,7 @@ and compile_prim (prim_info : Lam.prim_info) else let new_cxt = { lambda_cxt with continuation = NeedValue Not_tail } in Ext_list.split_map args (fun x -> - match compile_lambda new_cxt x with + match compile_lambda output_prefix new_cxt x with | { block; value = Some b } -> (block, b) | { value = None } -> assert false) in @@ -1527,19 +1530,19 @@ and compile_prim (prim_info : Lam.prim_info) else let new_cxt = { lambda_cxt with continuation = NeedValue Not_tail } in Ext_list.split_map args (fun x -> - match compile_lambda new_cxt x with + match compile_lambda output_prefix new_cxt x with | { block; value = Some b } -> (block, b) | { value = None } -> assert false) in let args_code : J.block = List.concat args_block in let exp = (* TODO: all can be done in [compile_primitive] *) - Lam_compile_primitive.translate loc lambda_cxt primitive args_expr + Lam_compile_primitive.translate output_prefix loc lambda_cxt primitive args_expr in Js_output.output_of_block_and_expression lambda_cxt.continuation args_code exp -and compile_lambda (lambda_cxt : Lam_compile_context.t) (cur_lam : Lam.t) : +and compile_lambda output_prefix (lambda_cxt : Lam_compile_context.t) (cur_lam : Lam.t) : Js_output.t = match cur_lam with | Lfunction { params; body; attr = { return_unit; async } } -> @@ -1550,7 +1553,7 @@ and compile_lambda (lambda_cxt : Lam_compile_context.t) (cur_lam : Lam.t) : here we share env *) (Js_output.output_as_block - (compile_lambda + (compile_lambda output_prefix { lambda_cxt with continuation = @@ -1561,15 +1564,15 @@ and compile_lambda (lambda_cxt : Lam_compile_context.t) (cur_lam : Lam.t) : jmp_table = Lam_compile_context.empty_handler_map; } body))) - | Lapply appinfo -> compile_apply appinfo lambda_cxt + | Lapply appinfo -> compile_apply output_prefix appinfo lambda_cxt | Llet (let_kind, id, arg, body) -> (* Order matters.. see comment below in [Lletrec] *) let args_code = - compile_lambda + compile_lambda output_prefix { lambda_cxt with continuation = Declare (let_kind, id) } arg in - Js_output.append_output args_code (compile_lambda lambda_cxt body) + Js_output.append_output args_code (compile_lambda output_prefix lambda_cxt body) | Lletrec (id_args, body) -> (* There is a bug in our current design, it requires compile args first (register that some objects are jsidentifiers) @@ -1582,8 +1585,8 @@ and compile_lambda (lambda_cxt : Lam_compile_context.t) (cur_lam : Lam.t) : 1. scan the lambda layer first, register js identifier before proceeding 2. delay the method call into javascript ast *) - let v = compile_recursive_lets lambda_cxt id_args in - Js_output.append_output v (compile_lambda lambda_cxt body) + let v = compile_recursive_lets output_prefix lambda_cxt id_args in + Js_output.append_output v (compile_lambda output_prefix lambda_cxt body) | Lvar id -> Js_output.output_of_expression lambda_cxt.continuation ~no_effects:no_effects_const (E.var id) @@ -1598,21 +1601,21 @@ and compile_lambda (lambda_cxt : Lam_compile_context.t) (cur_lam : Lam.t) : *) Js_output.output_of_block_and_expression lambda_cxt.continuation [] (E.ml_module_as_var i) - | Lprim prim_info -> compile_prim prim_info lambda_cxt + | Lprim prim_info -> compile_prim output_prefix prim_info lambda_cxt | Lsequence (l1, l2) -> let output_l1 = - compile_lambda { lambda_cxt with continuation = EffectCall Not_tail } l1 + compile_lambda output_prefix { lambda_cxt with continuation = EffectCall Not_tail } l1 in - let output_l2 = compile_lambda lambda_cxt l2 in + let output_l2 = compile_lambda output_prefix lambda_cxt l2 in Js_output.append_output output_l1 output_l2 | Lifthenelse (predicate, t_branch, f_branch) -> - compile_ifthenelse predicate t_branch f_branch lambda_cxt + compile_ifthenelse output_prefix predicate t_branch f_branch lambda_cxt | Lstringswitch (l, cases, default) -> - compile_stringswitch l cases default lambda_cxt - | Lswitch (switch_arg, sw) -> compile_switch switch_arg sw lambda_cxt - | Lstaticraise (i, largs) -> compile_staticraise i largs lambda_cxt - | Lstaticcatch _ -> compile_staticcatch cur_lam lambda_cxt - | Lwhile (p, body) -> compile_while p body lambda_cxt + compile_stringswitch output_prefix l cases default lambda_cxt + | Lswitch (switch_arg, sw) -> compile_switch output_prefix switch_arg sw lambda_cxt + | Lstaticraise (i, largs) -> compile_staticraise output_prefix i largs lambda_cxt + | Lstaticcatch _ -> compile_staticcatch output_prefix cur_lam lambda_cxt + | Lwhile (p, body) -> compile_while output_prefix p body lambda_cxt | Lfor (id, start, finish, direction, body) -> ( match (direction, finish) with | ( Upto, @@ -1622,12 +1625,12 @@ and compile_lambda (lambda_cxt : Lam_compile_context.t) (cur_lam : Lam.t) : args = [ new_finish; Lconst (Const_int { i = 1l }) ]; } | Lprim { primitive = Poffsetint -1; args = [ new_finish ] } ) ) -> - compile_for id start new_finish Up body lambda_cxt + compile_for output_prefix id start new_finish Up body lambda_cxt | _ -> - compile_for id start finish + compile_for output_prefix id start finish (if direction = Upto then Upto else Downto) body lambda_cxt) - | Lassign (id, lambda) -> compile_assign id lambda lambda_cxt + | Lassign (id, lambda) -> compile_assign output_prefix id lambda lambda_cxt | Ltrywith (lam, id, catch) -> (* generate documentation *) - compile_trywith lam id catch lambda_cxt + compile_trywith output_prefix lam id catch lambda_cxt diff --git a/jscomp/core/lam_compile.mli b/jscomp/core/lam_compile.mli index fd40a4bf1f9..ad12c5a0159 100644 --- a/jscomp/core/lam_compile.mli +++ b/jscomp/core/lam_compile.mli @@ -25,6 +25,6 @@ (** Compile single lambda IR to JS IR *) val compile_recursive_lets : - Lam_compile_context.t -> (Ident.t * Lam.t) list -> Js_output.t + string -> Lam_compile_context.t -> (Ident.t * Lam.t) list -> Js_output.t -val compile_lambda : Lam_compile_context.t -> Lam.t -> Js_output.t +val compile_lambda : string -> Lam_compile_context.t -> Lam.t -> Js_output.t diff --git a/jscomp/core/lam_compile_main.ml b/jscomp/core/lam_compile_main.ml index 8a0d3a4ea2e..51a6f025615 100644 --- a/jscomp/core/lam_compile_main.ml +++ b/jscomp/core/lam_compile_main.ml @@ -33,7 +33,7 @@ (* module S = Js_stmt_make *) -let compile_group (meta : Lam_stats.t) +let compile_group output_prefix (meta : Lam_stats.t) (x : Lam_group.t) : Js_output.t = match x with (* @@ -60,20 +60,20 @@ let compile_group (meta : Lam_stats.t) (* let lam = Optimizer.simplify_lets [] lam in *) (* can not apply again, it's wrong USE it with care*) (* ([Js_stmt_make.comment (Gen_of_env.query_type id env )], None) ++ *) - Lam_compile.compile_lambda { continuation = Declare (kind, id); + Lam_compile.compile_lambda output_prefix { continuation = Declare (kind, id); jmp_table = Lam_compile_context.empty_handler_map; meta } lam | Recursive id_lams -> - Lam_compile.compile_recursive_lets + Lam_compile.compile_recursive_lets output_prefix { continuation = EffectCall Not_tail; jmp_table = Lam_compile_context.empty_handler_map; meta } id_lams | Nop lam -> (* TODO: Side effect callls, log and see statistics *) - Lam_compile.compile_lambda {continuation = EffectCall Not_tail; + Lam_compile.compile_lambda output_prefix {continuation = EffectCall Not_tail; jmp_table = Lam_compile_context.empty_handler_map; meta } lam @@ -222,7 +222,7 @@ let maybe_pure = no_side_effects groups in let () = Ext_log.dwarn ~__POS__ "\n@[[TIME:]Pre-compile: %f@]@." (Sys.time () *. 1000.) in #endif let body = - Ext_list.map groups (fun group -> compile_group meta group) + Ext_list.map groups (fun group -> compile_group output_prefix meta group) |> Js_output.concat |> Js_output.output_as_block in diff --git a/jscomp/core/lam_compile_primitive.ml b/jscomp/core/lam_compile_primitive.ml index 17932ff6db8..4fac71d8a4a 100644 --- a/jscomp/core/lam_compile_primitive.ml +++ b/jscomp/core/lam_compile_primitive.ml @@ -36,8 +36,43 @@ let ensure_value_unit (st : Lam_compile_context.continuation) e : E.t = | EffectCall Not_tail -> e (* NeedValue should return a meaningful expression*) -let translate loc (cxt : Lam_compile_context.t) (prim : Lam_primitive.t) - (args : J.expression list) : J.expression = +let module_of_expression = function + | J.Var (J.Qualified (module_id, value)) -> [ (module_id, value) ] + | _ -> [] + +let get_module_system () = + let packages_info = Js_packages_state.get_packages_info () in + let module_systems = + Js_packages_info.map packages_info (fun { module_system } -> module_system) + in + match module_systems with + (* fixme: test mode where the module system is empty *) + | [] -> assert false + | module_system :: _rest -> module_system + +let import_of_path path = + E.call + ~info:{ arity = Full; call_info = Call_na } + (E.js_global "import") + [ E.str path ] + +let wrap_then import value = + let arg = Ident.create "m" in + E.call + ~info:{ arity = Full; call_info = Call_na } + (E.dot import "then") + [ + E.ocaml_fun ~return_unit:false ~async:false [ arg ] + [ + { + statement_desc = J.Return (E.dot (E.var arg) value); + comment = None; + }; + ]; + ] + +let translate output_prefix loc (cxt : Lam_compile_context.t) + (prim : Lam_primitive.t) (args : J.expression list) : J.expression = match prim with | Pis_not_none -> Js_of_lam_option.is_not_none (Ext_list.singleton_exn args) | Pcreate_extension s -> E.make_exception s @@ -78,6 +113,27 @@ let translate loc (cxt : Lam_compile_context.t) (prim : Lam_primitive.t) | _ -> E.runtime_call Js_runtime_modules.option "nullable_to_opt" args ) | _ -> assert false) + | Pimport -> ( + match args with + | [ e ] -> ( + let output_dir = Filename.dirname output_prefix in + + let module_id, module_value = + match module_of_expression e.expression_desc with + | [ module_ ] -> module_ + | _ -> assert false + (* TODO: graceful error message here *) + in + + let path = + Js_name_of_module_id.string_of_module_id module_id ~output_dir + (get_module_system ()) + in + + match module_value with + | Some value -> wrap_then (import_of_path path) value + | None -> import_of_path path) + | _ -> assert false) | Pjs_function_length -> E.function_length (Ext_list.singleton_exn args) | Pcaml_obj_length -> E.obj_length (Ext_list.singleton_exn args) | Pis_null -> E.is_null (Ext_list.singleton_exn args) @@ -301,7 +357,8 @@ let translate loc (cxt : Lam_compile_context.t) (prim : Lam_primitive.t) | Backend_type -> E.make_block E.zero_int_literal (Blk_constructor { name = "Other"; num_nonconst = 1; tag = 0 }) - [ E.str "BS" ] Immutable) + [ E.str "BS" ] + Immutable) | Pduprecord -> Lam_dispatch_primitive.translate loc "?obj_dup" args | Plazyforce (* FIXME: we don't inline lazy force or at least diff --git a/jscomp/core/lam_compile_primitive.mli b/jscomp/core/lam_compile_primitive.mli index 4ffe2c41989..b507f63b1cf 100644 --- a/jscomp/core/lam_compile_primitive.mli +++ b/jscomp/core/lam_compile_primitive.mli @@ -29,6 +29,7 @@ *) val translate : + string -> Location.t -> Lam_compile_context.t -> Lam_primitive.t -> diff --git a/jscomp/core/lam_convert.ml b/jscomp/core/lam_convert.ml index add8745cbc2..54bd8377796 100644 --- a/jscomp/core/lam_convert.ml +++ b/jscomp/core/lam_convert.ml @@ -480,6 +480,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : | "#nullable_to_opt" -> Pnull_undefined_to_opt | "#null_to_opt" -> Pnull_to_opt | "#is_nullable" -> Pis_null_undefined + | "#import" ->Pimport | "#string_append" -> Pstringadd | "#wrap_exn" -> Pwrap_exn | "#obj_length" -> Pcaml_obj_length diff --git a/jscomp/core/lam_primitive.ml b/jscomp/core/lam_primitive.ml index f840888f8c2..733b94dfb95 100644 --- a/jscomp/core/lam_primitive.ml +++ b/jscomp/core/lam_primitive.ml @@ -142,6 +142,7 @@ type t = | Pis_null | Pis_undefined | Pis_null_undefined + | Pimport | Pjs_typeof | Pjs_function_length | Pcaml_obj_length @@ -218,6 +219,7 @@ let eq_primitive_approx (lhs : t) (rhs : t) = | Psome_not_nest -> rhs = Psome_not_nest | Pis_undefined -> rhs = Pis_undefined | Pis_null_undefined -> rhs = Pis_null_undefined + | Pimport -> rhs = Pimport | Pjs_typeof -> rhs = Pjs_typeof | Pisint -> rhs = Pisint | Pis_poly_var_block -> rhs = Pis_poly_var_block diff --git a/jscomp/core/lam_primitive.mli b/jscomp/core/lam_primitive.mli index d26119f0925..421e3dca95e 100644 --- a/jscomp/core/lam_primitive.mli +++ b/jscomp/core/lam_primitive.mli @@ -130,6 +130,7 @@ type t = | Pis_null | Pis_undefined | Pis_null_undefined + | Pimport | Pjs_typeof | Pjs_function_length | Pcaml_obj_length diff --git a/jscomp/core/lam_print.ml b/jscomp/core/lam_print.ml index b6cb43989a0..39276633fa5 100644 --- a/jscomp/core/lam_print.ml +++ b/jscomp/core/lam_print.ml @@ -78,6 +78,7 @@ let primitive ppf (prim : Lam_primitive.t) = | Pval_from_option_not_nest -> fprintf ppf "[?unbox-not-nest]" | Pis_undefined -> fprintf ppf "[?undefined]" | Pis_null_undefined -> fprintf ppf "[?null?undefined]" + | Pimport -> fprintf ppf "[import]" | Pmakeblock (tag, _, Immutable) -> fprintf ppf "makeblock %i" tag | Pmakeblock (tag, _, Mutable) -> fprintf ppf "makemutable %i" tag | Pfield (n, field_info) -> ( diff --git a/jscomp/frontend/ast_await.ml b/jscomp/frontend/ast_await.ml index ac7305878ed..a6857d728da 100644 --- a/jscomp/frontend/ast_await.ml +++ b/jscomp/frontend/ast_await.ml @@ -5,3 +5,27 @@ let create_await_expression (e : Parsetree.expression) = { txt = Ldot (Ldot (Lident "Js", "Promise"), "unsafe_await"); loc } in Ast_helper.Exp.apply ~loc unsafe_await [ (Nolabel, e) ] + +let create_await_module_expression ~module_type_name (e : Parsetree.module_expr) + = + let open Ast_helper in + { + e with + pmod_desc = + Pmod_unpack + (create_await_expression + (Exp.apply + (Exp.ident ~loc:e.pmod_loc + { + txt = Longident.Ldot (Lident "Js", "import"); + loc = e.pmod_loc; + }) + [ + ( Nolabel, + Exp.constraint_ ~loc:e.pmod_loc + (Exp.pack ~loc:e.pmod_loc e) + (Typ.package ~loc:e.pmod_loc + { txt = Lident module_type_name; loc = e.pmod_loc } + []) ); + ])); + } diff --git a/jscomp/frontend/bs_builtin_ppx.ml b/jscomp/frontend/bs_builtin_ppx.ml index 17a4487decf..a7639b0dc36 100644 --- a/jscomp/frontend/bs_builtin_ppx.ml +++ b/jscomp/frontend/bs_builtin_ppx.ml @@ -227,9 +227,9 @@ let expr_mapper ~async_context ~in_function_def (self : mapper) match Ast_attributes.has_await_payload e.pexp_attributes with | None -> result | Some _ -> - if !async_context = false then - Location.raise_errorf ~loc:e.pexp_loc - "Await on expression not in an async context"; + (* if !async_context = false then + Location.raise_errorf ~loc:e.pexp_loc + "Await on expression not in an async context"; *) Ast_await.create_await_expression result let typ_mapper (self : mapper) (typ : Parsetree.core_type) = @@ -434,6 +434,13 @@ let local_module_name = incr v; "local_" ^ string_of_int !v +let local_module_type_name = + let v = ref 0 in + fun ({ txt } : Longident.t Location.loc) -> + incr v; + (Longident.flatten txt |> List.fold_left (fun ll l -> ll ^ l) "") + ^ string_of_int !v + let expand_reverse (stru : Ast_structure.t) (acc : Ast_structure.t) : Ast_structure.t = if stru = [] then acc @@ -497,6 +504,37 @@ let rec structure_mapper (self : mapper) (stru : Ast_structure.t) = | _ -> expand_reverse acc (structure_mapper self rest) in aux [] stru + | Pstr_module + ({ + pmb_expr = + { pmod_desc = Pmod_ident { txt; loc }; pmod_attributes } as me; + } as mb) + (* module M = @res.await Belt.List *) + when Res_parsetree_viewer.hasAwaitAttribute pmod_attributes -> + let item = self.structure_item self item in + let safe_module_type_name = local_module_type_name { txt; loc } in + let module_type_decl = + let open Ast_helper in + Str.modtype ~loc + (Mtd.mk ~loc + { txt = safe_module_type_name; loc } + ~typ:(Mty.typeof_ ~loc me)) + in + (* module BeltList0 = module type of Belt.List *) + module_type_decl + :: { + item with + pstr_desc = + Pstr_module + { + mb with + pmb_expr = + Ast_await.create_await_module_expression + ~module_type_name:safe_module_type_name mb.pmb_expr; + }; + } + (* module M = @res.await Belt.List *) + :: structure_mapper self rest | _ -> self.structure_item self item :: structure_mapper self rest) let mapper : mapper = diff --git a/jscomp/others/js.ml b/jscomp/others/js.ml index c8203dad146..90b8c288335 100644 --- a/jscomp/others/js.ml +++ b/jscomp/others/js.ml @@ -107,6 +107,7 @@ external toOption : 'a nullable -> 'a option = "#nullable_to_opt" external undefinedToOption : 'a undefined -> 'a option = "#undefined_to_opt" external nullToOption : 'a null -> 'a option = "#null_to_opt" external isNullable : 'a nullable -> bool = "#is_nullable" +external import : 'a -> 'a promise = "#import" external testAny : 'a -> bool = "#is_nullable" (** The same as {!test} except that it is more permissive on the types of input *) diff --git a/jscomp/runtime/js.ml b/jscomp/runtime/js.ml index 7ed38a60580..dacc4aceca0 100644 --- a/jscomp/runtime/js.ml +++ b/jscomp/runtime/js.ml @@ -78,6 +78,8 @@ external nullToOption : 'a null -> 'a option = "#null_to_opt" external isNullable : 'a nullable -> bool = "#is_nullable" +external import : 'a -> 'a promise = "#import" + (** The same as {!test} except that it is more permissive on the types of input *) external testAny : 'a -> bool = "#is_nullable" diff --git a/jscomp/test/Import.js b/jscomp/test/Import.js new file mode 100644 index 00000000000..a21d912bf11 --- /dev/null +++ b/jscomp/test/Import.js @@ -0,0 +1,58 @@ +'use strict'; + +var Curry = require("../../lib/js/curry.js"); + +async function eachIntAsync(list, f) { + return Curry._2(await import("../../lib/js/belt_List.js").then(function (m) { + return m.forEach; + }), list, f); +} + +function eachIntLazy(list, f) { + var obj = import("../../lib/js/belt_List.js").then(function (m) { + return m.forEach; + }); + var arg1 = function (each) { + return Promise.resolve(Curry._2(each, list, f)); + }; + return obj.then(arg1); +} + +eachIntLazy({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, (function (n) { + console.log("lazy", n); + })); + +eachIntAsync({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, (function (n) { + console.log("async", n); + })); + +var beltAsModule = import("../../lib/js/belt_List.js"); + +var M = await import("../../lib/js/belt_List.js"); + +var each = M.forEach; + +exports.eachIntAsync = eachIntAsync; +exports.eachIntLazy = eachIntLazy; +exports.beltAsModule = beltAsModule; +exports.M = M; +exports.each = each; +/* Not a pure module */ diff --git a/jscomp/test/Import.res b/jscomp/test/Import.res new file mode 100644 index 00000000000..c0ac165d05c --- /dev/null +++ b/jscomp/test/Import.res @@ -0,0 +1,17 @@ +let eachIntAsync = async (list: list, f: int => unit) => { + list->(await Js.import(Belt.List.forEach))(f) +} + +let eachIntLazy = (list: list, f: int => unit) => + Js.import(Belt.List.forEach) |> Js.Promise.then_(each => list->each(f)->Js.Promise.resolve) + +let _ = list{1, 2, 3}->eachIntLazy(n => Js.log2("lazy", n)) +let _ = list{1, 2, 3}->eachIntAsync(n => Js.log2("async", n)) + +module type BeltList = module type of Belt.List +let beltAsModule = Js.import(module(Belt.List: BeltList)) + +// module type BeltList0 = module type of Belt.List +// module M = unpack(@res.await Js.import(module(Belt.List: BeltList0))) +module M = @res.await Belt.List +let each = M.forEach \ No newline at end of file diff --git a/jscomp/test/build.ninja b/jscomp/test/build.ninja index 704df55b23f..cf97b64dd9d 100644 --- a/jscomp/test/build.ninja +++ b/jscomp/test/build.ninja @@ -20,6 +20,7 @@ o test/number_lexer.ml : mll test/number_lexer.mll o test/simple_lexer_test.ml : mll test/simple_lexer_test.mll o test/406_primitive_test.cmi test/406_primitive_test.cmj : cc test/406_primitive_test.ml | test/mt.cmj $bsc $stdlib runtime o test/EmptyRecord.cmi test/EmptyRecord.cmj : cc test/EmptyRecord.res | $bsc $stdlib runtime +o test/Import.cmi test/Import.cmj : cc test/Import.res | $bsc $stdlib runtime o test/SafePromises.cmi test/SafePromises.cmj : cc test/SafePromises.res | $bsc $stdlib runtime o test/UncurriedExternals.cmi test/UncurriedExternals.cmj : cc test/UncurriedExternals.res | $bsc $stdlib runtime o test/a.cmi test/a.cmj : cc test/a.ml | test/test_order.cmj $bsc $stdlib runtime @@ -720,4 +721,4 @@ o test/utf8_decode_test.cmi test/utf8_decode_test.cmj : cc test/utf8_decode_test o test/variant.cmi test/variant.cmj : cc test/variant.ml | $bsc $stdlib runtime o test/watch_test.cmi test/watch_test.cmj : cc test/watch_test.ml | $bsc $stdlib runtime o test/webpack_config.cmi test/webpack_config.cmj : cc test/webpack_config.ml | $bsc $stdlib runtime -o test : phony test/406_primitive_test.cmi test/406_primitive_test.cmj test/EmptyRecord.cmi test/EmptyRecord.cmj test/SafePromises.cmi test/SafePromises.cmj test/UncurriedExternals.cmi test/UncurriedExternals.cmj test/a.cmi test/a.cmj test/a_filename_test.cmi test/a_filename_test.cmj test/a_list_test.cmi test/a_list_test.cmj test/a_recursive_type.cmi test/a_recursive_type.cmj test/a_scope_bug.cmi test/a_scope_bug.cmj test/a_string_test.cmi test/a_string_test.cmj test/abstract_type.cmi test/abstract_type.cmj test/adt_optimize_test.cmi test/adt_optimize_test.cmj test/alias_test.cmi test/alias_test.cmj test/and_or_tailcall_test.cmi test/and_or_tailcall_test.cmj test/app_root_finder.cmi test/app_root_finder.cmj test/argv_test.cmi test/argv_test.cmj test/ari_regress_test.cmi test/ari_regress_test.cmj test/arith_lexer.cmi test/arith_lexer.cmj test/arith_parser.cmi test/arith_parser.cmj test/arith_syntax.cmi test/arith_syntax.cmj test/arity.cmi test/arity.cmj test/arity_deopt.cmi test/arity_deopt.cmj test/arity_infer.cmi test/arity_infer.cmj test/array_data_util.cmi test/array_data_util.cmj test/array_safe_get.cmi test/array_safe_get.cmj test/array_subtle_test.cmi test/array_subtle_test.cmj test/array_test.cmi test/array_test.cmj test/ast_abstract_test.cmi test/ast_abstract_test.cmj test/ast_js_mapper_poly_test.cmi test/ast_js_mapper_poly_test.cmj test/ast_js_mapper_test.cmi test/ast_js_mapper_test.cmj test/ast_mapper_defensive_test.cmi test/ast_mapper_defensive_test.cmj test/ast_mapper_unused_warning_test.cmi test/ast_mapper_unused_warning_test.cmj test/async_await.cmi test/async_await.cmj test/async_ideas.cmi test/async_ideas.cmj test/async_inline.cmi test/async_inline.cmj test/attr_test.cmi test/attr_test.cmj test/b.cmi test/b.cmj test/bal_set_mini.cmi test/bal_set_mini.cmj test/bang_primitive.cmi test/bang_primitive.cmj test/basic_module_test.cmi test/basic_module_test.cmj test/bb.cmi test/bb.cmj test/bdd.cmi test/bdd.cmj test/belt_internal_test.cmi test/belt_internal_test.cmj test/belt_result_alias_test.cmi test/belt_result_alias_test.cmj test/bench.cmi test/bench.cmj test/big_enum.cmi test/big_enum.cmj test/big_polyvar_test.cmi test/big_polyvar_test.cmj test/block_alias_test.cmi test/block_alias_test.cmj test/boolean_test.cmi test/boolean_test.cmj test/bs_MapInt_test.cmi test/bs_MapInt_test.cmj test/bs_abstract_test.cmi test/bs_abstract_test.cmj test/bs_array_test.cmi test/bs_array_test.cmj test/bs_auto_uncurry.cmi test/bs_auto_uncurry.cmj test/bs_auto_uncurry_test.cmi test/bs_auto_uncurry_test.cmj test/bs_float_test.cmi test/bs_float_test.cmj test/bs_hashmap_test.cmi test/bs_hashmap_test.cmj test/bs_hashset_int_test.cmi test/bs_hashset_int_test.cmj test/bs_hashtbl_string_test.cmi test/bs_hashtbl_string_test.cmj test/bs_ignore_effect.cmi test/bs_ignore_effect.cmj test/bs_ignore_test.cmi test/bs_ignore_test.cmj test/bs_int_test.cmi test/bs_int_test.cmj test/bs_list_test.cmi test/bs_list_test.cmj test/bs_map_set_dict_test.cmi test/bs_map_set_dict_test.cmj test/bs_map_test.cmi test/bs_map_test.cmj test/bs_min_max_test.cmi test/bs_min_max_test.cmj test/bs_mutable_set_test.cmi test/bs_mutable_set_test.cmj test/bs_node_string_buffer_test.cmi test/bs_node_string_buffer_test.cmj test/bs_poly_map_test.cmi test/bs_poly_map_test.cmj test/bs_poly_mutable_map_test.cmi test/bs_poly_mutable_map_test.cmj test/bs_poly_mutable_set_test.cmi test/bs_poly_mutable_set_test.cmj test/bs_poly_set_test.cmi test/bs_poly_set_test.cmj test/bs_qualified.cmi test/bs_qualified.cmj test/bs_queue_test.cmi test/bs_queue_test.cmj test/bs_rbset_int_bench.cmi test/bs_rbset_int_bench.cmj test/bs_rest_test.cmi test/bs_rest_test.cmj test/bs_set_bench.cmi test/bs_set_bench.cmj test/bs_set_int_test.cmi test/bs_set_int_test.cmj test/bs_sort_test.cmi test/bs_sort_test.cmj test/bs_splice_partial.cmi test/bs_splice_partial.cmj test/bs_stack_test.cmi test/bs_stack_test.cmj test/bs_string_test.cmi test/bs_string_test.cmj test/bs_unwrap_test.cmi test/bs_unwrap_test.cmj test/buffer_test.cmi test/buffer_test.cmj test/bytes_split_gpr_743_test.cmi test/bytes_split_gpr_743_test.cmj test/caml_compare_test.cmi test/caml_compare_test.cmj test/caml_format_test.cmi test/caml_format_test.cmj test/caml_sys_poly_fill_test.cmi test/caml_sys_poly_fill_test.cmj test/chain_code_test.cmi test/chain_code_test.cmj test/chn_test.cmi test/chn_test.cmj test/class_type_ffi_test.cmi test/class_type_ffi_test.cmj test/coercion_module_alias_test.cmi test/coercion_module_alias_test.cmj test/compare_test.cmi test/compare_test.cmj test/complete_parmatch_test.cmi test/complete_parmatch_test.cmj test/complex_if_test.cmi test/complex_if_test.cmj test/complex_test.cmi test/complex_test.cmj test/complex_while_loop.cmi test/complex_while_loop.cmj test/condition_compilation_test.cmi test/condition_compilation_test.cmj test/config1_test.cmi test/config1_test.cmj test/console_log_test.cmi test/console_log_test.cmj test/const_block_test.cmi test/const_block_test.cmj test/const_defs.cmi test/const_defs.cmj test/const_defs_test.cmi test/const_defs_test.cmj test/const_test.cmi test/const_test.cmj test/cont_int_fold_test.cmi test/cont_int_fold_test.cmj test/cps_test.cmi test/cps_test.cmj test/cross_module_inline_test.cmi test/cross_module_inline_test.cmj test/custom_error_test.cmi test/custom_error_test.cmj test/debug_keep_test.cmi test/debug_keep_test.cmj test/debug_mode_value.cmi test/debug_mode_value.cmj test/debug_tmp.cmi test/debug_tmp.cmj test/debugger_test.cmi test/debugger_test.cmj test/default_export_test.cmi test/default_export_test.cmj test/defunctor_make_test.cmi test/defunctor_make_test.cmj test/demo_int_map.cmi test/demo_int_map.cmj test/demo_page.cmi test/demo_page.cmj test/demo_pipe.cmi test/demo_pipe.cmj test/derive_dyntype.cmi test/derive_dyntype.cmj test/derive_projector_test.cmi test/derive_projector_test.cmj test/derive_type_test.cmi test/derive_type_test.cmj test/digest_test.cmi test/digest_test.cmj test/div_by_zero_test.cmi test/div_by_zero_test.cmj test/dollar_escape_test.cmi test/dollar_escape_test.cmj test/earger_curry_test.cmi test/earger_curry_test.cmj test/effect.cmi test/effect.cmj test/epsilon_test.cmi test/epsilon_test.cmj test/equal_box_test.cmi test/equal_box_test.cmj test/equal_exception_test.cmi test/equal_exception_test.cmj test/equal_test.cmi test/equal_test.cmj test/es6_export.cmi test/es6_export.cmj test/es6_import.cmi test/es6_import.cmj test/es6_module_test.cmi test/es6_module_test.cmj test/escape_esmodule.cmi test/escape_esmodule.cmj test/esmodule_ref.cmi test/esmodule_ref.cmj test/event_ffi.cmi test/event_ffi.cmj test/exception_alias.cmi test/exception_alias.cmj test/exception_def.cmi test/exception_def.cmj test/exception_raise_test.cmi test/exception_raise_test.cmj test/exception_rebind_test.cmi test/exception_rebind_test.cmj test/exception_rebound_err_test.cmi test/exception_rebound_err_test.cmj test/exception_repr_test.cmi test/exception_repr_test.cmj test/exception_value_test.cmi test/exception_value_test.cmj test/exn_error_pattern.cmi test/exn_error_pattern.cmj test/export_keyword.cmi test/export_keyword.cmj test/ext_array_test.cmi test/ext_array_test.cmj test/ext_bytes_test.cmi test/ext_bytes_test.cmj test/ext_filename_test.cmi test/ext_filename_test.cmj test/ext_list_test.cmi test/ext_list_test.cmj test/ext_pervasives_test.cmi test/ext_pervasives_test.cmj test/ext_string_test.cmi test/ext_string_test.cmj test/ext_sys_test.cmi test/ext_sys_test.cmj test/extensible_variant_test.cmi test/extensible_variant_test.cmj test/external_polyfill_test.cmi test/external_polyfill_test.cmj test/external_ppx.cmi test/external_ppx.cmj test/external_ppx2.cmi test/external_ppx2.cmj test/fail_comp.cmi test/fail_comp.cmj test/ffi_arity_test.cmi test/ffi_arity_test.cmj test/ffi_array_test.cmi test/ffi_array_test.cmj test/ffi_js_test.cmi test/ffi_js_test.cmj test/ffi_splice_test.cmi test/ffi_splice_test.cmj test/ffi_test.cmi test/ffi_test.cmj test/fib.cmi test/fib.cmj test/flattern_order_test.cmi test/flattern_order_test.cmj test/flexible_array_test.cmi test/flexible_array_test.cmj test/float_array.cmi test/float_array.cmj test/float_of_bits_test.cmi test/float_of_bits_test.cmj test/float_record.cmi test/float_record.cmj test/float_test.cmi test/float_test.cmj test/floatarray_test.cmi test/floatarray_test.cmj test/flow_parser_reg_test.cmi test/flow_parser_reg_test.cmj test/for_loop_test.cmi test/for_loop_test.cmj test/for_side_effect_test.cmi test/for_side_effect_test.cmj test/format_regression.cmi test/format_regression.cmj test/format_test.cmi test/format_test.cmj test/fs_test.cmi test/fs_test.cmj test/fun_pattern_match.cmi test/fun_pattern_match.cmj test/functor_app_test.cmi test/functor_app_test.cmj test/functor_def.cmi test/functor_def.cmj test/functor_ffi.cmi test/functor_ffi.cmj test/functor_inst.cmi test/functor_inst.cmj test/functors.cmi test/functors.cmj test/gbk.cmi test/gbk.cmj test/genlex_test.cmi test/genlex_test.cmj test/gentTypeReTest.cmi test/gentTypeReTest.cmj test/global_exception_regression_test.cmi test/global_exception_regression_test.cmj test/global_mangles.cmi test/global_mangles.cmj test/global_module_alias_test.cmi test/global_module_alias_test.cmj test/google_closure_test.cmi test/google_closure_test.cmj test/gpr496_test.cmi test/gpr496_test.cmj test/gpr_1072.cmi test/gpr_1072.cmj test/gpr_1072_reg.cmi test/gpr_1072_reg.cmj test/gpr_1150.cmi test/gpr_1150.cmj test/gpr_1154_test.cmi test/gpr_1154_test.cmj test/gpr_1170.cmi test/gpr_1170.cmj test/gpr_1240_missing_unbox.cmi test/gpr_1240_missing_unbox.cmj test/gpr_1245_test.cmi test/gpr_1245_test.cmj test/gpr_1268.cmi test/gpr_1268.cmj test/gpr_1409_test.cmi test/gpr_1409_test.cmj test/gpr_1423_app_test.cmi test/gpr_1423_app_test.cmj test/gpr_1423_nav.cmi test/gpr_1423_nav.cmj test/gpr_1438.cmi test/gpr_1438.cmj test/gpr_1481.cmi test/gpr_1481.cmj test/gpr_1484.cmi test/gpr_1484.cmj test/gpr_1501_test.cmi test/gpr_1501_test.cmj test/gpr_1503_test.cmi test/gpr_1503_test.cmj test/gpr_1539_test.cmi test/gpr_1539_test.cmj test/gpr_1658_test.cmi test/gpr_1658_test.cmj test/gpr_1667_test.cmi test/gpr_1667_test.cmj test/gpr_1692_test.cmi test/gpr_1692_test.cmj test/gpr_1698_test.cmi test/gpr_1698_test.cmj test/gpr_1701_test.cmi test/gpr_1701_test.cmj test/gpr_1716_test.cmi test/gpr_1716_test.cmj test/gpr_1717_test.cmi test/gpr_1717_test.cmj test/gpr_1728_test.cmi test/gpr_1728_test.cmj test/gpr_1749_test.cmi test/gpr_1749_test.cmj test/gpr_1759_test.cmi test/gpr_1759_test.cmj test/gpr_1760_test.cmi test/gpr_1760_test.cmj test/gpr_1762_test.cmi test/gpr_1762_test.cmj test/gpr_1817_test.cmi test/gpr_1817_test.cmj test/gpr_1822_test.cmi test/gpr_1822_test.cmj test/gpr_1891_test.cmi test/gpr_1891_test.cmj test/gpr_1943_test.cmi test/gpr_1943_test.cmj test/gpr_1946_test.cmi test/gpr_1946_test.cmj test/gpr_2316_test.cmi test/gpr_2316_test.cmj test/gpr_2352_test.cmi test/gpr_2352_test.cmj test/gpr_2413_test.cmi test/gpr_2413_test.cmj test/gpr_2474.cmi test/gpr_2474.cmj test/gpr_2487.cmi test/gpr_2487.cmj test/gpr_2503_test.cmi test/gpr_2503_test.cmj test/gpr_2608_test.cmi test/gpr_2608_test.cmj test/gpr_2614_test.cmi test/gpr_2614_test.cmj test/gpr_2633_test.cmi test/gpr_2633_test.cmj test/gpr_2642_test.cmi test/gpr_2642_test.cmj test/gpr_2652_test.cmi test/gpr_2652_test.cmj test/gpr_2682_test.cmi test/gpr_2682_test.cmj test/gpr_2700_test.cmi test/gpr_2700_test.cmj test/gpr_2731_test.cmi test/gpr_2731_test.cmj test/gpr_2789_test.cmi test/gpr_2789_test.cmj test/gpr_2931_test.cmi test/gpr_2931_test.cmj test/gpr_3142_test.cmi test/gpr_3142_test.cmj test/gpr_3154_test.cmi test/gpr_3154_test.cmj test/gpr_3209_test.cmi test/gpr_3209_test.cmj test/gpr_3492_test.cmi test/gpr_3492_test.cmj test/gpr_3519_jsx_test.cmi test/gpr_3519_jsx_test.cmj test/gpr_3519_test.cmi test/gpr_3519_test.cmj test/gpr_3536_test.cmi test/gpr_3536_test.cmj test/gpr_3546_test.cmi test/gpr_3546_test.cmj test/gpr_3548_test.cmi test/gpr_3548_test.cmj test/gpr_3549_test.cmi test/gpr_3549_test.cmj test/gpr_3566_drive_test.cmi test/gpr_3566_drive_test.cmj test/gpr_3566_test.cmi test/gpr_3566_test.cmj test/gpr_3595_test.cmi test/gpr_3595_test.cmj test/gpr_3609_test.cmi test/gpr_3609_test.cmj test/gpr_3697_test.cmi test/gpr_3697_test.cmj test/gpr_373_test.cmi test/gpr_373_test.cmj test/gpr_3770_test.cmi test/gpr_3770_test.cmj test/gpr_3852_alias.cmi test/gpr_3852_alias.cmj test/gpr_3852_alias_reify.cmi test/gpr_3852_alias_reify.cmj test/gpr_3852_effect.cmi test/gpr_3852_effect.cmj test/gpr_3865.cmi test/gpr_3865.cmj test/gpr_3865_bar.cmi test/gpr_3865_bar.cmj test/gpr_3865_foo.cmi test/gpr_3865_foo.cmj test/gpr_3875_test.cmi test/gpr_3875_test.cmj test/gpr_3877_test.cmi test/gpr_3877_test.cmj test/gpr_3895_test.cmi test/gpr_3895_test.cmj test/gpr_3897_test.cmi test/gpr_3897_test.cmj test/gpr_3931_test.cmi test/gpr_3931_test.cmj test/gpr_3980_test.cmi test/gpr_3980_test.cmj test/gpr_4025_test.cmi test/gpr_4025_test.cmj test/gpr_405_test.cmi test/gpr_405_test.cmj test/gpr_4069_test.cmi test/gpr_4069_test.cmj test/gpr_4265_test.cmi test/gpr_4265_test.cmj test/gpr_4274_test.cmi test/gpr_4274_test.cmj test/gpr_4280_test.cmi test/gpr_4280_test.cmj test/gpr_4407_test.cmi test/gpr_4407_test.cmj test/gpr_441.cmi test/gpr_441.cmj test/gpr_4442_test.cmi test/gpr_4442_test.cmj test/gpr_4491_test.cmi test/gpr_4491_test.cmj test/gpr_4494_test.cmi test/gpr_4494_test.cmj test/gpr_4519_test.cmi test/gpr_4519_test.cmj test/gpr_459_test.cmi test/gpr_459_test.cmj test/gpr_4632.cmi test/gpr_4632.cmj test/gpr_4639_test.cmi test/gpr_4639_test.cmj test/gpr_4900_test.cmi test/gpr_4900_test.cmj test/gpr_4924_test.cmi test/gpr_4924_test.cmj test/gpr_4931.cmi test/gpr_4931.cmj test/gpr_4931_allow.cmi test/gpr_4931_allow.cmj test/gpr_5071_test.cmi test/gpr_5071_test.cmj test/gpr_5169_test.cmi test/gpr_5169_test.cmj test/gpr_5218_test.cmi test/gpr_5218_test.cmj test/gpr_5280_optimize_test.cmi test/gpr_5280_optimize_test.cmj test/gpr_5312.cmi test/gpr_5312.cmj test/gpr_5557.cmi test/gpr_5557.cmj test/gpr_5753.cmi test/gpr_5753.cmj test/gpr_658.cmi test/gpr_658.cmj test/gpr_858_test.cmi test/gpr_858_test.cmj test/gpr_858_unit2_test.cmi test/gpr_858_unit2_test.cmj test/gpr_904_test.cmi test/gpr_904_test.cmj test/gpr_974_test.cmi test/gpr_974_test.cmj test/gpr_977_test.cmi test/gpr_977_test.cmj test/gpr_return_type_unused_attribute.cmi test/gpr_return_type_unused_attribute.cmj test/gray_code_test.cmi test/gray_code_test.cmj test/guide_for_ext.cmi test/guide_for_ext.cmj test/hamming_test.cmi test/hamming_test.cmj test/hash_collision_test.cmi test/hash_collision_test.cmj test/hash_sugar_desugar.cmi test/hash_sugar_desugar.cmj test/hash_test.cmi test/hash_test.cmj test/hashtbl_test.cmi test/hashtbl_test.cmj test/hello.foo.cmi test/hello.foo.cmj test/hello_res.cmi test/hello_res.cmj test/ignore_test.cmi test/ignore_test.cmj test/imm_map_bench.cmi test/imm_map_bench.cmj test/include_side_effect.cmi test/include_side_effect.cmj test/include_side_effect_free.cmi test/include_side_effect_free.cmj test/incomplete_toplevel_test.cmi test/incomplete_toplevel_test.cmj test/infer_type_test.cmi test/infer_type_test.cmj test/inline_const.cmi test/inline_const.cmj test/inline_const_test.cmi test/inline_const_test.cmj test/inline_edge_cases.cmi test/inline_edge_cases.cmj test/inline_map2_test.cmi test/inline_map2_test.cmj test/inline_map_demo.cmi test/inline_map_demo.cmj test/inline_map_test.cmi test/inline_map_test.cmj test/inline_record_test.cmi test/inline_record_test.cmj test/inline_regression_test.cmi test/inline_regression_test.cmj test/inline_string_test.cmi test/inline_string_test.cmj test/inner_call.cmi test/inner_call.cmj test/inner_define.cmi test/inner_define.cmj test/inner_unused.cmi test/inner_unused.cmj test/installation_test.cmi test/installation_test.cmj test/int32_test.cmi test/int32_test.cmj test/int64_mul_div_test.cmi test/int64_mul_div_test.cmj test/int64_string_bench.cmi test/int64_string_bench.cmj test/int64_string_test.cmi test/int64_string_test.cmj test/int64_test.cmi test/int64_test.cmj test/int_hashtbl_test.cmi test/int_hashtbl_test.cmj test/int_map.cmi test/int_map.cmj test/int_overflow_test.cmi test/int_overflow_test.cmj test/int_poly_var.cmi test/int_poly_var.cmj test/int_switch_test.cmi test/int_switch_test.cmj test/internal_unused_test.cmi test/internal_unused_test.cmj test/io_test.cmi test/io_test.cmj test/js_array_test.cmi test/js_array_test.cmj test/js_bool_test.cmi test/js_bool_test.cmj test/js_cast_test.cmi test/js_cast_test.cmj test/js_date_test.cmi test/js_date_test.cmj test/js_dict_test.cmi test/js_dict_test.cmj test/js_exception_catch_test.cmi test/js_exception_catch_test.cmj test/js_float_test.cmi test/js_float_test.cmj test/js_global_test.cmi test/js_global_test.cmj test/js_int_test.cmi test/js_int_test.cmj test/js_json_test.cmi test/js_json_test.cmj test/js_list_test.cmi test/js_list_test.cmj test/js_math_test.cmi test/js_math_test.cmj test/js_null_test.cmi test/js_null_test.cmj test/js_null_undefined_test.cmi test/js_null_undefined_test.cmj test/js_nullable_test.cmi test/js_nullable_test.cmj test/js_obj_test.cmi test/js_obj_test.cmj test/js_option_test.cmi test/js_option_test.cmj test/js_promise_basic_test.cmi test/js_promise_basic_test.cmj test/js_re_test.cmi test/js_re_test.cmj test/js_string_test.cmi test/js_string_test.cmj test/js_typed_array_test.cmi test/js_typed_array_test.cmj test/js_undefined_test.cmi test/js_undefined_test.cmj test/js_val.cmi test/js_val.cmj test/jsoo_400_test.cmi test/jsoo_400_test.cmj test/jsoo_485_test.cmi test/jsoo_485_test.cmj test/key_word_property.cmi test/key_word_property.cmj test/key_word_property2.cmi test/key_word_property2.cmj test/key_word_property_plus_test.cmi test/key_word_property_plus_test.cmj test/label_uncurry.cmi test/label_uncurry.cmj test/large_integer_pat.cmi test/large_integer_pat.cmj test/large_record_duplication_test.cmi test/large_record_duplication_test.cmj test/largest_int_flow.cmi test/largest_int_flow.cmj test/lazy_demo.cmi test/lazy_demo.cmj test/lazy_test.cmi test/lazy_test.cmj test/lexer_test.cmi test/lexer_test.cmj test/lib_js_test.cmi test/lib_js_test.cmj test/libarg_test.cmi test/libarg_test.cmj test/libqueue_test.cmi test/libqueue_test.cmj test/limits_test.cmi test/limits_test.cmj test/list_stack.cmi test/list_stack.cmj test/list_test.cmi test/list_test.cmj test/local_exception_test.cmi test/local_exception_test.cmj test/loop_regression_test.cmi test/loop_regression_test.cmj test/loop_suites_test.cmi test/loop_suites_test.cmj test/map_find_test.cmi test/map_find_test.cmj test/map_test.cmi test/map_test.cmj test/mario_game.cmi test/mario_game.cmj test/marshal.cmi test/marshal.cmj test/meth_annotation.cmi test/meth_annotation.cmj test/method_name_test.cmi test/method_name_test.cmj test/method_string_name.cmi test/method_string_name.cmj test/minimal_test.cmi test/minimal_test.cmj test/miss_colon_test.cmi test/miss_colon_test.cmj test/mock_mt.cmi test/mock_mt.cmj test/module_alias_test.cmi test/module_alias_test.cmj test/module_as_class_ffi.cmi test/module_as_class_ffi.cmj test/module_as_function.cmi test/module_as_function.cmj test/module_missing_conversion.cmi test/module_missing_conversion.cmj test/module_parameter_test.cmi test/module_parameter_test.cmj test/module_splice_test.cmi test/module_splice_test.cmj test/more_poly_variant_test.cmi test/more_poly_variant_test.cmj test/more_uncurry.cmi test/more_uncurry.cmj test/mpr_6033_test.cmi test/mpr_6033_test.cmj test/mt.cmi test/mt.cmj test/mt_global.cmi test/mt_global.cmj test/mutable_obj_test.cmi test/mutable_obj_test.cmj test/mutable_uncurry_test.cmi test/mutable_uncurry_test.cmj test/mutual_non_recursive_type.cmi test/mutual_non_recursive_type.cmj test/name_mangle_test.cmi test/name_mangle_test.cmj test/nested_include.cmi test/nested_include.cmj test/nested_module_alias.cmi test/nested_module_alias.cmj test/nested_obj_literal.cmi test/nested_obj_literal.cmj test/nested_obj_test.cmi test/nested_obj_test.cmj test/nested_pattern_match_test.cmi test/nested_pattern_match_test.cmj test/noassert.cmi test/noassert.cmj test/node_fs_test.cmi test/node_fs_test.cmj test/node_path_test.cmi test/node_path_test.cmj test/null_list_test.cmi test/null_list_test.cmj test/number_lexer.cmi test/number_lexer.cmj test/obj_literal_ppx.cmi test/obj_literal_ppx.cmj test/obj_literal_ppx_test.cmi test/obj_literal_ppx_test.cmj test/obj_magic_test.cmi test/obj_magic_test.cmj test/obj_type_test.cmi test/obj_type_test.cmj test/ocaml_re_test.cmi test/ocaml_re_test.cmj test/of_string_test.cmi test/of_string_test.cmj test/offset.cmi test/offset.cmj test/option_encoding_test.cmi test/option_encoding_test.cmj test/option_record_none_test.cmi test/option_record_none_test.cmj test/option_repr_test.cmi test/option_repr_test.cmj test/optional_ffi_test.cmi test/optional_ffi_test.cmj test/optional_regression_test.cmi test/optional_regression_test.cmj test/pipe_send_readline.cmi test/pipe_send_readline.cmj test/pipe_syntax.cmi test/pipe_syntax.cmj test/poly_empty_array.cmi test/poly_empty_array.cmj test/poly_variant_test.cmi test/poly_variant_test.cmj test/polymorphic_raw_test.cmi test/polymorphic_raw_test.cmj test/polymorphism_test.cmi test/polymorphism_test.cmj test/polyvar_convert.cmi test/polyvar_convert.cmj test/polyvar_test.cmi test/polyvar_test.cmj test/ppx_apply_test.cmi test/ppx_apply_test.cmj test/pq_test.cmi test/pq_test.cmj test/pr6726.cmi test/pr6726.cmj test/pr_regression_test.cmi test/pr_regression_test.cmj test/prepend_data_ffi.cmi test/prepend_data_ffi.cmj test/primitive_reg_test.cmi test/primitive_reg_test.cmj test/print_alpha_test.cmi test/print_alpha_test.cmj test/promise_catch_test.cmi test/promise_catch_test.cmj test/queue_402.cmi test/queue_402.cmj test/queue_test.cmi test/queue_test.cmj test/random_test.cmi test/random_test.cmj test/raw_hash_tbl_bench.cmi test/raw_hash_tbl_bench.cmj test/raw_output_test.cmi test/raw_output_test.cmj test/raw_pure_test.cmi test/raw_pure_test.cmj test/rbset.cmi test/rbset.cmj test/react.cmi test/react.cmj test/reactDOMRe.cmi test/reactDOMRe.cmj test/reactDOMServerRe.cmi test/reactDOMServerRe.cmj test/reactEvent.cmi test/reactEvent.cmj test/reactTestUtils.cmi test/reactTestUtils.cmj test/reasonReact.cmi test/reasonReact.cmj test/reasonReactCompat.cmi test/reasonReactCompat.cmj test/reasonReactOptimizedCreateClass.cmi test/reasonReactOptimizedCreateClass.cmj test/reasonReactRouter.cmi test/reasonReactRouter.cmj test/rebind_module.cmi test/rebind_module.cmj test/rebind_module_test.cmi test/rebind_module_test.cmj test/rec_array_test.cmi test/rec_array_test.cmj test/rec_fun_test.cmi test/rec_fun_test.cmj test/rec_module_opt.cmi test/rec_module_opt.cmj test/rec_module_test.cmi test/rec_module_test.cmj test/rec_value_test.cmi test/rec_value_test.cmj test/record_debug_test.cmi test/record_debug_test.cmj test/record_extension_test.cmi test/record_extension_test.cmj test/record_name_test.cmi test/record_name_test.cmj test/record_regression.cmi test/record_regression.cmj test/record_with_test.cmi test/record_with_test.cmj test/recursive_module.cmi test/recursive_module.cmj test/recursive_module_test.cmi test/recursive_module_test.cmj test/recursive_react_component.cmi test/recursive_react_component.cmj test/recursive_records_test.cmi test/recursive_records_test.cmj test/recursive_unbound_module_test.cmi test/recursive_unbound_module_test.cmj test/regression_print.cmi test/regression_print.cmj test/relative_path.cmi test/relative_path.cmj test/res_debug.cmi test/res_debug.cmj test/return_check.cmi test/return_check.cmj test/runtime_encoding_test.cmi test/runtime_encoding_test.cmj test/set_annotation.cmi test/set_annotation.cmj test/set_gen.cmi test/set_gen.cmj test/sexp.cmi test/sexp.cmj test/sexpm.cmi test/sexpm.cmj test/sexpm_test.cmi test/sexpm_test.cmj test/side_effect.cmi test/side_effect.cmj test/side_effect_free.cmi test/side_effect_free.cmj test/simple_derive_test.cmi test/simple_derive_test.cmj test/simple_derive_use.cmi test/simple_derive_use.cmj test/simple_lexer_test.cmi test/simple_lexer_test.cmj test/simplify_lambda_632o.cmi test/simplify_lambda_632o.cmj test/single_module_alias.cmi test/single_module_alias.cmj test/singular_unit_test.cmi test/singular_unit_test.cmj test/small_inline_test.cmi test/small_inline_test.cmj test/splice_test.cmi test/splice_test.cmj test/stack_comp_test.cmi test/stack_comp_test.cmj test/stack_test.cmi test/stack_test.cmj test/stream_parser_test.cmi test/stream_parser_test.cmj test/string_bound_get_test.cmi test/string_bound_get_test.cmj test/string_get_set_test.cmi test/string_get_set_test.cmj test/string_interp_test.cmi test/string_interp_test.cmj test/string_literal_print_test.cmi test/string_literal_print_test.cmj test/string_runtime_test.cmi test/string_runtime_test.cmj test/string_set.cmi test/string_set.cmj test/string_set_test.cmi test/string_set_test.cmj test/string_test.cmi test/string_test.cmj test/string_unicode_test.cmi test/string_unicode_test.cmj test/stringmatch_test.cmi test/stringmatch_test.cmj test/submodule.cmi test/submodule.cmj test/submodule_call.cmi test/submodule_call.cmj test/switch_case_test.cmi test/switch_case_test.cmj test/tailcall_inline_test.cmi test/tailcall_inline_test.cmj test/template.cmi test/template.cmj test/test.cmi test/test.cmj test/test2.cmi test/test2.cmj test/test_alias.cmi test/test_alias.cmj test/test_ari.cmi test/test_ari.cmj test/test_array.cmi test/test_array.cmj test/test_array_append.cmi test/test_array_append.cmj test/test_array_primitive.cmi test/test_array_primitive.cmj test/test_bool_equal.cmi test/test_bool_equal.cmj test/test_bs_this.cmi test/test_bs_this.cmj test/test_bug.cmi test/test_bug.cmj test/test_bytes.cmi test/test_bytes.cmj test/test_case_opt_collision.cmi test/test_case_opt_collision.cmj test/test_case_set.cmi test/test_case_set.cmj test/test_char.cmi test/test_char.cmj test/test_closure.cmi test/test_closure.cmj test/test_common.cmi test/test_common.cmj test/test_const_elim.cmi test/test_const_elim.cmj test/test_const_propogate.cmi test/test_const_propogate.cmj test/test_cpp.cmi test/test_cpp.cmj test/test_cps.cmi test/test_cps.cmj test/test_demo.cmi test/test_demo.cmj test/test_dup_param.cmi test/test_dup_param.cmj test/test_eq.cmi test/test_eq.cmj test/test_exception.cmi test/test_exception.cmj test/test_exception_escape.cmi test/test_exception_escape.cmj test/test_export2.cmi test/test_export2.cmj test/test_external.cmi test/test_external.cmj test/test_external_unit.cmi test/test_external_unit.cmj test/test_ffi.cmi test/test_ffi.cmj test/test_fib.cmi test/test_fib.cmj test/test_filename.cmi test/test_filename.cmj test/test_for_loop.cmi test/test_for_loop.cmj test/test_for_map.cmi test/test_for_map.cmj test/test_for_map2.cmi test/test_for_map2.cmj test/test_format.cmi test/test_format.cmj test/test_formatter.cmi test/test_formatter.cmj test/test_functor_dead_code.cmi test/test_functor_dead_code.cmj test/test_generative_module.cmi test/test_generative_module.cmj test/test_global_print.cmi test/test_global_print.cmj test/test_google_closure.cmi test/test_google_closure.cmj test/test_include.cmi test/test_include.cmj test/test_incomplete.cmi test/test_incomplete.cmj test/test_incr_ref.cmi test/test_incr_ref.cmj test/test_int_map_find.cmi test/test_int_map_find.cmj test/test_internalOO.cmi test/test_internalOO.cmj test/test_is_js.cmi test/test_is_js.cmj test/test_js_ffi.cmi test/test_js_ffi.cmj test/test_let.cmi test/test_let.cmj test/test_list.cmi test/test_list.cmj test/test_literal.cmi test/test_literal.cmj test/test_literals.cmi test/test_literals.cmj test/test_match_exception.cmi test/test_match_exception.cmj test/test_mutliple.cmi test/test_mutliple.cmj test/test_nat64.cmi test/test_nat64.cmj test/test_nested_let.cmi test/test_nested_let.cmj test/test_nested_print.cmi test/test_nested_print.cmj test/test_non_export.cmi test/test_non_export.cmj test/test_nullary.cmi test/test_nullary.cmj test/test_obj.cmi test/test_obj.cmj test/test_obj_simple_ffi.cmi test/test_obj_simple_ffi.cmj test/test_order.cmi test/test_order.cmj test/test_order_tailcall.cmi test/test_order_tailcall.cmj test/test_other_exn.cmi test/test_other_exn.cmj test/test_pack.cmi test/test_pack.cmj test/test_per.cmi test/test_per.cmj test/test_pervasive.cmi test/test_pervasive.cmj test/test_pervasives2.cmi test/test_pervasives2.cmj test/test_pervasives3.cmi test/test_pervasives3.cmj test/test_primitive.cmi test/test_primitive.cmj test/test_ramification.cmi test/test_ramification.cmj test/test_react.cmi test/test_react.cmj test/test_react_case.cmi test/test_react_case.cmj test/test_regex.cmi test/test_regex.cmj test/test_require.cmi test/test_require.cmj test/test_runtime_encoding.cmi test/test_runtime_encoding.cmj test/test_scope.cmi test/test_scope.cmj test/test_seq.cmi test/test_seq.cmj test/test_set.cmi test/test_set.cmj test/test_side_effect_functor.cmi test/test_side_effect_functor.cmj test/test_simple_include.cmi test/test_simple_include.cmj test/test_simple_pattern_match.cmi test/test_simple_pattern_match.cmj test/test_simple_ref.cmi test/test_simple_ref.cmj test/test_simple_tailcall.cmi test/test_simple_tailcall.cmj test/test_small.cmi test/test_small.cmj test/test_sprintf.cmi test/test_sprintf.cmj test/test_stack.cmi test/test_stack.cmj test/test_static_catch_ident.cmi test/test_static_catch_ident.cmj test/test_string.cmi test/test_string.cmj test/test_string_case.cmi test/test_string_case.cmj test/test_string_const.cmi test/test_string_const.cmj test/test_string_map.cmi test/test_string_map.cmj test/test_string_switch.cmi test/test_string_switch.cmj test/test_switch.cmi test/test_switch.cmj test/test_trywith.cmi test/test_trywith.cmj test/test_tuple.cmi test/test_tuple.cmj test/test_tuple_destructring.cmi test/test_tuple_destructring.cmj test/test_type_based_arity.cmi test/test_type_based_arity.cmj test/test_u.cmi test/test_u.cmj test/test_unknown.cmi test/test_unknown.cmj test/test_unsafe_cmp.cmi test/test_unsafe_cmp.cmj test/test_unsafe_obj_ffi.cmi test/test_unsafe_obj_ffi.cmj test/test_unsafe_obj_ffi_ppx.cmi test/test_unsafe_obj_ffi_ppx.cmj test/test_unsupported_primitive.cmi test/test_unsupported_primitive.cmj test/test_while_closure.cmi test/test_while_closure.cmj test/test_while_side_effect.cmi test/test_while_side_effect.cmj test/test_zero_nullable.cmi test/test_zero_nullable.cmj test/then_mangle_test.cmi test/then_mangle_test.cmj test/ticker.cmi test/ticker.cmj test/to_string_test.cmi test/to_string_test.cmj test/topsort_test.cmi test/topsort_test.cmj test/tramp_fib.cmi test/tramp_fib.cmj test/tuple_alloc.cmi test/tuple_alloc.cmj test/type_disambiguate.cmi test/type_disambiguate.cmj test/typeof_test.cmi test/typeof_test.cmj test/ui_defs.cmi test/unboxed_attribute.cmi test/unboxed_attribute.cmj test/unboxed_attribute_test.cmi test/unboxed_attribute_test.cmj test/unboxed_crash.cmi test/unboxed_crash.cmj test/unboxed_use_case.cmi test/unboxed_use_case.cmj test/uncurried_cast.cmi test/uncurried_cast.cmj test/uncurried_default.args.cmi test/uncurried_default.args.cmj test/uncurried_pipe.cmi test/uncurried_pipe.cmj test/uncurry_external_test.cmi test/uncurry_external_test.cmj test/uncurry_glob_test.cmi test/uncurry_glob_test.cmj test/uncurry_test.cmi test/uncurry_test.cmj test/undef_regression2_test.cmi test/undef_regression2_test.cmj test/undef_regression_test.cmi test/undef_regression_test.cmj test/undefine_conditional.cmi test/undefine_conditional.cmj test/unicode_type_error.cmi test/unicode_type_error.cmj test/unit_undefined_test.cmi test/unit_undefined_test.cmj test/unitest_string.cmi test/unitest_string.cmj test/unsafe_full_apply_primitive.cmi test/unsafe_full_apply_primitive.cmj test/unsafe_ppx_test.cmi test/unsafe_ppx_test.cmj test/unsafe_this.cmi test/unsafe_this.cmj test/update_record_test.cmi test/update_record_test.cmj test/utf8_decode_test.cmi test/utf8_decode_test.cmj test/variant.cmi test/variant.cmj test/watch_test.cmi test/watch_test.cmj test/webpack_config.cmi test/webpack_config.cmj +o test : phony test/406_primitive_test.cmi test/406_primitive_test.cmj test/EmptyRecord.cmi test/EmptyRecord.cmj test/Import.cmi test/Import.cmj test/SafePromises.cmi test/SafePromises.cmj test/UncurriedExternals.cmi test/UncurriedExternals.cmj test/a.cmi test/a.cmj test/a_filename_test.cmi test/a_filename_test.cmj test/a_list_test.cmi test/a_list_test.cmj test/a_recursive_type.cmi test/a_recursive_type.cmj test/a_scope_bug.cmi test/a_scope_bug.cmj test/a_string_test.cmi test/a_string_test.cmj test/abstract_type.cmi test/abstract_type.cmj test/adt_optimize_test.cmi test/adt_optimize_test.cmj test/alias_test.cmi test/alias_test.cmj test/and_or_tailcall_test.cmi test/and_or_tailcall_test.cmj test/app_root_finder.cmi test/app_root_finder.cmj test/argv_test.cmi test/argv_test.cmj test/ari_regress_test.cmi test/ari_regress_test.cmj test/arith_lexer.cmi test/arith_lexer.cmj test/arith_parser.cmi test/arith_parser.cmj test/arith_syntax.cmi test/arith_syntax.cmj test/arity.cmi test/arity.cmj test/arity_deopt.cmi test/arity_deopt.cmj test/arity_infer.cmi test/arity_infer.cmj test/array_data_util.cmi test/array_data_util.cmj test/array_safe_get.cmi test/array_safe_get.cmj test/array_subtle_test.cmi test/array_subtle_test.cmj test/array_test.cmi test/array_test.cmj test/ast_abstract_test.cmi test/ast_abstract_test.cmj test/ast_js_mapper_poly_test.cmi test/ast_js_mapper_poly_test.cmj test/ast_js_mapper_test.cmi test/ast_js_mapper_test.cmj test/ast_mapper_defensive_test.cmi test/ast_mapper_defensive_test.cmj test/ast_mapper_unused_warning_test.cmi test/ast_mapper_unused_warning_test.cmj test/async_await.cmi test/async_await.cmj test/async_ideas.cmi test/async_ideas.cmj test/async_inline.cmi test/async_inline.cmj test/attr_test.cmi test/attr_test.cmj test/b.cmi test/b.cmj test/bal_set_mini.cmi test/bal_set_mini.cmj test/bang_primitive.cmi test/bang_primitive.cmj test/basic_module_test.cmi test/basic_module_test.cmj test/bb.cmi test/bb.cmj test/bdd.cmi test/bdd.cmj test/belt_internal_test.cmi test/belt_internal_test.cmj test/belt_result_alias_test.cmi test/belt_result_alias_test.cmj test/bench.cmi test/bench.cmj test/big_enum.cmi test/big_enum.cmj test/big_polyvar_test.cmi test/big_polyvar_test.cmj test/block_alias_test.cmi test/block_alias_test.cmj test/boolean_test.cmi test/boolean_test.cmj test/bs_MapInt_test.cmi test/bs_MapInt_test.cmj test/bs_abstract_test.cmi test/bs_abstract_test.cmj test/bs_array_test.cmi test/bs_array_test.cmj test/bs_auto_uncurry.cmi test/bs_auto_uncurry.cmj test/bs_auto_uncurry_test.cmi test/bs_auto_uncurry_test.cmj test/bs_float_test.cmi test/bs_float_test.cmj test/bs_hashmap_test.cmi test/bs_hashmap_test.cmj test/bs_hashset_int_test.cmi test/bs_hashset_int_test.cmj test/bs_hashtbl_string_test.cmi test/bs_hashtbl_string_test.cmj test/bs_ignore_effect.cmi test/bs_ignore_effect.cmj test/bs_ignore_test.cmi test/bs_ignore_test.cmj test/bs_int_test.cmi test/bs_int_test.cmj test/bs_list_test.cmi test/bs_list_test.cmj test/bs_map_set_dict_test.cmi test/bs_map_set_dict_test.cmj test/bs_map_test.cmi test/bs_map_test.cmj test/bs_min_max_test.cmi test/bs_min_max_test.cmj test/bs_mutable_set_test.cmi test/bs_mutable_set_test.cmj test/bs_node_string_buffer_test.cmi test/bs_node_string_buffer_test.cmj test/bs_poly_map_test.cmi test/bs_poly_map_test.cmj test/bs_poly_mutable_map_test.cmi test/bs_poly_mutable_map_test.cmj test/bs_poly_mutable_set_test.cmi test/bs_poly_mutable_set_test.cmj test/bs_poly_set_test.cmi test/bs_poly_set_test.cmj test/bs_qualified.cmi test/bs_qualified.cmj test/bs_queue_test.cmi test/bs_queue_test.cmj test/bs_rbset_int_bench.cmi test/bs_rbset_int_bench.cmj test/bs_rest_test.cmi test/bs_rest_test.cmj test/bs_set_bench.cmi test/bs_set_bench.cmj test/bs_set_int_test.cmi test/bs_set_int_test.cmj test/bs_sort_test.cmi test/bs_sort_test.cmj test/bs_splice_partial.cmi test/bs_splice_partial.cmj test/bs_stack_test.cmi test/bs_stack_test.cmj test/bs_string_test.cmi test/bs_string_test.cmj test/bs_unwrap_test.cmi test/bs_unwrap_test.cmj test/buffer_test.cmi test/buffer_test.cmj test/bytes_split_gpr_743_test.cmi test/bytes_split_gpr_743_test.cmj test/caml_compare_test.cmi test/caml_compare_test.cmj test/caml_format_test.cmi test/caml_format_test.cmj test/caml_sys_poly_fill_test.cmi test/caml_sys_poly_fill_test.cmj test/chain_code_test.cmi test/chain_code_test.cmj test/chn_test.cmi test/chn_test.cmj test/class_type_ffi_test.cmi test/class_type_ffi_test.cmj test/coercion_module_alias_test.cmi test/coercion_module_alias_test.cmj test/compare_test.cmi test/compare_test.cmj test/complete_parmatch_test.cmi test/complete_parmatch_test.cmj test/complex_if_test.cmi test/complex_if_test.cmj test/complex_test.cmi test/complex_test.cmj test/complex_while_loop.cmi test/complex_while_loop.cmj test/condition_compilation_test.cmi test/condition_compilation_test.cmj test/config1_test.cmi test/config1_test.cmj test/console_log_test.cmi test/console_log_test.cmj test/const_block_test.cmi test/const_block_test.cmj test/const_defs.cmi test/const_defs.cmj test/const_defs_test.cmi test/const_defs_test.cmj test/const_test.cmi test/const_test.cmj test/cont_int_fold_test.cmi test/cont_int_fold_test.cmj test/cps_test.cmi test/cps_test.cmj test/cross_module_inline_test.cmi test/cross_module_inline_test.cmj test/custom_error_test.cmi test/custom_error_test.cmj test/debug_keep_test.cmi test/debug_keep_test.cmj test/debug_mode_value.cmi test/debug_mode_value.cmj test/debug_tmp.cmi test/debug_tmp.cmj test/debugger_test.cmi test/debugger_test.cmj test/default_export_test.cmi test/default_export_test.cmj test/defunctor_make_test.cmi test/defunctor_make_test.cmj test/demo_int_map.cmi test/demo_int_map.cmj test/demo_page.cmi test/demo_page.cmj test/demo_pipe.cmi test/demo_pipe.cmj test/derive_dyntype.cmi test/derive_dyntype.cmj test/derive_projector_test.cmi test/derive_projector_test.cmj test/derive_type_test.cmi test/derive_type_test.cmj test/digest_test.cmi test/digest_test.cmj test/div_by_zero_test.cmi test/div_by_zero_test.cmj test/dollar_escape_test.cmi test/dollar_escape_test.cmj test/earger_curry_test.cmi test/earger_curry_test.cmj test/effect.cmi test/effect.cmj test/epsilon_test.cmi test/epsilon_test.cmj test/equal_box_test.cmi test/equal_box_test.cmj test/equal_exception_test.cmi test/equal_exception_test.cmj test/equal_test.cmi test/equal_test.cmj test/es6_export.cmi test/es6_export.cmj test/es6_import.cmi test/es6_import.cmj test/es6_module_test.cmi test/es6_module_test.cmj test/escape_esmodule.cmi test/escape_esmodule.cmj test/esmodule_ref.cmi test/esmodule_ref.cmj test/event_ffi.cmi test/event_ffi.cmj test/exception_alias.cmi test/exception_alias.cmj test/exception_def.cmi test/exception_def.cmj test/exception_raise_test.cmi test/exception_raise_test.cmj test/exception_rebind_test.cmi test/exception_rebind_test.cmj test/exception_rebound_err_test.cmi test/exception_rebound_err_test.cmj test/exception_repr_test.cmi test/exception_repr_test.cmj test/exception_value_test.cmi test/exception_value_test.cmj test/exn_error_pattern.cmi test/exn_error_pattern.cmj test/export_keyword.cmi test/export_keyword.cmj test/ext_array_test.cmi test/ext_array_test.cmj test/ext_bytes_test.cmi test/ext_bytes_test.cmj test/ext_filename_test.cmi test/ext_filename_test.cmj test/ext_list_test.cmi test/ext_list_test.cmj test/ext_pervasives_test.cmi test/ext_pervasives_test.cmj test/ext_string_test.cmi test/ext_string_test.cmj test/ext_sys_test.cmi test/ext_sys_test.cmj test/extensible_variant_test.cmi test/extensible_variant_test.cmj test/external_polyfill_test.cmi test/external_polyfill_test.cmj test/external_ppx.cmi test/external_ppx.cmj test/external_ppx2.cmi test/external_ppx2.cmj test/fail_comp.cmi test/fail_comp.cmj test/ffi_arity_test.cmi test/ffi_arity_test.cmj test/ffi_array_test.cmi test/ffi_array_test.cmj test/ffi_js_test.cmi test/ffi_js_test.cmj test/ffi_splice_test.cmi test/ffi_splice_test.cmj test/ffi_test.cmi test/ffi_test.cmj test/fib.cmi test/fib.cmj test/flattern_order_test.cmi test/flattern_order_test.cmj test/flexible_array_test.cmi test/flexible_array_test.cmj test/float_array.cmi test/float_array.cmj test/float_of_bits_test.cmi test/float_of_bits_test.cmj test/float_record.cmi test/float_record.cmj test/float_test.cmi test/float_test.cmj test/floatarray_test.cmi test/floatarray_test.cmj test/flow_parser_reg_test.cmi test/flow_parser_reg_test.cmj test/for_loop_test.cmi test/for_loop_test.cmj test/for_side_effect_test.cmi test/for_side_effect_test.cmj test/format_regression.cmi test/format_regression.cmj test/format_test.cmi test/format_test.cmj test/fs_test.cmi test/fs_test.cmj test/fun_pattern_match.cmi test/fun_pattern_match.cmj test/functor_app_test.cmi test/functor_app_test.cmj test/functor_def.cmi test/functor_def.cmj test/functor_ffi.cmi test/functor_ffi.cmj test/functor_inst.cmi test/functor_inst.cmj test/functors.cmi test/functors.cmj test/gbk.cmi test/gbk.cmj test/genlex_test.cmi test/genlex_test.cmj test/gentTypeReTest.cmi test/gentTypeReTest.cmj test/global_exception_regression_test.cmi test/global_exception_regression_test.cmj test/global_mangles.cmi test/global_mangles.cmj test/global_module_alias_test.cmi test/global_module_alias_test.cmj test/google_closure_test.cmi test/google_closure_test.cmj test/gpr496_test.cmi test/gpr496_test.cmj test/gpr_1072.cmi test/gpr_1072.cmj test/gpr_1072_reg.cmi test/gpr_1072_reg.cmj test/gpr_1150.cmi test/gpr_1150.cmj test/gpr_1154_test.cmi test/gpr_1154_test.cmj test/gpr_1170.cmi test/gpr_1170.cmj test/gpr_1240_missing_unbox.cmi test/gpr_1240_missing_unbox.cmj test/gpr_1245_test.cmi test/gpr_1245_test.cmj test/gpr_1268.cmi test/gpr_1268.cmj test/gpr_1409_test.cmi test/gpr_1409_test.cmj test/gpr_1423_app_test.cmi test/gpr_1423_app_test.cmj test/gpr_1423_nav.cmi test/gpr_1423_nav.cmj test/gpr_1438.cmi test/gpr_1438.cmj test/gpr_1481.cmi test/gpr_1481.cmj test/gpr_1484.cmi test/gpr_1484.cmj test/gpr_1501_test.cmi test/gpr_1501_test.cmj test/gpr_1503_test.cmi test/gpr_1503_test.cmj test/gpr_1539_test.cmi test/gpr_1539_test.cmj test/gpr_1658_test.cmi test/gpr_1658_test.cmj test/gpr_1667_test.cmi test/gpr_1667_test.cmj test/gpr_1692_test.cmi test/gpr_1692_test.cmj test/gpr_1698_test.cmi test/gpr_1698_test.cmj test/gpr_1701_test.cmi test/gpr_1701_test.cmj test/gpr_1716_test.cmi test/gpr_1716_test.cmj test/gpr_1717_test.cmi test/gpr_1717_test.cmj test/gpr_1728_test.cmi test/gpr_1728_test.cmj test/gpr_1749_test.cmi test/gpr_1749_test.cmj test/gpr_1759_test.cmi test/gpr_1759_test.cmj test/gpr_1760_test.cmi test/gpr_1760_test.cmj test/gpr_1762_test.cmi test/gpr_1762_test.cmj test/gpr_1817_test.cmi test/gpr_1817_test.cmj test/gpr_1822_test.cmi test/gpr_1822_test.cmj test/gpr_1891_test.cmi test/gpr_1891_test.cmj test/gpr_1943_test.cmi test/gpr_1943_test.cmj test/gpr_1946_test.cmi test/gpr_1946_test.cmj test/gpr_2316_test.cmi test/gpr_2316_test.cmj test/gpr_2352_test.cmi test/gpr_2352_test.cmj test/gpr_2413_test.cmi test/gpr_2413_test.cmj test/gpr_2474.cmi test/gpr_2474.cmj test/gpr_2487.cmi test/gpr_2487.cmj test/gpr_2503_test.cmi test/gpr_2503_test.cmj test/gpr_2608_test.cmi test/gpr_2608_test.cmj test/gpr_2614_test.cmi test/gpr_2614_test.cmj test/gpr_2633_test.cmi test/gpr_2633_test.cmj test/gpr_2642_test.cmi test/gpr_2642_test.cmj test/gpr_2652_test.cmi test/gpr_2652_test.cmj test/gpr_2682_test.cmi test/gpr_2682_test.cmj test/gpr_2700_test.cmi test/gpr_2700_test.cmj test/gpr_2731_test.cmi test/gpr_2731_test.cmj test/gpr_2789_test.cmi test/gpr_2789_test.cmj test/gpr_2931_test.cmi test/gpr_2931_test.cmj test/gpr_3142_test.cmi test/gpr_3142_test.cmj test/gpr_3154_test.cmi test/gpr_3154_test.cmj test/gpr_3209_test.cmi test/gpr_3209_test.cmj test/gpr_3492_test.cmi test/gpr_3492_test.cmj test/gpr_3519_jsx_test.cmi test/gpr_3519_jsx_test.cmj test/gpr_3519_test.cmi test/gpr_3519_test.cmj test/gpr_3536_test.cmi test/gpr_3536_test.cmj test/gpr_3546_test.cmi test/gpr_3546_test.cmj test/gpr_3548_test.cmi test/gpr_3548_test.cmj test/gpr_3549_test.cmi test/gpr_3549_test.cmj test/gpr_3566_drive_test.cmi test/gpr_3566_drive_test.cmj test/gpr_3566_test.cmi test/gpr_3566_test.cmj test/gpr_3595_test.cmi test/gpr_3595_test.cmj test/gpr_3609_test.cmi test/gpr_3609_test.cmj test/gpr_3697_test.cmi test/gpr_3697_test.cmj test/gpr_373_test.cmi test/gpr_373_test.cmj test/gpr_3770_test.cmi test/gpr_3770_test.cmj test/gpr_3852_alias.cmi test/gpr_3852_alias.cmj test/gpr_3852_alias_reify.cmi test/gpr_3852_alias_reify.cmj test/gpr_3852_effect.cmi test/gpr_3852_effect.cmj test/gpr_3865.cmi test/gpr_3865.cmj test/gpr_3865_bar.cmi test/gpr_3865_bar.cmj test/gpr_3865_foo.cmi test/gpr_3865_foo.cmj test/gpr_3875_test.cmi test/gpr_3875_test.cmj test/gpr_3877_test.cmi test/gpr_3877_test.cmj test/gpr_3895_test.cmi test/gpr_3895_test.cmj test/gpr_3897_test.cmi test/gpr_3897_test.cmj test/gpr_3931_test.cmi test/gpr_3931_test.cmj test/gpr_3980_test.cmi test/gpr_3980_test.cmj test/gpr_4025_test.cmi test/gpr_4025_test.cmj test/gpr_405_test.cmi test/gpr_405_test.cmj test/gpr_4069_test.cmi test/gpr_4069_test.cmj test/gpr_4265_test.cmi test/gpr_4265_test.cmj test/gpr_4274_test.cmi test/gpr_4274_test.cmj test/gpr_4280_test.cmi test/gpr_4280_test.cmj test/gpr_4407_test.cmi test/gpr_4407_test.cmj test/gpr_441.cmi test/gpr_441.cmj test/gpr_4442_test.cmi test/gpr_4442_test.cmj test/gpr_4491_test.cmi test/gpr_4491_test.cmj test/gpr_4494_test.cmi test/gpr_4494_test.cmj test/gpr_4519_test.cmi test/gpr_4519_test.cmj test/gpr_459_test.cmi test/gpr_459_test.cmj test/gpr_4632.cmi test/gpr_4632.cmj test/gpr_4639_test.cmi test/gpr_4639_test.cmj test/gpr_4900_test.cmi test/gpr_4900_test.cmj test/gpr_4924_test.cmi test/gpr_4924_test.cmj test/gpr_4931.cmi test/gpr_4931.cmj test/gpr_4931_allow.cmi test/gpr_4931_allow.cmj test/gpr_5071_test.cmi test/gpr_5071_test.cmj test/gpr_5169_test.cmi test/gpr_5169_test.cmj test/gpr_5218_test.cmi test/gpr_5218_test.cmj test/gpr_5280_optimize_test.cmi test/gpr_5280_optimize_test.cmj test/gpr_5312.cmi test/gpr_5312.cmj test/gpr_5557.cmi test/gpr_5557.cmj test/gpr_5753.cmi test/gpr_5753.cmj test/gpr_658.cmi test/gpr_658.cmj test/gpr_858_test.cmi test/gpr_858_test.cmj test/gpr_858_unit2_test.cmi test/gpr_858_unit2_test.cmj test/gpr_904_test.cmi test/gpr_904_test.cmj test/gpr_974_test.cmi test/gpr_974_test.cmj test/gpr_977_test.cmi test/gpr_977_test.cmj test/gpr_return_type_unused_attribute.cmi test/gpr_return_type_unused_attribute.cmj test/gray_code_test.cmi test/gray_code_test.cmj test/guide_for_ext.cmi test/guide_for_ext.cmj test/hamming_test.cmi test/hamming_test.cmj test/hash_collision_test.cmi test/hash_collision_test.cmj test/hash_sugar_desugar.cmi test/hash_sugar_desugar.cmj test/hash_test.cmi test/hash_test.cmj test/hashtbl_test.cmi test/hashtbl_test.cmj test/hello.foo.cmi test/hello.foo.cmj test/hello_res.cmi test/hello_res.cmj test/ignore_test.cmi test/ignore_test.cmj test/imm_map_bench.cmi test/imm_map_bench.cmj test/include_side_effect.cmi test/include_side_effect.cmj test/include_side_effect_free.cmi test/include_side_effect_free.cmj test/incomplete_toplevel_test.cmi test/incomplete_toplevel_test.cmj test/infer_type_test.cmi test/infer_type_test.cmj test/inline_const.cmi test/inline_const.cmj test/inline_const_test.cmi test/inline_const_test.cmj test/inline_edge_cases.cmi test/inline_edge_cases.cmj test/inline_map2_test.cmi test/inline_map2_test.cmj test/inline_map_demo.cmi test/inline_map_demo.cmj test/inline_map_test.cmi test/inline_map_test.cmj test/inline_record_test.cmi test/inline_record_test.cmj test/inline_regression_test.cmi test/inline_regression_test.cmj test/inline_string_test.cmi test/inline_string_test.cmj test/inner_call.cmi test/inner_call.cmj test/inner_define.cmi test/inner_define.cmj test/inner_unused.cmi test/inner_unused.cmj test/installation_test.cmi test/installation_test.cmj test/int32_test.cmi test/int32_test.cmj test/int64_mul_div_test.cmi test/int64_mul_div_test.cmj test/int64_string_bench.cmi test/int64_string_bench.cmj test/int64_string_test.cmi test/int64_string_test.cmj test/int64_test.cmi test/int64_test.cmj test/int_hashtbl_test.cmi test/int_hashtbl_test.cmj test/int_map.cmi test/int_map.cmj test/int_overflow_test.cmi test/int_overflow_test.cmj test/int_poly_var.cmi test/int_poly_var.cmj test/int_switch_test.cmi test/int_switch_test.cmj test/internal_unused_test.cmi test/internal_unused_test.cmj test/io_test.cmi test/io_test.cmj test/js_array_test.cmi test/js_array_test.cmj test/js_bool_test.cmi test/js_bool_test.cmj test/js_cast_test.cmi test/js_cast_test.cmj test/js_date_test.cmi test/js_date_test.cmj test/js_dict_test.cmi test/js_dict_test.cmj test/js_exception_catch_test.cmi test/js_exception_catch_test.cmj test/js_float_test.cmi test/js_float_test.cmj test/js_global_test.cmi test/js_global_test.cmj test/js_int_test.cmi test/js_int_test.cmj test/js_json_test.cmi test/js_json_test.cmj test/js_list_test.cmi test/js_list_test.cmj test/js_math_test.cmi test/js_math_test.cmj test/js_null_test.cmi test/js_null_test.cmj test/js_null_undefined_test.cmi test/js_null_undefined_test.cmj test/js_nullable_test.cmi test/js_nullable_test.cmj test/js_obj_test.cmi test/js_obj_test.cmj test/js_option_test.cmi test/js_option_test.cmj test/js_promise_basic_test.cmi test/js_promise_basic_test.cmj test/js_re_test.cmi test/js_re_test.cmj test/js_string_test.cmi test/js_string_test.cmj test/js_typed_array_test.cmi test/js_typed_array_test.cmj test/js_undefined_test.cmi test/js_undefined_test.cmj test/js_val.cmi test/js_val.cmj test/jsoo_400_test.cmi test/jsoo_400_test.cmj test/jsoo_485_test.cmi test/jsoo_485_test.cmj test/key_word_property.cmi test/key_word_property.cmj test/key_word_property2.cmi test/key_word_property2.cmj test/key_word_property_plus_test.cmi test/key_word_property_plus_test.cmj test/label_uncurry.cmi test/label_uncurry.cmj test/large_integer_pat.cmi test/large_integer_pat.cmj test/large_record_duplication_test.cmi test/large_record_duplication_test.cmj test/largest_int_flow.cmi test/largest_int_flow.cmj test/lazy_demo.cmi test/lazy_demo.cmj test/lazy_test.cmi test/lazy_test.cmj test/lexer_test.cmi test/lexer_test.cmj test/lib_js_test.cmi test/lib_js_test.cmj test/libarg_test.cmi test/libarg_test.cmj test/libqueue_test.cmi test/libqueue_test.cmj test/limits_test.cmi test/limits_test.cmj test/list_stack.cmi test/list_stack.cmj test/list_test.cmi test/list_test.cmj test/local_exception_test.cmi test/local_exception_test.cmj test/loop_regression_test.cmi test/loop_regression_test.cmj test/loop_suites_test.cmi test/loop_suites_test.cmj test/map_find_test.cmi test/map_find_test.cmj test/map_test.cmi test/map_test.cmj test/mario_game.cmi test/mario_game.cmj test/marshal.cmi test/marshal.cmj test/meth_annotation.cmi test/meth_annotation.cmj test/method_name_test.cmi test/method_name_test.cmj test/method_string_name.cmi test/method_string_name.cmj test/minimal_test.cmi test/minimal_test.cmj test/miss_colon_test.cmi test/miss_colon_test.cmj test/mock_mt.cmi test/mock_mt.cmj test/module_alias_test.cmi test/module_alias_test.cmj test/module_as_class_ffi.cmi test/module_as_class_ffi.cmj test/module_as_function.cmi test/module_as_function.cmj test/module_missing_conversion.cmi test/module_missing_conversion.cmj test/module_parameter_test.cmi test/module_parameter_test.cmj test/module_splice_test.cmi test/module_splice_test.cmj test/more_poly_variant_test.cmi test/more_poly_variant_test.cmj test/more_uncurry.cmi test/more_uncurry.cmj test/mpr_6033_test.cmi test/mpr_6033_test.cmj test/mt.cmi test/mt.cmj test/mt_global.cmi test/mt_global.cmj test/mutable_obj_test.cmi test/mutable_obj_test.cmj test/mutable_uncurry_test.cmi test/mutable_uncurry_test.cmj test/mutual_non_recursive_type.cmi test/mutual_non_recursive_type.cmj test/name_mangle_test.cmi test/name_mangle_test.cmj test/nested_include.cmi test/nested_include.cmj test/nested_module_alias.cmi test/nested_module_alias.cmj test/nested_obj_literal.cmi test/nested_obj_literal.cmj test/nested_obj_test.cmi test/nested_obj_test.cmj test/nested_pattern_match_test.cmi test/nested_pattern_match_test.cmj test/noassert.cmi test/noassert.cmj test/node_fs_test.cmi test/node_fs_test.cmj test/node_path_test.cmi test/node_path_test.cmj test/null_list_test.cmi test/null_list_test.cmj test/number_lexer.cmi test/number_lexer.cmj test/obj_literal_ppx.cmi test/obj_literal_ppx.cmj test/obj_literal_ppx_test.cmi test/obj_literal_ppx_test.cmj test/obj_magic_test.cmi test/obj_magic_test.cmj test/obj_type_test.cmi test/obj_type_test.cmj test/ocaml_re_test.cmi test/ocaml_re_test.cmj test/of_string_test.cmi test/of_string_test.cmj test/offset.cmi test/offset.cmj test/option_encoding_test.cmi test/option_encoding_test.cmj test/option_record_none_test.cmi test/option_record_none_test.cmj test/option_repr_test.cmi test/option_repr_test.cmj test/optional_ffi_test.cmi test/optional_ffi_test.cmj test/optional_regression_test.cmi test/optional_regression_test.cmj test/pipe_send_readline.cmi test/pipe_send_readline.cmj test/pipe_syntax.cmi test/pipe_syntax.cmj test/poly_empty_array.cmi test/poly_empty_array.cmj test/poly_variant_test.cmi test/poly_variant_test.cmj test/polymorphic_raw_test.cmi test/polymorphic_raw_test.cmj test/polymorphism_test.cmi test/polymorphism_test.cmj test/polyvar_convert.cmi test/polyvar_convert.cmj test/polyvar_test.cmi test/polyvar_test.cmj test/ppx_apply_test.cmi test/ppx_apply_test.cmj test/pq_test.cmi test/pq_test.cmj test/pr6726.cmi test/pr6726.cmj test/pr_regression_test.cmi test/pr_regression_test.cmj test/prepend_data_ffi.cmi test/prepend_data_ffi.cmj test/primitive_reg_test.cmi test/primitive_reg_test.cmj test/print_alpha_test.cmi test/print_alpha_test.cmj test/promise_catch_test.cmi test/promise_catch_test.cmj test/queue_402.cmi test/queue_402.cmj test/queue_test.cmi test/queue_test.cmj test/random_test.cmi test/random_test.cmj test/raw_hash_tbl_bench.cmi test/raw_hash_tbl_bench.cmj test/raw_output_test.cmi test/raw_output_test.cmj test/raw_pure_test.cmi test/raw_pure_test.cmj test/rbset.cmi test/rbset.cmj test/react.cmi test/react.cmj test/reactDOMRe.cmi test/reactDOMRe.cmj test/reactDOMServerRe.cmi test/reactDOMServerRe.cmj test/reactEvent.cmi test/reactEvent.cmj test/reactTestUtils.cmi test/reactTestUtils.cmj test/reasonReact.cmi test/reasonReact.cmj test/reasonReactCompat.cmi test/reasonReactCompat.cmj test/reasonReactOptimizedCreateClass.cmi test/reasonReactOptimizedCreateClass.cmj test/reasonReactRouter.cmi test/reasonReactRouter.cmj test/rebind_module.cmi test/rebind_module.cmj test/rebind_module_test.cmi test/rebind_module_test.cmj test/rec_array_test.cmi test/rec_array_test.cmj test/rec_fun_test.cmi test/rec_fun_test.cmj test/rec_module_opt.cmi test/rec_module_opt.cmj test/rec_module_test.cmi test/rec_module_test.cmj test/rec_value_test.cmi test/rec_value_test.cmj test/record_debug_test.cmi test/record_debug_test.cmj test/record_extension_test.cmi test/record_extension_test.cmj test/record_name_test.cmi test/record_name_test.cmj test/record_regression.cmi test/record_regression.cmj test/record_with_test.cmi test/record_with_test.cmj test/recursive_module.cmi test/recursive_module.cmj test/recursive_module_test.cmi test/recursive_module_test.cmj test/recursive_react_component.cmi test/recursive_react_component.cmj test/recursive_records_test.cmi test/recursive_records_test.cmj test/recursive_unbound_module_test.cmi test/recursive_unbound_module_test.cmj test/regression_print.cmi test/regression_print.cmj test/relative_path.cmi test/relative_path.cmj test/res_debug.cmi test/res_debug.cmj test/return_check.cmi test/return_check.cmj test/runtime_encoding_test.cmi test/runtime_encoding_test.cmj test/set_annotation.cmi test/set_annotation.cmj test/set_gen.cmi test/set_gen.cmj test/sexp.cmi test/sexp.cmj test/sexpm.cmi test/sexpm.cmj test/sexpm_test.cmi test/sexpm_test.cmj test/side_effect.cmi test/side_effect.cmj test/side_effect_free.cmi test/side_effect_free.cmj test/simple_derive_test.cmi test/simple_derive_test.cmj test/simple_derive_use.cmi test/simple_derive_use.cmj test/simple_lexer_test.cmi test/simple_lexer_test.cmj test/simplify_lambda_632o.cmi test/simplify_lambda_632o.cmj test/single_module_alias.cmi test/single_module_alias.cmj test/singular_unit_test.cmi test/singular_unit_test.cmj test/small_inline_test.cmi test/small_inline_test.cmj test/splice_test.cmi test/splice_test.cmj test/stack_comp_test.cmi test/stack_comp_test.cmj test/stack_test.cmi test/stack_test.cmj test/stream_parser_test.cmi test/stream_parser_test.cmj test/string_bound_get_test.cmi test/string_bound_get_test.cmj test/string_get_set_test.cmi test/string_get_set_test.cmj test/string_interp_test.cmi test/string_interp_test.cmj test/string_literal_print_test.cmi test/string_literal_print_test.cmj test/string_runtime_test.cmi test/string_runtime_test.cmj test/string_set.cmi test/string_set.cmj test/string_set_test.cmi test/string_set_test.cmj test/string_test.cmi test/string_test.cmj test/string_unicode_test.cmi test/string_unicode_test.cmj test/stringmatch_test.cmi test/stringmatch_test.cmj test/submodule.cmi test/submodule.cmj test/submodule_call.cmi test/submodule_call.cmj test/switch_case_test.cmi test/switch_case_test.cmj test/tailcall_inline_test.cmi test/tailcall_inline_test.cmj test/template.cmi test/template.cmj test/test.cmi test/test.cmj test/test2.cmi test/test2.cmj test/test_alias.cmi test/test_alias.cmj test/test_ari.cmi test/test_ari.cmj test/test_array.cmi test/test_array.cmj test/test_array_append.cmi test/test_array_append.cmj test/test_array_primitive.cmi test/test_array_primitive.cmj test/test_bool_equal.cmi test/test_bool_equal.cmj test/test_bs_this.cmi test/test_bs_this.cmj test/test_bug.cmi test/test_bug.cmj test/test_bytes.cmi test/test_bytes.cmj test/test_case_opt_collision.cmi test/test_case_opt_collision.cmj test/test_case_set.cmi test/test_case_set.cmj test/test_char.cmi test/test_char.cmj test/test_closure.cmi test/test_closure.cmj test/test_common.cmi test/test_common.cmj test/test_const_elim.cmi test/test_const_elim.cmj test/test_const_propogate.cmi test/test_const_propogate.cmj test/test_cpp.cmi test/test_cpp.cmj test/test_cps.cmi test/test_cps.cmj test/test_demo.cmi test/test_demo.cmj test/test_dup_param.cmi test/test_dup_param.cmj test/test_eq.cmi test/test_eq.cmj test/test_exception.cmi test/test_exception.cmj test/test_exception_escape.cmi test/test_exception_escape.cmj test/test_export2.cmi test/test_export2.cmj test/test_external.cmi test/test_external.cmj test/test_external_unit.cmi test/test_external_unit.cmj test/test_ffi.cmi test/test_ffi.cmj test/test_fib.cmi test/test_fib.cmj test/test_filename.cmi test/test_filename.cmj test/test_for_loop.cmi test/test_for_loop.cmj test/test_for_map.cmi test/test_for_map.cmj test/test_for_map2.cmi test/test_for_map2.cmj test/test_format.cmi test/test_format.cmj test/test_formatter.cmi test/test_formatter.cmj test/test_functor_dead_code.cmi test/test_functor_dead_code.cmj test/test_generative_module.cmi test/test_generative_module.cmj test/test_global_print.cmi test/test_global_print.cmj test/test_google_closure.cmi test/test_google_closure.cmj test/test_include.cmi test/test_include.cmj test/test_incomplete.cmi test/test_incomplete.cmj test/test_incr_ref.cmi test/test_incr_ref.cmj test/test_int_map_find.cmi test/test_int_map_find.cmj test/test_internalOO.cmi test/test_internalOO.cmj test/test_is_js.cmi test/test_is_js.cmj test/test_js_ffi.cmi test/test_js_ffi.cmj test/test_let.cmi test/test_let.cmj test/test_list.cmi test/test_list.cmj test/test_literal.cmi test/test_literal.cmj test/test_literals.cmi test/test_literals.cmj test/test_match_exception.cmi test/test_match_exception.cmj test/test_mutliple.cmi test/test_mutliple.cmj test/test_nat64.cmi test/test_nat64.cmj test/test_nested_let.cmi test/test_nested_let.cmj test/test_nested_print.cmi test/test_nested_print.cmj test/test_non_export.cmi test/test_non_export.cmj test/test_nullary.cmi test/test_nullary.cmj test/test_obj.cmi test/test_obj.cmj test/test_obj_simple_ffi.cmi test/test_obj_simple_ffi.cmj test/test_order.cmi test/test_order.cmj test/test_order_tailcall.cmi test/test_order_tailcall.cmj test/test_other_exn.cmi test/test_other_exn.cmj test/test_pack.cmi test/test_pack.cmj test/test_per.cmi test/test_per.cmj test/test_pervasive.cmi test/test_pervasive.cmj test/test_pervasives2.cmi test/test_pervasives2.cmj test/test_pervasives3.cmi test/test_pervasives3.cmj test/test_primitive.cmi test/test_primitive.cmj test/test_ramification.cmi test/test_ramification.cmj test/test_react.cmi test/test_react.cmj test/test_react_case.cmi test/test_react_case.cmj test/test_regex.cmi test/test_regex.cmj test/test_require.cmi test/test_require.cmj test/test_runtime_encoding.cmi test/test_runtime_encoding.cmj test/test_scope.cmi test/test_scope.cmj test/test_seq.cmi test/test_seq.cmj test/test_set.cmi test/test_set.cmj test/test_side_effect_functor.cmi test/test_side_effect_functor.cmj test/test_simple_include.cmi test/test_simple_include.cmj test/test_simple_pattern_match.cmi test/test_simple_pattern_match.cmj test/test_simple_ref.cmi test/test_simple_ref.cmj test/test_simple_tailcall.cmi test/test_simple_tailcall.cmj test/test_small.cmi test/test_small.cmj test/test_sprintf.cmi test/test_sprintf.cmj test/test_stack.cmi test/test_stack.cmj test/test_static_catch_ident.cmi test/test_static_catch_ident.cmj test/test_string.cmi test/test_string.cmj test/test_string_case.cmi test/test_string_case.cmj test/test_string_const.cmi test/test_string_const.cmj test/test_string_map.cmi test/test_string_map.cmj test/test_string_switch.cmi test/test_string_switch.cmj test/test_switch.cmi test/test_switch.cmj test/test_trywith.cmi test/test_trywith.cmj test/test_tuple.cmi test/test_tuple.cmj test/test_tuple_destructring.cmi test/test_tuple_destructring.cmj test/test_type_based_arity.cmi test/test_type_based_arity.cmj test/test_u.cmi test/test_u.cmj test/test_unknown.cmi test/test_unknown.cmj test/test_unsafe_cmp.cmi test/test_unsafe_cmp.cmj test/test_unsafe_obj_ffi.cmi test/test_unsafe_obj_ffi.cmj test/test_unsafe_obj_ffi_ppx.cmi test/test_unsafe_obj_ffi_ppx.cmj test/test_unsupported_primitive.cmi test/test_unsupported_primitive.cmj test/test_while_closure.cmi test/test_while_closure.cmj test/test_while_side_effect.cmi test/test_while_side_effect.cmj test/test_zero_nullable.cmi test/test_zero_nullable.cmj test/then_mangle_test.cmi test/then_mangle_test.cmj test/ticker.cmi test/ticker.cmj test/to_string_test.cmi test/to_string_test.cmj test/topsort_test.cmi test/topsort_test.cmj test/tramp_fib.cmi test/tramp_fib.cmj test/tuple_alloc.cmi test/tuple_alloc.cmj test/type_disambiguate.cmi test/type_disambiguate.cmj test/typeof_test.cmi test/typeof_test.cmj test/ui_defs.cmi test/unboxed_attribute.cmi test/unboxed_attribute.cmj test/unboxed_attribute_test.cmi test/unboxed_attribute_test.cmj test/unboxed_crash.cmi test/unboxed_crash.cmj test/unboxed_use_case.cmi test/unboxed_use_case.cmj test/uncurried_cast.cmi test/uncurried_cast.cmj test/uncurried_default.args.cmi test/uncurried_default.args.cmj test/uncurried_pipe.cmi test/uncurried_pipe.cmj test/uncurry_external_test.cmi test/uncurry_external_test.cmj test/uncurry_glob_test.cmi test/uncurry_glob_test.cmj test/uncurry_test.cmi test/uncurry_test.cmj test/undef_regression2_test.cmi test/undef_regression2_test.cmj test/undef_regression_test.cmi test/undef_regression_test.cmj test/undefine_conditional.cmi test/undefine_conditional.cmj test/unicode_type_error.cmi test/unicode_type_error.cmj test/unit_undefined_test.cmi test/unit_undefined_test.cmj test/unitest_string.cmi test/unitest_string.cmj test/unsafe_full_apply_primitive.cmi test/unsafe_full_apply_primitive.cmj test/unsafe_ppx_test.cmi test/unsafe_ppx_test.cmj test/unsafe_this.cmi test/unsafe_this.cmj test/update_record_test.cmi test/update_record_test.cmj test/utf8_decode_test.cmi test/utf8_decode_test.cmj test/variant.cmi test/variant.cmj test/watch_test.cmi test/watch_test.cmj test/webpack_config.cmi test/webpack_config.cmj diff --git a/jscomp/test/flow_parser_reg_test.js b/jscomp/test/flow_parser_reg_test.js index 69602d9c490..0785c722282 100644 --- a/jscomp/test/flow_parser_reg_test.js +++ b/jscomp/test/flow_parser_reg_test.js @@ -15477,21 +15477,24 @@ function parse(content, options) { } } }; - var jsx_member_expression = function (param) { - var member_expression = param[1]; - var id = member_expression._object; - var _object; - _object = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_member_expression(id._0); - return node("JSXMemberExpression", param[0], [ - [ - "object", - _object - ], - [ - "property", - jsx_identifier(member_expression.property) - ] - ]); + var jsx_identifier = function (param) { + return node("JSXIdentifier", param[0], [[ + "name", + string(param[1].name) + ]]); + }; + var jsx_attribute_value = function (param) { + if (param.TAG === /* Literal */0) { + return literal([ + param._0, + param._1 + ]); + } else { + return jsx_expression_container([ + param._0, + param._1 + ]); + } }; var jsx_namespaced_name = function (param) { var namespaced_name = param[1]; @@ -15506,26 +15509,19 @@ function parse(content, options) { ] ]); }; - var jsx_identifier = function (param) { - return node("JSXIdentifier", param[0], [[ - "name", - string(param[1].name) - ]]); - }; - var jsx_element = function (param) { - var element = param[1]; - return node("JSXElement", param[0], [ - [ - "openingElement", - jsx_opening(element.openingElement) - ], + var jsx_member_expression = function (param) { + var member_expression = param[1]; + var id = member_expression._object; + var _object; + _object = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_member_expression(id._0); + return node("JSXMemberExpression", param[0], [ [ - "closingElement", - option(jsx_closing, element.closingElement) + "object", + _object ], [ - "children", - array_of_list(jsx_child, element.children) + "property", + jsx_identifier(member_expression.property) ] ]); }; @@ -15538,6 +15534,77 @@ function parse(content, options) { expression$1 ]]); }; + var literal = function (param) { + var lit = param[1]; + var raw = lit.raw; + var value = lit.value; + var loc = param[0]; + var value_; + if (typeof value === "number") { + value_ = $$null; + } else { + switch (value.TAG | 0) { + case /* String */0 : + value_ = string(value._0); + break; + case /* Boolean */1 : + value_ = bool(value._0); + break; + case /* Number */2 : + value_ = number$1(value._0); + break; + case /* RegExp */3 : + var match = value._0; + value_ = regexp$1(loc, match.pattern, match.flags); + break; + + } + } + var props; + var exit = 0; + if (typeof value === "number" || value.TAG !== /* RegExp */3) { + exit = 1; + } else { + var match$1 = value._0; + var regex = obj([ + [ + "pattern", + string(match$1.pattern) + ], + [ + "flags", + string(match$1.flags) + ] + ]); + props = [ + [ + "value", + value_ + ], + [ + "raw", + string(raw) + ], + [ + "regex", + regex + ] + ]; + } + if (exit === 1) { + props = [ + [ + "value", + value_ + ], + [ + "raw", + string(raw) + ] + ]; + } + return node("Literal", loc, props); + }; var identifier = function (param) { var id = param[1]; return node("Identifier", param[0], [ @@ -15555,6 +15622,83 @@ function parse(content, options) { ] ]); }; + var type_annotation = function (param) { + return node("TypeAnnotation", param[0], [[ + "typeAnnotation", + _type(param[1]) + ]]); + }; + var generic_type_qualified_identifier = function (param) { + var q = param[1]; + var id = q.qualification; + var qualification; + qualification = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("QualifiedTypeIdentifier", param[0], [ + [ + "qualification", + qualification + ], + [ + "id", + identifier(q.id) + ] + ]); + }; + var type_parameter_instantiation = function (param) { + return node("TypeParameterInstantiation", param[0], [[ + "params", + array_of_list(_type, param[1].params) + ]]); + }; + var pattern = function (param) { + var obj = param[1]; + var loc = param[0]; + switch (obj.TAG | 0) { + case /* Object */0 : + var obj$1 = obj._0; + return node("ObjectPattern", loc, [ + [ + "properties", + array_of_list(object_pattern_property, obj$1.properties) + ], + [ + "typeAnnotation", + option(type_annotation, obj$1.typeAnnotation) + ] + ]); + case /* Array */1 : + var arr = obj._0; + return node("ArrayPattern", loc, [ + [ + "elements", + array_of_list((function (param) { + return option(array_pattern_element, param); + }), arr.elements) + ], + [ + "typeAnnotation", + option(type_annotation, arr.typeAnnotation) + ] + ]); + case /* Assignment */2 : + var match = obj._0; + return node("AssignmentPattern", loc, [ + [ + "left", + pattern(match.left) + ], + [ + "right", + expression(match.right) + ] + ]); + case /* Identifier */3 : + return identifier(obj._0); + case /* Expression */4 : + return expression(obj._0); + + } + }; var expression = function (param) { var arr = param[1]; var loc = param[0]; @@ -16062,136 +16206,78 @@ function parse(content, options) { } }; - var object_type_call_property = function (param) { - var callProperty = param[1]; - return node("ObjectTypeCallProperty", param[0], [ + var interface_extends = function (param) { + var g = param[1]; + var id = g.id; + var id$1; + id$1 = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("InterfaceExtends", param[0], [ [ - "value", - function_type(callProperty.value) + "id", + id$1 ], [ - "static", - bool(callProperty.static) + "typeParameters", + option(type_parameter_instantiation, g.typeParameters) ] ]); }; - var object_type_property = function (param) { - var prop = param[1]; - var lit = prop.key; - var key; - switch (lit.TAG | 0) { - case /* Literal */0 : - key = literal(lit._0); - break; - case /* Identifier */1 : - key = identifier(lit._0); - break; - case /* Computed */2 : - throw { - RE_EXN_ID: "Failure", - _1: "There should not be computed object type property keys", - Error: new Error() - }; - - } - return node("ObjectTypeProperty", param[0], [ + var type_parameter_declaration = function (param) { + return node("TypeParameterDeclaration", param[0], [[ + "params", + array_of_list(type_param, param[1].params) + ]]); + }; + var object_type = function (param) { + var o = param[1]; + return node("ObjectTypeAnnotation", param[0], [ [ - "key", - key - ], - [ - "value", - _type(prop.value) + "properties", + array_of_list(object_type_property, o.properties) ], [ - "optional", - bool(prop.optional) + "indexers", + array_of_list(object_type_indexer, o.indexers) ], [ - "static", - bool(prop.static) + "callProperties", + array_of_list(object_type_call_property, o.callProperties) ] ]); }; - var object_type_indexer = function (param) { - var indexer = param[1]; - return node("ObjectTypeIndexer", param[0], [ - [ - "id", - identifier(indexer.id) - ], - [ - "key", - _type(indexer.key) - ], + var jsx_element = function (param) { + var element = param[1]; + return node("JSXElement", param[0], [ [ - "value", - _type(indexer.value) + "openingElement", + jsx_opening(element.openingElement) ], [ - "static", - bool(indexer.static) - ] - ]); - }; - var $$case = function (param) { - var c = param[1]; - return node("SwitchCase", param[0], [ - [ - "test", - option(expression, c.test) + "closingElement", + option(jsx_closing, element.closingElement) ], [ - "consequent", - array_of_list(statement, c.consequent) + "children", + array_of_list(jsx_child, element.children) ] ]); }; - var variable_declaration = function (param) { - var $$var = param[1]; - var match = $$var.kind; - var kind; - switch (match) { - case /* Var */0 : - kind = "var"; - break; - case /* Let */1 : - kind = "let"; - break; - case /* Const */2 : - kind = "const"; - break; - - } - return node("VariableDeclaration", param[0], [ - [ - "declarations", - array_of_list(variable_declarator, $$var.declarations) - ], - [ - "kind", - string(kind) - ] - ]); + var class_body = function (param) { + return node("ClassBody", param[0], [[ + "body", + array_of_list(class_element, param[1].body) + ]]); }; - var interface_declaration = function (param) { - var i = param[1]; - return node("InterfaceDeclaration", param[0], [ + var class_implements = function (param) { + var $$implements = param[1]; + return node("ClassImplements", param[0], [ [ "id", - identifier(i.id) + identifier($$implements.id) ], [ "typeParameters", - option(type_parameter_declaration, i.typeParameters) - ], - [ - "body", - object_type(i.body) - ], - [ - "extends", - array_of_list(interface_extends, i.extends) + option(type_parameter_instantiation, $$implements.typeParameters) ] ]); }; @@ -16715,328 +16801,244 @@ function parse(content, options) { } }; - var pattern = function (param) { - var obj = param[1]; - var loc = param[0]; - switch (obj.TAG | 0) { - case /* Object */0 : - var obj$1 = obj._0; - return node("ObjectPattern", loc, [ - [ - "properties", - array_of_list(object_pattern_property, obj$1.properties) - ], - [ - "typeAnnotation", - option(type_annotation, obj$1.typeAnnotation) - ] - ]); - case /* Array */1 : - var arr = obj._0; - return node("ArrayPattern", loc, [ - [ - "elements", - array_of_list((function (param) { - return option(array_pattern_element, param); - }), arr.elements) - ], - [ - "typeAnnotation", - option(type_annotation, arr.typeAnnotation) - ] - ]); - case /* Assignment */2 : - var match = obj._0; - return node("AssignmentPattern", loc, [ - [ - "left", - pattern(match.left) - ], - [ - "right", - expression(match.right) - ] - ]); - case /* Identifier */3 : - return identifier(obj._0); - case /* Expression */4 : - return expression(obj._0); - - } - }; - var declare_function = function (param) { - return node("DeclareFunction", param[0], [[ - "id", - identifier(param[1].id) - ]]); - }; - var export_specifiers = function (param) { - if (param !== undefined) { - if (param.TAG === /* ExportSpecifiers */0) { - return array_of_list(export_specifier, param._0); - } else { - return array([node("ExportBatchSpecifier", param._0, [[ - "name", - option(identifier, param._1) - ]])]); - } - } else { - return array([]); - } - }; - var type_alias = function (param) { - var alias = param[1]; - return node("TypeAlias", param[0], [ + var variable_declarator = function (param) { + var declarator = param[1]; + return node("VariableDeclarator", param[0], [ [ "id", - identifier(alias.id) - ], - [ - "typeParameters", - option(type_parameter_declaration, alias.typeParameters) + pattern(declarator.id) ], [ - "right", - _type(alias.right) + "init", + option(expression, declarator.init) ] ]); }; - var let_assignment = function (assignment) { - return obj([ + var array_pattern_element = function (p) { + if (p.TAG === /* Element */0) { + return pattern(p._0); + } + var match = p._0; + return node("SpreadElementPattern", match[0], [[ + "argument", + pattern(match[1].argument) + ]]); + }; + var object_pattern_property = function (param) { + if (param.TAG === /* Property */0) { + var match = param._0; + var prop = match[1]; + var lit = prop.key; + var match$1; + switch (lit.TAG | 0) { + case /* Literal */0 : + match$1 = [ + literal(lit._0), + false + ]; + break; + case /* Identifier */1 : + match$1 = [ + identifier(lit._0), + false + ]; + break; + case /* Computed */2 : + match$1 = [ + expression(lit._0), + true + ]; + break; + + } + return node("PropertyPattern", match[0], [ + [ + "key", + match$1[0] + ], + [ + "pattern", + pattern(prop.pattern) + ], + [ + "computed", + bool(match$1[1]) + ], + [ + "shorthand", + bool(prop.shorthand) + ] + ]); + } + var match$2 = param._0; + return node("SpreadPropertyPattern", match$2[0], [[ + "argument", + pattern(match$2[1].argument) + ]]); + }; + var export_specifier = function (param) { + var specifier = param[1]; + return node("ExportSpecifier", param[0], [ [ "id", - pattern(assignment.id) + identifier(specifier.id) ], [ - "init", - option(expression, assignment.init) + "name", + option(identifier, specifier.name) ] ]); }; - var block = function (param) { - return node("BlockStatement", param[0], [[ - "body", - array_of_list(statement, param[1].body) - ]]); - }; - var $$catch = function (param) { - var c = param[1]; - return node("CatchClause", param[0], [ - [ - "param", - pattern(c.param) - ], + var template_element = function (param) { + var element = param[1]; + var value = obj([ + [ + "raw", + string(element.value.raw) + ], + [ + "cooked", + string(element.value.cooked) + ] + ]); + return node("TemplateElement", param[0], [ [ - "guard", - option(expression, c.guard) + "value", + value ], [ - "body", - block(c.body) + "tail", + bool(element.tail) ] ]); }; - var literal = function (param) { - var lit = param[1]; - var raw = lit.raw; - var value = lit.value; - var loc = param[0]; - var value_; - if (typeof value === "number") { - value_ = $$null; - } else { - switch (value.TAG | 0) { - case /* String */0 : - value_ = string(value._0); - break; - case /* Boolean */1 : - value_ = bool(value._0); - break; - case /* Number */2 : - value_ = number$1(value._0); - break; - case /* RegExp */3 : - var match = value._0; - value_ = regexp$1(loc, match.pattern, match.flags); - break; - - } - } - var props; - var exit = 0; - if (typeof value === "number" || value.TAG !== /* RegExp */3) { - exit = 1; - } else { - var match$1 = value._0; - var regex = obj([ - [ - "pattern", - string(match$1.pattern) - ], - [ - "flags", - string(match$1.flags) - ] - ]); - props = [ - [ - "value", - value_ - ], - [ - "raw", - string(raw) - ], - [ - "regex", - regex - ] - ]; - } - if (exit === 1) { - props = [ - [ - "value", - value_ - ], - [ - "raw", - string(raw) - ] - ]; - } - return node("Literal", loc, props); - }; - var declare_variable = function (param) { - return node("DeclareVariable", param[0], [[ - "id", - identifier(param[1].id) - ]]); - }; - var declare_class = function (param) { - var d = param[1]; - return node("DeclareClass", param[0], [ + var function_type = function (param) { + var fn = param[1]; + return node("FunctionTypeAnnotation", param[0], [ [ - "id", - identifier(d.id) + "params", + array_of_list(function_type_param, fn.params) ], [ - "typeParameters", - option(type_parameter_declaration, d.typeParameters) + "returnType", + _type(fn.returnType) ], [ - "body", - object_type(d.body) + "rest", + option(function_type_param, fn.rest) ], [ - "extends", - array_of_list(interface_extends, d.extends) + "typeParameters", + option(type_parameter_declaration, fn.typeParameters) ] ]); }; - var type_parameter_declaration = function (param) { - return node("TypeParameterDeclaration", param[0], [[ - "params", - array_of_list(type_param, param[1].params) - ]]); - }; - var type_annotation = function (param) { - return node("TypeAnnotation", param[0], [[ - "typeAnnotation", - _type(param[1]) - ]]); - }; - var export_specifier = function (param) { - var specifier = param[1]; - return node("ExportSpecifier", param[0], [ + var object_type_call_property = function (param) { + var callProperty = param[1]; + return node("ObjectTypeCallProperty", param[0], [ [ - "id", - identifier(specifier.id) + "value", + function_type(callProperty.value) ], [ - "name", - option(identifier, specifier.name) + "static", + bool(callProperty.static) ] ]); }; - var type_parameter_instantiation = function (param) { - return node("TypeParameterInstantiation", param[0], [[ - "params", - array_of_list(_type, param[1].params) - ]]); + var object_type_property = function (param) { + var prop = param[1]; + var lit = prop.key; + var key; + switch (lit.TAG | 0) { + case /* Literal */0 : + key = literal(lit._0); + break; + case /* Identifier */1 : + key = identifier(lit._0); + break; + case /* Computed */2 : + throw { + RE_EXN_ID: "Failure", + _1: "There should not be computed object type property keys", + Error: new Error() + }; + + } + return node("ObjectTypeProperty", param[0], [ + [ + "key", + key + ], + [ + "value", + _type(prop.value) + ], + [ + "optional", + bool(prop.optional) + ], + [ + "static", + bool(prop.static) + ] + ]); }; - var class_implements = function (param) { - var $$implements = param[1]; - return node("ClassImplements", param[0], [ + var object_type_indexer = function (param) { + var indexer = param[1]; + return node("ObjectTypeIndexer", param[0], [ [ "id", - identifier($$implements.id) + identifier(indexer.id) ], [ - "typeParameters", - option(type_parameter_instantiation, $$implements.typeParameters) + "key", + _type(indexer.key) + ], + [ + "value", + _type(indexer.value) + ], + [ + "static", + bool(indexer.static) ] ]); }; - var class_body = function (param) { - return node("ClassBody", param[0], [[ - "body", - array_of_list(class_element, param[1].body) - ]]); - }; - var jsx_opening_attribute = function (attribute) { - if (attribute.TAG === /* Attribute */0) { - var param = attribute._0; - var attribute$1 = param[1]; - var id = attribute$1.name; - var name; - name = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); - return node("JSXAttribute", param[0], [ - [ - "name", - name - ], - [ - "value", - option(jsx_attribute_value, attribute$1.value) - ] - ]); - } else { - var param$1 = attribute._0; - return node("JSXSpreadAttribute", param$1[0], [[ - "argument", - expression(param$1[1].argument) - ]]); - } - }; - var jsx_name = function (id) { - switch (id.TAG | 0) { - case /* Identifier */0 : - return jsx_identifier(id._0); - case /* NamespacedName */1 : - return jsx_namespaced_name(id._0); - case /* MemberExpression */2 : - return jsx_member_expression(id._0); - - } + var comment = function (param) { + var c = param[1]; + var match; + match = c.TAG === /* Block */0 ? [ + "Block", + c._0 + ] : [ + "Line", + c._0 + ]; + return node(match[0], param[0], [[ + "value", + string(match[1]) + ]]); }; - var jsx_opening = function (param) { - var opening = param[1]; - return node("JSXOpeningElement", param[0], [ - [ - "name", - jsx_name(opening.name) - ], + var template_literal = function (param) { + var value = param[1]; + return node("TemplateLiteral", param[0], [ [ - "attributes", - array_of_list(jsx_opening_attribute, opening.attributes) + "quasis", + array_of_list(template_element, value.quasis) ], [ - "selfClosing", - bool(opening.selfClosing) + "expressions", + array_of_list(expression, value.expressions) ] ]); }; + var block = function (param) { + return node("BlockStatement", param[0], [[ + "body", + array_of_list(statement, param[1].body) + ]]); + }; var jsx_child = function (param) { var element = param[1]; var loc = param[0]; @@ -17076,96 +17078,241 @@ function parse(content, options) { jsx_name(param[1].name) ]]); }; - var generic_type_qualified_identifier = function (param) { - var q = param[1]; - var id = q.qualification; - var qualification; - qualification = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("QualifiedTypeIdentifier", param[0], [ + var jsx_opening = function (param) { + var opening = param[1]; + return node("JSXOpeningElement", param[0], [ [ - "qualification", - qualification + "name", + jsx_name(opening.name) + ], + [ + "attributes", + array_of_list(jsx_opening_attribute, opening.attributes) ], + [ + "selfClosing", + bool(opening.selfClosing) + ] + ]); + }; + var function_expression = function (param) { + var _function = param[1]; + var b = _function.body; + var body; + body = b.TAG === /* BodyBlock */0 ? block(b._0) : expression(b._0); + return node("FunctionExpression", param[0], [ [ "id", - identifier(q.id) + option(identifier, _function.id) + ], + [ + "params", + array_of_list(pattern, _function.params) + ], + [ + "defaults", + array_of_list((function (param) { + return option(expression, param); + }), _function.defaults) + ], + [ + "rest", + option(identifier, _function.rest) + ], + [ + "body", + body + ], + [ + "async", + bool(_function.async) + ], + [ + "generator", + bool(_function.generator) + ], + [ + "expression", + bool(_function.expression) + ], + [ + "returnType", + option(type_annotation, _function.returnType) + ], + [ + "typeParameters", + option(type_parameter_declaration, _function.typeParameters) ] ]); }; - var object_type = function (param) { - var o = param[1]; - return node("ObjectTypeAnnotation", param[0], [ + var type_alias = function (param) { + var alias = param[1]; + return node("TypeAlias", param[0], [ [ - "properties", - array_of_list(object_type_property, o.properties) + "id", + identifier(alias.id) ], [ - "indexers", - array_of_list(object_type_indexer, o.indexers) + "typeParameters", + option(type_parameter_declaration, alias.typeParameters) ], [ - "callProperties", - array_of_list(object_type_call_property, o.callProperties) + "right", + _type(alias.right) ] ]); }; - var interface_extends = function (param) { - var g = param[1]; - var id = g.id; - var id$1; - id$1 = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("InterfaceExtends", param[0], [ + var export_specifiers = function (param) { + if (param !== undefined) { + if (param.TAG === /* ExportSpecifiers */0) { + return array_of_list(export_specifier, param._0); + } else { + return array([node("ExportBatchSpecifier", param._0, [[ + "name", + option(identifier, param._1) + ]])]); + } + } else { + return array([]); + } + }; + var interface_declaration = function (param) { + var i = param[1]; + return node("InterfaceDeclaration", param[0], [ [ "id", - id$1 + identifier(i.id) ], [ "typeParameters", - option(type_parameter_instantiation, g.typeParameters) + option(type_parameter_declaration, i.typeParameters) + ], + [ + "body", + object_type(i.body) + ], + [ + "extends", + array_of_list(interface_extends, i.extends) ] ]); }; - var template_element = function (param) { - var element = param[1]; - var value = obj([ - [ - "raw", - string(element.value.raw) - ], - [ - "cooked", - string(element.value.cooked) - ] - ]); - return node("TemplateElement", param[0], [ + var declare_variable = function (param) { + return node("DeclareVariable", param[0], [[ + "id", + identifier(param[1].id) + ]]); + }; + var variable_declaration = function (param) { + var $$var = param[1]; + var match = $$var.kind; + var kind; + switch (match) { + case /* Var */0 : + kind = "var"; + break; + case /* Let */1 : + kind = "let"; + break; + case /* Const */2 : + kind = "const"; + break; + + } + return node("VariableDeclaration", param[0], [ + [ + "declarations", + array_of_list(variable_declarator, $$var.declarations) + ], + [ + "kind", + string(kind) + ] + ]); + }; + var declare_class = function (param) { + var d = param[1]; + return node("DeclareClass", param[0], [ + [ + "id", + identifier(d.id) + ], + [ + "typeParameters", + option(type_parameter_declaration, d.typeParameters) + ], + [ + "body", + object_type(d.body) + ], + [ + "extends", + array_of_list(interface_extends, d.extends) + ] + ]); + }; + var $$case = function (param) { + var c = param[1]; + return node("SwitchCase", param[0], [ + [ + "test", + option(expression, c.test) + ], + [ + "consequent", + array_of_list(statement, c.consequent) + ] + ]); + }; + var let_assignment = function (assignment) { + return obj([ + [ + "id", + pattern(assignment.id) + ], + [ + "init", + option(expression, assignment.init) + ] + ]); + }; + var $$catch = function (param) { + var c = param[1]; + return node("CatchClause", param[0], [ + [ + "param", + pattern(c.param) + ], [ - "value", - value + "guard", + option(expression, c.guard) ], [ - "tail", - bool(element.tail) + "body", + block(c.body) ] ]); }; - var function_type = function (param) { - var fn = param[1]; - return node("FunctionTypeAnnotation", param[0], [ - [ - "params", - array_of_list(function_type_param, fn.params) - ], + var declare_function = function (param) { + return node("DeclareFunction", param[0], [[ + "id", + identifier(param[1].id) + ]]); + }; + var function_type_param = function (param) { + var param$1 = param[1]; + return node("FunctionTypeParam", param[0], [ [ - "returnType", - _type(fn.returnType) + "name", + identifier(param$1.name) ], [ - "rest", - option(function_type_param, fn.rest) + "typeAnnotation", + _type(param$1.typeAnnotation) ], [ - "typeParameters", - option(type_parameter_declaration, fn.typeParameters) + "optional", + bool(param$1.optional) ] ]); }; @@ -17243,23 +17390,6 @@ function parse(content, options) { expression(match$3[1].argument) ]]); }; - var comprehension_block = function (param) { - var b = param[1]; - return node("ComprehensionBlock", param[0], [ - [ - "left", - pattern(b.left) - ], - [ - "right", - expression(b.right) - ], - [ - "each", - bool(b.each) - ] - ]); - }; var expression_or_spread = function (expr) { if (expr.TAG === /* Expression */0) { return expression(expr._0); @@ -17270,66 +17400,20 @@ function parse(content, options) { expression(match[1].argument) ]]); }; - var function_expression = function (param) { - var _function = param[1]; - var b = _function.body; - var body; - body = b.TAG === /* BodyBlock */0 ? block(b._0) : expression(b._0); - return node("FunctionExpression", param[0], [ - [ - "id", - option(identifier, _function.id) - ], - [ - "params", - array_of_list(pattern, _function.params) - ], - [ - "defaults", - array_of_list((function (param) { - return option(expression, param); - }), _function.defaults) - ], - [ - "rest", - option(identifier, _function.rest) - ], - [ - "body", - body - ], - [ - "async", - bool(_function.async) - ], - [ - "generator", - bool(_function.generator) - ], - [ - "expression", - bool(_function.expression) - ], + var comprehension_block = function (param) { + var b = param[1]; + return node("ComprehensionBlock", param[0], [ [ - "returnType", - option(type_annotation, _function.returnType) + "left", + pattern(b.left) ], [ - "typeParameters", - option(type_parameter_declaration, _function.typeParameters) - ] - ]); - }; - var template_literal = function (param) { - var value = param[1]; - return node("TemplateLiteral", param[0], [ - [ - "quasis", - array_of_list(template_element, value.quasis) + "right", + expression(b.right) ], [ - "expressions", - array_of_list(expression, value.expressions) + "each", + bool(b.each) ] ]); }; @@ -17480,125 +17564,41 @@ function parse(content, options) { ]); } }; - var comment = function (param) { - var c = param[1]; - var match; - match = c.TAG === /* Block */0 ? [ - "Block", - c._0 - ] : [ - "Line", - c._0 - ]; - return node(match[0], param[0], [[ - "value", - string(match[1]) - ]]); - }; - var function_type_param = function (param) { - var param$1 = param[1]; - return node("FunctionTypeParam", param[0], [ - [ - "name", - identifier(param$1.name) - ], - [ - "typeAnnotation", - _type(param$1.typeAnnotation) - ], - [ - "optional", - bool(param$1.optional) - ] - ]); - }; - var variable_declarator = function (param) { - var declarator = param[1]; - return node("VariableDeclarator", param[0], [ - [ - "id", - pattern(declarator.id) - ], - [ - "init", - option(expression, declarator.init) - ] - ]); - }; - var jsx_attribute_value = function (param) { - if (param.TAG === /* Literal */0) { - return literal([ - param._0, - param._1 - ]); - } else { - return jsx_expression_container([ - param._0, - param._1 - ]); - } - }; - var array_pattern_element = function (p) { - if (p.TAG === /* Element */0) { - return pattern(p._0); + var jsx_name = function (id) { + switch (id.TAG | 0) { + case /* Identifier */0 : + return jsx_identifier(id._0); + case /* NamespacedName */1 : + return jsx_namespaced_name(id._0); + case /* MemberExpression */2 : + return jsx_member_expression(id._0); + } - var match = p._0; - return node("SpreadElementPattern", match[0], [[ - "argument", - pattern(match[1].argument) - ]]); }; - var object_pattern_property = function (param) { - if (param.TAG === /* Property */0) { - var match = param._0; - var prop = match[1]; - var lit = prop.key; - var match$1; - switch (lit.TAG | 0) { - case /* Literal */0 : - match$1 = [ - literal(lit._0), - false - ]; - break; - case /* Identifier */1 : - match$1 = [ - identifier(lit._0), - false - ]; - break; - case /* Computed */2 : - match$1 = [ - expression(lit._0), - true - ]; - break; - - } - return node("PropertyPattern", match[0], [ - [ - "key", - match$1[0] - ], - [ - "pattern", - pattern(prop.pattern) - ], + var jsx_opening_attribute = function (attribute) { + if (attribute.TAG === /* Attribute */0) { + var param = attribute._0; + var attribute$1 = param[1]; + var id = attribute$1.name; + var name; + name = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); + return node("JSXAttribute", param[0], [ [ - "computed", - bool(match$1[1]) + "name", + name ], [ - "shorthand", - bool(prop.shorthand) + "value", + option(jsx_attribute_value, attribute$1.value) ] ]); + } else { + var param$1 = attribute._0; + return node("JSXSpreadAttribute", param$1[0], [[ + "argument", + expression(param$1[1].argument) + ]]); } - var match$2 = param._0; - return node("SpreadPropertyPattern", match$2[0], [[ - "argument", - pattern(match$2[1].argument) - ]]); }; var program$2 = function (param) { return node("Program", param[0], [ diff --git a/lib/es6/belt_internalBuckets.js b/lib/es6/belt_internalBuckets.js index 09cf0a8f55e..302642266ac 100644 --- a/lib/es6/belt_internalBuckets.js +++ b/lib/es6/belt_internalBuckets.js @@ -4,6 +4,19 @@ import * as Curry from "./curry.js"; import * as Belt_Array from "./belt_Array.js"; import * as Caml_option from "./caml_option.js"; +function copyBucket(c) { + if (c === undefined) { + return c; + } + var head = { + key: c.key, + value: c.value, + next: undefined + }; + copyAuxCont(c.next, head); + return head; +} + function copyAuxCont(_c, _prec) { while(true) { var prec = _prec; @@ -23,19 +36,6 @@ function copyAuxCont(_c, _prec) { }; } -function copyBucket(c) { - if (c === undefined) { - return c; - } - var head = { - key: c.key, - value: c.value, - next: undefined - }; - copyAuxCont(c.next, head); - return head; -} - function copyBuckets(buckets) { var len = buckets.length; var newBuckets = new Array(len); diff --git a/lib/js/belt_internalBuckets.js b/lib/js/belt_internalBuckets.js index cad3a978dca..eabd14bcbcd 100644 --- a/lib/js/belt_internalBuckets.js +++ b/lib/js/belt_internalBuckets.js @@ -4,6 +4,19 @@ var Curry = require("./curry.js"); var Belt_Array = require("./belt_Array.js"); var Caml_option = require("./caml_option.js"); +function copyBucket(c) { + if (c === undefined) { + return c; + } + var head = { + key: c.key, + value: c.value, + next: undefined + }; + copyAuxCont(c.next, head); + return head; +} + function copyAuxCont(_c, _prec) { while(true) { var prec = _prec; @@ -23,19 +36,6 @@ function copyAuxCont(_c, _prec) { }; } -function copyBucket(c) { - if (c === undefined) { - return c; - } - var head = { - key: c.key, - value: c.value, - next: undefined - }; - copyAuxCont(c.next, head); - return head; -} - function copyBuckets(buckets) { var len = buckets.length; var newBuckets = new Array(len);