mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-09 22:16:10 +03:00
Make the passes appear more clearly in the driver debug
This commit is contained in:
parent
ff60aee5ef
commit
8278bb8c5d
@ -56,7 +56,7 @@ module Passes = struct
|
|||||||
(forwarding their options as needed) *)
|
(forwarding their options as needed) *)
|
||||||
|
|
||||||
let surface options ~link_modules : Surface.Ast.program * Cli.backend_lang =
|
let surface options ~link_modules : Surface.Ast.program * Cli.backend_lang =
|
||||||
Message.emit_debug "Reading files...";
|
Message.emit_debug "- SURFACE -";
|
||||||
let language = get_lang options options.input_file in
|
let language = get_lang options options.input_file in
|
||||||
let prg =
|
let prg =
|
||||||
Surface.Parser_driver.parse_top_level_file options.input_file language
|
Surface.Parser_driver.parse_top_level_file options.input_file language
|
||||||
@ -70,6 +70,7 @@ module Passes = struct
|
|||||||
let desugared options ~link_modules :
|
let desugared options ~link_modules :
|
||||||
Desugared.Ast.program * Desugared.Name_resolution.context =
|
Desugared.Ast.program * Desugared.Name_resolution.context =
|
||||||
let prg, _ = surface options ~link_modules in
|
let prg, _ = surface options ~link_modules in
|
||||||
|
Message.emit_debug "- DESUGARED -";
|
||||||
Message.emit_debug "Name resolution...";
|
Message.emit_debug "Name resolution...";
|
||||||
let ctx = Desugared.Name_resolution.form_context prg in
|
let ctx = Desugared.Name_resolution.form_context prg in
|
||||||
(* let scope_uid = get_scope_uid options backend ctx in
|
(* let scope_uid = get_scope_uid options backend ctx in
|
||||||
@ -91,8 +92,8 @@ module Passes = struct
|
|||||||
* Desugared.Name_resolution.context
|
* Desugared.Name_resolution.context
|
||||||
* Desugared.Dependency.ExceptionsDependencies.t
|
* Desugared.Dependency.ExceptionsDependencies.t
|
||||||
Desugared.Ast.ScopeDef.Map.t =
|
Desugared.Ast.ScopeDef.Map.t =
|
||||||
Message.emit_debug "Collecting rules...";
|
|
||||||
let prg, ctx = desugared options ~link_modules in
|
let prg, ctx = desugared options ~link_modules in
|
||||||
|
Message.emit_debug "- SCOPELANG -";
|
||||||
let exceptions_graphs =
|
let exceptions_graphs =
|
||||||
Scopelang.From_desugared.build_exceptions_graph prg
|
Scopelang.From_desugared.build_exceptions_graph prg
|
||||||
in
|
in
|
||||||
@ -106,11 +107,12 @@ module Passes = struct
|
|||||||
* Desugared.Name_resolution.context
|
* Desugared.Name_resolution.context
|
||||||
* Scopelang.Dependency.TVertex.t list =
|
* Scopelang.Dependency.TVertex.t list =
|
||||||
let prg, ctx, _ = scopelang options ~link_modules in
|
let prg, ctx, _ = scopelang options ~link_modules in
|
||||||
Message.emit_debug "Typechecking...";
|
Message.emit_debug "- DCALC -";
|
||||||
let type_ordering =
|
let type_ordering =
|
||||||
Scopelang.Dependency.check_type_cycles prg.program_ctx.ctx_structs
|
Scopelang.Dependency.check_type_cycles prg.program_ctx.ctx_structs
|
||||||
prg.program_ctx.ctx_enums
|
prg.program_ctx.ctx_enums
|
||||||
in
|
in
|
||||||
|
Message.emit_debug "Typechecking...";
|
||||||
let prg = Scopelang.Ast.type_program prg in
|
let prg = Scopelang.Ast.type_program prg in
|
||||||
Message.emit_debug "Translating to default calculus...";
|
Message.emit_debug "Translating to default calculus...";
|
||||||
let prg = Dcalc.From_scopelang.translate_program prg in
|
let prg = Dcalc.From_scopelang.translate_program prg in
|
||||||
@ -151,7 +153,7 @@ module Passes = struct
|
|||||||
let prg, ctx, type_ordering =
|
let prg, ctx, type_ordering =
|
||||||
dcalc options ~link_modules ~optimize ~check_invariants
|
dcalc options ~link_modules ~optimize ~check_invariants
|
||||||
in
|
in
|
||||||
Message.emit_debug "Compiling program into lambda calculus...";
|
Message.emit_debug "- LCALC -";
|
||||||
let avoid_exceptions = avoid_exceptions || closure_conversion in
|
let avoid_exceptions = avoid_exceptions || closure_conversion in
|
||||||
let optimize = optimize || closure_conversion in
|
let optimize = optimize || closure_conversion in
|
||||||
(* --closure_conversion implies --avoid_exceptions and --optimize *)
|
(* --closure_conversion implies --avoid_exceptions and --optimize *)
|
||||||
@ -202,7 +204,7 @@ module Passes = struct
|
|||||||
lcalc options ~link_modules ~optimize ~check_invariants ~avoid_exceptions
|
lcalc options ~link_modules ~optimize ~check_invariants ~avoid_exceptions
|
||||||
~closure_conversion
|
~closure_conversion
|
||||||
in
|
in
|
||||||
Message.emit_debug "Compiling program into statement calculus...";
|
Message.emit_debug "- SCALC -";
|
||||||
Scalc.From_lcalc.translate_program prg, ctx, type_ordering
|
Scalc.From_lcalc.translate_program prg, ctx, type_ordering
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -569,10 +571,10 @@ module Commands = struct
|
|||||||
results
|
results
|
||||||
|
|
||||||
let interpret_dcalc options link_modules optimize check_invariants ex_scope =
|
let interpret_dcalc options link_modules optimize check_invariants ex_scope =
|
||||||
Interpreter.load_runtime_modules link_modules;
|
|
||||||
let prg, ctx, _ =
|
let prg, ctx, _ =
|
||||||
Passes.dcalc options ~link_modules ~optimize ~check_invariants
|
Passes.dcalc options ~link_modules ~optimize ~check_invariants
|
||||||
in
|
in
|
||||||
|
Interpreter.load_runtime_modules link_modules;
|
||||||
print_interpretation_results options Interpreter.interpret_program_dcalc prg
|
print_interpretation_results options Interpreter.interpret_program_dcalc prg
|
||||||
(get_scope_uid ctx ex_scope)
|
(get_scope_uid ctx ex_scope)
|
||||||
|
|
||||||
@ -870,6 +872,7 @@ let main () =
|
|||||||
| Some opts, _ -> opts.Cli.plugins_dirs
|
| Some opts, _ -> opts.Cli.plugins_dirs
|
||||||
| None, _ -> []
|
| None, _ -> []
|
||||||
in
|
in
|
||||||
|
Message.emit_debug "- INIT -";
|
||||||
List.iter
|
List.iter
|
||||||
(fun d ->
|
(fun d ->
|
||||||
if d = "" then ()
|
if d = "" then ()
|
||||||
|
Loading…
Reference in New Issue
Block a user