aboutsummaryrefslogtreecommitdiff
path: root/gdb/parser-defs.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-11-22 21:45:53 -0700
committerTom Tromey <tom@tromey.com>2017-12-30 17:05:37 -0700
commite9d9f57e11db6427db347bc5b9b100071355e63f (patch)
treeb431b37b9a20e1a406b30be36aee0f36489ef5ec /gdb/parser-defs.h
parenta594729cfb10457e0046359d2dde0c28b4185449 (diff)
downloadgdb-e9d9f57e11db6427db347bc5b9b100071355e63f.zip
gdb-e9d9f57e11db6427db347bc5b9b100071355e63f.tar.gz
gdb-e9d9f57e11db6427db347bc5b9b100071355e63f.tar.bz2
C++-ify parser_state
This mildly C++-ifies parser_state and stap_parse_info -- just enough to remove some cleanups. This version includes the changes implemented by Simon. Regression tested by the buildbot. gdb/ChangeLog 2017-12-30 Tom Tromey <tom@tromey.com> Simon Marchi <simon.marchi@ericsson.com> * stap-probe.h (struct stap_parse_info): Add constructor, destructor. * stap-probe.c (stap_parse_argument): Update. * rust-exp.y (rust_lex_tests): Update. * parser-defs.h (struct parser_state): Add constructor, destructor, release method. <expout>: Change type to expression_up. (null_post_parser): Change type. (initialize_expout, reallocate_expout): Remove. * parse.c (parser_state::parser_state): Rename from initialize_expout. (parser_state::release): Rename from reallocate_expout. (write_exp_elt, parse_exp_in_context_1, increase_expout_size): Update. (null_post_parser): Change type of "exp". * dtrace-probe.c (dtrace_probe::build_arg_exprs): Update. * ada-lang.c (resolve, resolve_subexp) (replace_operator_with_call): Change type of "expp". * language.h (struct language_defn) <la_post_parser>: Change type of "expp".
Diffstat (limited to 'gdb/parser-defs.h')
-rw-r--r--gdb/parser-defs.h36
1 files changed, 16 insertions, 20 deletions
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index f43fb75..907a798 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -37,14 +37,27 @@ extern int parser_debug;
struct parser_state
{
- /* The expression related to this parser state. */
+ /* Constructor. INITIAL_SIZE is the initial size of the expout
+ array. LANG is the language used to parse the expression. And
+ GDBARCH is the gdbarch to use during parsing. */
+
+ parser_state (size_t initial_size, const struct language_defn *lang,
+ struct gdbarch *gdbarch);
+
+ DISABLE_COPY_AND_ASSIGN (parser_state);
- struct expression *expout;
+ /* Resize the allocated expression to the correct size, and return
+ it as an expression_up -- passing ownership to the caller. */
+ expression_up release ();
/* The size of the expression above. */
size_t expout_size;
+ /* The expression related to this parser state. */
+
+ expression_up expout;
+
/* The number of elements already in the expression. This is used
to know where to put new elements. */
@@ -156,23 +169,6 @@ struct type_stack
int size;
};
-/* Helper function to initialize the expout, expout_size, expout_ptr
- trio inside PS before it is used to store expression elements created
- during the parsing of an expression. INITIAL_SIZE is the initial size of
- the expout array. LANG is the language used to parse the expression.
- And GDBARCH is the gdbarch to use during parsing. */
-
-extern void initialize_expout (struct parser_state *ps,
- size_t initial_size,
- const struct language_defn *lang,
- struct gdbarch *gdbarch);
-
-/* Helper function that reallocates the EXPOUT inside PS in order to
- eliminate any unused space. It is generally used when the expression
- has just been parsed and created. */
-
-extern void reallocate_expout (struct parser_state *ps);
-
/* Reverse an expression from suffix form (in which it is constructed)
to prefix form (in which we can conveniently print or execute it).
Ordinarily this always returns -1. However, if EXPOUT_LAST_STRUCT
@@ -265,7 +261,7 @@ extern struct type *follow_types (struct type *);
extern type_instance_flags follow_type_instance_flags ();
-extern void null_post_parser (struct expression **, int);
+extern void null_post_parser (expression_up *, int);
extern bool parse_float (const char *p, int len,
const struct type *type, gdb_byte *data);