Skip to content

Commit 054e647

Browse files
Simplify jsoo once more
1 parent 65eb326 commit 054e647

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

compiler/jsoo/jsoo_playground_main.ml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -519,24 +519,12 @@ module Compile = struct
519519
(a, b)
520520
in
521521
typed_tree |> Translmod.transl_implementation modulename
522-
|> fun (lambda, exports) ->
523-
let debug_outputs =
524-
if include_debug_outputs then
525-
let export_ident_sets = Set_ident.of_list exports in
526-
let lam, _ = Lam_convert.convert export_ident_sets lambda in
527-
Some
528-
( Printer.to_string Printast.implementation ast,
529-
Printer.to_string Printtyped.implementation_with_coercion
530-
typed_tree,
531-
Printer.to_string Printlambda.lambda lambda,
532-
Lam_print.lambda_to_string lam )
533-
else None
534-
in
522+
|> (* Printlambda.lambda ppf *) fun (lam, exports) ->
535523
let buffer = Buffer.create 1000 in
536524
let () =
537525
Js_dump_program.pp_deps_program ~output_prefix:""
538526
(* does not matter here *) module_system
539-
(Lam_compile_main.compile "" exports lambda)
527+
(Lam_compile_main.compile "" exports lam)
540528
(Ext_pp.from_buffer buffer)
541529
in
542530
let v = Buffer.contents buffer in
@@ -554,19 +542,26 @@ module Compile = struct
554542
("type", inject @@ Js.string "success");
555543
|]
556544
in
557-
let debug_attrs =
558-
match debug_outputs with
559-
| Some (parsetree, typedtree, lambda, lam) ->
545+
if include_debug_outputs then
546+
let export_ident_sets = Set_ident.of_list exports in
547+
let lam, _ = Lam_convert.convert export_ident_sets lambda in
548+
let parsetree = Printer.to_string Printast.implementation ast in
549+
let typedtree =
550+
Printer.to_string Printtyped.implementation_with_coercion typed_tree
551+
in
552+
let lambda = Printer.to_string Printlambda.lambda lambda in
553+
let lam = Lam_print.lambda_to_string lam in
554+
let debug_attrs =
560555
Js.Unsafe.
561556
[|
562557
("parsetree", inject @@ Js.string parsetree);
563558
("typedtree", inject @@ Js.string typedtree);
564559
("lambda", inject @@ Js.string lambda);
565560
("lam", inject @@ Js.string lam);
566561
|]
567-
| None -> [||]
568-
in
569-
Js.Unsafe.(obj (Array.append attrs debug_attrs))
562+
in
563+
Js.Unsafe.obj (Array.append attrs debug_attrs)
564+
else Js.Unsafe.obj attrs
570565
with e -> (
571566
match e with
572567
| Arg.Bad msg -> ErrorRet.make_warning_flag_error ~warn_flags msg

0 commit comments

Comments
 (0)