gdb: Convert language la_parser field to a method

This commit changes the language_data::la_parser 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 (parse): Rename to ada_language::parser.
	(ada_language_data): Delete la_parser initializer.
	(ada_language::parser): New member function, implementation from
	parse.
	* c-lang.c (c_language_data): Delete la_parser initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	(d_language::parser): New member function.
	* f-lang.c (f_language_data): Delete la_parser initializer.
	(f_language::parser): New member function.
	* go-lang.c (go_language_data): Delete la_parser initializer.
	(go_language::parser): New member function.
	* language.c (unk_lang_parser): Delete.
	(language_defn::parser): Define new member function.
	(unknown_language_data): Delete la_parser initializer.
	(unknown_language::parser): New member function.
	(auto_language_data): Delete la_parser initializer.
	(auto_language::parser): New member function.
	* language.h (language_data): Delete la_parser field.
	(language_defn::parser): Declare new member function.
	* m2-lang.c (m2_language_data): Delete la_parser initializer.
	(m2_language::parser): New member function.
	* objc-lang.c (objc_language_data): Delete la_parser initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	(pascal_language::parser): New member function.
	* parse.c (parse_exp_in_context): Update call to parser.
	* rust-lang.c (rust_language_data): Delete la_parser initializer.
	(rust_language::parser): New member function.
This commit is contained in:
Andrew Burgess 2020-06-02 14:48:04 +01:00
parent 3084d7a27b
commit 87afa6523b
14 changed files with 113 additions and 35 deletions

View file

@ -1,3 +1,37 @@
2020-06-23 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (parse): Rename to ada_language::parser.
(ada_language_data): Delete la_parser initializer.
(ada_language::parser): New member function, implementation from
parse.
* c-lang.c (c_language_data): Delete la_parser initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
(d_language::parser): New member function.
* f-lang.c (f_language_data): Delete la_parser initializer.
(f_language::parser): New member function.
* go-lang.c (go_language_data): Delete la_parser initializer.
(go_language::parser): New member function.
* language.c (unk_lang_parser): Delete.
(language_defn::parser): Define new member function.
(unknown_language_data): Delete la_parser initializer.
(unknown_language::parser): New member function.
(auto_language_data): Delete la_parser initializer.
(auto_language::parser): New member function.
* language.h (language_data): Delete la_parser field.
(language_defn::parser): Declare new member function.
* m2-lang.c (m2_language_data): Delete la_parser initializer.
(m2_language::parser): New member function.
* objc-lang.c (objc_language_data): Delete la_parser initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::parser): New member function.
* parse.c (parse_exp_in_context): Update call to parser.
* rust-lang.c (rust_language_data): Delete la_parser initializer.
(rust_language::parser): New member function.
2020-06-23 Andrew Burgess <andrew.burgess@embecosm.com> 2020-06-23 Andrew Burgess <andrew.burgess@embecosm.com>
* top.c (print_gdb_configuration): Print --with-python-libdir * top.c (print_gdb_configuration): Print --with-python-libdir

View file

@ -13534,13 +13534,6 @@ emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
ada_emit_char (c, type, stream, quoter, 1); ada_emit_char (c, type, stream, quoter, 1);
} }
static int
parse (struct parser_state *ps)
{
warnings_issued = 0;
return ada_parse (ps);
}
static const struct exp_descriptor ada_exp_descriptor = { static const struct exp_descriptor ada_exp_descriptor = {
ada_print_subexp, ada_print_subexp,
ada_operator_length, ada_operator_length,
@ -13718,7 +13711,6 @@ extern const struct language_data ada_language_data =
macro_expansion_no, macro_expansion_no,
ada_extensions, ada_extensions,
&ada_exp_descriptor, &ada_exp_descriptor,
parse,
resolve, resolve,
ada_printchar, /* Print a character constant */ ada_printchar, /* Print a character constant */
ada_printstr, /* Function to print string constant */ ada_printstr, /* Function to print string constant */
@ -14116,6 +14108,14 @@ public:
return {}; return {};
} }
/* See language.h. */
int parser (struct parser_state *ps) const override
{
warnings_issued = 0;
return ada_parse (ps);
}
protected: protected:
/* See language.h. */ /* See language.h. */

View file

@ -889,7 +889,6 @@ extern const struct language_data c_language_data =
macro_expansion_c, macro_expansion_c,
c_extensions, c_extensions,
&exp_descriptor_c, &exp_descriptor_c,
c_parse,
null_post_parser, null_post_parser,
c_printchar, /* Print a character constant */ c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */ c_printstr, /* Function to print string constant */
@ -997,7 +996,6 @@ extern const struct language_data cplus_language_data =
macro_expansion_c, macro_expansion_c,
cplus_extensions, cplus_extensions,
&exp_descriptor_c, &exp_descriptor_c,
c_parse,
null_post_parser, null_post_parser,
c_printchar, /* Print a character constant */ c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */ c_printstr, /* Function to print string constant */
@ -1202,7 +1200,6 @@ extern const struct language_data asm_language_data =
macro_expansion_c, macro_expansion_c,
asm_extensions, asm_extensions,
&exp_descriptor_c, &exp_descriptor_c,
c_parse,
null_post_parser, null_post_parser,
c_printchar, /* Print a character constant */ c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */ c_printstr, /* Function to print string constant */
@ -1265,7 +1262,6 @@ extern const struct language_data minimal_language_data =
macro_expansion_c, macro_expansion_c,
NULL, NULL,
&exp_descriptor_c, &exp_descriptor_c,
c_parse,
null_post_parser, null_post_parser,
c_printchar, /* Print a character constant */ c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */ c_printstr, /* Function to print string constant */

