Introduce expression::first_opcode

This adds a new helper method, expression::first_opcode, that extracts
the outermost opcode of an expression.  This simplifies some patches
in the expression rewrite series.

Note that this patch requires the earlier patch to avoid manual
dissection of OP_TYPE operations.

2020-12-15  Tom Tromey  <tom@tromey.com>

	* varobj.c (varobj_create): Use first_opcode.
	* value.c (init_if_undefined_command): Use first_opcode.
	* typeprint.c (whatis_exp): Use first_opcode.
	* tracepoint.c (validate_actionline): Use first_opcode.
	(encode_actions_1): Use first_opcode.
	* stack.c (return_command): Use first_opcode.
	* expression.h (struct expression) <first_opcode>: New method.
	* eval.c (parse_and_eval_type): Use first_opcode.
	* dtrace-probe.c (dtrace_process_dof_probe): Use first_opcode.
This commit is contained in:
Tom Tromey 2020-12-15 18:14:42 -07:00
parent 1ab8280d7d
commit 2adab65cc0
9 changed files with 31 additions and 11 deletions

View file

@ -493,7 +493,7 @@ whatis_exp (const char *exp, int show)
val = evaluate_type (expr.get ());
type = value_type (val);
if (show == -1 && expr->elts[0].opcode == OP_TYPE)
if (show == -1 && expr->first_opcode () == OP_TYPE)
{
/* The user expression names a type directly. */