GCC Middle and Back End API Reference
gengtype-state.c File Reference
#include "config.h"
#include "system.h"
#include "errors.h"
Include dependency graph for gengtype-state.c:

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
}

Functions

static struct fileloctype_lineloc ()
static void fatal_reading_state ()
static struct state_ident_ststate_ident_by_name ()
static struct state_token_stread_a_state_token ()
static struct state_token_stpeek_state_token ()
static void next_state_tokens ()
static enum state_token_en state_token_kind ()
static bool state_token_is_name ()
static int pair_list_length (pair_p list)
static int pair_list_length ()
static void write_state_trailer ()
void write_state ()
static void read_state_fileloc (struct fileloc *line)
static void read_state_options (options_p *opt)
static void read_state_type (type_p *current)
static void read_state_pair (pair_p *pair)
static int read_state_pair_list (pair_p *list)
static void read_state_fields (pair_p *fields)
static void read_state_common_type_content (type_p current)
static void record_type ()
static void read_state_already_seen_type ()
static void read_state_scalar_nonchar_type ()
static void read_state_scalar_char_type ()
static void read_state_string_type ()
static void read_state_lang_bitmap ()
static void read_state_undefined_type ()
static void read_state_struct_type ()
static void read_state_user_struct_type ()
static void read_state_union_type ()
static void read_state_pointer_type ()
static void read_state_array_type ()
static void read_state_lang_struct_type ()
static void read_state_param_struct_type ()
static void read_state_gc_used ()
static void read_state_common_type_content ()
void read_state_type ()
void read_state_fileloc ()
void read_state_fields ()
static void read_state_string_option ()
static void read_state_type_option ()
static void read_state_nested_option ()
static void read_state_option ()
void read_state_options ()
static void read_state_version ()
void read_state_pair ()
int read_state_pair_list ()
static void read_state_typedefs ()
static void read_state_structures ()
static void read_state_param_structs ()
static void read_state_variables ()
static void read_state_srcdir ()
static void read_state_languages ()
static void read_state_files_list ()
static void read_state_trailer ()
static unsigned hash_type_number ()
static int equals_type_number ()
static int string_eq ()
void read_state ()

Variables

static htab_t state_ident_tab
struct state_token_ststate_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

Enumeration Type Documentation

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.   
Enumerator:
STOK_NONE 
STOK_INTEGER 
STOK_STRING 
STOK_LEFTPAR 
STOK_RIGHTPAR 
STOK_NAME 

Function Documentation

static int equals_type_number ( )
static

References type::state_number.

Referenced by read_state().

static unsigned hash_type_number ( )
static
Utility functions for the state_seen_types hash table.   

References type::state_number.

Referenced by read_state().

static int pair_list_length ( pair_p  list)
static
Return the length of a linked list made of pairs.   

Referenced by state_writer::write_state_fields(), state_writer::write_state_typedefs(), and state_writer::write_state_variables().

static int pair_list_length ( )
static
Compute the length of a list of pairs, starting from the first
   one.   

References pair::next.

static struct state_token_st* read_a_state_token ( )
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.   

References fatal_reading_state(), obstack, state_bol, state_file, state_ident_by_name(), state_line, state_path, state_token_st::stok_col, state_token_st::stok_file, state_token_st::stok_ident, STOK_INTEGER, state_token_st::stok_kind, STOK_LEFTPAR, state_token_st::stok_line, STOK_NAME, state_token_st::stok_next, state_token_st::stok_num, STOK_RIGHTPAR, STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, and strlen().

Referenced by peek_state_token().

static void read_state_common_type_content ( )
static
static void read_state_fields ( pair_p fields)
static
static void read_state_fileloc ( struct fileloc line)
static

End of writing routines! The corresponding reading routines follow. *

Forward declarations, since some read_state_* functions are
   recursive!  

Referenced by read_state_lang_struct_type(), read_state_pair(), read_state_param_struct_type(), read_state_struct_type(), read_state_undefined_type(), read_state_union_type(), and read_state_user_struct_type().

static void read_state_gc_used ( )
static
static void read_state_lang_bitmap ( )
static
static void read_state_lang_struct_type ( )
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.   

References fatal_reading_state(), type::kind, type::next, next_state_tokens(), peek_state_token(), read_state_common_type_content(), read_state_fields(), read_state_fileloc(), read_state_lang_bitmap(), read_state_options(), read_state_type(), type::s, type::state_number, state_token_is_name(), state_token_kind(), STOK_INTEGER, STOK_LEFTPAR, state_token_st::stok_num, STOK_RIGHTPAR, STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, TYPE_LANG_STRUCT, and type::u.

Referenced by read_state_type().

static void read_state_options ( options_p opt)
static
static void read_state_pair ( pair_p pair)
static

Referenced by read_state_pair_list().

static int read_state_pair_list ( pair_p list)
static
Return the number of pairs actually read.   

Referenced by read_state_fields(), read_state_typedefs(), and read_state_variables().

int read_state_pair_list ( )
Return the number of pairs actually read.   

References pair::next, peek_state_token(), read_state_pair(), state_token_kind(), and STOK_RIGHTPAR.

static void read_state_param_struct_type ( )
static
static void read_state_pointer_type ( )
static
static void read_state_scalar_char_type ( )
static
Read the scalar_char type.   

References read_state_common_type_content(), and scalar_char.

Referenced by read_state_type().

static void read_state_scalar_nonchar_type ( )
static
Read the scalar_nonchar type.   

References read_state_common_type_content(), and scalar_nonchar.

Referenced by read_state_type().

static void read_state_string_type ( )
static
Read the string_type.   

References read_state_common_type_content(), and string_type.

Referenced by read_state_type().

static void read_state_trailer ( )
static
static void read_state_type_option ( )
static
Read a type option.   

References options::info, options::kind, OPTION_TYPE, read_state_type(), and options::type.

Referenced by read_state_option().

static void read_state_version ( )
static
static void record_type ( )
static
Record into the state_seen_types hash-table a type which we are
   reading, to enable recursive or circular references to it.   

References state_seen_types, and type().

Referenced by create_task_copyfn(), lower_send_shared_vars(), and read_state_common_type_content().

static struct state_ident_st* state_ident_by_name ( )
staticread
Find or allocate an identifier in our name hash table.   

References memset(), state_ident_tab, state_ident_st::stid_name, and strlen().

Referenced by read_a_state_token().

static int string_eq ( )
static

Referenced by read_state().

static struct fileloc* type_lineloc ( )
staticread
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 <jeremie.salvucci@free.fr>
   and Basile Starynkevitch <basile@starynkevitch.net>
Gives the file location of a type, if any.   

References type::kind, 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.

Referenced by state_writer::write_state_struct_union_type(), state_writer::write_state_undefined_type(), and state_writer::write_state_user_struct_type().

void write_state ( )
static void write_state_trailer ( )
static
Write the trailer.   

References errno, fatal(), and state_file.

Referenced by write_state().


Variable Documentation

long state_bol = 0
static

Referenced by read_a_state_token().

htab_t state_ident_tab
static

Referenced by read_state(), and state_ident_by_name().

const char* state_path = NULL
static
htab_t state_seen_types
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.   

Referenced by read_state(), read_state_already_seen_type(), and record_type().

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.   

Referenced by peek_state_token().