From: Andrew Burgess Date: Tue, 4 Aug 2020 15:31:56 +0000 (+0100) Subject: gdb: Convert language_data::la_exp_desc to a method X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5aba6ebefb9488163c82e198b73ecf0a05a5d1fd;p=binutils-gdb.git gdb: Convert language_data::la_exp_desc to a method Convert language_data::la_exp_desc member variable to a virtual method language_defn::expression_ops. The change of names brings this method more into line with the existing varobj_ops method, that also returns a table of function pointers. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_exp_desc initializer. (ada_language::expression_ops): New member function. * c-lang.c (c_language_data): Remove la_exp_desc initializer. (c_language::expression_ops): New member function. (cplus_language_data): Remove la_exp_desc initializer. (cplus_language::expression_ops): New member function. (asm_language_data): Remove la_exp_desc initializer. (asm_language::expression_ops): New member function. (minimal_language_data): Remove la_exp_desc initializer. (minimal_language::expression_ops): New member function. * d-lang.c (d_language_data): Remove la_exp_desc initializer. (d_language::expression_ops): New member function. * eval.c (evaluate_subexp): Update call to expression_ops. * expprint.c (print_subexp): Likewise. (op_name): Likewise. (dump_subexp_body): Likewise. * f-lang.c (f_language_data): Remove la_exp_desc initializer. (f_language::expression_ops): New member function. * go-lang.c (go_language_data): Remove la_exp_desc initializer. (go_language::expression_ops): New member function. * language.c (language_defn::expression_ops): New function. (unknown_language_data): Remove la_exp_desc initializer. (auto_language_data): Likewise. * language.h (language_data): Remove la_exp_desc field. (language_defn::expression_ops): Declare new member function. * m2-lang.c (m2_language_data): Remove la_exp_desc initializer. (m2_language::expression_ops): New member function. * objc-lang.c (objc_language_data): Remove la_exp_desc initializer. * opencl-lang.c (opencl_language_data): Remove la_exp_desc initializer. (opencl_language::expression_ops): New member function. * p-lang.c (pascal_language_data): Remove la_exp_desc initializer. * parse.c (operator_length): Update call to expression_ops. (exp_iterate): Likewise. * rust-lang.c (rust_language_data): Remove la_exp_desc initializer. (ruse_language::expression_ops): New member function. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 666dd1a4289..d646595e731 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,44 @@ +2020-09-16 Andrew Burgess + + * ada-lang.c (ada_language_data): Remove la_exp_desc initializer. + (ada_language::expression_ops): New member function. + * c-lang.c (c_language_data): Remove la_exp_desc initializer. + (c_language::expression_ops): New member function. + (cplus_language_data): Remove la_exp_desc initializer. + (cplus_language::expression_ops): New member function. + (asm_language_data): Remove la_exp_desc initializer. + (asm_language::expression_ops): New member function. + (minimal_language_data): Remove la_exp_desc initializer. + (minimal_language::expression_ops): New member function. + * d-lang.c (d_language_data): Remove la_exp_desc initializer. + (d_language::expression_ops): New member function. + * eval.c (evaluate_subexp): Update call to expression_ops. + * expprint.c (print_subexp): Likewise. + (op_name): Likewise. + (dump_subexp_body): Likewise. + * f-lang.c (f_language_data): Remove la_exp_desc initializer. + (f_language::expression_ops): New member function. + * go-lang.c (go_language_data): Remove la_exp_desc initializer. + (go_language::expression_ops): New member function. + * language.c (language_defn::expression_ops): New function. + (unknown_language_data): Remove la_exp_desc initializer. + (auto_language_data): Likewise. + * language.h (language_data): Remove la_exp_desc field. + (language_defn::expression_ops): Declare new member function. + * m2-lang.c (m2_language_data): Remove la_exp_desc initializer. + (m2_language::expression_ops): New member function. + * objc-lang.c (objc_language_data): Remove la_exp_desc + initializer. + * opencl-lang.c (opencl_language_data): Remove la_exp_desc + initializer. + (opencl_language::expression_ops): New member function. + * p-lang.c (pascal_language_data): Remove la_exp_desc initializer. + * parse.c (operator_length): Update call to expression_ops. + (exp_iterate): Likewise. + * rust-lang.c (rust_language_data): Remove la_exp_desc + initializer. + (ruse_language::expression_ops): New member function. + 2020-09-16 Andrew Burgess * ada-lang.c (ada_language_data): Remove la_varobj_ops diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 20fbf33af71..876125c4f18 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13708,7 +13708,6 @@ ada_get_symbol_name_matcher (const lookup_name_info &lookup_name) extern const struct language_data ada_language_data = { - &ada_exp_descriptor, ada_op_print_tab, /* expression operators for printing */ }; @@ -14206,6 +14205,11 @@ public: const struct lang_varobj_ops *varobj_ops () const override { return &ada_varobj_ops; } + /* See language.h. */ + + const struct exp_descriptor *expression_ops () const override + { return &ada_exp_descriptor; } + protected: /* See language.h. */ diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 9b21da15044..f29f3407e16 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -875,7 +875,6 @@ const struct exp_descriptor exp_descriptor_c = extern const struct language_data c_language_data = { - &exp_descriptor_c, c_op_print_tab, /* expression operators for printing */ }; @@ -947,6 +946,11 @@ public: enum macro_expansion macro_expansion () const override { return macro_expansion_c; } + + /* See language.h. */ + + const struct exp_descriptor *expression_ops () const override + { return &exp_descriptor_c; } }; /* Single instance of the C language class. */ @@ -985,7 +989,6 @@ enum cplus_primitive_types { extern const struct language_data cplus_language_data = { - &exp_descriptor_c, c_op_print_tab, /* expression operators for printing */ }; @@ -1179,6 +1182,11 @@ public: const struct lang_varobj_ops *varobj_ops () const override { return &cplus_varobj_ops; } + /* See language.h. */ + + const struct exp_descriptor *expression_ops () const override + { return &exp_descriptor_c; } + protected: /* See language.h. */ @@ -1198,7 +1206,6 @@ static cplus_language cplus_language_defn; extern const struct language_data asm_language_data = { - &exp_descriptor_c, c_op_print_tab, /* expression operators for printing */ }; @@ -1257,6 +1264,11 @@ public: enum macro_expansion macro_expansion () const override { return macro_expansion_c; } + + /* See language.h. */ + + const struct exp_descriptor *expression_ops () const override + { return &exp_descriptor_c; } }; /* The single instance of the ASM language class. */ @@ -1269,7 +1281,6 @@ static asm_language asm_language_defn; extern const struct language_data minimal_language_data = { - &exp_descriptor_c, c_op_print_tab, /* expression operators for printing */ }; @@ -1317,6 +1328,11 @@ public: enum macro_expansion macro_expansion () const override { return macro_expansion_c; } + + /* See language.h. */ + + const struct exp_descriptor *expression_ops () const override + { return &exp_descriptor_c; } }; /* The single instance of the minimal language class. */ diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 95175af4074..4b8020e2ec9 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -128,7 +128,6 @@ enum d_primitive_types { extern const struct language_data d_language_data = { - &exp_descriptor_c, d_op_print_tab, /* Expression operators for printing. */ }; @@ -276,6 +275,11 @@ public: const char *name_of_this () const override { return "this"; } + + /* See language.h. */ + + const struct exp_descriptor *expression_ops () const override + { return &exp_descriptor_c; } }; /* Single instance of the D language class. */ diff --git a/gdb/eval.c b/gdb/eval.c index 1af57fcad83..ead4c5fa546 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -74,7 +74,7 @@ evaluate_subexp (struct type *expect_type, struct expression *exp, && !thread_stack_temporaries_enabled_p (inferior_thread ())) stack_temporaries.emplace (inferior_thread ()); - retval = (*exp->language_defn->la_exp_desc->evaluate_exp) + retval = (*exp->language_defn->expression_ops ()->evaluate_exp) (expect_type, exp, pos, noside); if (stack_temporaries.has_value () diff --git a/gdb/expprint.c b/gdb/expprint.c index 36e18ea1a9f..8cca5b4f92c 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -50,7 +50,8 @@ void print_subexp (struct expression *exp, int *pos, struct ui_file *stream, enum precedence prec) { - exp->language_defn->la_exp_desc->print_subexp (exp, pos, stream, prec); + exp->language_defn->expression_ops ()->print_subexp (exp, pos, stream, + prec); } /* Standard implementation of print_subexp for use in language_defn @@ -692,7 +693,7 @@ op_name (struct expression *exp, enum exp_opcode opcode) unsigned (opcode)); return cell; } - return exp->language_defn->la_exp_desc->op_name (opcode); + return exp->language_defn->expression_ops ()->op_name (opcode); } /* Default name for the standard operator OPCODE (i.e., one defined in @@ -793,7 +794,8 @@ dump_subexp (struct expression *exp, struct ui_file *stream, int elt) static int dump_subexp_body (struct expression *exp, struct ui_file *stream, int elt) { - return exp->language_defn->la_exp_desc->dump_subexp_body (exp, stream, elt); + return exp->language_defn->expression_ops ()->dump_subexp_body (exp, stream, + elt); } /* Default value for subexp_body in exp_descriptor vector. */ diff --git a/gdb/f-lang.c b/gdb/f-lang.c index d333055510f..2bf046d64f9 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -486,7 +486,6 @@ static const struct exp_descriptor exp_descriptor_f = extern const struct language_data f_language_data = { - &exp_descriptor_f, f_op_print_tab, /* expression operators for printing */ }; @@ -732,6 +731,11 @@ public: enum array_ordering array_ordering () const override { return array_column_major; } + /* See language.h. */ + + const struct exp_descriptor *expression_ops () const override + { return &exp_descriptor_f; } + protected: /* See language.h. */ diff --git a/gdb/go-lang.c b/gdb/go-lang.c index c37e918e42a..eacc4debf42 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -508,7 +508,6 @@ enum go_primitive_types { extern const struct language_data go_language_data = { - &exp_descriptor_c, go_op_print_tab, /* Expression operators for printing. */ }; @@ -637,6 +636,11 @@ public: bool store_sym_names_in_linkage_form_p () const override { return true; } + + /* See language.h. */ + + const struct exp_descriptor *expression_ops () const override + { return &exp_descriptor_c; } }; /* Single instance of the Go language class. */ diff --git a/gdb/language.c b/gdb/language.c index bcffd3e1338..b467512e80d 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -774,6 +774,14 @@ language_defn::varobj_ops () const return &c_varobj_ops; } +/* See language.h. */ + +const struct exp_descriptor * +language_defn::expression_ops () const +{ + return &exp_descriptor_standard; +} + /* Return true if TYPE is a string type, otherwise return false. This default implementation only detects TYPE_CODE_STRING. */ @@ -808,7 +816,6 @@ unknown_language_arch_info (struct gdbarch *gdbarch, extern const struct language_data unknown_language_data = { - &exp_descriptor_standard, unk_op_print_tab, /* expression operators for printing */ }; @@ -940,7 +947,6 @@ static unknown_language unknown_language_defn; extern const struct language_data auto_language_data = { - &exp_descriptor_standard, unk_op_print_tab, /* expression operators for printing */ }; diff --git a/gdb/language.h b/gdb/language.h index 414488ddfbd..cfb3461a8cd 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -168,11 +168,6 @@ extern const char *default_word_break_characters (void); struct language_data { - /* Definitions related to expression printing, prefixifying, and - dumping. */ - - const struct exp_descriptor *la_exp_desc; - /* Table for printing expressions. */ const struct op_print *la_op_print_tab; @@ -567,6 +562,11 @@ struct language_defn : language_data virtual const struct lang_varobj_ops *varobj_ops () const; + /* Definitions related to expression printing, prefixifying, and + dumping. */ + + virtual const struct exp_descriptor *expression_ops () const; + protected: /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method. diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index c5206bbf901..b41d0b48d6e 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -199,7 +199,6 @@ const struct exp_descriptor exp_descriptor_modula2 = extern const struct language_data m2_language_data = { - &exp_descriptor_modula2, m2_op_print_tab, /* expression operators for printing */ }; @@ -444,6 +443,11 @@ public: bool range_checking_on_by_default () const override { return true; } + + /* See language.h. */ + + const struct exp_descriptor *expression_ops () const override + { return &exp_descriptor_modula2; } }; /* Single instance of the M2 language. */ diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 523902a0774..e78e0871aa9 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -323,7 +323,6 @@ static const struct op_print objc_op_print_tab[] = extern const struct language_data objc_language_data = { - &exp_descriptor_standard, objc_op_print_tab, /* Expression operators for printing */ }; diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 38dc73d1f22..e7186ebbf3f 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -1006,7 +1006,6 @@ const struct exp_descriptor exp_descriptor_opencl = /* Constant data representing the OpenCL language. */ extern const struct language_data opencl_language_data = { - &exp_descriptor_opencl, c_op_print_tab, /* expression operators for printing */ }; @@ -1070,6 +1069,11 @@ public: enum macro_expansion macro_expansion () const override { return macro_expansion_c; } + + /* See language.h. */ + + const struct exp_descriptor *expression_ops () const override + { return &exp_descriptor_opencl; } }; /* Single instance of the OpenCL language class. */ diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 6dd0b988a54..1acd591d41c 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -252,7 +252,6 @@ enum pascal_primitive_types { extern const struct language_data pascal_language_data = { - &exp_descriptor_standard, pascal_op_print_tab, /* expression operators for printing */ }; diff --git a/gdb/parse.c b/gdb/parse.c index 2fb474e27f1..37bafe4cf2d 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -762,8 +762,8 @@ void operator_length (const struct expression *expr, int endpos, int *oplenp, int *argsp) { - expr->language_defn->la_exp_desc->operator_length (expr, endpos, - oplenp, argsp); + expr->language_defn->expression_ops ()->operator_length (expr, endpos, + oplenp, argsp); } /* Default value for operator_length in exp_descriptor vectors. */ @@ -1374,8 +1374,9 @@ exp_iterate (struct expression *exp, gdb_assert (oplen > 0); pos = endpos - oplen; - if (exp->language_defn->la_exp_desc->operator_check (exp, pos, - objfile_func, data)) + if (exp->language_defn->expression_ops ()->operator_check (exp, pos, + objfile_func, + data)) return 1; endpos = pos; diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 96abca18241..8c952e394fb 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1901,7 +1901,6 @@ static const struct exp_descriptor exp_descriptor_rust = extern const struct language_data rust_language_data = { - &exp_descriptor_rust, c_op_print_tab, /* expression operators for printing */ }; @@ -2149,6 +2148,11 @@ public: bool range_checking_on_by_default () const override { return true; } + + /* See language.h. */ + + const struct exp_descriptor *expression_ops () const override + { return &exp_descriptor_rust; } }; /* Single instance of the Rust language class. */