blob: 6d170ac8f2f4d7c7bc5c28ed9821d3ab70a2527b [file] [log] [blame]
PulkoMandy17fc7592022-07-28 18:27:54 +02001/* $VER: vbcc (vbc.h) $Revision: 1.23 $ */
2
3#include "supp.h"
4
5#define eval_constn(a) eval_const(&a->val,a->ntyp->flags)
6
7typedef struct identifier_list{
8 char *identifier;
9 int length;
10 struct identifier_list *next;
11} identifier_list;
12typedef struct struct_identifier{
13/* int flags;*/
14 char *identifier;
15 struct struct_declaration *sd;
16 struct struct_identifier *next;
17} struct_identifier;
18
19#ifndef NODES
20#error wrong node
21typedef struct node{
22 int flags,lvalue,sidefx;
23 type *ntyp;
24 struct node *left;
25 struct node *right;
26 struct argument_list *alist;
27 char *identifier;
28 union atyps val;
29 struct obj o;
30} node;
31
32typedef node *np;
33
34#define NODES sizeof(node)
35#endif
36
37typedef struct argument_list{
38 np arg;
39 struct argument_list *next;
40 struct IC *pushic;
41} argument_list;
42
43
44#define MAXI 512 /* maximale Laenge von Identifiers in Bytes */
45#define MAXN 128 /* maximale Verschachtelung von Bloecken */
46
47extern struct tunit *first_tunit,*last_tunit;
48extern type *arith_typ(type*,type *);
49extern void insert_constn(np);
50extern int int_erw(int);
51extern type *andcomp(np,np);
52extern void simple_alg_opt(np);
53extern int type_expression(np,type *),
54 compatible_types(type *,type *,int),
55 compare_sd(struct struct_declaration *,struct struct_declaration *);
56#if HAVE_AOS4
57extern int aos4_attr(type *,char *);
58#endif
59extern np identifier_expression(void),constant_expression(void),string_expression(void),
60 postfix_expression(void),unary_expression(void),cast_expression(void),
61 multiplicative_expression(void),additive_expression(void),
62 shift_expression(void),relational_expression(void),equality_expression(void),
63 and_expression(void),exclusive_or_expression(void),
64 inclusive_or_expression(void),logical_and_expression(void),
65 logical_or_expression(void),conditional_expression(void),
66 assignment_expression(void),expression(void),primary_expression(void);
67extern struct argument_list *argument_list_expression(void);
68extern struct const_list *cl_from_string(char *start, char *end);
69
70extern np new_node(void);
71
72/* puh */
73extern int is_keyword(char *);
74extern void pre(FILE *,np),pra(FILE *,struct argument_list *);
75extern void free_expression(np),free_alist(struct argument_list *);
76extern void cpbez(char *m,int ckw),cpnum(char *m),killsp(void);
77extern void copy_token(/*no prototype because cpp.h not always included*/);
78extern void push_token(/*no prototype because cpp.h not always included*/);
79extern void next_token(void);
80extern struct struct_declaration *add_sd(struct struct_declaration *,int);
81extern void add_sl(struct struct_declaration *,struct struct_list (*)[]);
82extern void free_sd(struct struct_declaration *);
83extern void prl(FILE *,struct struct_declaration *);
84extern char *add_identifier(char *,int);
85extern type *declarator(type *),*direct_declarator(type *),
86 *pointer(type *),*declaration_specifiers(void);
87extern int declaration(int),type_uncomplete(type *);
88extern struct const_list *initialization(type *,int,int,int,struct struct_declaration *,struct const_list *);
89extern void init_local_compound(struct Var *);
90extern zmax init_dyn_sz,init_const_sz;
91extern int init_dyn_cnt,init_const_cnt;
92extern struct struct_declaration *find_struct(char *,int);
93extern void add_struct_identifier(char *,struct struct_declaration *);
94extern void free_si(struct struct_identifier *);
95extern char *ident;
96extern char number[MAXI],buff[MAXI];
97extern struct struct_declaration *first_sd[MAXN],*last_sd[MAXN],*merk_sdf,*merk_sdl;
98extern struct struct_identifier *first_si[MAXN],*last_si[MAXN],*merk_sif,*merk_sil;
99extern struct identifier_list *first_ilist[MAXN],*last_ilist[MAXN],*merk_ilistf,*merk_ilistl;
100extern void free_ilist(struct identifier_list *);
101extern int nesting;
102extern hashtable *hash_ext;
103extern struct Var *first_var[MAXN],*last_var[MAXN],*merk_varf,*merk_varl,*first_ext,*last_ext;
104extern struct Var *block_vla[MAXN];
105extern struct llist *vladeflabels[MAXN],*vlajmplabels[MAXN];
106extern struct vlaadjust_list *vlaadjusts[MAXN];
107extern void freevl(void);
108extern void clearvl(void);
109extern void free_var(struct Var *);
110extern void var_declaration(void);
111extern int storage_class_specifiers(void);
112extern void enter_block(void),leave_block(void);
113extern struct Var *find_var(char *,int);
114extern struct Var *find_ext_var(char *);
115extern struct Var *add_var(char *,type *,int,struct const_list *);
116extern void fi_from_attr(struct Var *);
117extern void needs(char *s);
118
119
120extern int usz;
121
122extern int c99;
123extern int opencl;
124extern int merge_strings;
125extern int mask_opt;
126extern int disallow_statics;
127extern int header_cnt;
128extern int softfloat;
129#define MAGIC_WPO 123
130extern int wpo,wpo_key;
131extern FILE *input_wpo;
132
133extern void gen_IC(np,int,int),convert(np,int),gen_label(int);
134extern void gen_test(struct obj *,int,int,int);
135extern void savescratch(int,struct IC *,int,struct obj *);
136typedef struct regargs_list{
137 struct regargs_list *next;
138 struct argument_list *al;
139 int reg;
140 struct Var *v;
141 int rsaved;
142} regargs_list;
143#ifdef HAVE_REGPARMS
144extern zmax push_args(struct argument_list *,struct struct_declaration *,int,struct regargs_list **,struct reg_handle *,struct obj *,type *,int,type *);
145#else
146extern zmax push_args(struct argument_list *,struct struct_declaration *,int,struct regargs_list **);
147#endif
148extern int allocreg(int,int);
149extern void free_reg(int),alloc_hardreg(int);
150
151extern FILE *out,*ic1,*ic2,*ppout,*cmdfile;
152
153extern void statement(void),labeled_statement(void),if_statement(void);
154extern void switch_statement(void),while_statement(void),for_statement(void);
155extern void do_statement(void),goto_statement(void),continue_statement(void);
156extern void break_statement(void),return_statement(void);
157extern void expression_statement(void),compound_statement(void);
158extern void translation_unit(void);
159extern int main(int, char *[]);
160extern int nocode,dontdelete,registerpri,looppri,currentpri;
161extern int no_cast_free;
162
163extern np makepointer(np);
164
165typedef struct vlaadjust_list {
166 struct IC *branch,*first;
167 struct vlaadjust_list *next;
168} vlaadjust_list;
169
170extern int switch_typ,switch_count,switch_act;
171typedef struct llist{
172 char *identifier;
173 int label,flags,switch_count;
174 struct llist *next;
175 union atyps val;
176} llist;
177#define LABELDEFINED 1
178#define LABELUSED 2
179#define LABELDEFAULT 4
180#define LSIZE sizeof(struct llist)
181extern struct llist *first_llist,*last_llist;
182extern struct llist *find_label(char *),*add_label(char *);
183extern void free_llist(struct llist *);
184
185extern int endok,return_label,return_value,break_label;
186extern int const_expr,for_decl;
187extern struct Var *return_var;
188extern type *return_typ;
189extern zmax local_offset[MAXN];
190
191extern void scratch_var(struct obj *,int,type *);
192extern void get_scratch(struct obj *,int,int,type *);
193extern void gen_cond(struct obj *,int,int,int);
194
195#define MAXCF 70
196extern int c_flags[MAXCF];
197extern char *c_flags_name[MAXCF];
198extern union ppi c_flags_val[MAXCF];
199
200extern FILE *open_out(char *,char *);
201
202extern char *inname;
203
204extern void gen_vars(struct Var *);
205
206/* Format der Tabelle fuer Fehlermeldungen */
207typedef struct err_out{
208 char *text;
209 int flags;
210} terr_out;
211
212
213/* Flags fuer err_out.flags */
214#define ERROR 1
215#define WARNING 2
216#define ANSIV 4
217#define INTERNAL 8
218#define FATAL 16
219#define MESSAGE 32
220#define DONTWARN 64
221#define PREPROC 128
222#define NOLINE 256
223#define INFUNC 512
224#define INIC 1024
225#define NORAUS 2048
226
227extern struct err_out err_out[];
228extern int err_num;
229
230typedef struct misra_err_out{
231 int chapter;
232 int rule;
233 char *text;
234 int flags;
235} tmisra_err_out;
236
237extern struct misra_err_out misra_err_out[];
238
239#define MISRA 1
240#define MISRA_PREPROC 2
241#define MISRA_2004 4
242#define MISRA_1998 8
243
244#ifdef HAVE_ECPP
245typedef struct ecpp_dtor_list {
246 struct Var *var;
247 struct ecpp_dtor_list *next;
248} ecpp_dtor_list;
249extern struct struct_declaration *current_class;
250extern type *current_func;
251extern struct ecpp_dtor_list *ecpp_dlist[MAXN];
252struct Var *ecpp_find_ext_var(char *identifier);
253struct Var *ecpp_find_var(char *identifier);
254struct struct_declaration *ecpp_find_scope(char* nested_name,char** identifier);
255struct struct_list *ecpp_find_member(char* identifier,struct struct_declaration *scope,struct struct_declaration** ret_scope,int search_flag);
256void ecpp_auto_call_dtors();
257int ecpp_is_friend(struct struct_declaration *class);
258#endif
259
260extern int afterlabel;
261
262extern int errors;
263
264extern int float_used;
265extern char *cur_func;
266extern Var *cur_funcv;
267extern int line;
268extern void free_clist(struct const_list *);
269extern struct const_list *first_clist,*last_clist;
270extern struct Var *regsbuf[MAXR+1];
271extern int regbnesting[MAXR+1];
272
273