gdb: Convert language la_print_type field to a method

This commit changes the language_data::la_print_type function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Delete la_print_type
	initializer.
	(ada_language::print_type): New member function.
	* c-lang.c (c_language_data): Delete la_print_type initializer.
	(c_language::print_type): New member function.
	(cplus_language_data): Delete la_print_type initializer.
	(cplus_language::print_type): New member function.
	(asm_language_data): Delete la_print_type initializer.
	(asm_language::print_type): New member function.
	(minimal_language_data): Delete la_print_type initializer.
	(minimal_language::print_type): New member function.
	* d-lang.c (d_language_data): Delete la_print_type initializer.
	(d_language::print_type): New member function.
	* f-lang.c (f_language_data): Delete la_print_type initializer.
	(f_language::print_type): New member function.
	* go-lang.c (go_language_data): Delete la_print_type initializer.
	(go_language::print_type): New member function.
	* language.c (unk_lang_print_type): Delete.
	(unknown_language_data): Delete la_print_type initializer.
	(unknown_language::print_type): New member function.
	(auto_language_data): Delete la_print_type initializer.
	(auto_language::print_type): New member function.
	* language.h (language_data): Delete la_print_type field.
	(language_defn::print_type): New function.
	(LA_PRINT_TYPE): Update.
	* m2-lang.c (m2_language_data): Delete la_print_type initializer.
	(m2_language::print_type): New member function.
	* objc-lang.c (objc_language_data): Delete la_print_type
	initializer.
	(objc_language::print_type): New member function.
	* opencl-lang.c (opencl_print_type): Delete, implementation moved
	to opencl_language::print_type.
	(opencl_language_data): Delete la_print_type initializer.
	(opencl_language::print_type): New member function, implementation
	from opencl_print_type.
	* p-lang.c (pascal_language_data): Delete la_print_type
	initializer.
	(pascal_language::print_type): New member function.
	* rust-lang.c (rust_print_type): Delete, implementation moved to
	rust_language::print_type.
	(rust_language_data): Delete la_print_type initializer.
	(rust_language::print_type): New member function, implementation
	from rust_print_type.
This commit is contained in:
Andrew Burgess 2020-05-14 18:41:39 +01:00
parent 6f8270197a
commit fbfb0a463f
13 changed files with 200 additions and 61 deletions

View File

@ -1,3 +1,49 @@
2020-06-02 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (ada_language_data): Delete la_print_type
initializer.
(ada_language::print_type): New member function.
* c-lang.c (c_language_data): Delete la_print_type initializer.
(c_language::print_type): New member function.
(cplus_language_data): Delete la_print_type initializer.
(cplus_language::print_type): New member function.
(asm_language_data): Delete la_print_type initializer.
(asm_language::print_type): New member function.
(minimal_language_data): Delete la_print_type initializer.
(minimal_language::print_type): New member function.
* d-lang.c (d_language_data): Delete la_print_type initializer.
(d_language::print_type): New member function.
* f-lang.c (f_language_data): Delete la_print_type initializer.
(f_language::print_type): New member function.
* go-lang.c (go_language_data): Delete la_print_type initializer.
(go_language::print_type): New member function.
* language.c (unk_lang_print_type): Delete.
(unknown_language_data): Delete la_print_type initializer.
(unknown_language::print_type): New member function.
(auto_language_data): Delete la_print_type initializer.
(auto_language::print_type): New member function.
* language.h (language_data): Delete la_print_type field.
(language_defn::print_type): New function.
(LA_PRINT_TYPE): Update.
* m2-lang.c (m2_language_data): Delete la_print_type initializer.
(m2_language::print_type): New member function.
* objc-lang.c (objc_language_data): Delete la_print_type
initializer.
(objc_language::print_type): New member function.
* opencl-lang.c (opencl_print_type): Delete, implementation moved
to opencl_language::print_type.
(opencl_language_data): Delete la_print_type initializer.
(opencl_language::print_type): New member function, implementation
from opencl_print_type.
* p-lang.c (pascal_language_data): Delete la_print_type
initializer.
(pascal_language::print_type): New member function.
* rust-lang.c (rust_print_type): Delete, implementation moved to
rust_language::print_type.
(rust_language_data): Delete la_print_type initializer.
(rust_language::print_type): New member function, implementation
from rust_print_type.
2020-06-02 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (ada_sniff_from_mangled_name): Delete function,

