2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 * Author: Ceriel J.H. Jacobs
8 /* T Y P E D E S C R I P T O R S T R U C T U R E */
10 /* $Id: type.H,v 1.57 1996/08/14 07:42:36 ceriel Exp $ */
14 struct paramlist { /* structure for parameterlist of a PROCEDURE */
15 struct paramlist *par_next;
16 struct def *par_def; /* "df" of parameter */
17 #define IsVarParam(xpar) ((int) ((xpar)->par_def->df_flags & D_VARPAR))
18 #define TypeOfParam(xpar) ((xpar)->par_def->df_type)
21 typedef struct paramlist t_param;
23 /* ALLOCDEF "paramlist" 20 */
26 struct def *en_enums; /* Definitions of enumeration literals */
27 arith en_ncst; /* Number of constants */
28 label en_rck; /* Label of range check descriptor */
29 #define enm_enums tp_value.tp_enum->en_enums
30 #define enm_ncst tp_value.tp_enum->en_ncst
31 #define enm_rck tp_value.tp_enum->en_rck
34 /* ALLOCDEF "enume" 5 */
37 arith su_lb, su_ub; /* lower bound and upper bound */
38 label su_rck; /* label of range check descriptor */
39 #define sub_lb tp_value.tp_subrange->su_lb
40 #define sub_ub tp_value.tp_subrange->su_ub
41 #define sub_rck tp_value.tp_subrange->su_rck
44 /* ALLOCDEF "subrange" 5 */
47 struct type *ar_elem; /* type of elements */
48 label ar_descr; /* label of array descriptor */
49 arith ar_elsize; /* size of elements */
50 arith ar_low; /* lower bound of index */
51 arith ar_high; /* upper bound of index */
52 #define arr_elem tp_value.tp_arr->ar_elem
53 #define arr_descr tp_value.tp_arr->ar_descr
54 #define arr_elsize tp_value.tp_arr->ar_elsize
55 #define arr_low tp_value.tp_arr->ar_low
56 #define arr_high tp_value.tp_arr->ar_high
59 /* ALLOCDEF "array" 5 */
62 struct scope *rc_scope; /* scope of this record */
63 /* members are in the symbol table */
64 #define rec_scope tp_value.tp_record.rc_scope
68 struct paramlist *pr_params;
69 arith pr_nbpar; /* number of bytes parameters accessed */
70 #define prc_params tp_value.tp_proc.pr_params
71 #define prc_nbpar tp_value.tp_proc.pr_nbpar
75 arith st_low; /* lowerbound of subrange type of set */
76 unsigned st_sz; /* size of constant set in compiler */
77 #define set_low tp_value.tp_set.st_low
78 #define set_sz tp_value.tp_set.st_sz
82 struct type *tp_next; /* used with ARRAY, PROCEDURE, POINTER, SET,
85 short tp_fund; /* fundamental type or constructor */
86 #define T_RECORD 0x0001
87 #define T_ENUMERATION 0x0002
88 #define T_INTEGER 0x0004
89 #define T_CARDINAL 0x0008
90 #define T_EQUAL 0x0010
92 #define T_HIDDEN 0x0040
93 #define T_POINTER 0x0080
97 #define T_SUBRANGE 0x0800
98 #define T_PROCEDURE 0x1000
99 #define T_ARRAY 0x2000
100 #define T_STRING 0x4000
101 #define T_INTORCARD (T_INTEGER|T_CARDINAL)
102 #define T_NOSUB (T_INTORCARD|T_ENUMERATION|T_CHAR)
103 #define T_NUMERIC (T_INTORCARD|T_REAL)
104 #define T_INDEX (T_ENUMERATION|T_CHAR|T_SUBRANGE)
105 #define T_DISCRETE (T_INDEX|T_INTORCARD)
106 #define T_CONSTRUCTED (T_ARRAY|T_SET|T_RECORD)
108 short tp_dbindex; /* index in debugger symbol table */
110 int tp_align; /* alignment requirement of this type */
111 arith tp_size; /* size of this type */
113 struct enume *tp_enum;
114 struct subrange *tp_subrange;
115 struct array *tp_arr;
116 struct record tp_record;
122 typedef struct type t_type;
124 /* ALLOCDEF "type" 50 */
143 *error_type; /* All from type.c */
147 #include "target_sizes.h"
148 #define word_align (AL_WORD)
149 #define short_align (AL_SHORT)
150 #define int_align (AL_INT)
151 #define long_align (AL_LONG)
152 #define float_align (AL_FLOAT)
153 #define double_align (AL_DOUBLE)
154 #define pointer_align (AL_POINTER)
155 #define struct_align (AL_STRUCT)
157 #define word_size (SZ_WORD)
158 #define dword_size (2 * SZ_WORD)
159 #define int_size (SZ_INT)
160 #define short_size (SZ_SHORT)
161 #define long_size (SZ_LONG)
162 #define float_size (SZ_FLOAT)
163 #define double_size (SZ_DOUBLE)
164 #define pointer_size (SZ_POINTER)
166 #define wrd_bits (8*(int)word_size)
177 struct_align; /* All from type.c */
187 pointer_size; /* All from type.c */
190 wrd_bits; /* from cstoper.c */
197 align(); /* type.c */
208 *RemoveEqual(); /* All from type.c */
210 #define NULLTYPE ((t_type *) 0)
212 #define IsConformantArray(tpx) ((tpx)->tp_fund==T_ARRAY && (tpx)->tp_size==0)
213 #define bounded(tpx) ((tpx)->tp_fund & T_INDEX)
214 #define complex(tpx) ((tpx)->tp_fund & (T_RECORD|T_ARRAY))
215 #define WA(sz) (align(sz, (int) word_size))
217 #define ResultType(tpx) (assert((tpx)->tp_fund == T_PROCEDURE),\
219 #define ParamList(tpx) (assert((tpx)->tp_fund == T_PROCEDURE),\
221 #define IndexType(tpx) (assert((tpx)->tp_fund == T_ARRAY),\
223 #define ElementType(tpx) (assert((tpx)->tp_fund == T_SET),\
225 #define PointedtoType(tpx) (assert((tpx)->tp_fund == T_POINTER),\
227 #define SubBaseType(tpx) (assert((tpx)->tp_fund == T_SUBRANGE), \
230 #define ResultType(tpx) ((tpx)->tp_next)
231 #define ParamList(tpx) ((tpx)->prc_params)
232 #define IndexType(tpx) ((tpx)->tp_next)
233 #define ElementType(tpx) ((tpx)->tp_next)
234 #define PointedtoType(tpx) ((tpx)->tp_next)
235 #define SubBaseType(tpx) ((tpx)->tp_next)
237 #define BaseType(tpx) ((tpx)->tp_fund == T_SUBRANGE ? (tpx)->tp_next : \
239 #define IsConstructed(tpx) ((tpx)->tp_fund & T_CONSTRUCTED)
240 #define TooBigForReturnArea(tpx) ((tpx)->tp_size > ret_area_size)
242 extern arith full_mask[];
243 extern arith max_int[];
244 extern arith min_int[];
246 #define ufit(n, i) (((n) & ~full_mask[(i)]) == 0)