GCC Middle and Back End API Reference
|
Public Member Functions | |
state_writer () | |
void | write_new_line () |
void | write_any_indent (int leading_spaces) |
void | begin_s_expr (const char *tag) |
void | end_s_expr () |
Private Attributes | |
int | m_state_written_type_count |
int | m_indent_amount |
int | m_had_recent_newline |
Friends | |
void | write_state (const char *state_path) |
A class for writing out "gtype.state".
state_writer::state_writer | ( | ) |
class state_writer's trivial constructor.
|
inherited |
Write the beginning of a new s-expresion e.g. "(!foo " The writer automatically adds whitespace to show the hierarchical structure of the expressions, so each one starts on a new line, and any within it will be at an increased indentation level.
References s_expr_writer::m_indent_amount, state_file, s_expr_writer::write_any_indent(), and s_expr_writer::write_new_line().
Referenced by write_state_fields(), write_state_fileloc(), write_state_files_list(), write_state_lang_struct_type(), write_state_languages(), write_state_option(), write_state_options(), write_state_pair(), write_state_srcdir(), write_state_structures(), write_state_type(), write_state_typedefs(), write_state_variables(), and write_state_version().
|
inherited |
Write out the end of an s-expression: any necssessary indentation, a closing parenthesis, and a new line.
References s_expr_writer::m_indent_amount, state_file, s_expr_writer::write_any_indent(), and s_expr_writer::write_new_line().
Referenced by write_state_fields(), write_state_fileloc(), write_state_files_list(), write_state_lang_struct_type(), write_state_languages(), write_state_option(), write_state_options(), write_state_pair(), write_state_srcdir(), write_state_structures(), write_state_type(), write_state_typedefs(), write_state_variables(), and write_state_version().
|
inherited |
If we've just had a newline, write the indentation amount, potentially omitting some spaces. LEADING_SPACES exists to support code that writes strings with leading spaces (e.g " foo") which might occur within a line, or could be the first thing on a line. By passing leading_spaces == 1, when such a string is the first thing on a line, write_any_indent () swallows the successive leading spaces into the indentation so that the "foo" begins at the expected column.
References i, s_expr_writer::m_had_recent_newline, s_expr_writer::m_indent_amount, and state_file.
Referenced by s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), write_state_a_string(), write_state_array_type(), write_state_callback_type(), write_state_common_type_content(), write_state_gc_used(), write_state_lang_bitmap(), write_state_nested_option(), write_state_option(), write_state_options(), write_state_pair(), write_state_pointer_type(), write_state_scalar_type(), write_state_string_option(), write_state_string_type(), write_state_struct_union_type(), write_state_type(), write_state_type_option(), write_state_undefined_type(), and write_state_user_struct_type().
|
inherited |
Write a newline to the output file, merging adjacent newlines.
References s_expr_writer::m_had_recent_newline, and state_file.
Referenced by s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), and write_state_structures().
|
private |
Write a null-terminated string in our lexical convention, very similar to the convention of C.
References state_file, and s_expr_writer::write_any_indent().
Referenced by write_state_array_type(), write_state_fileloc(), write_state_files_list(), write_state_nested_option(), write_state_pair(), write_state_srcdir(), write_state_string_option(), write_state_struct_union_type(), write_state_undefined_type(), write_state_user_struct_type(), and write_state_version().
|
private |
Write an array type.
References type::a, type::len, NULL, type::p, state_file, type::u, s_expr_writer::write_any_indent(), write_state_a_string(), write_state_common_type_content(), and write_state_type().
Referenced by write_state_type().
|
private |
Write the callback type. There is only one such thing!
References callback_type, fatal(), state_file, s_expr_writer::write_any_indent(), and write_state_common_type_content().
Referenced by write_state_type().
|
private |
Utility routine to write the common content of all types. Notice that the next field is *not* written on purpose.
References type::gc_used, type::pointer_to, state_file, type::state_number, s_expr_writer::write_any_indent(), write_state_gc_used(), and write_state_type().
Referenced by write_state_array_type(), write_state_callback_type(), write_state_pointer_type(), write_state_scalar_type(), write_state_string_type(), write_state_struct_union_type(), write_state_undefined_type(), and write_state_user_struct_type().
|
private |
Write a list of fields.
References s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), fields, gcc_assert, pair_list_length(), state_file, and write_state_pair_list().
Referenced by write_state_struct_union_type(), and write_state_user_struct_type().
|
private |
Write a file location. Files relative to $(srcdir) are quite frequent and are handled specially. This ensures that two gengtype state file-s produced by gengtype on the same GCC source tree are very similar and can be reasonably compared with diff, even if the two GCC source trees have different absolute paths.
References s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), fileloc::file, gcc_assert, get_file_srcdir_relative_path(), get_input_file_name(), fileloc::line, NULL, state_file, and write_state_a_string().
Referenced by write_state_pair(), write_state_struct_union_type(), write_state_undefined_type(), and write_state_user_struct_type().
|
private |
Count and write the list of our files.
References s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), get_file_srcdir_relative_path(), get_input_file_name(), get_lang_bitmap(), gt_files, i, NULL, num_build_headers, num_gt_files, state_file, and write_state_a_string().
|
private |
Write the gc_used information.
References GC_MAYBE_POINTED_TO, GC_POINTED_TO, GC_UNUSED, GC_USED, gcc_unreachable, state_file, and s_expr_writer::write_any_indent().
Referenced by write_state_common_type_content().
|
private |
Write a bitmap representing a set of GCC front-end languages.
References state_file, and s_expr_writer::write_any_indent().
Referenced by write_state_struct_union_type().
|
private |
Write a lang_struct type. This is tricky and was painful to debug, we deal with the next field specifically within their lang_struct subfield, which points to a linked list of homonumous types. Change this function with extreme care, see also read_state_lang_struct_type.
References s_expr_writer::begin_s_expr(), DBGPRINTF, s_expr_writer::end_s_expr(), gcc_assert, type::lang_struct, type::next, NULL, type::s, state_file, type::state_number, type::u, union_or_struct_p(), write_state_struct_union_type(), and write_state_type().
Referenced by write_state_type().
|
private |
Write the list of GCC front-end languages.
References s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), i, lang_dir_names, num_lang_dirs, and state_file.
|
private |
|
private |
References s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), fatal(), options::kind, options::name, NULL, OPTION_NESTED, OPTION_STRING, OPTION_TYPE, state_file, s_expr_writer::write_any_indent(), write_state_nested_option(), write_state_string_option(), and write_state_type_option().
Referenced by write_state_options().
|
private |
Write a list of GTY options.
References s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), options::next, NULL, state_file, s_expr_writer::write_any_indent(), and write_state_option().
Referenced by write_state_pair(), and write_state_struct_union_type().
|
private |
Write a pair.
References s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), pair::line, pair::name, NULL, pair::opt, state_file, pair::type, s_expr_writer::write_any_indent(), write_state_a_string(), write_state_fileloc(), write_state_options(), and write_state_type().
Referenced by write_state_pair_list().
|
private |
Write a pair list and return the number of pairs written.
References pair::next, NULL, and write_state_pair().
Referenced by write_state_fields(), write_state_typedefs(), and write_state_variables().
|
private |
Write a pointer type.
References type::p, state_file, type::u, s_expr_writer::write_any_indent(), write_state_common_type_content(), and write_state_type().
Referenced by write_state_type().
|
private |
Write a scalar type. We have only two of these.
References fatal(), scalar_char, scalar_nonchar, state_file, s_expr_writer::write_any_indent(), and write_state_common_type_content().
Referenced by write_state_type().
|
private |
Write the source directory. File locations within the source directory have been written specifically.
References s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), srcdir, and write_state_a_string().
|
private |
Our option-s have three kinds, each with its writer.
References options::info, NULL, state_file, options::string, s_expr_writer::write_any_indent(), and write_state_a_string().
Referenced by write_state_option().
|
private |
Write the string type. There is only one such thing!
References fatal(), state_file, string_type, s_expr_writer::write_any_indent(), and write_state_common_type_content().
Referenced by write_state_type().
|
private |
Write a GTY struct type.
References type::base_class, type::lang_struct, type::s, type::u, write_state_struct_union_type(), and write_state_type().
Referenced by write_state_type().
|
private |
Common code to write structure like types.
References type::bitmap, DBGPRINTF, type::fields, NULL, type::opt, type::s, state_file, type::state_number, type::tag, type_lineloc(), type::u, s_expr_writer::write_any_indent(), write_state_a_string(), write_state_common_type_content(), write_state_fields(), write_state_fileloc(), write_state_lang_bitmap(), and write_state_options().
Referenced by write_state_lang_struct_type(), write_state_struct_type(), and write_state_union_type().
|
private |
Write our structures.
References s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), type::next, NULL, progname, state_file, structures, verbosity_level, s_expr_writer::write_new_line(), and write_state_type().
|
private |
The important and recursive routine writing GTY types as understood by gengtype. Types which have a positive state_number have already been seen and written.
References s_expr_writer::begin_s_expr(), DBGPRINTF, s_expr_writer::end_s_expr(), gcc_unreachable, m_state_written_type_count, NULL, state_file, type::state_number, TYPE_ARRAY, TYPE_CALLBACK, TYPE_LANG_STRUCT, TYPE_NONE, TYPE_POINTER, TYPE_SCALAR, TYPE_STRING, TYPE_STRUCT, TYPE_UNDEFINED, TYPE_UNION, TYPE_USER_STRUCT, s_expr_writer::write_any_indent(), write_state_array_type(), write_state_callback_type(), write_state_lang_struct_type(), write_state_pointer_type(), write_state_scalar_type(), write_state_string_type(), write_state_struct_type(), write_state_undefined_type(), write_state_union_type(), and write_state_user_struct_type().
Referenced by write_state_array_type(), write_state_common_type_content(), write_state_lang_struct_type(), write_state_nested_option(), write_state_pair(), write_state_pointer_type(), write_state_struct_type(), write_state_structures(), write_state_type_option(), and write_state_union_type().
|
private |
References options::info, state_file, options::type, s_expr_writer::write_any_indent(), and write_state_type().
Referenced by write_state_option().
|
private |
When writing imported linked lists, like typedefs, structures, ... we count their length first and write it. This eases the reading, and enables an extra verification on the number of actually read items.
Write our typedefs.
References s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), gcc_assert, pair_list_length(), progname, state_file, typedefs, verbosity_level, and write_state_pair_list().
|
private |
Write an undefined type.
References DBGPRINTF, GC_UNUSED, type::gc_used, gcc_assert, NULL, type::s, state_file, type::state_number, type::tag, type_lineloc(), type::u, s_expr_writer::write_any_indent(), write_state_a_string(), write_state_common_type_content(), and write_state_fileloc().
Referenced by write_state_type().
|
private |
write a GTY union type.
References type::lang_struct, type::s, type::u, write_state_struct_union_type(), and write_state_type().
Referenced by write_state_type().
|
private |
Write a GTY user-defined struct type.
References DBGPRINTF, type::fields, NULL, type::s, state_file, type::state_number, type::tag, type_lineloc(), type::u, s_expr_writer::write_any_indent(), write_state_a_string(), write_state_common_type_content(), write_state_fields(), and write_state_fileloc().
Referenced by write_state_type().
|
private |
Write our variables.
References s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), gcc_assert, pair_list_length(), progname, state_file, variables, verbosity_level, and write_state_pair_list().
|
private |
Write version information.
References s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), and write_state_a_string().
|
friend |
The write_state routine is the only writing routine called by main in gengtype.cc. 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.
Write the state, and update the state_number field in types.
|
privateinherited |
Referenced by s_expr_writer::write_any_indent(), and s_expr_writer::write_new_line().
|
privateinherited |
Referenced by s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), and s_expr_writer::write_any_indent().
|
private |
Referenced by write_state_type().