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".
This commit is contained in:
Tom Tromey
2019-03-24 10:28:42 -06:00
parent 73923d7eed
commit 37eedb3982
9 changed files with 115 additions and 73 deletions

View File

@@ -624,26 +624,25 @@ dtrace_probe::build_arg_exprs (struct gdbarch *gdbarch)
value of the argument when executed at the PC of the probe. */
for (dtrace_probe_arg &arg : m_args)
{
/* Initialize the expression buffer in the parser state. The
language does not matter, since we are using our own
parser. */
parser_state pstate (current_language, gdbarch);
/* Initialize the expression builder. The language does not
matter, since we are using our own parser. */
expr_builder builder (current_language, gdbarch);
/* The argument value, which is ABI dependent and casted to
`long int'. */
gdbarch_dtrace_parse_probe_argument (gdbarch, &pstate, argc);
gdbarch_dtrace_parse_probe_argument (gdbarch, &builder, argc);
/* Casting to the expected type, but only if the type was
recognized at probe load time. Otherwise the argument will
be evaluated as the long integer passed to the probe. */
if (arg.type != NULL)
{
write_exp_elt_opcode (&pstate, UNOP_CAST);
write_exp_elt_type (&pstate, arg.type);
write_exp_elt_opcode (&pstate, UNOP_CAST);
write_exp_elt_opcode (&builder, UNOP_CAST);
write_exp_elt_type (&builder, arg.type);
write_exp_elt_opcode (&builder, UNOP_CAST);
}
arg.expr = pstate.release ();
arg.expr = builder.release ();
prefixify_expression (arg.expr.get ());
++argc;
}