1
%% =====================================================================
2
%% Header file for EDoc Type Representations
4
%% Copyright (C) 2001-2005 Richard Carlsson
6
%% This library is free software; you can redistribute it and/or modify
7
%% it under the terms of the GNU Lesser General Public License as
8
%% published by the Free Software Foundation; either version 2 of the
9
%% License, or (at your option) any later version.
11
%% This library is distributed in the hope that it will be useful, but
12
%% WITHOUT ANY WARRANTY; without even the implied warranty of
13
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
%% Lesser General Public License for more details.
16
%% You should have received a copy of the GNU Lesser General Public
17
%% License along with this library; if not, write to the Free Software
18
%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21
%% Author contact: richardc@csd.uu.se
22
%% =====================================================================
24
%% Type specification data structures
26
%% @type t_spec() = #t_spec{name = t_name(),
30
-record(t_spec, {name, type, defs=[]}). % function specification
32
%% @type type() = t_atom() | t_fun() | t_integer() | t_list() | t_nil()
33
%% | t_tuple() | t_type() | t_union() | t_var()
35
%% @type t_typedef() = #t_typedef{name = t_name(),
40
-record(t_typedef, {name, args, type,
41
defs=[]}). % type declaration/definition
43
%% @type t_throws() = #t_throws{type = type(),
46
-record(t_throws, {type, defs=[]}). % exception declaration
48
%% @type t_def() = #t_def{name = t_name(),
51
-record(t_def, {name, type}). % local definition 'name = type'
52
%% @type t_name() = #t_name{app = [] | atom(),
53
%% module = [] | atom(),
54
%% name = [] | atom()}
56
-record(t_name, {app = [], % app = [] if module = []
57
module=[], % unqualified if module = []
60
%% The following records all have 'a=[]' as their first field.
61
%% This is used for name annotations; in particular, the fun-argument
62
%% types of a function specification (t_spec) are often annotated with
63
%% the names of the corresponding formal parameters.
65
-define(t_ann(X), element(2, X)).
66
-define(set_t_ann(X, Y), setelement(2, X, Y)).
68
%% @type t_var() = #t_var{a = list(), name = [] | atom()}
70
-record(t_var, {a=[], name=[]}). % type variable
72
%% @type t_type() = #t_type{a = list(),
76
-record(t_type, {a=[], name, args = []}). % abstract type 'name(...)'
78
%% @type t_union() = #t_union{a = list(),
81
-record(t_union, {a=[], types = []}). % union type 't1|...|tN'
83
%% @type t_fun() = #t_fun{a = list(),
87
-record(t_fun, {a=[], args, range}). % function '(t1,...,tN) -> range'
89
%% @type t_tuple() = #t_tuple{a = list(),
92
-record(t_tuple, {a=[], types = []}). % tuple type '{t1,...,tN}'
94
%% @type t_list() = #t_list{a = list(),
97
-record(t_list, {a=[], type}). % list type '[type]'
99
%% @type t_nil() = #t_nil{a = list()}
101
-record(t_nil, {a=[]}). % empty-list constant '[]'
103
%% @type t_atom() = #t_atom{a = list(),
106
-record(t_atom, {a=[], val}). % atom constant
108
%% @type t_integer() = #t_integer{a = list(),
111
-record(t_integer, {a=[], val}). % integer constant
113
%% @type t_float() = #t_float{a = list(),
116
-record(t_float, {a=[], val}). % floating-point constant
118
%% @type t_record() = #t_list{a = list(),
120
%% fields = [field()]}
122
-record(t_record, {a=[], name, fields = []}). % record type '#r{f1,...,fN}'
124
%% @type t_field() = #t_field{a = list(),
128
-record(t_field, {a=[], name, type}). % named field 'n1=t1'