aboutsummaryrefslogtreecommitdiff
path: root/gdb/parser-defs.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-03-24 10:28:42 -0600
committerTom Tromey <tom@tromey.com>2019-04-04 19:55:10 -0600
commit37eedb39824dc26c82a92b5515a352d7de0c9b5b (patch)
treeaaa2ca172270575273773089cbdcea2978e83ed1 /gdb/parser-defs.h
parent73923d7eedc7ab52144308ef7e9c12cbe4341bca (diff)
downloadgdb-37eedb39824dc26c82a92b5515a352d7de0c9b5b.zip
gdb-37eedb39824dc26c82a92b5515a352d7de0c9b5b.tar.gz
gdb-37eedb39824dc26c82a92b5515a352d7de0c9b5b.tar.bz2
Make base class for parser_state
This makes a new base class, expr_builder, for parser_state. This separates the state needed to construct an expression from the state needed by the parsers. gdb/ChangeLog 2019-04-04 Tom Tromey <tom@tromey.com> * gdbarch.h, gdbarch.c: Rebuild. * gdbarch.sh (dtrace_parse_probe_argument): Change type. * stap-probe.h: (struct stap_parse_info): Replace "parser_state" with "expr_builder". * parser-defs.h (struct expr_builder): Rename from "parser_state". (parser_state): New class. * parse.c (expr_builder): Rename. (expr_builder::release): Rename. (write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym) (write_exp_elt_msym, write_exp_elt_block, write_exp_elt_objfile) (write_exp_elt_longcst, write_exp_elt_floatcst) (write_exp_elt_type, write_exp_elt_intern, write_exp_string) (write_exp_string_vector, write_exp_bitstring) (write_exp_msymbol, mark_struct_expression) (write_dollar_variable) (insert_type_address_space, increase_expout_size): Replace "parser_state" with "expr_builder". * dtrace-probe.c: Replace "parser_state" with "expr_builder". * amd64-linux-tdep.c (amd64_dtrace_parse_probe_argument): Replace "parser_state" with "expr_builder".
Diffstat (limited to 'gdb/parser-defs.h')
-rw-r--r--gdb/parser-defs.h56
1 files changed, 38 insertions, 18 deletions
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 8fcbca3..5bc9d25 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -32,15 +32,17 @@ struct internalvar;
extern int parser_debug;
-struct parser_state
+/* A class that can be used to build a "struct expression". */
+
+struct expr_builder
{
/* Constructor. LANG is the language used to parse the expression.
And GDBARCH is the gdbarch to use during parsing. */
- parser_state (const struct language_defn *lang,
+ expr_builder (const struct language_defn *lang,
struct gdbarch *gdbarch);
- DISABLE_COPY_AND_ASSIGN (parser_state);
+ DISABLE_COPY_AND_ASSIGN (expr_builder);
/* Resize the allocated expression to the correct size, and return
it as an expression_up -- passing ownership to the caller. */
@@ -74,6 +76,24 @@ struct parser_state
size_t expout_ptr;
};
+/* An instance of this type is instantiated during expression parsing,
+ and passed to the appropriate parser. It holds both inputs to the
+ parser, and result. */
+
+struct parser_state : public expr_builder
+{
+ /* Constructor. LANG is the language used to parse the expression.
+ And GDBARCH is the gdbarch to use during parsing. */
+
+ parser_state (const struct language_defn *lang,
+ struct gdbarch *gdbarch)
+ : expr_builder (lang, gdbarch)
+ {
+ }
+
+ DISABLE_COPY_AND_ASSIGN (parser_state);
+};
+
/* If this is nonzero, this block is used as the lexical context
for symbol names. */
@@ -236,36 +256,36 @@ struct type_stack
extern int prefixify_expression (struct expression *expr);
-extern void write_exp_elt_opcode (struct parser_state *, enum exp_opcode);
+extern void write_exp_elt_opcode (struct expr_builder *, enum exp_opcode);
-extern void write_exp_elt_sym (struct parser_state *, struct symbol *);
+extern void write_exp_elt_sym (struct expr_builder *, struct symbol *);
-extern void write_exp_elt_longcst (struct parser_state *, LONGEST);
+extern void write_exp_elt_longcst (struct expr_builder *, LONGEST);
-extern void write_exp_elt_floatcst (struct parser_state *, const gdb_byte *);
+extern void write_exp_elt_floatcst (struct expr_builder *, const gdb_byte *);
-extern void write_exp_elt_type (struct parser_state *, struct type *);
+extern void write_exp_elt_type (struct expr_builder *, struct type *);
-extern void write_exp_elt_intern (struct parser_state *, struct internalvar *);
+extern void write_exp_elt_intern (struct expr_builder *, struct internalvar *);
-extern void write_exp_string (struct parser_state *, struct stoken);
+extern void write_exp_string (struct expr_builder *, struct stoken);
-void write_exp_string_vector (struct parser_state *, int type,
+void write_exp_string_vector (struct expr_builder *, int type,
struct stoken_vector *vec);
-extern void write_exp_bitstring (struct parser_state *, struct stoken);
+extern void write_exp_bitstring (struct expr_builder *, struct stoken);
-extern void write_exp_elt_block (struct parser_state *, const struct block *);
+extern void write_exp_elt_block (struct expr_builder *, const struct block *);
-extern void write_exp_elt_objfile (struct parser_state *,
+extern void write_exp_elt_objfile (struct expr_builder *,
struct objfile *objfile);
-extern void write_exp_msymbol (struct parser_state *,
+extern void write_exp_msymbol (struct expr_builder *,
struct bound_minimal_symbol);
-extern void write_dollar_variable (struct parser_state *, struct stoken str);
+extern void write_dollar_variable (struct expr_builder *, struct stoken str);
-extern void mark_struct_expression (struct parser_state *);
+extern void mark_struct_expression (struct expr_builder *);
extern const char *find_template_name_end (const char *);
@@ -281,7 +301,7 @@ extern void push_type (enum type_pieces);
extern void push_type_int (int);
-extern void insert_type_address_space (struct parser_state *, char *);
+extern void insert_type_address_space (struct expr_builder *, char *);
extern enum type_pieces pop_type (void);