Module Oug_mod


module Oug_mod: sig .. end
Representation of the graph of a module, but also the global graph, seen as a big module.

val ident_packed : Ident.t
module Graph: Oug_graph.S  with
  type key = Oug_types.elt_id
  and type edge_data = Oug_types.depend
module Elt_map: Map.S  with
  type key = Oug_types.elt_id
  and type 'a t = 'a Oug_types.Elt_map.t

type t = {
   mod_name : string; (*the top module name*)
   mod_intf : bool option; (*whether it is an interface (.mli) or not, or a big graph (None)*)
   mod_elts : Oug_types.elt_map; (*All the elements*)
   mod_pending : (string * Oug_actions.pending_action) list; (*Pending actions, each associated to a top module name*)
   mod_env : Oug_types.elt_id Oug_env.t; (*Current environment*)
   mod_elt_env : Oug_types.elt_id Oug_env.t Elt_map.t; (*Environment of each element*)
   mod_elt_intf : (Oug_types.elt_id Oug_env.Interface.t * (string * Oug_types.elt_id) list)
Elt_map.t
;
(*interface and (for functors) parameters*)
   mod_graph : Graph.t; (*The graph*)
   mod_groups : (unit, Oug_types.Elt_set.t) Oug_tmap.t; (*Groups of recursive elements*)
   mod_cur_name : Oug_types.absname; (*Current absolute name*)
   mod_cur_id : Oug_types.elt_id; (*Current element id*)
}
val create : Oug_loc.location -> bool option -> string -> t
create loc intf name create a new structure for the given module. intf will be put in the intf field of Oug_mod.t.
val size : t -> int * int
Return the number of elements and the number of edges in the graph.
val input_file : string -> t
Load a Oug_mod.t from the given file.
val output_file : string -> t -> unit
Store a Oug_mod.t in the given file.
val dummy_t : t

Getters and setters


val get_elt : t -> Oug_types.elt_id -> Oug_types.elt
val get_elt_env : t -> Oug_types.elt_id -> Oug_types.elt_id Oug_env.t
val set_elt_env : t -> Oug_types.elt_id -> Oug_types.elt_id Oug_env.t -> t
val get_elt_intf : t ->
Oug_types.elt_id ->
Oug_types.elt_id Oug_env.Interface.t * (string * Oug_types.elt_id) list
val set_elt_intf : t ->
Oug_types.elt_id ->
Oug_types.elt_id Oug_env.Interface.t * (string * Oug_types.elt_id) list ->
t
val add_depend : t ->
src:Oug_types.elt_id ->
data:Oug_types.depend -> dst:Oug_types.elt_id -> t
Add an edge to the graph, or do nothing if the same edge already exists.
val elt_alias_dst : t -> Oug_types.elt_id -> Oug_types.elt_id list
elt_alias_dst t id returns the list of elements whose element id is an alias for, that is all elements e where an edge Alias exists from id to e.
val get_export_final : t -> Oug_types.elt_id -> Oug_types.elt_id
Follow the Export edges from the given element until no more can be followed, and return the last element, which can be the same as given if it is not an "exporter".
val elt_set : t -> Oug_types.Elt_set.t
Getting all elements as a set.

Adding elements


