mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-26 05:47:26 +08:00
Remove per-language op_name functions
enum exp_opcode is created from all the .def files, but then each language is required to implement its own op_name function to turn an enum value to a string. This seemed over-complicated to me, and this patch removes the per-language functions in favor of simply using the .def names for all languages. Note that op_name is only used for dumping expressions, which is a maintainer/debug feature. Furthermore, I don't think there was any case where the .def name and the string name differed. gdb/ChangeLog 2020-11-30 Tom Tromey <tom@tromey.com> * rust-lang.c (rust_op_name): Remove. (exp_descriptor_rust): Update. * parser-defs.h (op_name_standard): Don't declare. (struct exp_descriptor) <op_name>: Remove. * parse.c (exp_descriptor_standard): Update. * opencl-lang.c (exp_descriptor_opencl): Update. * m2-lang.c (m2_language::exp_descriptor_modula2): Update. * f-lang.c (op_name_f): Remove. (f_language::exp_descriptor_tab): Update. * expression.h (op_name): Update. * expprint.c (op_name): Rewrite. (op_name_standard): Remove. (dump_raw_expression, dump_subexp): Update. * c-lang.c (exp_descriptor_c): Update. * ax-gdb.c (gen_expr): Update. * ada-lang.c (ada_op_name): Remove. (ada_exp_descriptor): Update.
This commit is contained in:
@ -685,26 +685,11 @@ op_string (enum exp_opcode op)
|
||||
|
||||
static int dump_subexp_body (struct expression *exp, struct ui_file *, int);
|
||||
|
||||
/* Name for OPCODE, when it appears in expression EXP. */
|
||||
|
||||
const char *
|
||||
op_name (struct expression *exp, enum exp_opcode opcode)
|
||||
{
|
||||
if (opcode >= OP_UNUSED_LAST)
|
||||
{
|
||||
char *cell = get_print_cell ();
|
||||
xsnprintf (cell, PRINT_CELL_SIZE, "unknown opcode: %u",
|
||||
unsigned (opcode));
|
||||
return cell;
|
||||
}
|
||||
return exp->language_defn->expression_ops ()->op_name (opcode);
|
||||
}
|
||||
|
||||
/* Default name for the standard operator OPCODE (i.e., one defined in
|
||||
the definition of enum exp_opcode). */
|
||||
|
||||
const char *
|
||||
op_name_standard (enum exp_opcode opcode)
|
||||
op_name (enum exp_opcode opcode)
|
||||
{
|
||||
switch (opcode)
|
||||
{
|
||||
@ -719,6 +704,8 @@ op_name_standard (enum exp_opcode opcode)
|
||||
case name: \
|
||||
return #name ;
|
||||
#include "std-operator.def"
|
||||
#include "ada-operator.def"
|
||||
#include "fortran-operator.def"
|
||||
#undef OP
|
||||
}
|
||||
}
|
||||
@ -747,7 +734,7 @@ dump_raw_expression (struct expression *exp, struct ui_file *stream,
|
||||
{
|
||||
fprintf_filtered (stream, "\t%5d ", elt);
|
||||
|
||||
const char *opcode_name = op_name (exp, exp->elts[elt].opcode);
|
||||
const char *opcode_name = op_name (exp->elts[elt].opcode);
|
||||
fprintf_filtered (stream, "%20s ", opcode_name);
|
||||
|
||||
print_longest (stream, 'd', 0, exp->elts[elt].longconst);
|
||||
@ -782,7 +769,7 @@ dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
|
||||
fprintf_filtered (stream, " ");
|
||||
indent += 2;
|
||||
|
||||
fprintf_filtered (stream, "%-20s ", op_name (exp, exp->elts[elt].opcode));
|
||||
fprintf_filtered (stream, "%-20s ", op_name (exp->elts[elt].opcode));
|
||||
|
||||
elt = dump_subexp_body (exp, stream, elt);
|
||||
|
||||
|
Reference in New Issue
Block a user