1 (***********************************************************************)
4 (* Maxence Guesdon, projet Cristal, INRIA Rocquencourt *)
6 (* Copyright 2001 Institut National de Recherche en Informatique et *)
7 (* en Automatique. All rights reserved. This file is distributed *)
8 (* under the terms of the Q Public License version 1.0. *)
10 (***********************************************************************)
14 (** Representation and manipulation of values, class attributes and class methods. *)
16 module Name
= Odoc_name
20 (** Representation of a value. *)
23 mutable val_info
: Odoc_types.info
option ;
24 val_type
: Types.type_expr
;
25 val_recursive
: bool ;
26 mutable val_parameters
: Odoc_parameter.parameter list
;
27 mutable val_code
: string option ;
28 mutable val_loc
: Odoc_types.location
;
31 (** Representation of a class attribute. *)
33 att_value
: t_value
; (** an attribute has almost all the same information
38 (** Representation of a class method. *)
40 met_value
: t_value
; (** a method has almost all the same information
48 (** Returns the text associated to the given parameter name
49 in the given value, or None. *)
50 let value_parameter_text_by_name v name
=
55 let t = List.assoc name i
.Odoc_types.i_params
in
61 (** Update the parameters text of a t_value, according to the val_info field. *)
62 let update_value_parameters_text v
=
64 Odoc_parameter.update_parameter_text
(value_parameter_text_by_name v
) p
66 List.iter
f v
.val_parameters
68 (** Create a list of (parameter name, typ) from a type, according to the arrows.
69 [parameter_list_from_arrows t = [ a ; b ]] if t = a -> b -> c.*)
70 let parameter_list_from_arrows typ
=
72 match t.Types.desc
with
73 Types.Tarrow
(l
, t1
, t2
, _
) ->
76 | Types.Tsubst texp
->
78 | Types.Tpoly
(texp
, _
) -> iter texp
91 (** Create a list of parameters with dummy names "??" from a type list.
92 Used when we want to merge the parameters of a value, from the .ml
93 and the .mli file. In the .mli file we don't have parameter names
94 so there is nothing to merge. With this dummy list we can merge the
95 parameter names from the .ml and the type from the .mli file. *)
96 let dummy_parameter_list typ
=
102 '?'
-> String.sub s
1 ((String.length s
) - 1)
105 Printtyp.mark_loops typ
;
106 let liste_param = parameter_list_from_arrows typ
in
107 let rec iter (label
, t) =
108 match t.Types.desc
with
112 (List.map
(fun t2
-> iter ("", t2
)) l
, t)
114 (* if there is a label, then we don't want to decompose the tuple *)
115 Odoc_parameter.Simple_name
116 { Odoc_parameter.sn_name
= normal_name label
;
117 Odoc_parameter.sn_type
= t ;
118 Odoc_parameter.sn_text
= None
}
124 Odoc_parameter.Simple_name
125 { Odoc_parameter.sn_name
= normal_name label
;
126 Odoc_parameter.sn_type
= t ;
127 Odoc_parameter.sn_text
= None
}
129 List.map
iter liste_param
131 (** Return true if the value is a function, i.e. has a functional type.*)
134 match t.Types.desc
with