@@ -180556,9 +180556,9 @@ val add_structure : string -> (Parsetree.expression option -> unit) -> unit
180556180556
180557180557val add_signature : string -> (Parsetree.expression option -> unit) -> unit
180558180558
180559- val iter_on_bs_config_stru : Parsetree.structure -> unit
180559+ val process_str : Parsetree.structure -> unit
180560180560
180561- val iter_on_bs_config_sigi : Parsetree.signature -> unit
180561+ val process_sig : Parsetree.signature -> unit
180562180562
180563180563end = struct
180564180564#1 "ast_config.ml"
@@ -180602,7 +180602,15 @@ let signature_config_table : action_table ref = ref Map_string.empty
180602180602let add_signature k v =
180603180603 signature_config_table := Map_string.add !signature_config_table k v
180604180604
180605- let rec iter_on_bs_config_stru (x : Parsetree.structure) =
180605+ let process_directives str =
180606+ Js_config.directives := []; (* Restt: multiple calls possible e.g. with bsc from the command-line *)
180607+ str |> List.iter(fun (item : Parsetree.structure_item) -> match item.pstr_desc with
180608+ | Pstr_attribute ({ txt = "directive" },
180609+ PStr [ { pstr_desc = Pstr_eval ({ pexp_desc = Pexp_constant (Pconst_string (d, _)) }, _) } ]) ->
180610+ Js_config.directives := !Js_config.directives @ [d]
180611+ | _ -> ())
180612+
180613+ let rec iter_on_bs_config_str (x : Parsetree.structure) =
180606180614 match x with
180607180615 | [] -> ()
180608180616 | {
@@ -180615,10 +180623,14 @@ let rec iter_on_bs_config_stru (x : Parsetree.structure) =
180615180623 Ext_list.iter
180616180624 (Ast_payload.ident_or_record_as_config loc payload)
180617180625 (Ast_payload.table_dispatch !structural_config_table)
180618- | { pstr_desc = Pstr_attribute _ } :: rest -> iter_on_bs_config_stru rest
180626+ | { pstr_desc = Pstr_attribute _ } :: rest -> iter_on_bs_config_str rest
180619180627 | _ :: _ -> ()
180620180628
180621- let rec iter_on_bs_config_sigi (x : Parsetree.signature) =
180629+ let process_str str =
180630+ iter_on_bs_config_str str;
180631+ process_directives str
180632+
180633+ let rec iter_on_bs_config_sig (x : Parsetree.signature) =
180622180634 match x with
180623180635 | [] -> ()
180624180636 | {
@@ -180631,9 +180643,10 @@ let rec iter_on_bs_config_sigi (x : Parsetree.signature) =
180631180643 Ext_list.iter
180632180644 (Ast_payload.ident_or_record_as_config loc payload)
180633180645 (Ast_payload.table_dispatch !signature_config_table)
180634- | { psig_desc = Psig_attribute _ } :: rest -> iter_on_bs_config_sigi rest
180646+ | { psig_desc = Psig_attribute _ } :: rest -> iter_on_bs_config_sig rest
180635180647 | _ :: _ -> ()
180636180648
180649+ let process_sig s = iter_on_bs_config_sig s
180637180650end
180638180651module Ccomp : sig
180639180652#1 "ccomp.mli"
@@ -286751,7 +286764,7 @@ let unsafe_mapper = Bs_builtin_ppx.mapper
286751286764
286752286765let rewrite_signature (ast : Parsetree.signature) : Parsetree.signature =
286753286766 Bs_ast_invariant.iter_warnings_on_sigi ast;
286754- Ast_config.iter_on_bs_config_sigi ast;
286767+ Ast_config.process_sig ast;
286755286768 let ast =
286756286769 match !Js_config.jsx_version with
286757286770 | None -> ast
@@ -286771,7 +286784,7 @@ let rewrite_signature (ast : Parsetree.signature) : Parsetree.signature =
286771286784
286772286785let rewrite_implementation (ast : Parsetree.structure) : Parsetree.structure =
286773286786 Bs_ast_invariant.iter_warnings_on_stru ast;
286774- Ast_config.iter_on_bs_config_stru ast;
286787+ Ast_config.process_str ast;
286775286788 let ast =
286776286789 match !Js_config.jsx_version with
286777286790 | None -> ast
@@ -294220,7 +294233,7 @@ let process_with_gentype cmt_file =
294220294233
294221294234let after_parsing_sig ppf outputprefix ast =
294222294235 if !Clflags.only_parse = false then (
294223- Ast_config.iter_on_bs_config_sigi ast;
294236+ Ast_config.process_sig ast;
294224294237 if !Js_config.modules then
294225294238 output_deps_set !Location.input_name
294226294239 (Ast_extract.read_parse_and_extract Mli ast);
@@ -294313,7 +294326,7 @@ let after_parsing_impl ppf outputprefix (ast : Parsetree.structure) =
294313294326 if !Clflags.only_parse = false then (
294314294327 Js_config.all_module_aliases :=
294315294328 !Clflags.assume_no_mli = Mli_non_exists && all_module_alias ast;
294316- Ast_config.iter_on_bs_config_stru ast;
294329+ Ast_config.process_str ast;
294317294330 let ast = if !Js_config.no_export then no_export ast else ast in
294318294331 if !Js_config.modules then
294319294332 output_deps_set !Location.input_name
0 commit comments