Give a language to a type

This changes main_type to hold a language, and updates the debug
readers to set this field.  This is done by adding the language to the
type-allocator object.

Note that the non-DWARF readers are changed on a "best effort" basis.

This patch also reimplements type::is_array_like to use the type's
language, and it adds a new type::is_string_like as well.  This in
turn lets us change the Python implementation of these methods to
simply defer to the type.
This commit is contained in:
Tom Tromey
2023-09-05 12:29:23 -06:00
parent 26733fc747
commit 76fc0f6213
9 changed files with 98 additions and 94 deletions

View File

@ -448,17 +448,19 @@ static PyObject *
typy_is_array_like (PyObject *self, void *closure)
{
struct type *type = ((type_object *) self)->type;
bool result = false;
try
{
type = check_typedef (type);
result = type->is_array_like ();
}
catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
if (type->is_array_like ())
if (result)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
@ -475,14 +477,7 @@ typy_is_string_like (PyObject *self, void *closure)
try
{
type = check_typedef (type);
const language_defn *lang = nullptr;
if (HAVE_GNAT_AUX_INFO (type))
lang = language_def (language_ada);
else if (HAVE_RUST_SPECIFIC (type))
lang = language_def (language_rust);
if (lang != nullptr)
result = lang->is_string_type_p (type);
result = type->is_string_like ();
}
catch (const gdb_exception &except)
{