* ada-lang.c (desc_data_type): Remove, replace by ...

(desc_data_target_type): ... this.
	(thin_data_pntr): Use desc_data_target_type instead of desc_data_type.
	(ada_is_array_descriptor_type): Likewise.
	(ada_type_of_array): Likewise.
	(ada_coerce_to_simple_array_type): Likewise.
	(ada_array_element_type): Likewise.
This commit is contained in:
Ulrich Weigand 2009-05-18 13:55:49 +00:00
parent aaa88a990d
commit 556bdfd450
2 changed files with 37 additions and 25 deletions

View file

@ -1,3 +1,13 @@
2009-05-18 Ulrich Weigand <uweigand@de.ibm.com>
* ada-lang.c (desc_data_type): Remove, replace by ...
(desc_data_target_type): ... this.
(thin_data_pntr): Use desc_data_target_type instead of desc_data_type.
(ada_is_array_descriptor_type): Likewise.
(ada_type_of_array): Likewise.
(ada_coerce_to_simple_array_type): Likewise.
(ada_array_element_type): Likewise.
2009-05-18 Ulrich Weigand <uweigand@de.ibm.com> 2009-05-18 Ulrich Weigand <uweigand@de.ibm.com>
* ada-valprint.c (ada_val_print_1): Use val_print_string to print * ada-valprint.c (ada_val_print_1): Use val_print_string to print

View file

@ -79,7 +79,7 @@ static int fat_pntr_bounds_bitpos (struct type *);
static int fat_pntr_bounds_bitsize (struct type *); static int fat_pntr_bounds_bitsize (struct type *);
static struct type *desc_data_type (struct type *); static struct type *desc_data_target_type (struct type *);
static struct value *desc_data (struct value *); static struct value *desc_data (struct value *);
@ -1281,11 +1281,13 @@ static struct value *
thin_data_pntr (struct value *val) thin_data_pntr (struct value *val)
{ {
struct type *type = value_type (val); struct type *type = value_type (val);
struct type *data_type = desc_data_target_type (thin_descriptor_type (type));
data_type = lookup_pointer_type (data_type);
if (TYPE_CODE (type) == TYPE_CODE_PTR) if (TYPE_CODE (type) == TYPE_CODE_PTR)
return value_cast (desc_data_type (thin_descriptor_type (type)), return value_cast (data_type, value_copy (val));
value_copy (val));
else else
return value_from_longest (desc_data_type (thin_descriptor_type (type)), return value_from_longest (data_type,
VALUE_ADDRESS (val) + value_offset (val)); VALUE_ADDRESS (val) + value_offset (val));
} }
@ -1389,23 +1391,28 @@ fat_pntr_bounds_bitsize (struct type *type)
} }
/* If TYPE is the type of an array descriptor (fat or thin pointer) or a /* If TYPE is the type of an array descriptor (fat or thin pointer) or a
pointer to one, the type of its array data (a pointer to one, the type of its array data (a array-with-no-bounds type);
pointer-to-array-with-no-bounds type); otherwise, NULL. Use otherwise, NULL. Use ada_type_of_array to get an array type with bounds
ada_type_of_array to get an array type with bounds data. */ data. */
static struct type * static struct type *
desc_data_type (struct type *type) desc_data_target_type (struct type *type)
{ {
type = desc_base_type (type); type = desc_base_type (type);
/* NOTE: The following is bogus; see comment in desc_bounds. */ /* NOTE: The following is bogus; see comment in desc_bounds. */
if (is_thin_pntr (type)) if (is_thin_pntr (type))
return lookup_pointer_type return desc_base_type (TYPE_FIELD_TYPE (thin_descriptor_type (type), 1));
(desc_base_type (TYPE_FIELD_TYPE (thin_descriptor_type (type), 1)));
else if (is_thick_pntr (type)) else if (is_thick_pntr (type))
return lookup_struct_elt_type (type, "P_ARRAY", 1); {
else struct type *data_type = lookup_struct_elt_type (type, "P_ARRAY", 1);
return NULL;
if (data_type
&& TYPE_CODE (ada_check_typedef (data_type)) == TYPE_CODE_PTR)
return TYPE_TARGET_TYPE (data_type);
}
return NULL;
} }
/* If ARR is an array descriptor (fat or thin pointer), a pointer to /* If ARR is an array descriptor (fat or thin pointer), a pointer to
@ -1556,18 +1563,14 @@ ada_is_simple_array_type (struct type *type)
int int
ada_is_array_descriptor_type (struct type *type) ada_is_array_descriptor_type (struct type *type)
{ {
struct type *data_type = desc_data_type (type); struct type *data_type = desc_data_target_type (type);
if (type == NULL) if (type == NULL)
return 0; return 0;
type = ada_check_typedef (type); type = ada_check_typedef (type);
return return (data_type != NULL
data_type != NULL && TYPE_CODE (data_type) == TYPE_CODE_ARRAY
&& ((TYPE_CODE (data_type) == TYPE_CODE_PTR && desc_arity (desc_bounds_type (type)) > 0);
&& TYPE_TARGET_TYPE (data_type) != NULL
&& TYPE_CODE (TYPE_TARGET_TYPE (data_type)) == TYPE_CODE_ARRAY)
|| TYPE_CODE (data_type) == TYPE_CODE_ARRAY)
&& desc_arity (desc_bounds_type (type)) > 0;
} }
/* Non-zero iff type is a partially mal-formed GNAT array /* Non-zero iff type is a partially mal-formed GNAT array
@ -1605,7 +1608,7 @@ ada_type_of_array (struct value *arr, int bounds)
if (!bounds) if (!bounds)
return return
ada_check_typedef (TYPE_TARGET_TYPE (desc_data_type (value_type (arr)))); ada_check_typedef (desc_data_target_type (value_type (arr)));
else else
{ {
struct type *elt_type; struct type *elt_type;
@ -1693,7 +1696,7 @@ ada_coerce_to_simple_array_type (struct type *type)
return decode_packed_array_type (type); return decode_packed_array_type (type);
if (ada_is_array_descriptor_type (type)) if (ada_is_array_descriptor_type (type))
return ada_check_typedef (TYPE_TARGET_TYPE (desc_data_type (type))); return ada_check_typedef (desc_data_target_type (type));
return type; return type;
} }
@ -2377,7 +2380,7 @@ ada_array_element_type (struct type *type, int nindices)
int k; int k;
struct type *p_array_type; struct type *p_array_type;
p_array_type = desc_data_type (type); p_array_type = desc_data_target_type (type);
k = ada_array_arity (type); k = ada_array_arity (type);
if (k == 0) if (k == 0)
@ -2386,7 +2389,6 @@ ada_array_element_type (struct type *type, int nindices)
/* Initially p_array_type = elt_type(*)[]...(k times)...[]. */ /* Initially p_array_type = elt_type(*)[]...(k times)...[]. */
if (nindices >= 0 && k > nindices) if (nindices >= 0 && k > nindices)
k = nindices; k = nindices;
p_array_type = TYPE_TARGET_TYPE (p_array_type);
while (k > 0 && p_array_type != NULL) while (k > 0 && p_array_type != NULL)
{ {
p_array_type = ada_check_typedef (TYPE_TARGET_TYPE (p_array_type)); p_array_type = ada_check_typedef (TYPE_TARGET_TYPE (p_array_type));