Skip to content

Commit 5482a8d

Browse files
authored
Remove Lev_module_definition from lambda (#135)
1 parent 261e016 commit 5482a8d

11 files changed

+335
-346
lines changed

bytecomp/bytegen.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,6 @@ let rec comp_expr env exp sz cont =
10141014
let cont1 = add_event ev cont in
10151015
comp_expr env lam sz cont1
10161016
end
1017-
| Lev_module_definition _ ->
1018-
comp_expr env lam sz cont
10191017
end
10201018
| Lifused (_, exp) ->
10211019
comp_expr env exp sz cont

lambda/lambda.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,6 @@ and lambda_event_kind =
533533
| Lev_after of Types.type_expr
534534
| Lev_function
535535
| Lev_pseudo
536-
| Lev_module_definition of Ident.t
537536

538537
type program =
539538
{ compilation_unit : Compilation_unit.t;

lambda/lambda.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,6 @@ and lambda_event_kind =
447447
| Lev_after of Types.type_expr
448448
| Lev_function
449449
| Lev_pseudo
450-
| Lev_module_definition of Ident.t
451450

452451
type program =
453452
{ compilation_unit : Compilation_unit.t;

lambda/printlambda.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,6 @@ let rec lam ppf = function
786786
| Lev_after _ -> "after"
787787
| Lev_function -> "funct-body"
788788
| Lev_pseudo -> "pseudo"
789-
| Lev_module_definition ident ->
790-
Format.asprintf "module-defn(%a)" Ident.print ident
791789
in
792790
(* -dno-locations also hides the placement of debug events;
793791
this is good for the readability of the resulting output (usually

lambda/translcore.ml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -715,16 +715,10 @@ and transl_exp0 ~in_new_scope ~scopes e =
715715
let lam = !transl_module ~scopes Tcoerce_none None modl in
716716
Lsequence(Lprim(Pignore, [lam], of_location ~scopes loc.loc),
717717
transl_exp ~scopes body)
718-
| Texp_letmodule(Some id, loc, Mp_present, modl, body) ->
718+
| Texp_letmodule(Some id, _loc, Mp_present, modl, body) ->
719719
let defining_expr =
720720
let mod_scopes = enter_module_definition ~scopes id in
721-
let lam = !transl_module ~scopes:mod_scopes Tcoerce_none None modl in
722-
Levent (lam, {
723-
lev_loc = of_location ~scopes loc.loc;
724-
lev_kind = Lev_module_definition id;
725-
lev_repr = None;
726-
lev_env = Env.empty;
727-
})
721+
!transl_module ~scopes:mod_scopes Tcoerce_none None modl
728722
in
729723
Llet(Strict, Lambda.layout_module, id, defining_expr, transl_exp ~scopes body)
730724
| Texp_letmodule(_, _, Mp_absent, _, body) ->

lambda/translmod.ml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -457,15 +457,15 @@ let compile_recmodule ~scopes compile_rhs bindings cont =
457457
eval_rec_bindings
458458
(reorder_rec_bindings
459459
(List.map
460-
(fun {mb_id=id; mb_name; mb_expr=modl; mb_loc=loc; _} ->
460+
(fun {mb_id=id; mb_name; mb_expr=modl; _} ->
461461
let id_or_ignore_loc, shape =
462462
match id with
463463
| None ->
464464
let loc = of_location ~scopes mb_name.loc in
465465
Ignore_loc loc, Result.Error Unnamed
466466
| Some id -> Id id, init_shape id modl
467467
in
468-
(id_or_ignore_loc, modl.mod_loc, shape, compile_rhs id modl loc))
468+
(id_or_ignore_loc, modl.mod_loc, shape, compile_rhs id modl))
469469
bindings))
470470
cont
471471

@@ -720,14 +720,6 @@ and transl_structure ~scopes loc fields cc rootpath final_env = function
720720
of_location ~scopes mb.mb_name.loc), body),
721721
size
722722
| Some id ->
723-
let module_body =
724-
Levent (module_body, {
725-
lev_loc = of_location ~scopes mb.mb_loc;
726-
lev_kind = Lev_module_definition id;
727-
lev_repr = None;
728-
lev_env = Env.empty;
729-
})
730-
in
731723
Llet(pure_module mb.mb_expr, Lambda.layout_module, id, module_body, body), size
732724
end
733725
| Tstr_module ({mb_presence=Mp_absent}) ->
@@ -741,21 +733,13 @@ and transl_structure ~scopes loc fields cc rootpath final_env = function
741733
transl_structure ~scopes loc ext_fields cc rootpath final_env rem
742734
in
743735
let lam =
744-
compile_recmodule ~scopes (fun id modl loc ->
736+
compile_recmodule ~scopes (fun id modl ->
745737
match id with
746738
| None -> transl_module ~scopes Tcoerce_none None modl
747739
| Some id ->
748-
let module_body =
749-
transl_module
750-
~scopes:(enter_module_definition ~scopes id)
751-
Tcoerce_none (field_path rootpath id) modl
752-
in
753-
Levent (module_body, {
754-
lev_loc = of_location ~scopes loc;
755-
lev_kind = Lev_module_definition id;
756-
lev_repr = None;
757-
lev_env = Env.empty;
758-
})
740+
transl_module
741+
~scopes:(enter_module_definition ~scopes id)
742+
Tcoerce_none (field_path rootpath id) modl
759743
) bindings body
760744
in
761745
lam, size
@@ -1238,7 +1222,7 @@ let transl_store_structure ~scopes glob map prims aliases str =
12381222
| Tstr_recmodule bindings ->
12391223
let ids = List.filter_map (fun mb -> mb.mb_id) bindings in
12401224
compile_recmodule ~scopes
1241-
(fun id modl _loc ->
1225+
(fun id modl ->
12421226
Lambda.subst no_env_update subst
12431227
(match id with
12441228
| None ->
@@ -1638,7 +1622,7 @@ let transl_toplevel_item ~scopes item =
16381622
| Tstr_recmodule bindings ->
16391623
let idents = List.filter_map (fun mb -> mb.mb_id) bindings in
16401624
compile_recmodule ~scopes
1641-
(fun id modl _loc ->
1625+
(fun id modl ->
16421626
match id with
16431627
| None ->
16441628
transl_module ~scopes Tcoerce_none None modl

testsuite/tests/basic-modules/anonymous.ocamlc.reference

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@
1414
(ignore
1515
(let (x =[(consts ()) (non_consts ([0: [int], [int]]))] [0: 4 2])
1616
(makeblock 0 x)))
17-
(apply (field 1 (global CamlinternalMod!)) [0: [0]] A
18-
(module-defn(A) Anonymous anonymous.ml(23):567-608 A))
17+
(apply (field 1 (global CamlinternalMod!)) [0: [0]] A A)
1918
(apply (field 1 (global CamlinternalMod!)) [0: [0]] B
20-
(module-defn(B) Anonymous anonymous.ml(33):703-773
21-
(let (x =[(consts ()) (non_consts ([0: *, *]))] [0: "foo" "bar"])
22-
(makeblock 0))))
19+
(let (x =[(consts ()) (non_consts ([0: *, *]))] [0: "foo" "bar"])
20+
(makeblock 0)))
2321
(let
2422
(f = (function {nlocal = 0} param : int 0) s = (makemutable 0 ""))
2523
(seq

testsuite/tests/basic-modules/anonymous.ocamlopt.flambda.reference

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@
1313
(ignore
1414
(let (x =[(consts ()) (non_consts ([0: [int], [int]]))] [0: 4 2])
1515
(makeblock 0 x)))
16-
(apply (field 1 (global CamlinternalMod!)) [0: [0]] A
17-
(module-defn(A) Anonymous anonymous.ml(23):567-608 A))
16+
(apply (field 1 (global CamlinternalMod!)) [0: [0]] A A)
1817
(apply (field 1 (global CamlinternalMod!)) [0: [0]] B
19-
(module-defn(B) Anonymous anonymous.ml(33):703-773
20-
(let (x =[(consts ()) (non_consts ([0: *, *]))] [0: "foo" "bar"])
21-
(makeblock 0))))
18+
(let (x =[(consts ()) (non_consts ([0: *, *]))] [0: "foo" "bar"])
19+
(makeblock 0)))
2220
(let (f = (function {nlocal = 0} param : int 0) s = (makemutable 0 ""))
2321
(seq
2422
(ignore
Lines changed: 45 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,53 @@
11
(setglobal Functors!
22
(let
33
(O =
4-
(module-defn(O) Functors functors.ml(12):184-279
5-
(function {nlocal = 0} X is_a_functor always_inline never_loop
6-
(let
7-
(cow =
8-
(function {nlocal = 0} x[int] : int (apply (field 0 X) x))
9-
sheep =
10-
(function {nlocal = 0} x[int] : int (+ 1 (apply cow x))))
11-
(makeblock 0 cow sheep))))
4+
(function {nlocal = 0} X is_a_functor always_inline never_loop
5+
(let
6+
(cow = (function {nlocal = 0} x[int] : int (apply (field 0 X) x))
7+
sheep = (function {nlocal = 0} x[int] : int (+ 1 (apply cow x))))
8+
(makeblock 0 cow sheep)))
129
F =
13-
(module-defn(F) Functors functors.ml(17):281-392
14-
(function {nlocal = 0} X Y is_a_functor always_inline never_loop
15-
(let
16-
(cow =
17-
(function {nlocal = 0} x[int] : int
18-
(apply (field 0 Y) (apply (field 0 X) x)))
19-
sheep =
20-
(function {nlocal = 0} x[int] : int (+ 1 (apply cow x))))
21-
(makeblock 0 cow sheep))))
10+
(function {nlocal = 0} X Y is_a_functor always_inline never_loop
11+
(let
12+
(cow =
13+
(function {nlocal = 0} x[int] : int
14+
(apply (field 0 Y) (apply (field 0 X) x)))
15+
sheep = (function {nlocal = 0} x[int] : int (+ 1 (apply cow x))))
16+
(makeblock 0 cow sheep)))
2217
F1 =
23-
(module-defn(F1) Functors functors.ml(31):516-632
24-
(function {nlocal = 0} X Y is_a_functor always_inline never_loop
25-
(let
26-
(cow =
27-
(function {nlocal = 0} x[int] : int
28-
(apply (field 0 Y) (apply (field 0 X) x)))
29-
sheep =
30-
(function {nlocal = 0} x[int] : int (+ 1 (apply cow x))))
31-
(makeblock 0 sheep))))
18+
(function {nlocal = 0} X Y is_a_functor always_inline never_loop
19+
(let
20+
(cow =
21+
(function {nlocal = 0} x[int] : int
22+
(apply (field 0 Y) (apply (field 0 X) x)))
23+
sheep = (function {nlocal = 0} x[int] : int (+ 1 (apply cow x))))
24+
(makeblock 0 sheep)))
3225
F2 =
33-
(module-defn(F2) Functors functors.ml(36):634-784
34-
(function {nlocal = 0} X Y is_a_functor always_inline never_loop
35-
(let
36-
(X =a (makeblock 0 (field 1 X))
37-
Y =a (makeblock 0 (field 1 Y))
38-
cow =
39-
(function {nlocal = 0} x[int] : int
40-
(apply (field 0 Y) (apply (field 0 X) x)))
41-
sheep =
42-
(function {nlocal = 0} x[int] : int (+ 1 (apply cow x))))
43-
(makeblock 0 sheep))))
44-
M =
45-
(module-defn(M) Functors functors.ml(41):786-970
26+
(function {nlocal = 0} X Y is_a_functor always_inline never_loop
4627
(let
47-
(F =
48-
(module-defn(F) Functors.M functors.ml(44):849-966
49-
(function {nlocal = 0} X Y is_a_functor always_inline
50-
never_loop
51-
(let
52-
(cow =
53-
(function {nlocal = 0} x[int] : int
54-
(apply (field 0 Y) (apply (field 0 X) x)))
55-
sheep =
56-
(function {nlocal = 0} x[int] : int
57-
(+ 1 (apply cow x))))
58-
(makeblock 0 cow sheep)))))
59-
(makeblock 0
60-
(function {nlocal = 0} funarg funarg is_a_functor stub
61-
(let
62-
(let =
63-
(apply F (makeblock 0 (field 1 funarg))
64-
(makeblock 0 (field 1 funarg))))
65-
(makeblock 0 (field 1 let))))))))
28+
(X =a (makeblock 0 (field 1 X))
29+
Y =a (makeblock 0 (field 1 Y))
30+
cow =
31+
(function {nlocal = 0} x[int] : int
32+
(apply (field 0 Y) (apply (field 0 X) x)))
33+
sheep = (function {nlocal = 0} x[int] : int (+ 1 (apply cow x))))
34+
(makeblock 0 sheep)))
35+
M =
36+
(let
37+
(F =
38+
(function {nlocal = 0} X Y is_a_functor always_inline never_loop
39+
(let
40+
(cow =
41+
(function {nlocal = 0} x[int] : int
42+
(apply (field 0 Y) (apply (field 0 X) x)))
43+
sheep =
44+
(function {nlocal = 0} x[int] : int (+ 1 (apply cow x))))
45+
(makeblock 0 cow sheep))))
46+
(makeblock 0
47+
(function {nlocal = 0} funarg funarg is_a_functor stub
48+
(let
49+
(let =
50+
(apply F (makeblock 0 (field 1 funarg))
51+
(makeblock 0 (field 1 funarg))))
52+
(makeblock 0 (field 1 let)))))))
6653
(makeblock 0 O F F1 F2 M)))

0 commit comments

Comments
 (0)