[jit] Fix the saving of the 'cfg->ret_var_set' flag when inlining, it was set to...
[mono.git] / mcs / jay / defs.h
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Robert Paul Corbett.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by the University of
19  *      California, Berkeley and its contributors.
20  * 4. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  *      @(#)defs.h      5.6 (Berkeley) 5/24/93
37  */
38
39 #include <assert.h>
40 #include <ctype.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include <errno.h>
45
46 /* Quiet warnings which might bother rpm */
47 #ifdef __GNUC__
48 #pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
49 #pragma GCC diagnostic ignored "-Wreturn-type"
50 #endif
51
52 /*  machine-dependent definitions                       */
53 /*  the following definitions are for the Tahoe         */
54 /*  they might have to be changed for other machines    */
55
56 /*  MAXCHAR is the largest unsigned character value     */
57 /*  MAXSHORT is the largest value of a C short          */
58 /*  MINSHORT is the most negative value of a C short    */
59 /*  MAXTABLE is the maximum table size                  */
60 /*  BITS_PER_WORD is the number of bits in a C unsigned */
61 /*  WORDSIZE computes the number of words needed to     */
62 /*      store n bits                                    */
63 /*  BIT returns the value of the n-th bit starting      */
64 /*      from r (0-indexed)                              */
65 /*  SETBIT sets the n-th bit starting from r            */
66
67 #define MAXCHAR         255
68 #define MAXSHORT        32767
69 #define MINSHORT        -32768
70 #define MAXTABLE        32500
71 #define BITS_PER_WORD   32
72 #define WORDSIZE(n)     (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD)
73 #define BIT(r, n)       ((((r)[(n)>>5])>>((n)&31))&1)
74 #define SETBIT(r, n)    ((r)[(n)>>5]|=((unsigned)1<<((n)&31)))
75
76
77 /*  character names  */
78
79 #define NUL             '\0'    /*  the null character  */
80 #define NEWLINE         '\n'    /*  line feed  */
81 #define SP              ' '     /*  space  */
82 #define BS              '\b'    /*  backspace  */
83 #define HT              '\t'    /*  horizontal tab  */
84 #define VT              '\013'  /*  vertical tab  */
85 #define CR              '\r'    /*  carriage return  */
86 #define FF              '\f'    /*  form feed  */
87 #define QUOTE           '\''    /*  single quote  */
88 #define DOUBLE_QUOTE    '\"'    /*  double quote  */
89 #define BACKSLASH       '\\'    /*  backslash  */
90
91
92 /* defines for constructing filenames */
93
94 #define CODE_SUFFIX     ".code.c"
95 #define DEFINES_SUFFIX  ".tab.h"
96 #define OUTPUT_SUFFIX   ".tab.c"
97 #define VERBOSE_SUFFIX  ".output"
98
99
100 /* keyword codes */
101
102 #define TOKEN 0
103 #define LEFT 1
104 #define RIGHT 2
105 #define NONASSOC 3
106 #define MARK 4
107 #define TEXT 5
108 #define TYPE 6
109 #define START 7
110
111
112 /*  symbol classes  */
113
114 #define UNKNOWN 0
115 #define TERM 1
116 #define NONTERM 2
117
118
119 /*  the undefined value  */
120
121 #define UNDEFINED (-1)
122
123
124 /*  action codes  */
125
126 #define SHIFT 1
127 #define REDUCE 2
128
129
130 /*  character macros  */
131
132 #define IS_IDENT(c)     (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$')
133 #define IS_OCTAL(c)     ((c) >= '0' && (c) <= '7')
134 #define NUMERIC_VALUE(c)        ((c) - '0')
135
136
137 /*  symbol macros  */
138
139 #define ISTOKEN(s)      ((s) < start_symbol)
140 #define ISVAR(s)        ((s) >= start_symbol)
141
142
143 /*  storage allocation macros  */
144
145 #define CALLOC(k,n)     (calloc((unsigned)(k),(unsigned)(n)))
146 #define FREE(x)         (free((char*)(x)))
147 #define MALLOC(n)       (malloc((unsigned)(n)))
148 #define NEW(t)          ((t*)allocate(sizeof(t)))
149 #define NEW2(n,t)       ((t*)allocate((unsigned)((n)*sizeof(t))))
150 #define REALLOC(p,n)    (realloc((char*)(p),(unsigned)(n)))
151
152
153 /*  the structure of a symbol table entry  */
154
155 typedef struct bucket bucket;
156 struct bucket
157 {
158     struct bucket *link;
159     struct bucket *next;
160     char *name;
161     char *tag;
162     short value;
163     short index;
164     short prec;
165     char class;
166     char assoc;
167 };
168
169
170 /*  the structure of the LR(0) state machine  */
171
172 typedef struct core core;
173 struct core
174 {
175     struct core *next;
176     struct core *link;
177     short number;
178     short accessing_symbol;
179     short nitems;
180     short items[1];
181 };
182
183
184 /*  the structure used to record shifts  */
185
186 typedef struct shifts shifts;
187 struct shifts
188 {
189     struct shifts *next;
190     short number;
191     short nshifts;
192     short shift[1];
193 };
194
195
196 /*  the structure used to store reductions  */
197
198 typedef struct reductions reductions;
199 struct reductions
200 {
201     struct reductions *next;
202     short number;
203     short nreds;
204     short rules[1];
205 };
206
207
208 /*  the structure used to represent parser actions  */
209
210 typedef struct action action;
211 struct action
212 {
213     struct action *next;
214     short symbol;
215     short number;
216     short prec;
217     char action_code;
218     char assoc;
219     char suppressed;
220 };
221
222
223 /* global variables */
224
225 extern char tflag;
226 extern char vflag;
227
228 extern char *myname;
229 extern char *cptr;
230 extern char *line;
231 extern int lineno;
232 extern int outline;
233
234 extern char *action_file_name;
235 extern char *input_file_name;
236 extern char *prolog_file_name;
237 extern char *local_file_name;
238 extern char *verbose_file_name;
239
240 extern FILE *action_file;
241 extern FILE *input_file;
242 extern FILE *prolog_file;
243 extern FILE *local_file;
244 extern FILE *verbose_file;
245
246 extern int nitems;
247 extern int nrules;
248 extern int nsyms;
249 extern int ntokens;
250 extern int nvars;
251 extern int ntags;
252 extern int nmethods;
253
254 extern char *line_format;
255 extern char *default_line_format;
256
257 extern int   start_symbol;
258 extern char  **symbol_name;
259 extern short *symbol_value;
260 extern short *symbol_prec;
261 extern char  *symbol_assoc;
262 extern char  **methods;
263
264 extern short *ritem;
265 extern short *rlhs;
266 extern short *rrhs;
267 extern short *rprec;
268 extern char  *rassoc;
269
270 extern short **derives;
271 extern char *nullable;
272
273 extern bucket *first_symbol;
274 extern bucket *last_symbol;
275
276 extern int nstates;
277 extern core *first_state;
278 extern shifts *first_shift;
279 extern reductions *first_reduction;
280 extern short *accessing_symbol;
281 extern core **state_table;
282 extern shifts **shift_table;
283 extern reductions **reduction_table;
284 extern unsigned *LA;
285 extern short *LAruleno;
286 extern short *lookaheads;
287 extern short *goto_map;
288 extern short *from_state;
289 extern short *to_state;
290
291 extern action **parser;
292 extern int SRtotal;
293 extern int RRtotal;
294 extern short *SRconflicts;
295 extern short *RRconflicts;
296 extern short *defred;
297 extern short *rules_used;
298 extern short nunused;
299 extern short final_state;
300
301 /* global functions */
302
303 extern char *allocate();
304 extern bucket *lookup();
305 extern bucket *make_bucket();
306
307