diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-06-23 20:07:09 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-09-16 10:16:45 +0100 |
commit | 6f7664a9c33b110248d0fb68bcc41fdb48396c51 (patch) | |
tree | fe43babfa27c4ee8bfe20dbb3bbf9f5725a5d4b2 /gdb/expprint.c | |
parent | 5bae7c4e048c69fe6eae96596c800a92b643f563 (diff) | |
download | fsf-binutils-gdb-6f7664a9c33b110248d0fb68bcc41fdb48396c51.zip fsf-binutils-gdb-6f7664a9c33b110248d0fb68bcc41fdb48396c51.tar.gz fsf-binutils-gdb-6f7664a9c33b110248d0fb68bcc41fdb48396c51.tar.bz2 |
gdb: Convert la_name and la_natural_name to methods
Convert the two language_data member variables la_name and
la_natural_name to virtual methods in language_defn struct called name
and natural_name respectively.
The virtual methods in the language_defn base class are pure virtual,
as every language must implement these, and as every language has a
unique name there's no sensible default here.
Given that every language must implement these methods I did wonder
about making this data passed into the base class constructor, but in
the end I went with the virtual method approach. I'm open to changing
this approach if people prefer the constructor approach.
During updating the calls to language_defn::name I found in
add_set_language_command a place where we took la_name and then
capitalised the first letter to create a language name that could be
used in the documentation string. I replaced this with a use of
natural_name instead as this seemed a better choice, in most cases
this will make no difference, as for most languages the natural_name
is just the name with the first character in upper case, but for some
languages, for example 'Open-CL' and 'Objective-C' this is not the
case.
In the case of asm_language the name is 'asm', while the natural_name
was previously 'assembly'. I changed the natural name to 'Assembly',
this makes the documentation string case above cleaner, however, this
will change the MI output for -var-info-expression, where the 'lang'
field will change from 'assembly' to 'Assembly'. It is possible this
could be a breaking change if a front-end is relying on the existing
name.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove la_name and
la_natural_name initializers.
(ada_language::name): New member function.
(ada_language::natural_name): New member function.
* c-lang.c (c_language_data): Remove la_name and
la_natural_name initializers.
(c_language::name): New member function.
(c_language::natural_name): New member function.
(cplus_language_data): Remove la_name and
la_natural_name initializers.
(cplus_language::name): New member function.
(cplus_language::natural_name): New member function.
(asm_language_data): Remove la_name and
la_natural_name initializers.
(asm_language::name): New member function.
(asm_language::natural_name): New member function.
(minimal_language_data): Remove la_name and
la_natural_name initializers.
(minimal_language::name): New member function.
(minimal_language::natural_name): New member function.
* compile/compile.c (compile_to_object): Update call to
lanugage_defn::name.
* d-lang.c (d_language_data): Remove la_name and
la_natural_name initializers.
(d_language::name): New member function.
(d_language::natural_name): New member function.
* expprint.c (print_subexp_standard): Update call to
language_defn::name.
(dump_raw_expression): Likewise
(dump_prefix_expression): Likewise.
* f-lang.c (f_language_data): Remove la_name and
la_natural_name initializers.
(f_language::name): New member function.
(f_language::natural_name): New member function.
* go-lang.c (go_language_data): Remove la_name and
la_natural_name initializers.
(go_language::name): New member function.
(go_language::natural_name): New member function.
* language.c (show_language_command): Update call to
language_defn::name.
(set_language_command): Likewise.
(language_enum): Likewise.
(language_str): Likewise.
(add_set_language_command): Likewise, use
language_defn::natural_name in the doc string.
(unknown_language_data): Remove la_name and
la_natural_name initializers.
(unknown_language::name): New member function.
(unknown_language::natural_name): New member function.
(auto_language_data): Remove la_name and
la_natural_name initializers.
(auto_language::name): New member function.
(auto_language::natural_name): New member function.
(language_lookup_primitive_type_as_symbol): Update call to
language_defn::name.
* language.h (language_data): Remove la_name and la_natural_name
member variables.
(language_defn::name): New member function.
(language_defn::natural_name): New member function.
* m2-lang.c (m2_language_data): Remove la_name and
la_natural_name initializers.
(m2_language::name): New member function.
(m2_language::natural_name): New member function.
* mi/mi-cmd-var.c (mi_cmd_var_info_expression): Update call to
language_defn::natural_name.
* objc-lang.c (objc_language_data): Remove la_name and
la_natural_name initializers.
(objc_language::name): New member function.
(objc_language::natural_name): New member function.
* opencl-lang.c (opencl_language_data): Remove la_name and
la_natural_name initializers.
(opencl_language::name): New member function.
(opencl_language::natural_name): New member function.
* p-lang.c (pascal_language_data): Remove la_name and
la_natural_name initializers.
(pascal_language::name): New member function.
(pascal_language::natural_name): New member function.
* rust-lang.c (rust_language_data): Remove la_name and
la_natural_name initializers.
(rust_language::name): New member function.
(rust_language::natural_name): New member function.
* symtab.c (lookup_language_this): Update call to
language_defn::name.
Diffstat (limited to 'gdb/expprint.c')
-rw-r--r-- | gdb/expprint.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gdb/expprint.c b/gdb/expprint.c index 24d647e..36e18ea 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -509,7 +509,7 @@ print_subexp_standard (struct expression *exp, int *pos, else fprintf_styled (stream, metadata_style.style (), _("<language %s has no 'this'>"), - exp->language_defn->la_name); + exp->language_defn->name ()); return; /* Modula-2 ops */ @@ -734,7 +734,7 @@ dump_raw_expression (struct expression *exp, struct ui_file *stream, if (note) fprintf_filtered (stream, ", %s:", note); fprintf_filtered (stream, "\n\tLanguage %s, %d elements, %ld bytes each.\n", - exp->language_defn->la_name, exp->nelts, + exp->language_defn->name (), exp->nelts, (long) sizeof (union exp_element)); fprintf_filtered (stream, "\t%5s %20s %16s %s\n", "Index", "Opcode", "Hex Value", "String Value"); @@ -1159,7 +1159,7 @@ dump_prefix_expression (struct expression *exp, struct ui_file *stream) fputs_filtered (", after conversion to prefix form:\nExpression: `", stream); print_expression (exp, stream); fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n", - exp->language_defn->la_name, exp->nelts, + exp->language_defn->name (), exp->nelts, (long) sizeof (union exp_element)); fputs_filtered ("\n", stream); |