View File

@ -13919,7 +13919,6 @@ extern const struct language_data ada_language_data =
ada_printchar, /* Print a character constant */
ada_printstr, /* Function to print string constant */
emit_char, /* Function to print single char (not used) */
ada_print_type, /* Print a type using appropriate syntax */
ada_print_typedef, /* Print a typedef using appropriate syntax */
ada_value_print_inner, /* la_value_print_inner */
ada_value_print, /* Print a top-level value */
@ -14106,6 +14105,15 @@ public:
return false;
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
ada_print_type (type, varstring, stream, show, level, flags);
}
};
/* Single instance of the Ada language class. */

View File

@ -905,7 +905,6 @@ extern const struct language_data c_language_data =
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
c_emit_char, /* Print a single char */
c_print_type, /* Print a type using appropriate syntax */
c_print_typedef, /* Print a typedef using appropriate syntax */
c_value_print_inner, /* la_value_print_inner */
c_value_print, /* Print a top-level value */
@ -950,6 +949,15 @@ public:
{
return c_get_compile_context ();
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
c_print_type (type, varstring, stream, show, level, flags);
}
};
/* Single instance of the C language class. */
@ -1007,7 +1015,6 @@ extern const struct language_data cplus_language_data =
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
c_emit_char, /* Print a single char */
c_print_type, /* Print a type using appropriate syntax */
c_print_typedef, /* Print a typedef using appropriate syntax */
c_value_print_inner, /* la_value_print_inner */
c_value_print, /* Print a top-level value */
@ -1136,6 +1143,15 @@ public:
*demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
return *demangled != NULL;
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
c_print_type (type, varstring, stream, show, level, flags);
}
};
/* The single instance of the C++ language class. */
@ -1165,7 +1181,6 @@ extern const struct language_data asm_language_data =
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
c_emit_char, /* Print a single char */
c_print_type, /* Print a type using appropriate syntax */
c_print_typedef, /* Print a typedef using appropriate syntax */
c_value_print_inner, /* la_value_print_inner */
c_value_print, /* Print a top-level value */
@ -1206,6 +1221,15 @@ public:
{
c_language_arch_info (gdbarch, lai);
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
c_print_type (type, varstring, stream, show, level, flags);
}
};
/* The single instance of the ASM language class. */
@ -1232,7 +1256,6 @@ extern const struct language_data minimal_language_data =
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
c_emit_char, /* Print a single char */
c_print_type, /* Print a type using appropriate syntax */
c_print_typedef, /* Print a typedef using appropriate syntax */
c_value_print_inner, /* la_value_print_inner */
c_value_print, /* Print a top-level value */
@ -1271,6 +1294,15 @@ public:
{
c_language_arch_info (gdbarch, lai);
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
c_print_type (type, varstring, stream, show, level, flags);
}
};
/* The single instance of the minimal language class. */

View File

@ -147,7 +147,6 @@ extern const struct language_data d_language_data =
c_printchar, /* Print a character constant. */
c_printstr, /* Function to print string constant. */
c_emit_char, /* Print a single char. */
c_print_type, /* Print a type using appropriate syntax. */
c_print_typedef, /* Print a typedef using appropriate
syntax. */
d_value_print_inner, /* la_value_print_inner */
@ -252,6 +251,15 @@ public:
*demangled = d_demangle (mangled, 0);
return *demangled != NULL;
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
c_print_type (type, varstring, stream, show, level, flags);
}
};
/* Single instance of the D language class. */

View File

@ -608,7 +608,6 @@ extern const struct language_data f_language_data =
f_printchar, /* Print character constant */
f_printstr, /* function to print string constant */
f_emit_char, /* Function to print a single character */
f_print_type, /* Print a type using appropriate syntax */
f_print_typedef, /* Print a typedef using appropriate syntax */
f_value_print_innner, /* la_value_print_inner */
c_value_print, /* FIXME */
@ -690,6 +689,15 @@ public:
{
return cp_search_name_hash (name);
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
f_print_type (type, varstring, stream, show, level, flags);
}
};
/* Single instance of the Fortran language class. */