View file

@ -142,7 +142,6 @@ extern const struct language_data d_language_data =
macro_expansion_no, macro_expansion_no,
d_extensions, d_extensions,
&exp_descriptor_c, &exp_descriptor_c,
d_parse,
null_post_parser, null_post_parser,
c_printchar, /* Print a character constant. */ c_printchar, /* Print a character constant. */
c_printstr, /* Function to print string constant. */ c_printstr, /* Function to print string constant. */
@ -273,6 +272,13 @@ public:
{ {
return d_lookup_symbol_nonlocal (this, name, block, domain); return d_lookup_symbol_nonlocal (this, name, block, domain);
} }
/* See language.h. */
int parser (struct parser_state *ps) const override
{
return d_parse (ps);
}
}; };
/* Single instance of the D language class. */ /* Single instance of the D language class. */

View file

@ -564,7 +564,6 @@ extern const struct language_data f_language_data =
macro_expansion_no, macro_expansion_no,
f_extensions, f_extensions,
&exp_descriptor_f, &exp_descriptor_f,
f_parse, /* parser */
null_post_parser, null_post_parser,
f_printchar, /* Print character constant */ f_printchar, /* Print character constant */
f_printstr, /* function to print string constant */ f_printstr, /* function to print string constant */
@ -713,6 +712,13 @@ public:
return cp_lookup_symbol_nonlocal (this, name, block, domain); return cp_lookup_symbol_nonlocal (this, name, block, domain);
} }
/* See language.h. */
int parser (struct parser_state *ps) const override
{
return f_parse (ps);
}
protected: protected:
/* See language.h. */ /* See language.h. */

View file

@ -527,7 +527,6 @@ extern const struct language_data go_language_data =
macro_expansion_no, macro_expansion_no,
NULL, NULL,
&exp_descriptor_c, &exp_descriptor_c,
go_parse,
null_post_parser, null_post_parser,
c_printchar, /* Print a character constant. */ c_printchar, /* Print a character constant. */
c_printstr, /* Function to print string constant. */ c_printstr, /* Function to print string constant. */
@ -638,6 +637,13 @@ public:
{ {
return go_value_print_inner (val, stream, recurse, options); return go_value_print_inner (val, stream, recurse, options);
} }
/* See language.h. */
int parser (struct parser_state *ps) const override
{
return go_parse (ps);
}
}; };
/* Single instance of the Go language class. */ /* Single instance of the Go language class. */

View file