val add_val : t ->
Oug_loc.location ->
?inst_var:bool ->
?group:Oug_types.group_id ->
Oug_types.absname -> Oug_types.elt_id * t
val add_pattern : t ->
Oug_loc.location ->
?group:Oug_types.group_id ->
Oug_types.absname -> Oug_types.elt_id * t
val copy_val_or_pattern : t ->
Oug_types.elt_id -> Oug_types.absname -> Oug_types.elt_id * t
val add_expr : t ->
Oug_loc.location ->
?group:Oug_types.group_id ->
?kind:Oug_types.expr_kind -> string -> Oug_types.elt_id * t
val copy_expr : t -> Oug_types.elt_id -> Oug_types.elt_id * t
val add_module : ?contain:bool ->
t ->
Oug_loc.location ->
Oug_types.elt_id Oug_env.t ->
Oug_types.absname -> Oug_types.elt_id * t
val add_module_to_env : t ->
intf:Oug_types.elt_id Oug_env.Interface.t ->
?args:(string * Oug_types.elt_id) list ->
string -> Oug_types.elt_id -> t
val add_type_field : t ->
Oug_loc.location ->
Oug_types.elt_id Oug_env.t ->
Oug_types.absname -> Oug_types.elt_id * t
val add_type : t ->
?group:Oug_types.group_id ->
Oug_loc.location ->
Oug_types.absname -> Oug_types.type_kind -> Oug_types.elt_id * t
val add_type_with_env_kind : t ->
?group:Oug_types.group_id ->
Oug_loc.location ->
Oug_types.absname ->
Oug_types.elt_id Oug_env.type_kind -> Oug_types.elt_id * t
val copy_type : t ->
'a ->
Oug_types.absname ->
Oug_types.elt_id Oug_env.type_kind -> Oug_types.elt_id * t
val add_method : t ->
Oug_loc.location -> Oug_types.absname -> Oug_types.elt_id * t
val copy_method : t -> 'a -> Oug_types.absname -> Oug_types.elt_id * t
val add_group : t -> unit Oug_tmap.key * t
val set_group : t -> unit Oug_tmap.key -> Oug_types.Elt_set.t -> t
val add_pending : t -> string -> Oug_actions.pending_action -> t
add_pending t mod_name action adds a new pending action to t, associated to the top module name mod_name.
val map_pending_action_ids : (Oug_types.elt_id -> Oug_types.elt_id) ->
'a * Oug_actions.pending_action -> 'a * Oug_actions.pending_action
val ids_in_pending_action : Oug_actions.pending_action -> Oug_types.elt_id list
val ids_in_pending_actions : t -> Oug_types.Elt_set.t
val find_and_add_depend_to_value : t ->
Oug_types.elt_id -> Oug_types.depend -> Oug_types.absname -> t
val find_and_add_depend_to_type : t ->
Oug_types.elt_id -> Oug_types.depend -> Oug_types.absname -> t

Getting strings


val string_of_mod_elt : t -> Oug_types.elt_id -> string
val string_of_action : t -> Oug_actions.pending_action -> string
val string_of_pending : t -> string
val string_of_one_elt_intf : t -> Oug_types.elt_id -> string
val string_of_elt_intf : t -> string
val string_of_one_elt_env : t -> Oug_types.elt_id -> string
val string_of_elt_env : t -> string

Utilities


val fold_on_packed_modules : (t ->
Oug_types.elt_id -> Oug_types.elt_id Oug_env.Interface.t -> t) ->
t -> Oug_types.elt_id -> t
val fold_contained : ?recu:bool ->
'a ->
('a -> 'b -> ('b * Oug_types.depend) list) ->
('c -> 'b -> 'c) -> 'c -> 'b -> 'c
val container : t -> Oug_types.elt_id -> Oug_types.elt_id option
container t id returns the optional contained of element id, that is the element e when an edge Contain exists from e to id.
val succ_by_kinds : t ->
Oug_types.elt_id ->
Oug_types.depend list -> (Oug_types.elt_id * Oug_types.depend) list
val replace_in_actions : Oug_types.elt_id ->
Oug_types.elt_id list ->
('a * Oug_actions.pending_action) list ->
('a * Oug_actions.pending_action) list
val filter_actions : (string * Oug_actions.pending_action -> bool) -> t -> t
val add_reversed_use_where_contain : t -> t
Replace each Contain edge by a Use edge in reverse order.
val gather_sub_exps : t ->
Oug_loc.location ->
?force:bool ->
?kind:Oug_types.expr_kind ->
string -> Oug_types.elt_id list -> Oug_types.elt_id option * t
val gather_sub_exps_opt : t ->
Oug_loc.location ->
?force:bool ->
string -> Oug_types.elt_id option list -> Oug_types.elt_id option * t
module Mod_dep: Oug_graph.S  with
  type key = string * bool
  and type edge_data = unit
val build_mod_deps : t list -> Mod_dep.t
Build graph of module dependencies from a list of modules. The returned graph may contain module names and intf/impl which are not in the list in parameter.
val dep_sort_modules : t list -> t list
Sort modules in dependency order; elements depending on nobody are last.

Reducing graph

This consists in removing some elements and managing the edges related to these elements.
val reduce_graph : ?progress:(t -> 'a) ->
t ->
Oug_types.depend list ->
?edge_map:(Oug_types.depend -> Oug_types.depend -> Oug_types.depend) ->
(t -> Oug_types.elt_id -> Oug_types.elt -> bool) -> t
val reduce_expressions : t -> t
val reduce_aliases : ?progress:(t -> 'a) -> t -> t