1 /* Process source files and output type information.
2 Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 /* A file position, mostly for error messages.
21 The FILE element may be compared using pointer equality. */
27 /* Kinds of types we can understand. */
39 typedef struct pair
*pair_p
;
40 typedef struct type
*type_p
;
41 typedef unsigned lang_bitmap
;
43 /* Option data for the 'nested_ptr' option. */
44 struct nested_ptr_data
{
46 const char *convert_to
;
47 const char *convert_from
;
50 /* A way to pass data through to the output end. */
51 typedef struct options
{
57 /* A name and a type. */
68 /* A description of a type. */
81 enum gc_used_enum gc_used
;
99 type_p param
[NUM_PARAM
];
106 ((x)->kind == TYPE_UNION || \
107 ((x)->kind == TYPE_LANG_STRUCT \
108 && (x)->u.s.lang_struct->kind == TYPE_UNION))
109 #define UNION_OR_STRUCT_P(x) \
110 ((x)->kind == TYPE_UNION \
111 || (x)->kind == TYPE_STRUCT \
112 || (x)->kind == TYPE_LANG_STRUCT)
114 /* The one and only TYPE_STRING. */
115 extern struct type string_type
;
117 /* Variables used to communicate between the lexer and the parser. */
118 extern int lexer_toplevel_done
;
119 extern struct fileloc lexer_line
;
121 /* Print an error message. */
122 extern void error_at_line
123 (struct fileloc
*pos
, const char *msg
, ...) ATTRIBUTE_PRINTF_2
;
125 /* Combines xmalloc() and vasprintf(). */
126 extern int xvasprintf (char **, const char *, va_list)
127 ATTRIBUTE_PRINTF (2, 0);
128 /* Like the above, but more convenient for quick coding. */
129 extern char * xasprintf (const char *, ...)
132 /* Constructor routines for types. */
133 extern void do_typedef (const char *s
, type_p t
, struct fileloc
*pos
);
134 extern type_p
resolve_typedef (const char *s
, struct fileloc
*pos
);
135 extern type_p
new_structure (const char *name
, int isunion
,
136 struct fileloc
*pos
, pair_p fields
,
138 extern type_p
find_structure (const char *s
, int isunion
);
139 extern type_p
create_scalar_type (const char *name
, size_t name_len
);
140 extern type_p
create_pointer (type_p t
);
141 extern type_p
create_array (type_p t
, const char *len
);
142 extern options_p
create_option (options_p
, const char *name
, const void *info
);
143 extern type_p
adjust_field_type (type_p
, options_p
);
144 extern void note_variable (const char *s
, type_p t
, options_p o
,
145 struct fileloc
*pos
);
146 extern void note_yacc_type (options_p o
, pair_p fields
,
147 pair_p typeinfo
, struct fileloc
*pos
);
149 /* Lexer and parser routines, most automatically generated. */
150 extern int yylex (void);
151 extern void yyerror (const char *);
152 extern int yyparse (void);
153 extern void parse_file (const char *name
);
155 /* Output file handling. */
157 /* Structure representing an output file. */
167 typedef struct outf
* outf_p
;
169 /* An output file, suitable for definitions, that can see declarations
170 made in INPUT_FILE and is linked into every language that uses
172 extern outf_p get_output_file_with_visibility
173 (const char *input_file
);
174 const char *get_output_file_name (const char *);
176 /* A list of output files suitable for definitions. There is one
177 BASE_FILES entry for each language. */
178 extern outf_p base_files
[];
180 /* A bitmap that specifies which of BASE_FILES should be used to
181 output a definition that is different for each language and must be
182 defined once in each language that uses INPUT_FILE. */
183 extern lang_bitmap
get_base_file_bitmap (const char *input_file
);
185 /* Print, like fprintf, to O. */
186 extern void oprintf (outf_p o
, const char *S
, ...)