View File

@ -532,7 +532,6 @@ extern const struct language_data go_language_data =
c_printchar, /* Print a character constant. */
c_printstr, /* Function to print string constant. */
c_emit_char, /* Print a single char. */
go_print_type, /* Print a type using appropriate syntax. */
c_print_typedef, /* Print a typedef using appropriate
syntax. */
go_value_print_inner, /* la_value_print_inner */
@ -626,6 +625,15 @@ public:
*demangled = go_demangle (mangled, 0);
return *demangled != NULL;
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
go_print_type (type, varstring, stream, show, level, flags);
}
};
/* Single instance of the Go language class. */

View File

@ -727,15 +727,6 @@ unk_lang_printstr (struct ui_file *stream, struct type *type,
"function unk_lang_printstr called."));
}
static void
unk_lang_print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags)
{
error (_("internal error - unimplemented "
"function unk_lang_print_type called."));
}
static void
unk_lang_value_print_inner (struct value *val,
struct ui_file *stream, int recurse,
@ -802,7 +793,6 @@ extern const struct language_data unknown_language_data =
unk_lang_printchar, /* Print character constant */
unk_lang_printstr,
unk_lang_emit_char,
unk_lang_print_type, /* Print a type using appropriate syntax */
default_print_typedef, /* Print a typedef using appropriate syntax */
unk_lang_value_print_inner, /* la_value_print_inner */
unk_lang_value_print, /* Print a top-level value */
@ -841,6 +831,15 @@ public:
{
unknown_language_arch_info (gdbarch, lai);
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
error (_("unimplemented unknown_language::print_type called"));
}
};
/* Single instance of the unknown language class. */
@ -865,7 +864,6 @@ extern const struct language_data auto_language_data =
unk_lang_printchar, /* Print character constant */
unk_lang_printstr,
unk_lang_emit_char,
unk_lang_print_type, /* Print a type using appropriate syntax */
default_print_typedef, /* Print a typedef using appropriate syntax */
unk_lang_value_print_inner, /* la_value_print_inner */
unk_lang_value_print, /* Print a top-level value */
@ -904,6 +902,15 @@ public:
{
unknown_language_arch_info (gdbarch, lai);
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
error (_("unimplemented auto_language::print_type called"));
}
};
/* Single instance of the fake "auto" language. */

View File

@ -248,11 +248,6 @@ struct language_data
void (*la_emitchar) (int ch, struct type *chtype,
struct ui_file * stream, int quoter);
/* Print a type using syntax appropriate for this language. */
void (*la_print_type) (struct type *, const char *, struct ui_file *, int,
int, const struct type_print_options *);
/* Print a typedef using syntax appropriate for this language.
TYPE is the underlying type. NEW_SYMBOL is the symbol naming
the type. STREAM is the output stream on which to print. */
@ -517,6 +512,11 @@ struct language_defn : language_data
return false;
}
/* Print a type using syntax appropriate for this language. */
virtual void print_type (struct type *, const char *, struct ui_file *, int,
int, const struct type_print_options *) const = 0;
/* List of all known languages. */
static const struct language_defn *languages[nr_languages];
};
@ -605,7 +605,7 @@ extern enum language set_language (enum language);
with the "set language" command. */
#define LA_PRINT_TYPE(type,varstring,stream,show,level,flags) \
(current_language->la_print_type(type,varstring,stream,show,level,flags))
(current_language->print_type(type,varstring,stream,show,level,flags))
#define LA_PRINT_TYPEDEF(type,new_symbol,stream) \
(current_language->la_print_typedef(type,new_symbol,stream))

View File

@ -367,7 +367,6 @@ extern const struct language_data m2_language_data =
m2_printchar, /* Print character constant */
m2_printstr, /* function to print string constant */
m2_emit_char, /* Function to print a single character */
m2_print_type, /* Print a type using appropriate syntax */
m2_print_typedef, /* Print a typedef using appropriate syntax */
m2_value_print_inner, /* la_value_print_inner */
c_value_print, /* Print a top-level value */
@ -425,6 +424,15 @@ public:
lai->bool_type_symbol = "BOOLEAN";
lai->bool_type_default = builtin->builtin_bool;
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
m2_print_type (type, varstring, stream, show, level, flags);
}
};
/* Single instance of the M2 language. */

