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".
This commit is contained in:
Tom Tromey
2017-11-22 21:45:53 -07:00
parent a594729cfb
commit e9d9f57e11
9 changed files with 110 additions and 102 deletions

View File

@@ -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. */
struct expression *expout;
parser_state (size_t initial_size, const struct language_defn *lang,
struct gdbarch *gdbarch);
DISABLE_COPY_AND_ASSIGN (parser_state);
/* 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);