Skip to content

Commit c4ec857

Browse files
authored
flambda-backend: Revert "Revert "Refactor Persistent_env to separate imports from bound names"" (#2632)
Revert "Revert "Refactor `Persistent_env` to separate imports from bound name…" This reverts commit cdbde41.
1 parent 3d901f7 commit c4ec857

File tree

6 files changed

+207
-110
lines changed

6 files changed

+207
-110
lines changed

.depend

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,35 +1321,43 @@ typing/patterns.cmi : \
13211321
parsing/asttypes.cmi
13221322
typing/persistent_env.cmo : \
13231323
utils/warnings.cmi \
1324+
typing/subst.cmi \
1325+
typing/shape.cmi \
13241326
utils/misc.cmi \
13251327
parsing/location.cmi \
13261328
utils/load_path.cmi \
13271329
utils/lazy_backtrack.cmi \
13281330
utils/import_info.cmi \
1331+
typing/ident.cmi \
13291332
utils/consistbl.cmi \
13301333
utils/compilation_unit.cmi \
13311334
file_formats/cmi_format.cmi \
13321335
utils/clflags.cmi \
13331336
typing/persistent_env.cmi
13341337
typing/persistent_env.cmx : \
13351338
utils/warnings.cmx \
1339+
typing/subst.cmx \
1340+
typing/shape.cmx \
13361341
utils/misc.cmx \
13371342
parsing/location.cmx \
13381343
utils/load_path.cmx \
13391344
utils/lazy_backtrack.cmx \
13401345
utils/import_info.cmx \
1346+
typing/ident.cmx \
13411347
utils/consistbl.cmx \
13421348
utils/compilation_unit.cmx \
13431349
file_formats/cmi_format.cmx \
13441350
utils/clflags.cmx \
13451351
typing/persistent_env.cmi
13461352
typing/persistent_env.cmi : \
13471353
typing/subst.cmi \
1354+
typing/shape.cmi \
13481355
utils/misc.cmi \
13491356
parsing/location.cmi \
13501357
utils/load_path.cmi \
13511358
utils/lazy_backtrack.cmi \
13521359
utils/import_info.cmi \
1360+
typing/ident.cmi \
13531361
utils/consistbl.cmi \
13541362
utils/compilation_unit.cmi \
13551363
file_formats/cmi_format.cmi

testsuite/tests/templates/basic/bad_param_impl.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
ocamlc_byte_exit_status = "2";
1010
compiler_output = "bad_param_impl.output";
1111
ocamlc.byte;
12-
reason = "error broken, will be fixed by #1764";
13-
skip;
1412
compiler_reference = "bad_param_impl.reference";
1513
check-ocamlc.byte-output;
1614
*)

testsuite/tests/templates/basic/test.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
compiler_output = "bad_ref_direct.output";
99
ocamlc_byte_exit_status = "2";
1010
ocamlc.byte;
11-
reason = "correct error message not yet implemented";
12-
skip;
1311
compiler_reference = "bad_ref_direct.reference";
1412
check-ocamlc.byte-output;
1513
*)

typing/env.ml

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ let map_summary f = function
173173
| Env_value_unbound (s, u, r) -> Env_value_unbound (f s, u, r)
174174
| Env_module_unbound (s, u, r) -> Env_module_unbound (f s, u, r)
175175

176-
type address =
176+
type address = Persistent_env.address =
177177
| Aunit of Compilation_unit.t
178178
| Alocal of Ident.t
179179
| Adot of address * int
@@ -953,34 +953,24 @@ let components_of_module ~alerts ~uid env ps path addr mty shape =
953953
}
954954
}
955955

956-
let read_sign_of_cmi { Persistent_env.Persistent_signature.cmi; _ } =
957-
let name =
958-
match cmi.cmi_kind with
959-
| Normal { cmi_impl } -> cmi_impl
960-
| Parameter -> Misc.fatal_error "Unsupported import of parameter module"
961-
in
962-
let sign = cmi.cmi_sign in
963-
let flags = cmi.cmi_flags in
964-
let id = Ident.create_persistent (Compilation_unit.name_as_string name) in
956+
let read_sign_of_cmi sign name uid ~shape ~address:addr ~flags =
957+
let id = Ident.create_persistent (Compilation_unit.Name.to_string name) in
965958
let path = Pident id in
966959
let alerts =
967960
List.fold_left (fun acc -> function Alerts s -> s | _ -> acc)
968961
Misc.Stdlib.String.Map.empty
969962
flags
970963
in
971-
let sign = Subst.Lazy.signature Make_local Subst.identity sign in
972964
let md =
973965
{ Subst.Lazy.md_type = Mty_signature sign;
974966
md_loc = Location.none;
975967
md_attributes = [];
976-
md_uid = Uid.of_compilation_unit_id name;
968+
md_uid = uid;
977969
}
978970
in
979-
let mda_address = Lazy_backtrack.create_forced (Aunit name) in
971+
let mda_address = Lazy_backtrack.create_forced addr in
980972
let mda_declaration = md in
981-
let mda_shape =
982-
Shape.for_persistent_unit (name |> Compilation_unit.full_path_as_string)
983-
in
973+
let mda_shape = shape in
984974
let mda_components =
985975
let mty = md.md_type in
986976
components_of_module ~alerts ~uid:md.md_uid
@@ -1016,7 +1006,7 @@ let check_pers_mod ~loc name =
10161006
Persistent_env.check !persistent_env read_sign_of_cmi ~loc name
10171007

10181008
let crc_of_unit name =
1019-
Persistent_env.crc_of_unit !persistent_env read_sign_of_cmi name
1009+
Persistent_env.crc_of_unit !persistent_env name
10201010

10211011
let is_imported_opaque modname =
10221012
Persistent_env.is_imported_opaque !persistent_env modname
@@ -2646,13 +2636,8 @@ let open_signature
26462636

26472637
(* Read a signature from a file *)
26482638
let read_signature modname filename ~add_binding =
2649-
let mda =
2650-
read_pers_mod modname filename ~add_binding
2651-
in
2652-
let md = Subst.Lazy.force_module_decl mda.mda_declaration in
2653-
match md.md_type with
2654-
| Mty_signature sg -> sg
2655-
| Mty_ident _ | Mty_functor _ | Mty_alias _ | Mty_strengthen _ -> assert false
2639+
let mty = read_pers_mod modname filename ~add_binding in
2640+
Subst.Lazy.force_signature mty
26562641

26572642
let is_identchar_latin1 = function
26582643
| 'A'..'Z' | 'a'..'z' | '_' | '\192'..'\214' | '\216'..'\246'

0 commit comments

Comments
 (0)