while (arity > 0)
{
type_allocator alloc (arr->type ());
- struct type *array_type = alloc.new_type ();
struct value *low = desc_one_bound (descriptor, arity, 0);
struct value *high = desc_one_bound (descriptor, arity, 1);
= create_static_range_type (alloc, low->type (),
longest_to_int (value_as_long (low)),
longest_to_int (value_as_long (high)));
- elt_type = create_array_type (array_type, elt_type, range_type);
+ elt_type = create_array_type (alloc, elt_type, range_type);
if (ada_is_unconstrained_packed_array_type (arr->type ()))
{
int array_bitsize =
(hi - lo + 1) * TYPE_FIELD_BITSIZE (elt_type, 0);
- array_type->set_length ((array_bitsize + 7) / 8);
+ elt_type->set_length ((array_bitsize + 7) / 8);
}
}
}
else
index_type = type->index_type ();
- new_type = type_allocator (type).new_type ();
+ type_allocator alloc (type);
new_elt_type =
constrained_packed_array_type (ada_check_typedef (type->target_type ()),
elt_bits);
- create_array_type (new_type, new_elt_type, index_type);
+ new_type = create_array_type (alloc, new_elt_type, index_type);
TYPE_FIELD_BITSIZE (new_type, 0) = *elt_bits;
new_type->set_name (ada_type_name (type));
struct type *index_type
= create_static_range_type (alloc, base_index_type, low, high);
struct type *slice_type = create_array_type_with_stride
- (NULL, type0->target_type (), index_type,
+ (alloc, type0->target_type (), index_type,
type0->dyn_prop (DYN_PROP_BYTE_STRIDE),
TYPE_FIELD_BITSIZE (type0, 0));
int base_low = ada_discrete_type_low_bound (type0->index_type ());
struct type *index_type
= create_static_range_type (alloc, type->index_type (), low, high);
struct type *slice_type = create_array_type_with_stride
- (NULL, type->target_type (), index_type,
+ (alloc, type->target_type (), index_type,
type->dyn_prop (DYN_PROP_BYTE_STRIDE),
TYPE_FIELD_BITSIZE (type, 0));
gdb::optional<LONGEST> low_pos, high_pos;
high < low ? low - 1 : high);
struct type *elt_type = ada_array_element_type (arr_type0, 1);
- return value::allocate (create_array_type (NULL, elt_type, index_type));
+ return value::allocate (create_array_type (alloc, elt_type, index_type));
}
\f
if (elt_type0 == elt_type && !constrained_packed_array_p)
result = type0;
else
- result = create_array_type (type_allocator (type0).new_type (),
- elt_type, type0->index_type ());
+ {
+ type_allocator alloc (type0);
+ result = create_array_type (alloc, elt_type, type0->index_type ());
+ }
}
else
{
struct type *range_type =
to_fixed_range_type (index_type_desc->field (i).type (), dval);
- result = create_array_type (type_allocator (elt_type0).new_type (),
- result, range_type);
+ type_allocator alloc (elt_type0);
+ result = create_array_type (alloc, result, range_type);
elt_type0 = elt_type0->target_type ();
}
}
type_allocator alloc (objfile);
range_type
= create_static_range_type (alloc, index_type, 0, n - 1);
- type =
- create_array_type (NULL, base_type, range_type);
+ type = create_array_type (alloc, base_type, range_type);
}
return type;
}
type_allocator alloc (objfile);
range_type = create_static_range_type (alloc, idx_type, 0, ar.ctr_nelems - 1);
- type = create_array_type (NULL, element_type, range_type);
+ type = create_array_type (alloc, element_type, range_type);
if (ar.ctr_nelems <= 1) /* Check if undefined upper bound. */
{
range_type->bounds ()->high.set_undefined ();
index_type = objfile_type (objfile)->builtin_int;
type_allocator alloc (objfile);
range_type = create_static_range_type (alloc, index_type, 0, -1);
- type = create_array_type_with_stride (NULL, element_type, range_type,
+ type = create_array_type_with_stride (alloc, element_type, range_type,
byte_stride_prop, bit_stride);
return set_die_type (die, type, cu);
}
type = element_type;
+ type_allocator alloc (cu->per_objfile->objfile);
if (read_array_order (die, cu) == DW_ORD_col_major)
{
int i = 0;
while (i < range_types.size ())
{
- type = create_array_type_with_stride (NULL, type, range_types[i++],
+ type = create_array_type_with_stride (alloc, type, range_types[i++],
byte_stride_prop, bit_stride);
type->set_is_multi_dimensional (true);
bit_stride = 0;
size_t ndim = range_types.size ();
while (ndim-- > 0)
{
- type = create_array_type_with_stride (NULL, type, range_types[ndim],
+ type = create_array_type_with_stride (alloc, type, range_types[ndim],
byte_stride_prop, bit_stride);
type->set_is_multi_dimensional (true);
bit_stride = 0;
range_type = create_range_type (alloc, index_type, &low_bound, &prop, 0);
}
char_type = language_string_char_type (cu->language_defn, gdbarch);
- type = create_string_type (NULL, char_type, range_type);
+ type = create_string_type (alloc, char_type, range_type);
return set_die_type (die, type, cu);
}
range_type =
create_static_range_type (alloc, idx_type,
0, array_size - 1);
- follow_type =
- create_array_type ((struct type *) NULL,
- follow_type, range_type);
+ follow_type = create_array_type (alloc,
+ follow_type,
+ range_type);
}
else
follow_type = lookup_pointer_type (follow_type);
builtin_f_type (gdbarch)->builtin_integer,
1, ndimensions);
struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer;
- struct type *result_type = create_array_type (nullptr, elm_type, range);
+ struct type *result_type = create_array_type (alloc, elm_type, range);
struct value *result = value::allocate (result_type);
/* Walk the array dimensions backwards due to the way the array will be
builtin_type (gdbarch)->builtin_int,
1, ndimensions);
struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer;
- struct type *result_type = create_array_type (nullptr, elm_type, range);
+ struct type *result_type = create_array_type (alloc, elm_type, range);
struct value *result = value::allocate (result_type);
LONGEST elm_len = elm_type->length ();
&p_low, &p_high, 0, &p_stride,
true);
array_slice_type
- = create_array_type (nullptr, array_slice_type, new_range);
+ = create_array_type (alloc, array_slice_type, new_range);
}
if (fortran_array_slicing_debug)
&p_low, &p_high, 0, &p_stride,
true);
repacked_array_type
- = create_array_type (nullptr, repacked_array_type, new_range);
+ = create_array_type (alloc, repacked_array_type, new_range);
}
/* Now copy the elements from the original ARRAY into the packed
return false;
}
-/* Create an array type using either a blank type supplied in
- RESULT_TYPE, or creating a new type, inheriting the objfile from
- RANGE_TYPE.
-
- Elements will be of type ELEMENT_TYPE, the indices will be of type
- RANGE_TYPE.
-
- BYTE_STRIDE_PROP, when not NULL, provides the array's byte stride.
- This byte stride property is added to the resulting array type
- as a DYN_PROP_BYTE_STRIDE. As a consequence, the BYTE_STRIDE_PROP
- argument can only be used to create types that are objfile-owned
- (see add_dyn_prop), meaning that either this function must be called
- with an objfile-owned RESULT_TYPE, or an objfile-owned RANGE_TYPE.
-
- BIT_STRIDE is taken into account only when BYTE_STRIDE_PROP is NULL.
- If BIT_STRIDE is not zero, build a packed array type whose element
- size is BIT_STRIDE. Otherwise, ignore this parameter.
-
- FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
- sure it is TYPE_CODE_UNDEF before we bash it into an array
- type? */
+/* See gdbtypes.h. */
struct type *
-create_array_type_with_stride (struct type *result_type,
+create_array_type_with_stride (type_allocator &alloc,
struct type *element_type,
struct type *range_type,
struct dynamic_prop *byte_stride_prop,
byte_stride_prop = NULL;
}
- if (result_type == NULL)
- result_type = type_allocator (range_type).new_type ();
+ struct type *result_type = alloc.new_type ();
result_type->set_code (TYPE_CODE_ARRAY);
result_type->set_target_type (element_type);
return result_type;
}
-/* Same as create_array_type_with_stride but with no bit_stride
- (BIT_STRIDE = 0), thus building an unpacked array. */
+/* See gdbtypes.h. */
struct type *
-create_array_type (struct type *result_type,
+create_array_type (type_allocator &alloc,
struct type *element_type,
struct type *range_type)
{
- return create_array_type_with_stride (result_type, element_type,
+ return create_array_type_with_stride (alloc, element_type,
range_type, NULL, 0);
}
range_type = create_static_range_type (alloc, index_type,
low_bound, high_bound);
- return create_array_type (NULL, element_type, range_type);
+ return create_array_type (alloc, element_type, range_type);
}
-/* Create a string type using either a blank type supplied in
- RESULT_TYPE, or creating a new type. String types are similar
- enough to array of char types that we can use create_array_type to
- build the basic type and then bash it into a string type.
-
- For fixed length strings, the range type contains 0 as the lower
- bound and the length of the string minus one as the upper bound.
-
- FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
- sure it is TYPE_CODE_UNDEF before we bash it into a string
- type? */
+/* See gdbtypes.h. */
struct type *
-create_string_type (struct type *result_type,
+create_string_type (type_allocator &alloc,
struct type *string_char_type,
struct type *range_type)
{
- result_type = create_array_type (result_type,
- string_char_type,
- range_type);
+ struct type *result_type = create_array_type (alloc,
+ string_char_type,
+ range_type);
result_type->set_code (TYPE_CODE_STRING);
return result_type;
}
else
bit_stride = TYPE_FIELD_BITSIZE (type, 0);
- return create_array_type_with_stride (type, elt_type, range_type, NULL,
+ type_allocator alloc (type, type_allocator::SMASH);
+ return create_array_type_with_stride (alloc, elt_type, range_type, NULL,
bit_stride);
}
LONGEST low_bound,
LONGEST high_bound);
+/* Create an array type using ALLOC.
+
+ Elements will be of type ELEMENT_TYPE, the indices will be of type
+ RANGE_TYPE.
+
+ BYTE_STRIDE_PROP, when not NULL, provides the array's byte stride.
+ This byte stride property is added to the resulting array type
+ as a DYN_PROP_BYTE_STRIDE. As a consequence, the BYTE_STRIDE_PROP
+ argument can only be used to create types that are objfile-owned
+ (see add_dyn_prop), meaning that either this function must be called
+ with an objfile-owned RESULT_TYPE, or an objfile-owned RANGE_TYPE.
+
+ BIT_STRIDE is taken into account only when BYTE_STRIDE_PROP is NULL.
+ If BIT_STRIDE is not zero, build a packed array type whose element
+ size is BIT_STRIDE. Otherwise, ignore this parameter. */
extern struct type *create_array_type_with_stride
- (struct type *, struct type *, struct type *,
- struct dynamic_prop *, unsigned int);
+ (type_allocator &alloc, struct type *element_type,
+ struct type *range_type, struct dynamic_prop *byte_stride_prop,
+ unsigned int bit_stride);
/* Create a range type using ALLOC with a dynamic range from LOW_BOUND
to HIGH_BOUND, inclusive. INDEX_TYPE is the underlying type. BIAS
const struct dynamic_prop *high_bound, LONGEST bias,
const struct dynamic_prop *stride, bool byte_stride_p);
-extern struct type *create_array_type (struct type *, struct type *,
- struct type *);
+/* Same as create_array_type_with_stride but with no bit_stride
+ (BIT_STRIDE = 0), thus building an unpacked array. */
+
+extern struct type *create_array_type (type_allocator &alloc,
+ struct type *element_type,
+ struct type *range_type);
extern struct type *lookup_array_range_type (struct type *, LONGEST, LONGEST);
-extern struct type *create_string_type (struct type *, struct type *,
- struct type *);
+/* Create a string type using ALLOC. String types are similar enough
+ to array of char types that we can use create_array_type to build
+ the basic type and then bash it into a string type.
+
+ For fixed length strings, the range type contains 0 as the lower
+ bound and the length of the string minus one as the upper bound. */
+
+extern struct type *create_string_type (type_allocator &alloc,
+ struct type *string_char_type,
+ struct type *range_type);
+
extern struct type *lookup_string_range_type (struct type *, LONGEST, LONGEST);
extern struct type *create_set_type (struct type *, struct type *);
type_allocator alloc (indx);
range = create_static_range_type (alloc, indx, lower, upper);
- t = create_array_type (NULL, *tpp, range);
+ t = create_array_type (alloc, *tpp, range);
}
/* We used to fill in the supplied array element bitsize
objfile_type (objfile)->builtin_int,
0, ind);
sym->set_type
- (create_array_type (NULL, objfile_type (objfile)->builtin_char,
+ (create_array_type (alloc, objfile_type (objfile)->builtin_char,
range_type));
string_value
= (gdb_byte *) obstack_alloc (&objfile->objfile_obstack, ind + 1);
type_allocator alloc (objfile);
range_type =
create_static_range_type (alloc, index_type, lower, upper);
- type = create_array_type (type, element_type, range_type);
+ type_allocator smash_alloc (type, type_allocator::SMASH);
+ type = create_array_type (smash_alloc, element_type, range_type);
return type;
}
range_type->target_type (),
low_bound,
new_length + low_bound - 1);
- arg2->deprecated_set_type (create_array_type (NULL,
+ arg2->deprecated_set_type (create_array_type (alloc,
element_type,
range_type));
return arg2;
LONGEST offset
= (lowbound - lowerbound) * check_typedef (element_type)->length ();
- slice_type = create_array_type (NULL,
+ slice_type = create_array_type (alloc,
element_type,
slice_range_type);
slice_type->set_code (array_type->code ());