From 2adab65cc07f07a581d57b05dfbc100952fab748 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 15 Dec 2020 18:14:42 -0700 Subject: 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 * 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) : New method. * eval.c (parse_and_eval_type): Use first_opcode. * dtrace-probe.c (dtrace_process_dof_probe): Use first_opcode. --- gdb/value.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gdb/value.c') diff --git a/gdb/value.c b/gdb/value.c index eba5bce..9584fc1 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1981,7 +1981,7 @@ init_if_undefined_command (const char* args, int from_tty) /* Validate the expression. Was the expression an assignment? Or even an expression at all? */ - if (expr->nelts == 0 || expr->elts[0].opcode != BINOP_ASSIGN) + if (expr->nelts == 0 || expr->first_opcode () != BINOP_ASSIGN) error (_("Init-if-undefined requires an assignment expression.")); /* Extract the variable from the parsed expression. -- cgit v1.1