summaryrefslogtreecommitdiff
path: root/bcc/types.h
blob: effcfcd4bebbb2cc4e852c924668b8b0b2bc4d71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/* types.h - type definitions for bcc */

/* Copyright (C) 1992 Bruce Evans */

/*
  source types big enough to handle target quantities
  these have to be match the source compiler and target machine
  this is impossible if the source long type is too small
*/

typedef unsigned char char_t;	/* target char */
typedef long value_t;		/* target ints, longs and offsets */
typedef unsigned long uvalue_t;	/* target unsigned ints, longs and offsets */

#ifdef I8088
typedef long offset_T;		/* target machine offset */
typedef unsigned long uoffset_T;	/* target unsigned machine offset */
#define outuvalue outhex
#define outvalue outshex
#endif
#ifdef MC6809
typedef int offset_T;
typedef unsigned uoffset_T;
#endif


/*
  storage class type must hold all the flags defined elsewhere
  it must have a few more bits than the target has registers
*/

#ifdef I8088
typedef unsigned store_pt;	/* promoted store_t */
typedef unsigned store_t;	/* storage class flags */
#endif
#ifdef MC6809
#ifdef __STDC__
typedef int store_pt;
# else
typedef unsigned store_pt;
# endif
typedef unsigned char store_t;
#endif


/*
  types for library routines
*/

typedef int fd_t;		/* file descriptor */


/*
  basic scalar types - may be tuned to suit machine
*/

typedef int fastin_pt;		/* promoted fastin_t */
				/* always an int - use to show that the */
				/* value may be accessed as a fastin_t */
typedef char fastin_t;		/* fast int - a small integer value */
				/* on some machines, chars can be accessed */
				/* more efficiently than ints for arithmetic */
				/* such as comparing and masking which */
				/* does not requiring promotion */
				/* change to int if chars are inefficient */
				/* or if char has < 8 bits */
typedef int smalin_pt;		/* promoted smalin_t */
typedef char smalin_t;		/* small int - a small integer value */
				/* on most machines, chars are stored in */
				/* less space than any other type */
				/* change to fastin_t if this is not true */
				/* or if char has < 8 bits */
				/* or if space is not a limiting factor */
#ifdef __STDC__
typedef int smalu_pt;
#else
typedef unsigned smalu_pt;
#endif
typedef unsigned char smalu_t;


/*
  derived scalar types
  the types containing bit flags fit in an 8 bit smalin_t
*/

typedef fastin_pt bool_pt;	/* promoted bool_t */
typedef fastin_t bool_t;	/* boolean: TRUE if nonzero */
typedef fastin_pt ccode_pt;	/* promoted ccode_t */
typedef fastin_t ccode_t;	/* condition code code */
typedef smalu_pt constr_pt;	/* promoted constr_t */
typedef smalu_t constr_t;	/* type constructor flags */
typedef smalu_pt indn_pt;	/* promoted indn_t */
typedef smalu_t indn_t;		/* storage indirection count */
typedef unsigned label_no;	/* label number */
typedef smalu_t maclev_t;	/* macro expansion level */
typedef smalin_pt op_pt;	/* promoted op_t */
typedef smalin_t op_t;		/* operator code */
typedef smalu_t sc_t;		/* storage class flags */
typedef smalu_pt scalar_pt;	/* promoted scalar_t */
typedef smalu_t scalar_t;	/* type scalar flags */
typedef smalu_t scopelev_t;	/* scope level */
typedef fastin_pt sym_pt;	/* promoted sym_t */
typedef fastin_t sym_t;		/* symbol code from scanner */
typedef smalu_t weight_t;	/* expression tree node weight */


/*
  derived structure types
  the fields are ordered in a way that is most space-efficient
  when smalin_t is char and smalu_t is unsigned char
  the first element of the structures is the one most frequently accessed
*/

/*
  expression table entry format
*/

struct nodestruct
{
    op_t tag;
    weight_t weight;
    smalu_t flags;
    struct typestruct *nodetype;
    union nodeunion
    {
	struct nodestruct *nodeptr;
	struct symstruct *symptr;
    } left;
    struct nodestruct *right;
};

/*
  symbol table entry format
*/

struct symstruct
{
    store_t storage;
    indn_t indcount;
    sc_t flags;
    scopelev_t level;
    struct symstruct *next;
    struct symstruct **prev;
    struct typestruct *type;
    union
    {
	double *offd;		/* value for double constants */
	offset_T offi;		/* offset for register or global storage */
	label_no offlabel;	/* label number for strings */
	char *offp;		/* to string for macro definitions */
	sym_pt offsym;		/* symbol code for keywords */
	value_t offv;		/* value for integral constants */
    }
     offset;
    union
    {
	label_no label;		/* label number for strings */
	char namea[1];		/* variable length array for declarations */
	char *namep;		/* to constant storage for exprs */
    }
     name;
};

/*
  type table entry format
*/

struct typestruct
{
    scalar_t scalar;		/* scalar type flags u d f l i s c */
    constr_t constructor;	/* constructed type flags a f p s/u */
    char structkey[2];		/* unique prefix for member names */
				/* ranges from "\001\001" to "@\377" */
				/* avoiding nulls */
    uoffset_T alignmask;	/* alignment mask, typesize - 1 for scalars */
    uoffset_T typesize;		/* size of this type */
    char *tname;		/* name of scalar type or constructor */
    struct typelist *listtype;	/* list of member types */
    struct typestruct *nexttype;
				/* next in list */
    struct typestruct *prevtype;
				/* previous in list */
    struct typestruct *sidetype;
				/* next in sideways list */
};

/*
  list of type structures
*/

struct typelist
{
    struct typelist *tlnext;
    struct typestruct *tltype;
};


/*
  definitions to avoid passing raw NULLs to functions
*/

#define NULLNODE ((struct nodestruct *) NULL)
#define NULLTYPE ((struct typestruct *) NULL)