View File

@ -373,7 +373,6 @@ extern const struct language_data objc_language_data =
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
c_emit_char,
c_print_type, /* Print a type using appropriate syntax */
c_print_typedef, /* Print a typedef using appropriate syntax */
c_value_print_inner, /* la_value_print_inner */
c_value_print, /* Print a top-level value */
@ -420,6 +419,15 @@ public:
*demangled = objc_demangle (mangled, 0);
return *demangled != NULL;
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
c_print_type (type, varstring, stream, show, level, flags);
}
};
/* Single instance of the class representing the Objective-C language. */

View File

@ -994,27 +994,6 @@ Cannot perform conditional operation on vectors with different sizes"));
return evaluate_subexp_c (expect_type, exp, pos, noside);
}
/* Print OpenCL types. */
static void
opencl_print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags)
{
/* We nearly always defer to C type printing, except that vector
types are considered primitive in OpenCL, and should always
be printed using their TYPE_NAME. */
if (show > 0)
{
type = check_typedef (type);
if (type->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type)
&& type->name () != NULL)
show = 0;
}
c_print_type (type, varstring, stream, show, level, flags);
}
const struct exp_descriptor exp_descriptor_opencl =
{
print_subexp_standard,
@ -1042,7 +1021,6 @@ extern const struct language_data opencl_language_data =
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
c_emit_char, /* Print a single char */
opencl_print_type, /* Print a type using appropriate syntax */
c_print_typedef, /* Print a typedef using appropriate syntax */
c_value_print_inner, /* la_value_print_inner */
c_value_print, /* Print a top-level value */
@ -1091,6 +1069,26 @@ public:
lai->bool_type_symbol = "int";
lai->bool_type_default = types [opencl_primitive_type_int];
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
/* We nearly always defer to C type printing, except that vector types
are considered primitive in OpenCL, and should always be printed
using their TYPE_NAME. */
if (show > 0)
{
type = check_typedef (type);
if (type->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type)
&& type->name () != NULL)
show = 0;
}
c_print_type (type, varstring, stream, show, level, flags);
}
};
/* Single instance of the OpenCL language class. */

View File

@ -398,7 +398,6 @@ extern const struct language_data pascal_language_data =
pascal_printchar, /* Print a character constant */
pascal_printstr, /* Function to print string constant */
pascal_emit_char, /* Print a single char */
pascal_print_type, /* Print a type using appropriate syntax */
pascal_print_typedef, /* Print a typedef using appropriate syntax */
pascal_value_print_inner, /* la_value_print_inner */
pascal_value_print, /* Print a top-level value */
@ -478,6 +477,15 @@ public:
lai->bool_type_symbol = "boolean";
lai->bool_type_default = builtin->builtin_bool;
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
pascal_print_type (type, varstring, stream, show, level, flags);
}
};
/* Single instance of the Pascal language class. */

View File

@ -951,16 +951,6 @@ rust_internal_print_type (struct type *type, const char *varstring,
}
}
static void
rust_print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags)
{
print_offset_data podata;
rust_internal_print_type (type, varstring, stream, show, level,
flags, false, &podata);
}
/* Like arch_composite_type, but uses TYPE to decide how to allocate
@ -2063,7 +2053,6 @@ extern const struct language_data rust_language_data =
rust_printchar, /* Print a character constant */
rust_printstr, /* Function to print string constant */
rust_emitchar, /* Print a single char */
rust_print_type, /* Print a type using appropriate syntax */
rust_print_typedef, /* Print a typedef using appropriate syntax */
rust_value_print_inner, /* la_value_print_inner */
c_value_print, /* Print a top-level value */
@ -2144,6 +2133,17 @@ public:
*demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
return *demangled != NULL;
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
print_offset_data podata;
rust_internal_print_type (type, varstring, stream, show, level,
flags, false, &podata);
}
};
/* Single instance of the Rust language class. */