@ -47,8 +47,6 @@
#include <algorithm> #include <algorithm>
#include "gdbarch.h" #include "gdbarch.h"
static int unk_lang_parser (struct parser_state *);
static void set_range_case (void); static void set_range_case (void);
static void unk_lang_emit_char (int c, struct type *type, static void unk_lang_emit_char (int c, struct type *type,
@ -643,6 +641,14 @@ language_defn::value_print (struct value *val, struct ui_file *stream,
/* See language.h. */ /* See language.h. */
int
language_defn::parser (struct parser_state *ps) const
{
return c_parse (ps);
}
/* See language.h. */
void void
language_defn::value_print_inner language_defn::value_print_inner
(struct value *val, struct ui_file *stream, int recurse, (struct value *val, struct ui_file *stream, int recurse,
@ -718,12 +724,6 @@ default_is_string_type_p (struct type *type)
/* Define the language that is no language. */ /* Define the language that is no language. */
static int
unk_lang_parser (struct parser_state *ps)
{
return 1;
}
static void static void
unk_lang_emit_char (int c, struct type *type, struct ui_file *stream, unk_lang_emit_char (int c, struct type *type, struct ui_file *stream,
int quoter) int quoter)
@ -777,7 +777,6 @@ extern const struct language_data unknown_language_data =
macro_expansion_no, macro_expansion_no,
NULL, NULL,
&exp_descriptor_standard, &exp_descriptor_standard,
unk_lang_parser,
null_post_parser, null_post_parser,
unk_lang_printchar, /* Print character constant */ unk_lang_printchar, /* Print character constant */
unk_lang_printstr, unk_lang_printstr,
@ -842,6 +841,14 @@ public:
{ {
error (_("unimplemented unknown_language::value_print_inner called")); error (_("unimplemented unknown_language::value_print_inner called"));
} }
/* See language.h. */
int parser (struct parser_state *ps) const override
{
/* No parsing is done, just claim success. */
return 1;
}
}; };
/* Single instance of the unknown language class. */ /* Single instance of the unknown language class. */
@ -861,7 +868,6 @@ extern const struct language_data auto_language_data =
macro_expansion_no, macro_expansion_no,
NULL, NULL,
&exp_descriptor_standard, &exp_descriptor_standard,
unk_lang_parser,
null_post_parser, null_post_parser,
unk_lang_printchar, /* Print character constant */ unk_lang_printchar, /* Print character constant */
unk_lang_printstr, unk_lang_printstr,
@ -926,6 +932,14 @@ public:
{ {
error (_("unimplemented auto_language::value_print_inner called")); error (_("unimplemented auto_language::value_print_inner called"));
} }
/* See language.h. */
int parser (struct parser_state *ps) const override
{
/* No parsing is done, just claim success. */
return 1;
}
}; };
/* Single instance of the fake "auto" language. */ /* Single instance of the fake "auto" language. */

View file

@ -225,10 +225,6 @@ struct language_data
const struct exp_descriptor *la_exp_desc; const struct exp_descriptor *la_exp_desc;
/* Parser function. */
int (*la_parser) (struct parser_state *);
/* Given an expression *EXPP created by prefixifying the result of /* Given an expression *EXPP created by prefixifying the result of
la_parser, perform any remaining processing necessary to complete la_parser, perform any remaining processing necessary to complete
its translation. *EXPP may change; la_post_parser is responsible its translation. *EXPP may change; la_post_parser is responsible
@ -540,6 +536,10 @@ struct language_defn : language_data
(struct value *val, struct ui_file *stream, int recurse, (struct value *val, struct ui_file *stream, int recurse,
const struct value_print_options *options) const; const struct value_print_options *options) const;
/* Parser function. */
virtual int parser (struct parser_state *ps) const;
protected: protected:
/* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method. /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.

View file

@ -362,7 +362,6 @@ extern const struct language_data m2_language_data =
macro_expansion_no, macro_expansion_no,
NULL, NULL,
&exp_descriptor_modula2, &exp_descriptor_modula2,
m2_parse, /* parser */
null_post_parser, null_post_parser,
m2_printchar, /* Print character constant */ m2_printchar, /* Print character constant */
m2_printstr, /* function to print string constant */ m2_printstr, /* function to print string constant */
@ -430,6 +429,13 @@ public:
{ {
return m2_value_print_inner (val, stream, recurse, options); return m2_value_print_inner (val, stream, recurse, options);
} }
/* See language.h. */
int parser (struct parser_state *ps) const override
{
return m2_parse (ps);
}
}; };
/* Single instance of the M2 language. */ /* Single instance of the M2 language. */

View file

@ -337,7 +337,6 @@ extern const struct language_data objc_language_data =
macro_expansion_c, macro_expansion_c,
objc_extensions, objc_extensions,
&exp_descriptor_standard, &exp_descriptor_standard,
c_parse,
null_post_parser, null_post_parser,
c_printchar, /* Print a character constant */ c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */ c_printstr, /* Function to print string constant */

View file

@ -1016,7 +1016,6 @@ extern const struct language_data opencl_language_data =
macro_expansion_c, macro_expansion_c,
NULL, NULL,
&exp_descriptor_opencl, &exp_descriptor_opencl,
c_parse,
null_post_parser, null_post_parser,
c_printchar, /* Print a character constant */ c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */ c_printstr, /* Function to print string constant */

View file

@ -393,7 +393,6 @@ extern const struct language_data pascal_language_data =
macro_expansion_no, macro_expansion_no,
p_extensions, p_extensions,
&exp_descriptor_standard, &exp_descriptor_standard,
pascal_parse,
null_post_parser, null_post_parser,
pascal_printchar, /* Print a character constant */ pascal_printchar, /* Print a character constant */
pascal_printstr, /* Function to print string constant */ pascal_printstr, /* Function to print string constant */
@ -492,6 +491,13 @@ public:
{ {
return pascal_value_print_inner (val, stream, recurse, options); return pascal_value_print_inner (val, stream, recurse, options);
} }
/* See language.h. */
int parser (struct parser_state *ps) const override
{
return pascal_parse (ps);
}
}; };
/* Single instance of the Pascal language class. */ /* Single instance of the Pascal language class. */

View file

@ -1119,7 +1119,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
try try
{ {
lang->la_parser (&ps); lang->parser (&ps);
} }
catch (const gdb_exception &except) catch (const gdb_exception &except)
{ {

View file

@ -1989,7 +1989,6 @@ extern const struct language_data rust_language_data =
macro_expansion_no, macro_expansion_no,
rust_extensions, rust_extensions,
&exp_descriptor_rust, &exp_descriptor_rust,
rust_parse,
null_post_parser, null_post_parser,
rust_printchar, /* Print a character constant */ rust_printchar, /* Print a character constant */
rust_printstr, /* Function to print string constant */ rust_printstr, /* Function to print string constant */
@ -2142,6 +2141,13 @@ public:
} }
return result; return result;
} }
/* See language.h. */
int parser (struct parser_state *ps) const override
{
return rust_parse (ps);
}
}; };
/* Single instance of the Rust language class. */ /* Single instance of the Rust language class. */