Skip to content

Commit cdbde41

Browse files
authored
Revert "Refactor Persistent_env to separate imports from bound names" (ocaml-flambda#2611)
Revert "Refactor `Persistent_env` to separate imports from bound names (ocaml-flambda#2585)" This reverts commit f733b9c.
1 parent 8267d9c commit cdbde41

File tree

6 files changed

+110
-207
lines changed

6 files changed

+110
-207
lines changed

ocaml/.depend

-8
Original file line numberDiff line numberDiff line change
@@ -1321,43 +1321,35 @@ typing/patterns.cmi : \
13211321
parsing/asttypes.cmi
13221322
typing/persistent_env.cmo : \
13231323
utils/warnings.cmi \
1324-
typing/subst.cmi \
1325-
typing/shape.cmi \
13261324
utils/misc.cmi \
13271325
parsing/location.cmi \
13281326
utils/load_path.cmi \
13291327
utils/lazy_backtrack.cmi \
13301328
utils/import_info.cmi \
1331-
typing/ident.cmi \
13321329
utils/consistbl.cmi \
13331330
utils/compilation_unit.cmi \
13341331
file_formats/cmi_format.cmi \
13351332
utils/clflags.cmi \
13361333
typing/persistent_env.cmi
13371334
typing/persistent_env.cmx : \
13381335
utils/warnings.cmx \
1339-
typing/subst.cmx \
1340-
typing/shape.cmx \
13411336
utils/misc.cmx \
13421337
parsing/location.cmx \
13431338
utils/load_path.cmx \
13441339
utils/lazy_backtrack.cmx \
13451340
utils/import_info.cmx \
1346-
typing/ident.cmx \
13471341
utils/consistbl.cmx \
13481342
utils/compilation_unit.cmx \
13491343
file_formats/cmi_format.cmx \
13501344
utils/clflags.cmx \
13511345
typing/persistent_env.cmi
13521346
typing/persistent_env.cmi : \
13531347
typing/subst.cmi \
1354-
typing/shape.cmi \
13551348
utils/misc.cmi \
13561349
parsing/location.cmi \
13571350
utils/load_path.cmi \
13581351
utils/lazy_backtrack.cmi \
13591352
utils/import_info.cmi \
1360-
typing/ident.cmi \
13611353
utils/consistbl.cmi \
13621354
utils/compilation_unit.cmi \
13631355
file_formats/cmi_format.cmi

ocaml/testsuite/tests/templates/basic/bad_param_impl.ml

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
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;
1214
compiler_reference = "bad_param_impl.reference";
1315
check-ocamlc.byte-output;
1416
*)

ocaml/testsuite/tests/templates/basic/test.ml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
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;
1113
compiler_reference = "bad_ref_direct.reference";
1214
check-ocamlc.byte-output;
1315
*)

ocaml/typing/env.ml

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

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
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
958965
let path = Pident id in
959966
let alerts =
960967
List.fold_left (fun acc -> function Alerts s -> s | _ -> acc)
961968
Misc.Stdlib.String.Map.empty
962969
flags
963970
in
971+
let sign = Subst.Lazy.signature Make_local Subst.identity sign in
964972
let md =
965973
{ Subst.Lazy.md_type = Mty_signature sign;
966974
md_loc = Location.none;
967975
md_attributes = [];
968-
md_uid = uid;
976+
md_uid = Uid.of_compilation_unit_id name;
969977
}
970978
in
971-
let mda_address = Lazy_backtrack.create_forced addr in
979+
let mda_address = Lazy_backtrack.create_forced (Aunit name) in
972980
let mda_declaration = md in
973-
let mda_shape = shape in
981+
let mda_shape =
982+
Shape.for_persistent_unit (name |> Compilation_unit.full_path_as_string)
983+
in
974984
let mda_components =
975985
let mty = md.md_type in
976986
components_of_module ~alerts ~uid:md.md_uid
@@ -1006,7 +1016,7 @@ let check_pers_mod ~loc name =
10061016
Persistent_env.check !persistent_env read_sign_of_cmi ~loc name
10071017

10081018
let crc_of_unit name =
1009-
Persistent_env.crc_of_unit !persistent_env name
1019+
Persistent_env.crc_of_unit !persistent_env read_sign_of_cmi name
10101020

10111021
let is_imported_opaque modname =
10121022
Persistent_env.is_imported_opaque !persistent_env modname
@@ -2636,8 +2646,13 @@ let open_signature
26362646

26372647
(* Read a signature from a file *)
26382648
let read_signature modname filename ~add_binding =
2639-
let mty = read_pers_mod modname filename ~add_binding in
2640-
Subst.Lazy.force_signature mty
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
26412656

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

0 commit comments

Comments
 (0)