- else if (ada_is_wrapper_field (type, i))
- {
- struct value *v = /* Do not let indent join lines here. */
- ada_index_struct_field_1 (index_p, arg,
- offset + TYPE_FIELD_BITPOS (type, i) / 8,
- TYPE_FIELD_TYPE (type, i));
-
- if (v != NULL)
- return v;
- }
-
- else if (ada_is_variant_part (type, i))
- {
- /* PNH: Do we ever get here? See ada_search_struct_field,
- find_struct_field. */
- error (_("Cannot assign this kind of variant record"));
- }
- else if (*index_p == 0)
- return ada_value_primitive_field (arg, offset, i, type);
- else
- *index_p -= 1;
- }
- return NULL;
-}
-
-/* Given ARG, a value of type (pointer or reference to a)*
- structure/union, extract the component named NAME from the ultimate
- target structure/union and return it as a value with its
- appropriate type.
-
- The routine searches for NAME among all members of the structure itself
- and (recursively) among all members of any wrapper members
- (e.g., '_parent').
-
- If NO_ERR, then simply return NULL in case of error, rather than
- calling error. */
-
-struct value *
-ada_value_struct_elt (struct value *arg, const char *name, int no_err)
-{
- struct type *t, *t1;
- struct value *v;
- int check_tag;
-
- v = NULL;
- t1 = t = ada_check_typedef (value_type (arg));
- if (TYPE_CODE (t) == TYPE_CODE_REF)
- {
- t1 = TYPE_TARGET_TYPE (t);
- if (t1 == NULL)
- goto BadValue;
- t1 = ada_check_typedef (t1);
- if (TYPE_CODE (t1) == TYPE_CODE_PTR)
- {
- arg = coerce_ref (arg);
- t = t1;
- }
- }
-
- while (TYPE_CODE (t) == TYPE_CODE_PTR)
- {
- t1 = TYPE_TARGET_TYPE (t);
- if (t1 == NULL)
- goto BadValue;
- t1 = ada_check_typedef (t1);
- if (TYPE_CODE (t1) == TYPE_CODE_PTR)
- {
- arg = value_ind (arg);
- t = t1;
- }
- else
- break;
- }
-
- if (TYPE_CODE (t1) != TYPE_CODE_STRUCT && TYPE_CODE (t1) != TYPE_CODE_UNION)
- goto BadValue;
-
- if (t1 == t)
- v = ada_search_struct_field (name, arg, 0, t);
- else
- {
- int bit_offset, bit_size, byte_offset;
- struct type *field_type;
- CORE_ADDR address;
-
- if (TYPE_CODE (t) == TYPE_CODE_PTR)
- address = value_address (ada_value_ind (arg));
- else
- address = value_address (ada_coerce_ref (arg));
-
- /* Check to see if this is a tagged type. We also need to handle
- the case where the type is a reference to a tagged type, but
- we have to be careful to exclude pointers to tagged types.
- The latter should be shown as usual (as a pointer), whereas
- a reference should mostly be transparent to the user. */
-
- if (ada_is_tagged_type (t1, 0)
- || (TYPE_CODE (t1) == TYPE_CODE_REF
- && ada_is_tagged_type (TYPE_TARGET_TYPE (t1), 0)))
- {
- /* We first try to find the searched field in the current type.
- If not found then let's look in the fixed type. */
-
- if (!find_struct_field (name, t1, 0,
- &field_type, &byte_offset, &bit_offset,
- &bit_size, NULL))
- check_tag = 1;
- else
- check_tag = 0;
- }
- else
- check_tag = 0;