@@ -45,39 +45,41 @@ let process_with_gentype cmt_file =
45
45
if ! Clflags. bs_gentype then GenTypeMain. processCmtFile cmt_file
46
46
47
47
let after_parsing_sig ppf outputprefix ast =
48
- Ast_config. iter_on_bs_config_sigi ast;
49
- if ! Js_config. modules then
50
- output_deps_set ! Location. input_name
51
- (Ast_extract. read_parse_and_extract Mli ast);
52
- (if ! Js_config. binary_ast then
53
- let sourcefile = ! Location. input_name in
54
- Binary_ast. write_ast Mli ~sourcefile
55
- ~output: (outputprefix ^ Literals. suffix_iast)
56
- (* to support relocate to another directory *)
57
- ast);
58
- if ! Js_config. as_pp then (
59
- output_string stdout Config. ast_intf_magic_number;
60
- output_value stdout (! Location. input_name : string );
61
- output_value stdout ast);
62
- if ! Js_config. syntax_only then Warnings. check_fatal ()
63
- else
64
- let modulename = module_of_filename outputprefix in
65
- Lam_compile_env. reset () ;
66
- let initial_env = Res_compmisc. initial_env () in
67
- Env. set_unit_name modulename;
68
- let tsg = Typemod. transl_signature initial_env ast in
69
- if ! Clflags. dump_typedtree then fprintf ppf " %a@." Printtyped. interface tsg;
70
- let sg = tsg.sig_type in
71
- ignore (Includemod. signatures initial_env sg sg);
72
- Delayed_checks. force_delayed_checks () ;
73
- Warnings. check_fatal () ;
74
- let deprecated = Builtin_attributes. deprecated_of_sig ast in
75
- let sg =
76
- Env. save_signature ~deprecated sg modulename (outputprefix ^ " .cmi" )
77
- in
78
- Typemod. save_signature modulename tsg outputprefix ! Location. input_name
79
- initial_env sg;
80
- process_with_gentype (outputprefix ^ " .cmti" )
48
+ if ! Clflags. only_parse = false then (
49
+ Ast_config. iter_on_bs_config_sigi ast;
50
+ if ! Js_config. modules then
51
+ output_deps_set ! Location. input_name
52
+ (Ast_extract. read_parse_and_extract Mli ast);
53
+ (if ! Js_config. binary_ast then
54
+ let sourcefile = ! Location. input_name in
55
+ Binary_ast. write_ast Mli ~sourcefile
56
+ ~output: (outputprefix ^ Literals. suffix_iast)
57
+ (* to support relocate to another directory *)
58
+ ast);
59
+ if ! Js_config. as_pp then (
60
+ output_string stdout Config. ast_intf_magic_number;
61
+ output_value stdout (! Location. input_name : string );
62
+ output_value stdout ast);
63
+ if ! Js_config. syntax_only then Warnings. check_fatal ()
64
+ else
65
+ let modulename = module_of_filename outputprefix in
66
+ Lam_compile_env. reset () ;
67
+ let initial_env = Res_compmisc. initial_env () in
68
+ Env. set_unit_name modulename;
69
+ let tsg = Typemod. transl_signature initial_env ast in
70
+ if ! Clflags. dump_typedtree then
71
+ fprintf ppf " %a@." Printtyped. interface tsg;
72
+ let sg = tsg.sig_type in
73
+ ignore (Includemod. signatures initial_env sg sg);
74
+ Delayed_checks. force_delayed_checks () ;
75
+ Warnings. check_fatal () ;
76
+ let deprecated = Builtin_attributes. deprecated_of_sig ast in
77
+ let sg =
78
+ Env. save_signature ~deprecated sg modulename (outputprefix ^ " .cmi" )
79
+ in
80
+ Typemod. save_signature modulename tsg outputprefix ! Location. input_name
81
+ initial_env sg;
82
+ process_with_gentype (outputprefix ^ " .cmti" ))
81
83
82
84
let interface ~parser ppf ?outputprefix fname =
83
85
let outputprefix =
@@ -126,48 +128,49 @@ let no_export (rest : Parsetree.structure) : Parsetree.structure =
126
128
| _ -> rest
127
129
128
130
let after_parsing_impl ppf outputprefix (ast : Parsetree.structure ) =
129
- Js_config. all_module_aliases :=
130
- ! Clflags. assume_no_mli = Mli_non_exists && all_module_alias ast;
131
- Ast_config. iter_on_bs_config_stru ast;
132
- let ast = if ! Js_config. no_export then no_export ast else ast in
133
- if ! Js_config. modules then
134
- output_deps_set ! Location. input_name
135
- (Ast_extract. read_parse_and_extract Ml ast);
136
- (if ! Js_config. binary_ast then
137
- let sourcefile = ! Location. input_name in
138
- Binary_ast. write_ast ~sourcefile Ml
139
- ~output: (outputprefix ^ Literals. suffix_ast)
140
- ast);
141
- if ! Js_config. as_pp then (
142
- output_string stdout Config. ast_impl_magic_number;
143
- output_value stdout (! Location. input_name : string );
144
- output_value stdout ast);
145
- if ! Js_config. syntax_only then Warnings. check_fatal ()
146
- else
147
- let modulename = Ext_filename. module_name outputprefix in
148
- Lam_compile_env. reset () ;
149
- let env = Res_compmisc. initial_env () in
150
- Env. set_unit_name modulename;
151
- let typedtree, coercion, _, _ =
152
- Typemod. type_implementation_more
153
- ?check_exists:(if ! Js_config. force_cmi then None else Some () )
154
- ! Location. input_name outputprefix modulename env ast
155
- in
156
- let typedtree_coercion = (typedtree, coercion) in
157
- print_if ppf Clflags. dump_typedtree Printtyped. implementation_with_coercion
158
- typedtree_coercion;
159
- (if ! Js_config. cmi_only then Warnings. check_fatal ()
131
+ if ! Clflags. only_parse = false then (
132
+ Js_config. all_module_aliases :=
133
+ ! Clflags. assume_no_mli = Mli_non_exists && all_module_alias ast;
134
+ Ast_config. iter_on_bs_config_stru ast;
135
+ let ast = if ! Js_config. no_export then no_export ast else ast in
136
+ if ! Js_config. modules then
137
+ output_deps_set ! Location. input_name
138
+ (Ast_extract. read_parse_and_extract Ml ast);
139
+ (if ! Js_config. binary_ast then
140
+ let sourcefile = ! Location. input_name in
141
+ Binary_ast. write_ast ~sourcefile Ml
142
+ ~output: (outputprefix ^ Literals. suffix_ast)
143
+ ast);
144
+ if ! Js_config. as_pp then (
145
+ output_string stdout Config. ast_impl_magic_number;
146
+ output_value stdout (! Location. input_name : string );
147
+ output_value stdout ast);
148
+ if ! Js_config. syntax_only then Warnings. check_fatal ()
160
149
else
161
- let lambda, exports =
162
- Translmod. transl_implementation modulename typedtree_coercion
163
- in
164
- let js_program =
165
- print_if_pipe ppf Clflags. dump_rawlambda Printlambda. lambda lambda
166
- |> Lam_compile_main. compile outputprefix exports
150
+ let modulename = Ext_filename. module_name outputprefix in
151
+ Lam_compile_env. reset () ;
152
+ let env = Res_compmisc. initial_env () in
153
+ Env. set_unit_name modulename;
154
+ let typedtree, coercion, _, _ =
155
+ Typemod. type_implementation_more
156
+ ?check_exists:(if ! Js_config. force_cmi then None else Some () )
157
+ ! Location. input_name outputprefix modulename env ast
167
158
in
168
- if not ! Js_config. cmj_only then
169
- Lam_compile_main. lambda_as_module js_program outputprefix);
170
- process_with_gentype (outputprefix ^ " .cmt" )
159
+ let typedtree_coercion = (typedtree, coercion) in
160
+ print_if ppf Clflags. dump_typedtree
161
+ Printtyped. implementation_with_coercion typedtree_coercion;
162
+ (if ! Js_config. cmi_only then Warnings. check_fatal ()
163
+ else
164
+ let lambda, exports =
165
+ Translmod. transl_implementation modulename typedtree_coercion
166
+ in
167
+ let js_program =
168
+ print_if_pipe ppf Clflags. dump_rawlambda Printlambda. lambda lambda
169
+ |> Lam_compile_main. compile outputprefix exports
170
+ in
171
+ if not ! Js_config. cmj_only then
172
+ Lam_compile_main. lambda_as_module js_program outputprefix);
173
+ process_with_gentype (outputprefix ^ " .cmt" ))
171
174
172
175
let implementation ~parser ppf ?outputprefix fname =
173
176
let outputprefix =
0 commit comments