]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gengtype.h
fix changelog error
[thirdparty/gcc.git] / gcc / gengtype.h
CommitLineData
e2500fed 1/* Process source files and output type information.
f8ed6dc5
JS
2 Copyright (C) 2002, 2003, 2004, 2007, 2008, 2010
3 Free Software Foundation, Inc.
e2500fed 4
e1b793e7 5 This file is part of GCC.
e2500fed 6
e1b793e7
BS
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
e2500fed 11
e1b793e7
BS
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
e2500fed 16
e1b793e7
BS
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
e2500fed 20
065ae611
ZW
21#ifndef GCC_GENGTYPE_H
22#define GCC_GENGTYPE_H
23
f8ed6dc5
JS
24/* Sets of accepted source languages like C, C++, Ada... are
25 represented by a bitmap. */
26typedef unsigned lang_bitmap;
27
b8698a0f 28/* A file position, mostly for error messages.
e2500fed 29 The FILE element may be compared using pointer equality. */
e1b793e7
BS
30struct fileloc
31{
e2500fed
GK
32 const char *file;
33 int line;
34};
35
065ae611 36/* Data types handed around within, but opaque to, the lexer and parser. */
b453c95f
GK
37typedef struct pair *pair_p;
38typedef struct type *type_p;
e5cfc29f 39typedef const struct type *const_type_p;
065ae611 40typedef struct options *options_p;
e2500fed 41
e2500fed
GK
42/* Variables used to communicate between the lexer and the parser. */
43extern int lexer_toplevel_done;
44extern struct fileloc lexer_line;
45
f8ed6dc5
JS
46/* Structure representing an output file. */
47struct outf
48{
49 struct outf *next;
50 const char *name;
51 size_t buflength;
52 size_t bufused;
53 char *buf;
54};
55typedef struct outf *outf_p;
56
57/* The list of output files. */
58extern outf_p output_files;
59
60/* The output header file that is included into pretty much every
61 source file. */
62extern outf_p header_file;
63
64/* Print, like fprintf, to O. No-op if O is NULL. */
65void
66oprintf (outf_p o, const char *S, ...)
67 ATTRIBUTE_PRINTF_2;
68
69/* An output file, suitable for definitions, that can see declarations
70 made in INPUT_FILE and is linked into every language that uses
71 INPUT_FILE. May return NULL in plugin mode. */
72extern outf_p get_output_file_with_visibility (const char *input_file);
73
74/* Source directory. */
75extern const char *srcdir; /* (-S) program argument. */
76
77/* Length of srcdir name. */
78extern size_t srcdir_len;
79
80/* Variable used for reading and writing the state. */
81extern const char *read_state_filename; /* (-r) program argument. */
82extern const char *write_state_filename; /* (-w) program argument. */
83
e2500fed 84/* Print an error message. */
b8698a0f 85extern void error_at_line
e1b793e7 86(const struct fileloc *pos, const char *msg, ...) ATTRIBUTE_PRINTF_2;
e2500fed 87
01d419ae 88/* Like asprintf, but calls fatal() on out of memory. */
f8ed6dc5 89extern char *xasprintf (const char *, ...) ATTRIBUTE_PRINTF_1;
01d419ae 90
e2500fed 91/* Constructor routines for types. */
3d7aafde 92extern void do_typedef (const char *s, type_p t, struct fileloc *pos);
95161faf 93extern void do_scalar_typedef (const char *s, struct fileloc *pos);
3d7aafde 94extern type_p resolve_typedef (const char *s, struct fileloc *pos);
0f01f026
RS
95extern type_p new_structure (const char *name, int isunion,
96 struct fileloc *pos, pair_p fields,
97 options_p o);
3d7aafde 98extern type_p find_structure (const char *s, int isunion);
95161faf 99extern type_p create_scalar_type (const char *name);
3d7aafde
AJ
100extern type_p create_pointer (type_p t);
101extern type_p create_array (type_p t, const char *len);
e1b793e7
BS
102extern options_p create_option (options_p, const char *name,
103 const void *info);
065ae611 104extern options_p create_nested_ptr_option (options_p, type_p t,
e1b793e7
BS
105 const char *from,
106 const char *to);
107extern pair_p create_field_at (pair_p next, type_p type,
108 const char *name, options_p opt,
109 struct fileloc *pos);
01d419ae 110extern pair_p nreverse_pairs (pair_p list);
3d7aafde
AJ
111extern type_p adjust_field_type (type_p, options_p);
112extern void note_variable (const char *s, type_p t, options_p o,
113 struct fileloc *pos);
8ad97cfc 114extern void note_def_vec (const char *type_name, bool is_scalar,
4a399aef
ZW
115 struct fileloc *pos);
116extern void note_def_vec_alloc (const char *type, const char *astrat,
117 struct fileloc *pos);
e2500fed 118
01d419ae
ZW
119/* Lexer and parser routines. */
120extern int yylex (const char **yylval);
121extern void yybegin (const char *fname);
122extern void yyend (void);
3d7aafde 123extern void parse_file (const char *name);
01d419ae
ZW
124extern bool hit_error;
125
126/* Token codes. */
e1b793e7
BS
127enum
128 {
129 EOF_TOKEN = 0,
130
131 /* Per standard convention, codes in the range (0, UCHAR_MAX]
132 represent single characters with those character codes. */
133
134 CHAR_TOKEN_OFFSET = UCHAR_MAX + 1,
135 GTY_TOKEN = CHAR_TOKEN_OFFSET,
136 TYPEDEF,
137 EXTERN,
138 STATIC,
139 UNION,
140 STRUCT,
141 ENUM,
142 VEC_TOKEN,
143 DEFVEC_OP,
144 DEFVEC_I,
145 DEFVEC_ALLOC,
146 ELLIPSIS,
147 PTR_ALIAS,
148 NESTED_PTR,
149 PARAM_IS,
150 NUM,
151 SCALAR,
152 ID,
153 STRING,
154 CHAR,
155 ARRAY,
156
157 /* print_token assumes that any token >= FIRST_TOKEN_WITH_VALUE may have
158 a meaningful value to be printed. */
159 FIRST_TOKEN_WITH_VALUE = PARAM_IS
160 };
f8ed6dc5
JS
161
162
1d32bbcd
BS
163/* Level for verbose messages, e.g. output file generation... */
164extern int verbosity_level; /* (-v) program argument. */
165
f8ed6dc5
JS
166/* For debugging purposes we provide two flags. */
167
168/* Dump everything to understand gengtype's state. Might be useful to
169 gengtype users. */
170extern int do_dump; /* (-d) program argument. */
171
172/* Trace the execution by many DBGPRINTF (with the position inside
173 gengtype source code). Only useful to debug gengtype itself. */
174extern int do_debug; /* (-D) program argument. */
175
176#if ENABLE_CHECKING
177#define DBGPRINTF(Fmt,...) do {if (do_debug) \
178 fprintf (stderr, "%s:%d: " Fmt "\n", \
179 lbasename (__FILE__),__LINE__, ##__VA_ARGS__);} while (0)
180void dbgprint_count_type_at (const char *, int, const char *, type_p);
181#define DBGPRINT_COUNT_TYPE(Msg,Ty) do {if (do_debug) \
182 dbgprint_count_type_at (__FILE__, __LINE__, Msg, Ty);}while (0)
183#else
184#define DBGPRINTF(Fmt,...) do {/*nodbgrintf*/} while (0)
185#define DBGPRINT_COUNT_TYPE(Msg,Ty) do{/*nodbgprint_count_type*/}while (0)
186#endif /*ENABLE_CHECKING */
187
065ae611 188#endif