Skip to content

Commit c0136fe

Browse files
committed
fixup: ocamlformat
Fixup for "Fix remaining bugs in CPS transform and effect handling"
1 parent bdf7014 commit c0136fe

File tree

2 files changed

+64
-64
lines changed

2 files changed

+64
-64
lines changed

compiler/lib/effects.ml

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -603,53 +603,53 @@ let duplicate_code ~st pc =
603603
state
604604
|> DuplicateSt.run
605605
(let open DuplicateSt in
606-
let block = Addr.Map.find pc st.blocks in
607-
(* Also duplicate nested functions *)
608-
let* rev_new_body =
609-
list_fold_left
610-
block.body
611-
~f:(fun body_acc (instr, loc) ->
612-
match instr with
613-
| Let (f, Closure (params, (pc', args))) ->
614-
let* () = duplicate ~blocks pc' in
615-
let* new_pc' = find_or_add_pc pc' in
616-
return
617-
((Let (f, Closure (params, (new_pc', args))), loc) :: body_acc)
618-
| i -> return ((i, loc) :: body_acc))
619-
~init:[]
620-
in
621-
let new_body = List.rev rev_new_body in
622-
(* Update branch targets *)
623-
let update (pc, args) =
624-
let* pc = find_or_add_pc pc in
625-
return (pc, args)
626-
in
627-
let* branch =
628-
match block.branch with
629-
| ((Return _ | Raise _ | Stop) as b), loc -> return (b, loc)
630-
| Branch cont, loc ->
631-
let* cont = update cont in
632-
return (Branch cont, loc)
633-
| Cond (x, c1, c2), loc ->
634-
let* c1 = update c1 in
635-
let* c2 = update c2 in
636-
return (Cond (x, c1, c2), loc)
637-
| Switch (x, conts_block, conts_int), loc ->
638-
let* conts_block = array_map conts_block ~f:update in
639-
let* conts_int = array_map ~f:update conts_int in
640-
return (Switch (x, conts_block, conts_int), loc)
641-
| Pushtrap (c1, x, c2, poptraps), loc ->
642-
let* c1 = update c1 in
643-
let* c2 = update c2 in
644-
return (Pushtrap (c1, x, c2, poptraps), loc)
645-
| Poptrap cont, loc ->
646-
let* cont = update cont in
647-
return (Poptrap cont, loc)
648-
in
649-
let new_block = { block with body = new_body; branch } in
650-
let* new_pc = find_or_add_pc pc in
651-
let* () = add_block new_pc new_block in
652-
return ()))
606+
let block = Addr.Map.find pc st.blocks in
607+
(* Also duplicate nested functions *)
608+
let* rev_new_body =
609+
list_fold_left
610+
block.body
611+
~f:(fun body_acc (instr, loc) ->
612+
match instr with
613+
| Let (f, Closure (params, (pc', args))) ->
614+
let* () = duplicate ~blocks pc' in
615+
let* new_pc' = find_or_add_pc pc' in
616+
return
617+
((Let (f, Closure (params, (new_pc', args))), loc) :: body_acc)
618+
| i -> return ((i, loc) :: body_acc))
619+
~init:[]
620+
in
621+
let new_body = List.rev rev_new_body in
622+
(* Update branch targets *)
623+
let update (pc, args) =
624+
let* pc = find_or_add_pc pc in
625+
return (pc, args)
626+
in
627+
let* branch =
628+
match block.branch with
629+
| ((Return _ | Raise _ | Stop) as b), loc -> return (b, loc)
630+
| Branch cont, loc ->
631+
let* cont = update cont in
632+
return (Branch cont, loc)
633+
| Cond (x, c1, c2), loc ->
634+
let* c1 = update c1 in
635+
let* c2 = update c2 in
636+
return (Cond (x, c1, c2), loc)
637+
| Switch (x, conts_block, conts_int), loc ->
638+
let* conts_block = array_map conts_block ~f:update in
639+
let* conts_int = array_map ~f:update conts_int in
640+
return (Switch (x, conts_block, conts_int), loc)
641+
| Pushtrap (c1, x, c2, poptraps), loc ->
642+
let* c1 = update c1 in
643+
let* c2 = update c2 in
644+
return (Pushtrap (c1, x, c2, poptraps), loc)
645+
| Poptrap cont, loc ->
646+
let* cont = update cont in
647+
return (Poptrap cont, loc)
648+
in
649+
let new_block = { block with body = new_body; branch } in
650+
let* new_pc = find_or_add_pc pc in
651+
let* () = add_block new_pc new_block in
652+
return ()))
653653
pc
654654
blocks
655655
(state, ())

compiler/lib/lambda_lifting_simple.ml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,14 @@ let rec traverse
198198
current_contiguous ->
199199
let program, functions, lifters =
200200
(if debug ()
201-
then
202-
Format.(
203-
eprintf
204-
"@[<v>Need to lift:@,%a@,@]"
205-
(pp_print_list ~pp_sep:pp_print_space pp_print_string)
206-
(List.map
207-
~f:(fun (f, _, _, _, _) -> Code.Var.to_string f)
208-
current_contiguous)));
201+
then
202+
Format.(
203+
eprintf
204+
"@[<v>Need to lift:@,%a@,@]"
205+
(pp_print_list ~pp_sep:pp_print_space pp_print_string)
206+
(List.map
207+
~f:(fun (f, _, _, _, _) -> Code.Var.to_string f)
208+
current_contiguous)));
209209
List.fold_left
210210
current_contiguous
211211
~f:(fun st (_, _, pc, _, _) ->
@@ -246,15 +246,15 @@ let rec traverse
246246
in
247247
let f_tuple = Var.fresh_n "recfuncs" in
248248
(if debug ()
249-
then
250-
Format.(
251-
eprintf
252-
"LIFT %a in tuple %s (depth:%d free_vars:%d)@,"
253-
(pp_print_list ~pp_sep:pp_print_space pp_print_string)
254-
(List.map ~f:Code.Var.to_string f's)
255-
(Code.Var.to_string f_tuple)
256-
depth
257-
(Var.Set.cardinal free_vars)));
249+
then
250+
Format.(
251+
eprintf
252+
"LIFT %a in tuple %s (depth:%d free_vars:%d)@,"
253+
(pp_print_list ~pp_sep:pp_print_space pp_print_string)
254+
(List.map ~f:Code.Var.to_string f's)
255+
(Code.Var.to_string f_tuple)
256+
depth
257+
(Var.Set.cardinal free_vars)));
258258
let pc_tuple = program.free_pc in
259259
let lifted_block =
260260
let tuple = Var.fresh_n "tuple" in

0 commit comments

Comments
 (0)