@@ -228,13 +228,13 @@ type initialization = J.block
228228let compile output_prefix =
229229
230230let rec compile_external_field (* Like [List.empty]*)
231- (lamba_cxt : Lam_compile_context.t ) (id : Ident.t ) name : Js_output.t =
232- match Lam_compile_env. query_external_id_info id name with
231+ ?( dynamic_import = false ) (lamba_cxt : Lam_compile_context.t ) (id : Ident.t ) name : Js_output.t =
232+ match Lam_compile_env. query_external_id_info ~dynamic_import id name with
233233 | { persistent_closed_lambda = Some lam } when Lam_util. not_function lam ->
234234 compile_lambda lamba_cxt lam
235235 | _ ->
236236 Js_output. output_of_expression lamba_cxt.continuation
237- ~no_effects: no_effects_const (E. ml_var_dot id name)
237+ ~no_effects: no_effects_const (E. ml_var_dot ~dynamic_import id name)
238238(* TODO: how nested module call would behave,
239239 In the future, we should keep in track of if
240240 it is fully applied from [Lapply]
@@ -263,10 +263,10 @@ let rec compile_external_field (* Like [List.empty]*)
263263 for the function, generative module or functor can be a function,
264264 however it can not be global -- global can only module
265265*)
266- and compile_external_field_apply (appinfo : Lam.apply ) (module_id : Ident.t )
266+ and compile_external_field_apply ?( dynamic_import = false ) (appinfo : Lam.apply ) (module_id : Ident.t )
267267 (field_name : string ) (lambda_cxt : Lam_compile_context.t ) : Js_output.t =
268268 let ident_info =
269- Lam_compile_env. query_external_id_info module_id field_name
269+ Lam_compile_env. query_external_id_info ~dynamic_import module_id field_name
270270 in
271271 let ap_args = appinfo.ap_args in
272272 match ident_info.persistent_closed_lambda with
@@ -292,7 +292,7 @@ and compile_external_field_apply (appinfo : Lam.apply) (module_id : Ident.t)
292292 | _ -> assert false )
293293 in
294294
295- let fn = E. ml_var_dot module_id ident_info.name in
295+ let fn = E. ml_var_dot ~dynamic_import module_id ident_info.name in
296296 let expression =
297297 match appinfo.ap_info.ap_status with
298298 | (App_infer_full | App_uncurry ) as ap_status ->
@@ -1410,11 +1410,11 @@ and compile_apply (appinfo : Lam.apply) (lambda_cxt : Lam_compile_context.t) =
14101410 (* External function call: it can not be tailcall in this case*)
14111411 | {
14121412 ap_func =
1413- Lprim { primitive = Pfield (_, fld_info); args = [ Lglobal_module id ]; _ };
1413+ Lprim { primitive = Pfield (_, fld_info); args = [ Lglobal_module (id, dynamic_import) ]; _ };
14141414 } -> (
14151415 match fld_info with
14161416 | Fld_module { name } ->
1417- compile_external_field_apply appinfo id name lambda_cxt
1417+ compile_external_field_apply ~dynamic_import appinfo id name lambda_cxt
14181418 | _ -> assert false )
14191419 | _ -> (
14201420 (* TODO: ---
@@ -1491,11 +1491,11 @@ and compile_apply (appinfo : Lam.apply) (lambda_cxt : Lam_compile_context.t) =
14911491and compile_prim (prim_info : Lam.prim_info )
14921492 (lambda_cxt : Lam_compile_context.t ) =
14931493 match prim_info with
1494- | { primitive = Pfield (_ , fld_info ); args = [ Lglobal_module id ]; _ } -> (
1494+ | { primitive = Pfield (_ , fld_info ); args = [ Lglobal_module (id, dynamic_import) ]; _ } -> (
14951495 (* should be before Lglobal_global *)
14961496 match fld_info with
14971497 | Fld_module { name = field } ->
1498- compile_external_field lambda_cxt id field
1498+ compile_external_field ~dynamic_import lambda_cxt id field
14991499 | _ -> assert false )
15001500 | { primitive = Praise ; args = [ e ]; _ } -> (
15011501 match
@@ -1715,13 +1715,13 @@ and compile_lambda (lambda_cxt : Lam_compile_context.t) (cur_lam : Lam.t) :
17151715 Js_output. output_of_expression lambda_cxt.continuation
17161716 ~no_effects: no_effects_const
17171717 (Lam_compile_const. translate c)
1718- | Lglobal_module i ->
1718+ | Lglobal_module ( i , dynamic_import ) ->
17191719 (* introduced by
17201720 1. {[ include Array --> let include = Array ]}
17211721 2. inline functor application
17221722 *)
17231723 Js_output. output_of_block_and_expression lambda_cxt.continuation []
1724- (E. ml_module_as_var i)
1724+ (E. ml_module_as_var ~dynamic_import i)
17251725 | Lprim prim_info -> compile_prim prim_info lambda_cxt
17261726 | Lsequence (l1 , l2 ) ->
17271727 let output_l1 =
@@ -1759,4 +1759,4 @@ and compile_lambda (lambda_cxt : Lam_compile_context.t) (cur_lam : Lam.t) :
17591759in compile_recursive_lets, compile_lambda
17601760
17611761let compile_recursive_lets ~output_prefix = fst (compile output_prefix)
1762- let compile_lambda ~output_prefix = snd (compile output_prefix)
1762+ let compile_lambda ~output_prefix = snd (compile output_prefix)
0 commit comments