Implement support for Ada interface types.

* ada-lang.c (ada_is_dispatch_table_ptr_type): New function.
        (ada_is_ignored_field): Ignore fields that are a dispatch table
        of a tagged type.
This commit is contained in:
Joel Brobecker 2008-01-01 07:21:59 +00:00
parent 636265b635
commit 73fb998568
2 changed files with 50 additions and 6 deletions

View File

@ -1,3 +1,11 @@
2008-01-01 Joel Brobecker <brobecker@adacore.com>
Implement support for Ada interface types.
* ada-lang.c (ada_is_dispatch_table_ptr_type): New function.
(ada_is_ignored_field): Ignore fields that are a dispatch table
of a tagged type.
2008-01-01 Joel Brobecker <brobecker@adacore.com>
* top.c (print_gdb_version): Update copyright year.

View File

@ -5277,6 +5277,24 @@ ada_add_block_symbols (struct obstack *obstackp,
/* Field Access */
/* Return non-zero if TYPE is a pointer to the GNAT dispatch table used
for tagged types. */
static int
ada_is_dispatch_table_ptr_type (struct type *type)
{
char *name;
if (TYPE_CODE (type) != TYPE_CODE_PTR)
return 0;
name = TYPE_NAME (TYPE_TARGET_TYPE (type));
if (name == NULL)
return 0;
return (strcmp (name, "ada__tags__dispatch_table") == 0);
}
/* True if field number FIELD_NUM in struct or union type TYPE is supposed
to be invisible to users. */
@ -5285,12 +5303,30 @@ ada_is_ignored_field (struct type *type, int field_num)
{
if (field_num < 0 || field_num > TYPE_NFIELDS (type))
return 1;
else
{
const char *name = TYPE_FIELD_NAME (type, field_num);
return (name == NULL
|| (name[0] == '_' && strncmp (name, "_parent", 7) != 0));
}
/* Check the name of that field. */
{
const char *name = TYPE_FIELD_NAME (type, field_num);
/* Anonymous field names should not be printed.
brobecker/2007-02-20: I don't think this can actually happen
but we don't want to print the value of annonymous fields anyway. */
if (name == NULL)
return 1;
/* A field named "_parent" is internally generated by GNAT for
tagged types, and should not be printed either. */
if (name[0] == '_' && strncmp (name, "_parent", 7) != 0)
return 1;
}
/* If this is the dispatch table of a tagged type, then ignore. */
if (ada_is_tagged_type (type, 1)
&& ada_is_dispatch_table_ptr_type (TYPE_FIELD_TYPE (type, field_num)))
return 1;
/* Not a special field, so it should not be ignored. */
return 0;
}
/* True iff TYPE has a tag field. If REFOK, then TYPE may also be a