+2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * 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.
+
2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (ada_language_data): Remove la_name_of_this
extern const struct language_data ada_language_data =
{
- "ada", /* Language name */
- "Ada",
language_ada,
range_check_off,
case_sensitive_on, /* Yes, Ada is case-insensitive, but
: language_defn (language_ada, ada_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "ada"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Ada"; }
+
/* Print an array element index using the Ada syntax. */
void print_array_index (struct type *index_type,
extern const struct language_data c_language_data =
{
- "c", /* Language name */
- "C",
language_c,
range_check_off,
case_sensitive_on,
: language_defn (language_c, c_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "c"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "C"; }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
extern const struct language_data cplus_language_data =
{
- "c++", /* Language name */
- "C++",
language_cplus,
range_check_off,
case_sensitive_on,
/* See language.h. */
+ const char *name () const override
+ { return "c++"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "C++"; }
+
+ /* See language.h. */
+
struct language_pass_by_ref_info pass_by_reference_info
(struct type *type) const override
{
extern const struct language_data asm_language_data =
{
- "asm", /* Language name */
- "assembly",
language_asm,
range_check_off,
case_sensitive_on,
: language_defn (language_asm, asm_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "asm"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Assembly"; }
+
/* See language.h.
FIXME: Should this have its own arch info method? */
extern const struct language_data minimal_language_data =
{
- "minimal", /* Language name */
- "Minimal",
language_minimal,
range_check_off,
case_sensitive_on,
: language_defn (language_minimal, minimal_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "minimal"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Minimal"; }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
(current_language->get_compile_instance ());
if (compiler == nullptr)
error (_("No compiler support for language %s."),
- current_language->la_name);
+ current_language->name ());
compiler->set_print_callback (print_callback, NULL);
compiler->set_scope (scope);
compiler->set_block (expr_block);
extern const struct language_data d_language_data =
{
- "d",
- "D",
language_d,
range_check_off,
case_sensitive_on,
: language_defn (language_d, d_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "d"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "D"; }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
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 */
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");
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);
extern const struct language_data f_language_data =
{
- "fortran",
- "Fortran",
language_fortran,
range_check_on,
case_sensitive_off,
: language_defn (language_fortran, f_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "fortran"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Fortran"; }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
extern const struct language_data go_language_data =
{
- "go",
- "Go",
language_go,
range_check_off,
case_sensitive_on,
: language_defn (language_go, go_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "go"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Go"; }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
fprintf_filtered (gdb_stdout,
_("The current source language is "
"\"auto; currently %s\".\n"),
- current_language->la_name);
+ current_language->name ());
else
fprintf_filtered (gdb_stdout,
_("The current source language is \"%s\".\n"),
- current_language->la_name);
+ current_language->name ());
if (has_stack_frames ())
{
/* Search the list of languages for a match. */
for (const auto &lang : language_defn::languages)
{
- if (strcmp (lang->la_name, language) == 0)
+ if (strcmp (lang->name (), language) == 0)
{
/* Found it! Go into manual mode, and use this language. */
if (lang->la_language == language_auto)
language_enum (const char *str)
{
for (const auto &lang : language_defn::languages)
- if (strcmp (lang->la_name, str) == 0)
+ if (strcmp (lang->name (), str) == 0)
return lang->la_language;
if (strcmp (str, "local") == 0)
const char *
language_str (enum language lang)
{
- return language_def (lang)->la_name;
+ return language_def (lang)->name ();
}
\f
/* Display "auto", "local" and "unknown" first, and then the rest,
alpha sorted. */
const char **language_names_p = language_names;
- *language_names_p++ = language_def (language_auto)->la_name;
+ *language_names_p++ = language_def (language_auto)->name ();
*language_names_p++ = "local";
- *language_names_p++ = language_def (language_unknown)->la_name;
+ *language_names_p++ = language_def (language_unknown)->name ();
const char **sort_begin = language_names_p;
for (const auto &lang : language_defn::languages)
{
if (lang->la_language == language_auto
|| lang->la_language == language_unknown)
continue;
- *language_names_p++ = lang->la_name;
+ *language_names_p++ = lang->name ();
}
*language_names_p = NULL;
std::sort (sort_begin, language_names_p, compare_cstrings);
|| lang->la_language == language_auto)
continue;
- /* FIXME: i18n: for now assume that the human-readable name is
- just a capitalization of the internal name. */
/* Note that we add the newline at the front, so we don't wind
up with a trailing newline. */
- doc.printf ("\n%-16s Use the %c%s language",
- lang->la_name,
- /* Capitalize first letter of language name. */
- toupper (lang->la_name[0]),
- lang->la_name + 1);
+ doc.printf ("\n%-16s Use the %s language",
+ lang->name (),
+ lang->natural_name ());
}
add_setshow_enum_cmd ("language", class_support,
extern const struct language_data unknown_language_data =
{
- "unknown",
- "Unknown",
language_unknown,
range_check_off,
case_sensitive_on,
: language_defn (language_unknown, unknown_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "unknown"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Unknown"; }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
extern const struct language_data auto_language_data =
{
- "auto",
- "Auto",
language_auto,
range_check_off,
case_sensitive_on,
: language_defn (language_auto, auto_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "auto"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Auto"; }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
fprintf_unfiltered (gdb_stdlog,
"language_lookup_primitive_type_as_symbol"
" (%s, %s, %s)",
- la->la_name, host_address_to_string (gdbarch), name);
+ la->name (), host_address_to_string (gdbarch), name);
}
typep = language_lookup_primitive_type_1 (lai, name);
struct language_data
{
- /* Name of the language. */
-
- const char *la_name;
-
- /* Natural or official name of the language. */
-
- const char *la_natural_name;
-
/* its symtab language-enum (defs.h). */
enum language la_language;
languages[lang] = this;
}
+ /* Name of the language. */
+
+ virtual const char *name () const = 0;
+
+ /* Natural or official name of the language. */
+
+ virtual const char *natural_name () const = 0;
+
/* Print the index of an element of an array. This default
implementation prints using C99 syntax. */
extern const struct language_data m2_language_data =
{
- "modula-2",
- "Modula-2",
language_m2,
range_check_on,
case_sensitive_on,
: language_defn (language_m2, m2_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "modula-2"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Modula-2"; }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
lang = varobj_get_language (var);
- uiout->field_string ("lang", lang->la_natural_name);
+ uiout->field_string ("lang", lang->natural_name ());
std::string exp = varobj_get_expression (var);
uiout->field_string ("exp", exp.c_str ());
extern const struct language_data objc_language_data =
{
- "objective-c", /* Language name */
- "Objective-C",
language_objc,
range_check_off,
case_sensitive_on,
: language_defn (language_objc, objc_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "objective-c"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Objective-C"; }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
/* Constant data representing the OpenCL language. */
extern const struct language_data opencl_language_data =
{
- "opencl", /* Language name */
- "OpenCL C",
language_opencl,
range_check_off,
case_sensitive_on,
: language_defn (language_opencl, opencl_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "opencl"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "OpenCL C"; }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
extern const struct language_data pascal_language_data =
{
- "pascal", /* Language name */
- "Pascal",
language_pascal,
range_check_on,
case_sensitive_on,
: language_defn (language_pascal, pascal_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "pascal"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Pascal"; }
+
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
extern const struct language_data rust_language_data =
{
- "rust",
- "Rust",
language_rust,
range_check_on,
case_sensitive_on,
: language_defn (language_rust, rust_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "rust"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Rust"; }
+
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
fprintf_unfiltered (gdb_stdlog,
"lookup_language_this (%s, %s (objfile %s))",
- lang->la_name, host_address_to_string (block),
+ lang->name (), host_address_to_string (block),
objfile_debug_name (objfile));
}