forked from Leffmann/vbcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvbc.h
263 lines (224 loc) · 8.23 KB
/
vbc.h
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/* $VER: vbcc (vbc.h) V0.8 */
#include "supp.h"
#define eval_constn(a) eval_const(&a->val,a->ntyp->flags)
struct identifier_list{
char *identifier;
int length;
struct identifier_list *next;
};
struct struct_identifier{
/* int flags;*/
char *identifier;
struct struct_declaration *sd;
struct struct_identifier *next;
};
#ifndef NODES
#error wrong node
struct node{
int flags,lvalue,sidefx;
struct Typ *ntyp;
struct node *left;
struct node *right;
struct argument_list *alist;
char *identifier;
union atyps val;
struct obj o;
};
typedef struct node *np;
#define NODES sizeof(struct node)
#endif
struct argument_list{
np arg;
struct argument_list *next;
struct IC *pushic;
};
#define MAXI 512 /* maximale Laenge von Identifiers in Bytes */
#define MAXN 128 /* maximale Verschachtelung von Bloecken */
extern struct tunit *first_tunit,*last_tunit;
extern struct Typ *arith_typ(struct Typ*,struct Typ *);
extern void insert_constn(np);
extern int int_erw(int);
extern int type_expression(np),compatible_types(struct Typ *,struct Typ *,int),
compare_sd(struct struct_declaration *,struct struct_declaration *);
#if HAVE_AOS4
extern int aos4_attr(struct Typ *,char *);
#endif
extern np identifier_expression(void),constant_expression(void),string_expression(void),
postfix_expression(void),unary_expression(void),cast_expression(void),
multiplicative_expression(void),additive_expression(void),
shift_expression(void),relational_expression(void),equality_expression(void),
and_expression(void),exclusive_or_expression(void),
inclusive_or_expression(void),logical_and_expression(void),
logical_or_expression(void),conditional_expression(void),
assignment_expression(void),expression(void),primary_expression(void);
extern struct argument_list *argument_list_expression(void);
extern struct const_list *cl_from_string(char *start, char *end);
extern np new_node(void);
/* puh */
extern int is_keyword(char *);
extern void pre(FILE *,np),pra(FILE *,struct argument_list *);
extern void free_expression(np),free_alist(struct argument_list *);
extern void cpbez(char *m,int ckw),cpnum(char *m),killsp(void);
extern void copy_token(/*no prototype because cpp.h not always included*/);
extern void push_token(/*no prototype because cpp.h not always included*/);
extern void next_token(void);
extern struct struct_declaration *add_sd(struct struct_declaration *,int);
extern void add_sl(struct struct_declaration *,struct struct_list (*)[]);
extern void free_sd(struct struct_declaration *);
extern void prl(FILE *,struct struct_declaration *);
extern char *add_identifier(char *,int);
extern struct Typ *declarator(struct Typ *),*direct_declarator(struct Typ *),
*pointer(struct Typ *),*declaration_specifiers(void);
extern int declaration(int),type_uncomplete(struct Typ *);
extern struct const_list *initialization(struct Typ *,int,int,int,struct struct_declaration *,struct const_list *);
extern void init_local_compound(struct Var *);
extern zmax init_dyn_sz,init_const_sz;
extern int init_dyn_cnt,init_const_cnt;
extern struct struct_declaration *find_struct(char *,int);
extern void add_struct_identifier(char *,struct struct_declaration *);
extern void free_si(struct struct_identifier *);
extern char *ident;
extern char number[MAXI],buff[MAXI];
extern struct struct_declaration *first_sd[MAXN],*last_sd[MAXN],*merk_sdf,*merk_sdl;
extern struct struct_identifier *first_si[MAXN],*last_si[MAXN],*merk_sif,*merk_sil;
extern struct identifier_list *first_ilist[MAXN],*last_ilist[MAXN],*merk_ilistf,*merk_ilistl;
extern void free_ilist(struct identifier_list *);
extern int nesting;
extern struct Var *first_var[MAXN],*last_var[MAXN],*merk_varf,*merk_varl,*first_ext,*last_ext;
extern struct Var *block_vla[MAXN];
extern struct llist *vladeflabels[MAXN],*vlajmplabels[MAXN];
extern struct vlaadjust_list *vlaadjusts[MAXN];
extern void freevl(void);
extern void clearvl(void);
extern void free_var(struct Var *);
extern void var_declaration(void);
extern int storage_class_specifiers(void);
extern void enter_block(void),leave_block(void);
extern struct Var *find_var(char *,int);
extern struct Var *find_ext_var(char *);
extern struct Var *add_var(char *,struct Typ *,int,struct const_list *);
extern void fi_from_attr(struct Var *);
extern int usz;
extern int c99;
extern int opencl;
extern int disallow_statics;
extern int header_cnt;
extern int softfloat;
#define MAGIC_WPO 123
extern int wpo,wpo_key;
extern FILE *input_wpo;
extern void gen_IC(np,int,int),convert(np,int),gen_label(int);
extern void gen_test(struct obj *,int,int,int);
extern void savescratch(int,struct IC *,int,struct obj *);
struct regargs_list{
struct regargs_list *next;
struct argument_list *al;
int reg;
struct Var *v;
};
#ifdef HAVE_REGPARMS
extern zmax push_args(struct argument_list *,struct struct_declaration *,int,struct regargs_list **,struct reg_handle *,struct obj *,struct Typ *,int,struct Typ *);
#else
extern zmax push_args(struct argument_list *,struct struct_declaration *,int,struct regargs_list **);
#endif
extern int allocreg(int,int);
extern void free_reg(int),alloc_hardreg(int);
extern FILE *out,*ic1,*ic2,*ppout,*cmdfile;
extern void statement(void),labeled_statement(void),if_statement(void);
extern void switch_statement(void),while_statement(void),for_statement(void);
extern void do_statement(void),goto_statement(void),continue_statement(void);
extern void break_statement(void),return_statement(void);
extern void expression_statement(void),compound_statement(void);
extern void translation_unit(void);
extern int main(int, char *[]);
extern int nocode,dontdelete,registerpri,looppri,currentpri;
extern int no_cast_free;
extern np makepointer(np);
struct vlaadjust_list {
struct IC *branch,*first;
struct vlaadjust_list *next;
};
extern int switch_typ,switch_count,switch_act;
struct llist{
char *identifier;
int label,flags,switch_count;
struct llist *next;
union atyps val;
};
#define LABELDEFINED 1
#define LABELUSED 2
#define LABELDEFAULT 4
#define LSIZE sizeof(struct llist)
extern struct llist *first_llist,*last_llist;
extern struct llist *find_label(char *),*add_label(char *);
extern void free_llist(struct llist *);
extern int endok,return_label,return_value,break_label;
extern int const_expr,for_decl;
extern struct Var *return_var;
extern struct Typ *return_typ;
extern zmax local_offset[MAXN];
extern void scratch_var(struct obj *,int,struct Typ *);
extern void get_scratch(struct obj *,int,int,struct Typ *);
extern void gen_cond(struct obj *,int,int,int);
#define MAXCF 60
extern int c_flags[MAXCF];
extern char *c_flags_name[MAXCF];
extern union ppi c_flags_val[MAXCF];
extern FILE *open_out(char *,char *);
extern char *inname;
extern void gen_vars(struct Var *);
/* Format der Tabelle fuer Fehlermeldungen */
struct err_out{
char *text;
int flags;
};
/* Flags fuer err_out.flags */
#define ERROR 1
#define WARNING 2
#define ANSIV 4
#define INTERNAL 8
#define FATAL 16
#define MESSAGE 32
#define DONTWARN 64
#define PREPROC 128
#define NOLINE 256
#define INFUNC 512
#define INIC 1024
#define NORAUS 2048
extern struct err_out err_out[];
extern int err_num;
struct misra_err_out{
int chapter;
int rule;
char *text;
int flags;
};
extern struct misra_err_out misra_err_out[];
#define MISRA 1
#define MISRA_PREPROC 2
#define MISRA_2004 4
#define MISRA_1998 8
#ifdef HAVE_ECPP
struct ecpp_dtor_list {
struct Var *var;
struct ecpp_dtor_list *next;
};
extern struct struct_declaration *current_class;
extern struct Typ *current_func;
extern struct ecpp_dtor_list *ecpp_dlist[MAXN];
struct Var *ecpp_find_ext_var(char *identifier);
struct Var *ecpp_find_var(char *identifier);
struct struct_declaration *ecpp_find_scope(char* nested_name,char** identifier);
struct struct_list *ecpp_find_member(char* identifier,struct struct_declaration *scope,struct struct_declaration** ret_scope,int search_flag);
void ecpp_auto_call_dtors();
int ecpp_is_friend(struct struct_declaration *class);
#endif
extern int afterlabel;
extern int errors;
extern int float_used;
extern char *cur_func;
extern int line;
extern void free_clist(struct const_list *);
extern struct const_list *first_clist,*last_clist;
extern struct Var *regsbuf[MAXR+1];
extern int regbnesting[MAXR+1];