/* Gengtype persistent state serialization & de-serialization.
Useful for gengtype in plugin mode.
- Copyright (C) 2010-2013 Free Software Foundation, Inc.
+ Copyright (C) 2010-2020 Free Software Foundation, Inc.
This file is part of GCC.
and Basile Starynkevitch <basile@starynkevitch.net>
*/
-#ifdef GENERATOR_FILE
-#include "bconfig.h"
-#else
+#ifdef HOST_GENERATOR_FILE
#include "config.h"
+#define GENERATOR_FILE 1
+#else
+#include "bconfig.h"
#endif
#include "system.h"
#include "errors.h" /* For fatal. */
-#include "double-int.h"
-#include "hashtab.h"
#include "version.h" /* For version_string & pkgversion_string. */
#include "obstack.h"
#include "gengtype.h"
case TYPE_USER_STRUCT:
case TYPE_UNDEFINED:
return CONST_CAST (struct fileloc*, &ty->u.s.line);
- case TYPE_PARAM_STRUCT:
- return CONST_CAST (struct fileloc*, &ty->u.param_struct.line);
case TYPE_SCALAR:
case TYPE_STRING:
case TYPE_POINTER:
void write_state_user_struct_type (type_p current);
void write_state_union_type (type_p current);
void write_state_lang_struct_type (type_p current);
- void write_state_param_struct_type (type_p current);
void write_state_pointer_type (type_p current);
void write_state_array_type (type_p current);
void write_state_gc_used (enum gc_used_enum gus);
int write_state_pair_list (pair_p list);
void write_state_typedefs (void);
void write_state_structures (void);
- void write_state_param_structs (void);
void write_state_variables (void);
void write_state_srcdir (void);
void write_state_files_list (void);
/* Fatal message while reading state. */
-static inline void
+static void
fatal_reading_state (struct state_token_st* tok, const char*msg)
{
if (tok)
* 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
end_s_expr ();
}
-/* Write a parametrized structure GTY type. */
-void
-state_writer::write_state_param_struct_type (type_p current)
-{
- int i;
-
- write_any_indent (0);
- fprintf (state_file, "param_struct ");
- write_state_common_type_content (current);
- write_state_type (current->u.param_struct.stru);
- for (i = 0; i < NUM_PARAM; i++)
- {
- if (current->u.param_struct.param[i] != NULL)
- write_state_type (current->u.param_struct.param[i]);
- else
- {
- write_any_indent (0);
- fprintf (state_file, "nil ");
- }
- }
- write_state_fileloc (¤t->u.param_struct.line);
-}
-
/* Write a pointer type. */
void
state_writer::write_state_pointer_type (type_p current)
case TYPE_LANG_STRUCT:
write_state_lang_struct_type (current);
break;
- case TYPE_PARAM_STRUCT:
- write_state_param_struct_type (current);
- break;
case TYPE_SCALAR:
write_state_scalar_type (current);
break;
}
-/* When writing imported linked lists, like typedefs, structures,
- param_structs, ... we count their length first and write it. These
- eases the reading, and enables an extra verification on the number
- of actually read items. */
+/* 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. */
void
printf ("%s wrote %d structures in state\n", progname, nbstruct);
}
-/* Write our param_struct-s. */
-void
-state_writer::write_state_param_structs (void)
-{
- int nbparamstruct = 0;
- type_p current;
-
- for (current = param_structs; current != NULL; current = current->next)
- nbparamstruct++;
-
- begin_s_expr ("param_structs");
- fprintf (state_file, "%d", nbparamstruct);
-
- for (current = param_structs; current != NULL; current = current->next)
- write_state_type (current);
-
- end_s_expr ();
-}
-
/* Write our variables. */
void
state_writer::write_state_variables (void)
sw.write_state_files_list ();
sw.write_state_structures ();
sw.write_state_typedefs ();
- sw.write_state_param_structs ();
sw.write_state_variables ();
write_state_trailer ();
statelen = ftell (state_file);
read_state_lang_bitmap (&(type->u.s.bitmap));
read_state_type (&(type->u.s.lang_struct));
read_state_type (&(type->u.s.base_class));
+ if (type->u.s.base_class)
+ add_subclass (type->u.s.base_class, type);
}
else
{
}
-/* Read a param_struct type for GTY parametrized structures. */
-static void
-read_state_param_struct_type (type_p type)
-{
- int i;
- struct state_token_st *t0;
-
- type->kind = TYPE_PARAM_STRUCT;
- read_state_common_type_content (type);
- DBGPRINTF ("read param_struct type @%p #%d",
- (void *) type, type->state_number);
- read_state_type (&(type->u.param_struct.stru));
-
- for (i = 0; i < NUM_PARAM; i++)
- {
- t0 = peek_state_token (0);
- if (state_token_is_name (t0, "nil"))
- {
- type->u.param_struct.param[i] = NULL;
- next_state_tokens (1);
- }
- else
- read_state_type (&(type->u.param_struct.param[i]));
- }
- read_state_fileloc (&(type->u.param_struct.line));
-}
-
-
/* Read the gc used information. */
static void
read_state_gc_used (enum gc_used_enum *pgus)
next_state_tokens (1);
read_state_lang_struct_type (*current);
}
- else if (state_token_is_name (t0, "param_struct"))
- {
- *current = XCNEW (struct type);
- next_state_tokens (1);
- read_state_param_struct_type (*current);
- }
else if (state_token_is_name (t0, "pointer"))
{
*current = XCNEW (struct type);
next_state_tokens (1);
read_state_type (&((*current)->type));
read_state_fileloc (&((*current)->line));
- read_state_options (&((*current)->opt));;
+ read_state_options (&((*current)->opt));
t0 = peek_state_token (0);
if (state_token_kind (t0) == STOK_RIGHTPAR)
{
}
-/* Read the param_struct-s. */
-static void
-read_state_param_structs (type_p *param_structs)
-{
- int nbparamstructs = 0;
- int countparamstructs = 0;
- type_p head = NULL;
- type_p previous = NULL;
- type_p tmp;
- struct state_token_st *t0 = peek_state_token (0);
- struct state_token_st *t1 = peek_state_token (1);
- struct state_token_st *t2 = peek_state_token (2);
-
- if (state_token_kind (t0) == STOK_LEFTPAR
- && state_token_is_name (t1, "!param_structs")
- && state_token_kind (t2) == STOK_INTEGER)
- {
- nbparamstructs = t2->stok_un.stok_num;
- next_state_tokens (3);
- t0 = t1 = t2 = NULL;
- t0 = peek_state_token (0);
- while (state_token_kind (t0) != STOK_RIGHTPAR)
- {
- tmp = NULL;
- read_state_type (&tmp);
- if (head == NULL)
- {
- head = tmp;
- previous = head;
- }
- else
- {
- previous->next = tmp;
- previous = tmp;
- }
- t0 = peek_state_token (0);
- countparamstructs++;
- }
- next_state_tokens (1);
- }
- else
- fatal_reading_state (t0, "Bad param_structs syntax");
- t0 = peek_state_token (0);
- if (countparamstructs != nbparamstructs)
- fatal_reading_state_printf
- (t0,
- "invalid number of param_structs expected %d got %d",
- nbparamstructs, countparamstructs);
- *param_structs = head;
-}
-
-
/* Read the variables. */
static void
read_state_variables (pair_p *variables)
"expecting file in !fileslist of state file");
};
t0 = peek_state_token (0);
- if (!state_token_kind (t0) == STOK_RIGHTPAR)
+ if (state_token_kind (t0) != STOK_RIGHTPAR)
fatal_reading_state (t0, "missing ) for !fileslist in state file");
next_state_tokens (1);
}
(NULL_STATE_TOKEN, "input error while reading state [%s]",
xstrerror (errno));
read_state_typedefs (&typedefs);
- read_state_param_structs (¶m_structs);
read_state_variables (&variables);
read_state_trailer ();