GCC Middle and Back End API Reference
|
Data Structures | |
struct | state_ident_st |
struct | state_token_st |
class | s_expr_writer |
class | state_writer |
Enumerations | |
enum | state_token_en { STOK_NONE, STOK_INTEGER, STOK_STRING, STOK_LEFTPAR, STOK_RIGHTPAR, STOK_NAME } |
Variables | |
static htab_t | state_ident_tab |
struct state_token_st * | state_token = NULL_STATE_TOKEN |
static FILE * | state_file |
static const char * | state_path = NULL |
static int | state_line = 0 |
static long | state_bol = 0 |
static htab_t | state_seen_types |
enum state_token_en |
The state file has simplistic lispy lexical tokens. Its lexer gives a linked list of struct state_token_st, through the peek_state_token function. Lexical tokens are consumed with next_state_tokens.
The lexical kind of each lispy token.
|
static |
|
inlinestatic |
Fatal error messages when reading the state. They are extremely unlikely, and only appear when this gengtype-state.c file is buggy, or when reading a gengtype state which was not generated by the same version of gengtype or GCC.
Fatal message while reading state.
References memset(), state_ident_tab, state_ident_st::stid_name, and strlen().
Referenced by read_state_fileloc(), read_state_param_structs(), read_state_srcdir(), read_state_type(), and read_state_variables().
|
static |
Utility functions for the state_seen_types hash table.
|
static |
Consume the next DEPTH tokens and free them.
Referenced by read_state_common_type_content(), read_state_fileloc(), read_state_gc_used(), read_state_param_struct_type(), read_state_param_structs(), read_state_srcdir(), read_state_type(), and read_state_variables().
|
static |
Return the length of a linked list made of pairs.
|
static |
Compute the length of a list of pairs, starting from the first one.
|
staticread |
Used for lexical look-ahead. Retrieves the lexical token of rank DEPTH, starting with 0 when reading the state file. Gives null on end of file.
Referenced by read_state_fileloc(), read_state_param_structs(), read_state_srcdir(), and read_state_type().
|
staticread |
Our token lexer is heavily inspired by MELT's lexer, and share some code with the file gcc/melt-runtime.c of the GCC MELT branch! We really want the gengtype state to be easily parsable by MELT. This is a usual lispy lexing routine, dealing with spaces and comments, numbers, parenthesis, names, strings.
Handle spaces, count lines.
Skip comments starting with semi-colon.
Read signed numbers.
Read an opening left parenthesis.
Read an closing right parenthesis.
Read identifiers, using an obstack.
Read a string, dealing with escape sequences a la C!
Got an unexpected character.
References state_file.
void read_state | ( | ) |
The function reading the state, called by main from gengtype.c.
|
static |
Read an already seen type.
|
static |
Read a GTY-ed array type.
Referenced by read_state_gc_used().
|
static |
|
static |
Utility function to read the common content of types.
We don't read the next field of the type.
References next_state_tokens().
|
static |
void read_state_fields | ( | ) |
Read the fields of a GTY-ed type.
|
static |
End of writing routines! The corresponding reading routines follow.
Forward declarations, since some read_state_* functions are recursive!
void read_state_fileloc | ( | ) |
Read a file location. Files within the source directory are dealt with specifically.
References nested_ptr_data::convert_from, nested_ptr_data::convert_to, fatal_reading_state(), options::info, options::kind, options::nested, next_state_tokens(), OPTION_NESTED, peek_state_token(), read_state_type(), state_token_is_name(), state_token_kind(), STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, and nested_ptr_data::type.
|
static |
Read the sequence of files.
Allocate & fill a gt_file entry with space for the lang_bitmap before!
|
static |
Read the gc used information.
References next_state_tokens(), and read_state_array_type().
|
static |
Read a lang_bitmap representing a set of GCC front-end languages.
|
static |
Read a lang_struct type for GTY-ed struct-s which depends upon GCC front-end languages. This is a tricky function and it was painful to debug. Change it with extreme care. See also write_state_lang_struct_type.
Within lang_struct-ures, the lang_struct field is a linked list of homonymous types!
Parse (!homotypes <number-types> <type-1> .... <type-n>)
|
static |
Read the sequence of GCC front-end languages.
References type::state_number.
|
static |
Read a nested option.
|
static |
Read an GTY option.
Referenced by read_state_type_option().
|
static |
void read_state_options | ( | ) |
Read a list of options.
|
static |
void read_state_pair | ( | ) |
Read a pair.
|
static |
Return the number of pairs actually read.
int read_state_pair_list | ( | ) |
Return the number of pairs actually read.
don't consume the ); the caller will eat it.
|
static |
Read a param_struct type for GTY parametrized structures.
References next_state_tokens(), and read_state_struct_type().
|
static |
Read the param_struct-s.
References fatal_reading_state(), lang_dir_names, next_state_tokens(), peek_state_token(), state_token_kind(), state_ident_st::stid_name, state_token_st::stok_ident, STOK_NAME, and state_token_st::stok_un.
|
static |
Read a GTY-ed pointer type.
|
static |
Read the scalar_char type.
|
static |
Read the scalar_nonchar type.
|
static |
Read the source directory.
References fatal_reading_state(), next_state_tokens(), peek_state_token(), state_token_is_name(), state_token_kind(), STOK_LEFTPAR, and STOK_RIGHTPAR.
|
static |
Read a string option.
|
static |
Read the string_type.
References type::kind, and TYPE_USER_STRUCT.
|
static |
Read a GTY-ed struct type.
Referenced by read_state_param_struct_type().
|
static |
Read the structures.
|
static |
Read the trailer.
|
static |
Referenced by read_state_fileloc().
void read_state_type | ( | ) |
Read a GTY-ed type.
References fatal_reading_state(), fileloc::file, free(), input_file_by_name(), fileloc::line, next_state_tokens(), path, peek_state_token(), srcdir, state_token_is_name(), state_token_kind(), STOK_INTEGER, state_token_st::stok_num, STOK_RIGHTPAR, STOK_STRING, state_token_st::stok_string, and state_token_st::stok_un.
|
static |
Read a type option.
References options::next, and read_state_option().
|
static |
Read the typedefs.
|
static |
Read an undefined type.
|
static |
Read a GTY-ed union type.
|
static |
Read a GTY-ed user-provided struct TYPE.
|
static |
Read the variables.
References fatal_reading_state(), free(), gt_files, input_file_by_name(), next_state_tokens(), set_lang_bitmap(), srcdir, state_token_st::stok_string, and state_token_st::stok_un.
|
static |
Read a version, and check against the version of the gengtype.
Check that the read version string is the same as current version.
|
static |
Record into the state_seen_types hash-table a type which we are reading, to enable recursive or circular references to it.
References type::s, type::state_number, and type::u.
|
staticread |
Find or allocate an identifier in our name hash table.
References state_bol, state_file, and state_line.
|
inlinestatic |
Test if a token is a given name i.e. an identifier.
References pair::next.
Referenced by read_state_fileloc(), read_state_srcdir(), and read_state_type().
|
inlinestatic |
Safely retrieve the lexical kind of a token.
Referenced by read_state_fileloc(), read_state_param_structs(), read_state_srcdir(), and read_state_type().
|
static |
|
staticread |
@verbatim
Gengtype persistent state serialization & de-serialization. Useful for gengtype in plugin mode.
Copyright (C) 2010-2013 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.
Contributed by Jeremie Salvucci jerem and Basile Starynkevitch ie.s alvuc ci@f ree.f rbasil e@st arynk evit ch.ne t
Gives the file location of a type, if any.
References type::param_struct, type::s, TYPE_ARRAY, TYPE_LANG_STRUCT, TYPE_NONE, TYPE_PARAM_STRUCT, TYPE_POINTER, TYPE_SCALAR, TYPE_STRING, TYPE_STRUCT, TYPE_UNDEFINED, TYPE_UNION, TYPE_USER_STRUCT, and type::u.
void write_state | ( | ) |
The write_state routine is the only writing routine called by main in gengtype.c. To avoid messing the state if gengtype is interrupted or aborted, we write a temporary file and rename it after having written it in totality.
We write a unique temporary file which is renamed when complete * only. So even if gengtype is interrupted, the written state file * won't be partially written, since the temporary file is not yet * renamed in that case.
This is the first line of the state. Perhaps the file utility could know about that, so don't change it often.
Output a few comments for humans.
The first non-comment significant line gives the version string.
References type().
|
static |
Write the trailer.
This test should probably catch IO errors like disk full...
|
static |
Referenced by state_ident_by_name().
|
static |
Used by the reading lexer.
Referenced by read_a_state_token(), state_ident_by_name(), state_writer::write_state_array_type(), state_writer::write_state_fileloc(), state_writer::write_state_param_structs(), state_writer::write_state_scalar_type(), state_writer::write_state_type(), state_writer::write_state_union_type(), state_writer::write_state_variables(), and state_writer::write_state_version().
|
static |
Referenced by fatal_reading_state().
|
static |
Referenced by state_ident_by_name().
|
static |
|
static |
Following routines are useful for serializing datas. * * We want to serialize : * - typedefs list * - structures list * - param_structs list * - variables list * * So, we have one routine for each kind of data. The main writing * routine is write_state. The main reading routine is * read_state. Most writing routines write_state_FOO have a * corresponding reading routine read_state_FOO. Reading is done in a * recursive descending way, and any read error is fatal.
When reading the state, we need to remember the previously seen types by their state_number, since GTY-ed types are usually shared.
struct state_token_st* state_token = NULL_STATE_TOKEN |
the state_token pointer contains the leftmost current token. The tokens are organized in a linked queue, using stok_next, for token look-ahead.