jon.recoil.org

Module Type_shape

module Uid = Shape.Uid
module Layout = Jkind_types.Sort.Const
type base_layout = Jkind_types.Sort.base
type path_lookup = Path.t -> args:Shape.t list -> Shape.t option
module Type_shape : sig ... end
module Type_decl_shape : sig ... end
module Evaluation_diagnostics : sig ... end
val unfold_and_evaluate : ?diagnostics:Type_shape.Evaluation_diagnostics.t -> Shape.t -> Shape.t

unfold_and_evaluate performs call-by-value evaluation of shapes. It should be applied after reduce (from shape_reduce.ml) has already been used. More specifically, when producing a type shape with of_type_expr, the resulting shape is not a normal form. A normal form---at least for the emission into DWARF debug information---should no longer contain structures (from modules), lambdas (from functors and parametric types), application (from functor instantiation and type application), mutually recursive declarations and their projections (Constr and Proj_decl). (Due to missing information, it might still contain compilation units Comp_unit and projections Proj from them.)

We reach the normal form of a type shape (e.g., during the emission of DWARF information) in two steps:

1. We execute shape_reduce, which will substitute compilation units with their shapes loaded from .cms files and then reduce away projections Proj and functor applications. It will also, partially, deal with instantiation of type variables. That is, of_type_declaration inserts lambdas for non-recursive types with type arguments. These are reduced away via shape_reduce. (For (mutually-)recursive types, the next step handles the instantiation.) 2. After shape reduction, the type declaration can still contain recursive or mutually-recursive declarations, which have not been unfolded. Since we cannot directly emit these into DWARF, we then unfold recursive declarations applied to type shape arguments into recursive types with unfold_and_evaluate. For example, type 'a list = [] | :: of 'a * 'a list applied to int becomes the type shape Mu (Variant [] | :: of int * #0).

type shape_with_layout = private {
  1. type_shape : Shape.t;
  2. type_layout : Layout.t;
  3. type_name : string;
}
val all_type_decls : Shape.t Uid.Tbl.t
val add_to_type_decls : (Ident.t * Types.type_declaration) list -> Type_shape.path_lookup -> unit
val add_to_type_shapes : Uid.t -> Types.type_expr -> Layout.t -> name:string -> Type_shape.path_lookup -> unit
val estimate_layout_from_type_shape : Shape.t -> Layout.t option
val print_table_all_type_decls : Stdlib.Format.formatter -> unit
val print_table_all_type_shapes : Stdlib.Format.formatter -> unit
val print_debug_uid_tables : Stdlib.Format.formatter -> unit