gdb: Convert language la_lookup_symbol_nonlocal field to a method

This commit changes the language_data::la_lookup_symbol_nonlocal
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_lookup_symbol_nonlocal): Rename to
	ada_language::lookup_symbol_nonlocal.
	(ada_language_data): Delete la_lookup_symbol_nonlocal initializer.
	(ada_language::lookup_symbol_nonlocal): New member function,
	implementation from ada_lookup_symbol_nonlocal.
	* c-lang.c (c_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(cplus_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(cplus_language::lookup_symbol_nonlocal): New member function.
	(asm_language_data): Delete la_lookup_symbol_nonlocal initializer.
	(minimal_language_data) Likewise.
	* cp-namespace.c (cp_lookup_nested_symbol): Update comment.
	* d-lang.c (d_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(d_language::lookup_symbol_nonlocal): New member function.
	* f-lang.c (f_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(f_language::lookup_symbol_nonlocal): New member function.
	* go-lang.c (go_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete la_lookup_symbol_nonlocal
	field.
	(language_defn::lookup_symbol_nonlocal): New member function.
	* m2-lang.c (m2_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_lookup_symbol_nonlocal): Rename to
	rust_language::lookup_symbol_nonlocal.
	(rust_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(rust_language::lookup_symbol_nonlocal): New member function,
	implementation from rust_lookup_symbol_nonlocal.
	* symtab.c (lookup_symbol_aux): Update call to
	lookup_symbol_nonlocal.
	(basic_lookup_symbol_nonlocal): Rename to...
	(language_defn::lookup_symbol_nonlocal): ...this, and update
	header comment.  Remove language_defn parameter, and replace with
	uses of `this'.
	* symtab.h (basic_lookup_symbol_nonlocal): Delete declaration.
This commit is contained in:
Andrew Burgess
2020-06-01 22:17:59 +01:00
parent ebe2334ee6
commit a78a19b152
16 changed files with 171 additions and 128 deletions

@ -5764,46 +5764,6 @@ ada_lookup_symbol (const char *name, const struct block *block0,
return info;
}
static struct block_symbol
ada_lookup_symbol_nonlocal (const struct language_defn *langdef,
const char *name,
const struct block *block,
const domain_enum domain)
{
struct block_symbol sym;
sym = ada_lookup_symbol (name, block_static_block (block), domain);
if (sym.symbol != NULL)
return sym;
/* If we haven't found a match at this point, try the primitive
types. In other languages, this search is performed before
searching for global symbols in order to short-circuit that
global-symbol search if it happens that the name corresponds
to a primitive type. But we cannot do the same in Ada, because
it is perfectly legitimate for a program to declare a type which
has the same name as a standard type. If looking up a type in
that situation, we have traditionally ignored the primitive type
in favor of user-defined types. This is why, unlike most other
languages, we search the primitive types this late and only after
having searched the global symbols without success. */
if (domain == VAR_DOMAIN)
{
struct gdbarch *gdbarch;
if (block == NULL)
gdbarch = target_gdbarch ();
else
gdbarch = block_gdbarch (block);
sym.symbol = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name);
if (sym.symbol != NULL)
return sym;
}
return {};
}
/* True iff STR is a possible encoded suffix of a normal Ada name
that is to be ignored for matching purposes. Suffixes of parallel
@ -13766,7 +13726,6 @@ extern const struct language_data ada_language_data =
ada_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
true, /* la_store_sym_names_in_linkage_form_p */
ada_lookup_symbol_nonlocal, /* Looking up non-local symbols. */
ada_op_print_tab, /* expression operators for printing */
0, /* c-style arrays */
1, /* String lower bound */
@ -14116,6 +14075,47 @@ public:
return ada_value_print_inner (val, stream, recurse, options);
}
/* See language.h. */
struct block_symbol lookup_symbol_nonlocal
(const char *name, const struct block *block,
const domain_enum domain) const override
{
struct block_symbol sym;
sym = ada_lookup_symbol (name, block_static_block (block), domain);
if (sym.symbol != NULL)
return sym;
/* If we haven't found a match at this point, try the primitive
types. In other languages, this search is performed before
searching for global symbols in order to short-circuit that
global-symbol search if it happens that the name corresponds
to a primitive type. But we cannot do the same in Ada, because
it is perfectly legitimate for a program to declare a type which
has the same name as a standard type. If looking up a type in
that situation, we have traditionally ignored the primitive type
in favor of user-defined types. This is why, unlike most other
languages, we search the primitive types this late and only after
having searched the global symbols without success. */
if (domain == VAR_DOMAIN)
{
struct gdbarch *gdbarch;
if (block == NULL)
gdbarch = target_gdbarch ();
else
gdbarch = block_gdbarch (block);
sym.symbol
= language_lookup_primitive_type_as_symbol (this, gdbarch, name);
if (sym.symbol != NULL)
return sym;
}
return {};
}
protected:
/* See language.h. */