Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/bytecomp/translmod.ml b/bytecomp/translmod.ml
- index 8bf2608..3b94a91 100644
- --- a/bytecomp/translmod.ml
- +++ b/bytecomp/translmod.ml
- @@ -228,6 +228,19 @@ let compile_recmodule compile_rhs bindings cont =
- bindings))
- cont
- +(* Extract the list of "value" identifiers bound by a signature.
- + "Value" identifiers are identifiers for signature components that
- + correspond to a run-time value: values, exceptions, modules, classes.
- + Note: manifest primitives do not correspond to a run-time value! *)
- +
- +let rec bound_value_identifiers = function
- + [] -> []
- + | Sig_value(id, {val_kind = Val_reg}) :: rem ->
- + id :: bound_value_identifiers rem
- + | Sig_exception(id, decl) :: rem -> id :: bound_value_identifiers rem
- + | Sig_module(id, mty, _) :: rem -> id :: bound_value_identifiers rem
- + | Sig_class(id, decl, _) :: rem -> id :: bound_value_identifiers rem
- + | _ :: rem -> bound_value_identifiers rem
- (* Compile a module expression *)
- @@ -329,7 +342,8 @@ and transl_structure fields cc rootpath = function
- transl_structure (List.rev ids @ fields) cc rootpath rem)
- | Tstr_class_type cl_list ->
- transl_structure fields cc rootpath rem
- - | Tstr_include(modl, ids) ->
- + | Tstr_include(modl, sg) ->
- + let ids = bound_value_identifiers sg in
- let mid = Ident.create "include" in
- let rec rebind_idents pos newfields = function
- [] ->
- @@ -377,7 +391,7 @@ let rec defined_idents = function
- | Tstr_class cl_list ->
- List.map (fun (ci, _, _) -> ci.ci_id_class) cl_list @ defined_idents rem
- | Tstr_class_type cl_list -> defined_idents rem
- - | Tstr_include(modl, ids) -> ids @ defined_idents rem
- + | Tstr_include(modl, sg) -> bound_value_identifiers sg @ defined_idents rem
- (* second level idents (module M = struct ... let id = ... end),
- and all sub-levels idents *)
- @@ -396,7 +410,7 @@ let rec more_idents = function
- | Tstr_open _ -> more_idents rem
- | Tstr_class cl_list -> more_idents rem
- | Tstr_class_type cl_list -> more_idents rem
- - | Tstr_include(modl, ids) -> more_idents rem
- + | Tstr_include(modl, _) -> more_idents rem
- | Tstr_module(id, _, { mod_desc = Tmod_structure str }) ->
- all_idents str.str_items @ more_idents rem
- | Tstr_module(id, _, _) -> more_idents rem
- @@ -419,7 +433,7 @@ and all_idents = function
- | Tstr_class cl_list ->
- List.map (fun (ci, _, _) -> ci.ci_id_class) cl_list @ all_idents rem
- | Tstr_class_type cl_list -> all_idents rem
- - | Tstr_include(modl, ids) -> ids @ all_idents rem
- + | Tstr_include(modl, sg) -> bound_value_identifiers sg @ all_idents rem
- | Tstr_module(id, _, { mod_desc = Tmod_structure str }) ->
- id :: all_idents str.str_items @ all_idents rem
- | Tstr_module(id, _, _) -> id :: all_idents rem
- @@ -526,7 +540,8 @@ let transl_store_structure glob map prims str =
- transl_store rootpath (add_idents false ids subst) rem)
- | Tstr_class_type cl_list ->
- transl_store rootpath subst rem
- - | Tstr_include(modl, ids) ->
- + | Tstr_include(modl, sg) ->
- + let ids = bound_value_identifiers sg in
- let mid = Ident.create "include" in
- let rec store_idents pos = function
- [] -> transl_store rootpath (add_idents true ids subst) rem
- @@ -719,7 +734,8 @@ let transl_toplevel_item item =
- cl_list)
- | Tstr_class_type cl_list ->
- lambda_unit
- - | Tstr_include(modl, ids) ->
- + | Tstr_include(modl, sg) ->
- + let ids = bound_value_identifiers sg in
- let mid = Ident.create "include" in
- let rec set_idents pos = function
- [] ->
- diff --git a/tools/untypeast.ml b/tools/untypeast.ml
- index e1719d9..c1b4264 100644
- --- a/tools/untypeast.ml
- +++ b/tools/untypeast.ml
- @@ -319,7 +319,7 @@ and untype_signature_item item =
- | Tsig_modtype (_id, name, mdecl) ->
- Psig_modtype (name, untype_modtype_declaration mdecl)
- | Tsig_open (ovf, _path, lid) -> Psig_open (ovf, lid)
- - | Tsig_include (mty, _lid) -> Psig_include (untype_module_type mty)
- + | Tsig_include (mty, _) -> Psig_include (untype_module_type mty)
- | Tsig_class list ->
- Psig_class (List.map untype_class_description list)
- | Tsig_class_type list ->
- diff --git a/typing/typedtree.ml b/typing/typedtree.ml
- index 89ac527..405e56b 100644
- --- a/typing/typedtree.ml
- +++ b/typing/typedtree.ml
- @@ -202,7 +202,7 @@ and structure_item_desc =
- | Tstr_open of override_flag * Path.t * Longident.t loc
- | Tstr_class of (class_declaration * string list * virtual_flag) list
- | Tstr_class_type of (Ident.t * string loc * class_type_declaration) list
- - | Tstr_include of module_expr * Ident.t list
- + | Tstr_include of module_expr * Types.signature
- and module_coercion =
- Tcoerce_none
- diff --git a/typing/typedtree.mli b/typing/typedtree.mli
- index 70e79b0..a263c90 100644
- --- a/typing/typedtree.mli
- +++ b/typing/typedtree.mli
- @@ -201,7 +201,7 @@ and structure_item_desc =
- | Tstr_open of override_flag * Path.t * Longident.t loc
- | Tstr_class of (class_declaration * string list * virtual_flag) list
- | Tstr_class_type of (Ident.t * string loc * class_type_declaration) list
- - | Tstr_include of module_expr * Ident.t list
- + | Tstr_include of module_expr * Types.signature
- and module_coercion =
- Tcoerce_none
- diff --git a/typing/typedtreeMap.ml b/typing/typedtreeMap.ml
- index 2b6f641..7c8c633 100644
- --- a/typing/typedtreeMap.ml
- +++ b/typing/typedtreeMap.ml
- @@ -139,8 +139,8 @@ module MakeMap(Map : MapArgument) = struct
- (id, name, Map.leave_class_infos { ct with ci_expr = ci_expr})
- ) list in
- Tstr_class_type list
- - | Tstr_include (mexpr, idents) ->
- - Tstr_include (map_module_expr mexpr, idents)
- + | Tstr_include (mexpr, sg) ->
- + Tstr_include (map_module_expr mexpr, sg)
- in
- Map.leave_structure_item { item with str_desc = str_desc}
- @@ -402,7 +402,7 @@ module MakeMap(Map : MapArgument) = struct
- | Tsig_modtype (id, name, mdecl) ->
- Tsig_modtype (id, name, map_modtype_declaration mdecl)
- | Tsig_open _ -> item.sig_desc
- - | Tsig_include (mty, lid) -> Tsig_include (map_module_type mty, lid)
- + | Tsig_include (mty, sg) -> Tsig_include (map_module_type mty, sg)
- | Tsig_class list -> Tsig_class (List.map map_class_description list)
- | Tsig_class_type list ->
- Tsig_class_type (List.map map_class_type_declaration list)
- diff --git a/typing/typemod.ml b/typing/typemod.ml
- index 475cb9b..521b078 100644
- --- a/typing/typemod.ml
- +++ b/typing/typemod.ml
- @@ -688,20 +688,6 @@ let check_nongen_scheme env str =
- let check_nongen_schemes env str =
- List.iter (check_nongen_scheme env) str
- -(* Extract the list of "value" identifiers bound by a signature.
- - "Value" identifiers are identifiers for signature components that
- - correspond to a run-time value: values, exceptions, modules, classes.
- - Note: manifest primitives do not correspond to a run-time value! *)
- -
- -let rec bound_value_identifiers = function
- - [] -> []
- - | Sig_value(id, {val_kind = Val_reg}) :: rem ->
- - id :: bound_value_identifiers rem
- - | Sig_exception(id, decl) :: rem -> id :: bound_value_identifiers rem
- - | Sig_module(id, mty, _) :: rem -> id :: bound_value_identifiers rem
- - | Sig_class(id, decl, _) :: rem -> id :: bound_value_identifiers rem
- - | _ :: rem -> bound_value_identifiers rem
- -
- (* Helpers for typing recursive modules *)
- let anchor_submodule name anchor =
- @@ -1146,7 +1132,7 @@ and type_structure ?(toplevel = false) funct_body anchor env sstr scope =
- List.iter
- (check_sig_item type_names module_names modtype_names loc) sg;
- let new_env = Env.add_signature sg env in
- - let item = mk (Tstr_include (modl, bound_value_identifiers sg)) in
- + let item = mk (Tstr_include (modl, sg)) in
- let (str_rem, sig_rem, final_env) = type_struct new_env srem in
- (item :: str_rem,
- sg @ sig_rem,
- diff --git a/typing/typemod.mli b/typing/typemod.mli
- index d34bde8..cda0069 100644
- --- a/typing/typemod.mli
- +++ b/typing/typemod.mli
- @@ -39,8 +39,6 @@ val save_signature : string -> Typedtree.signature -> string -> string ->
- val package_units:
- string list -> string -> string -> Typedtree.module_coercion
- -val bound_value_identifiers : Types.signature_item list -> Ident.t list
- -
- type error =
- Cannot_apply of module_type
- | Not_included of Includemod.error list
Add Comment
Please, Sign In to add comment