1 /* type.h - types for bcc */
2 
3 /* Copyright (C) 1992 Bruce Evans */
4 
5 /*
6   A type is essentially a "constructor", a size, and a list of pointers
7   leading to a scalar type.
8   The type constructors are codes for the scalar types and (), [], *,
9   struct and union.
10   The scalar types are char, short, int, long, float and double.
11   The type lists are triply linked.
12 
13   Part of the type structure might look like
14 
15 			   int		(int)
16 			    =
17 	    func <-------> int		(int ())
18 	     |		    =
19 	      --> ptr <--> int		(int *)
20 
21   (the exact structure depends on the order of declarations).
22   This layout results from the pre-declared (int) and (int ()) followed by
23   a declaration using (int *).
24   The sideways link (from func to ptr here) allows all types leading to a
25   given type to be found.
26   This allows different declarations of (int *) to be recognised as the same.
27   Type equivalence is equality of type pointers.
28 */
29 
30 /*
31   flags for scalar types
32   up to 3 of the flags may be set (none for constructed types)
33   the 2nd and third flags can only be UNSIGNED or DLONG
34   UNSIGNED only applies to integral types
35   DLONG only applies to long and unsigned long types and says that these
36   are actually longer than an int
37 */
38 
39 #define	CHAR		0x01
40 #define	SHORT		0x02
41 #define	INT		0x04
42 #define	LONG		0x08
43 #define	FLOAT		0x10
44 #define DOUBLE		0x20
45 #define UNSIGNED	0x40
46 #define DLONG		0x80
47 
48 #define ISCALAR		(CHAR | SHORT | INT | LONG)
49 #define RSCALAR		(FLOAT | DOUBLE)
50 
51 /*
52   flags for type constructor
53   at most 1 of the flags may be set (none for scalar types)
54   flags are used for fast testing for array/pointer
55 */
56 
57 #define ARRAY		1
58 #define FUNCTION	2
59 #define POINTER		4
60 #define STRUCTU		8
61 #define VOID		0x10
62 
63 /* type sizes */
64 /* default sizes and long and float sizes are hard-coded into type data */
65 
66 extern uoffset_T ctypesize;
67 extern uoffset_T dtypesize;
68 extern uoffset_T ftypesize;
69 extern uoffset_T itypesize;
70 extern uoffset_T ptypesize;
71 extern uoffset_T stypesize;
72 
73 /* basic scalar types */
74 
75 EXTERN struct typestruct *dtype;
76 EXTERN struct typestruct *fltype;
77 EXTERN struct typestruct *itype;
78 EXTERN struct typestruct *ltype;
79 EXTERN struct typestruct *sctype;
80 EXTERN struct typestruct *stype;
81 EXTERN struct typestruct *uctype;
82 EXTERN struct typestruct *uitype;
83 EXTERN struct typestruct *ultype;
84 EXTERN struct typestruct *ustype;
85 EXTERN struct typestruct *vtype;
86 
87 /* working type */
88 
89 EXTERN struct typestruct *ctype;
90 
91 /* constructed types */
92 
93 EXTERN struct typestruct *fitype;
94 EXTERN struct typestruct *pctype;
95 
96 /* return type of current function */
97 
98 EXTERN struct typestruct *returntype;
99