while (arity > 0)
{
type_allocator alloc (arr->type ());
- struct type *range_type = alloc.new_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);
arity -= 1;
- create_static_range_type (range_type, low->type (),
- longest_to_int (value_as_long (low)),
- longest_to_int (value_as_long (high)));
+ struct type *range_type
+ = 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);
if (ada_is_unconstrained_packed_array_type (arr->type ()))
{
struct type *type0 = ada_check_typedef (type);
struct type *base_index_type = type0->index_type ()->target_type ();
+ type_allocator alloc (base_index_type);
struct type *index_type
- = create_static_range_type (NULL, base_index_type, low, high);
+ = 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,
type0->dyn_prop (DYN_PROP_BYTE_STRIDE),
{
struct type *type = ada_check_typedef (array->type ());
struct type *base_index_type = type->index_type ()->target_type ();
+ type_allocator alloc (type->index_type ());
struct type *index_type
- = create_static_range_type (NULL, type->index_type (), low, high);
+ = 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,
type->dyn_prop (DYN_PROP_BYTE_STRIDE),
empty_array (struct type *arr_type, int low, int high)
{
struct type *arr_type0 = ada_check_typedef (arr_type);
+ type_allocator alloc (arr_type0->index_type ()->target_type ());
struct type *index_type
= create_static_range_type
- (NULL, arr_type0->index_type ()->target_type (), low,
+ (alloc, arr_type0->index_type ()->target_type (), low,
high < low ? low - 1 : high);
struct type *elt_type = ada_array_element_type (arr_type0, 1);
if (L < INT_MIN || U > INT_MAX)
return raw_type;
else
- return create_static_range_type (type_allocator (raw_type).new_type (),
- raw_type, L, U);
+ {
+ type_allocator alloc (raw_type);
+ return create_static_range_type (alloc, raw_type, L, U);
+ }
}
else
{
}
}
- type = create_static_range_type (type_allocator (raw_type).new_type (),
- base_type, L, U);
+ type_allocator alloc (raw_type);
+ type = create_static_range_type (alloc, base_type, L, U);
/* create_static_range_type alters the resulting type's length
to match the size of the base_type, which is not what we want.
Set it back to the original range type's length. */
base_type = decode_type (cs, new_c_type, aux, objfile);
index_type = objfile_type (objfile)->builtin_int;
+ type_allocator alloc (objfile);
range_type
- = create_static_range_type (NULL, index_type, 0, n - 1);
+ = create_static_range_type (alloc, index_type, 0, n - 1);
type =
create_array_type (NULL, base_type, range_type);
}
if (idx_type == nullptr)
idx_type = objfile_type (objfile)->builtin_int;
- range_type = create_static_range_type (NULL, idx_type, 0, ar.ctr_nelems - 1);
+ 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);
if (ar.ctr_nelems <= 1) /* Check if undefined upper bound. */
{
range_fields[i + 1].set_name (objfile->intern (name));
}
- struct type *bounds = type_allocator (objfile).new_type ();
+ type_allocator alloc (objfile);
+ struct type *bounds = alloc.new_type ();
bounds->set_code (TYPE_CODE_STRUCT);
bounds->set_num_fields (range_fields.size ());
gdb_assert (iter->code () == TYPE_CODE_ARRAY);
iter->main_type->dyn_prop_list = nullptr;
iter->set_index_type
- (create_static_range_type (NULL, bounds->field (i).type (), 1, 0));
+ (create_static_range_type (alloc, bounds->field (i).type (), 1, 0));
iter = iter->target_type ();
}
if (die->child == NULL)
{
index_type = objfile_type (objfile)->builtin_int;
- range_type = create_static_range_type (NULL, index_type, 0, -1);
+ 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,
byte_stride_prop, bit_stride);
return set_die_type (die, type, cu);
}
index_type = objfile_type (objfile)->builtin_int;
+ type_allocator alloc (objfile);
if (length_is_constant)
- range_type = create_static_range_type (NULL, index_type, 1, length);
+ range_type = create_static_range_type (alloc, index_type, 1, length);
else
{
struct dynamic_prop low_bound;
low_bound.set_const_val (1);
- range_type = create_range_type (NULL, index_type, &low_bound, &prop, 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_allocator alloc (cu->per_objfile->objfile);
if (attr_byte_stride != nullptr
|| attr_bit_stride != nullptr)
{
= byte_stride_p ? &byte_stride_prop : &bit_stride_prop;
range_type
- = create_range_type_with_stride (NULL, orig_base_type, &low,
+ = create_range_type_with_stride (alloc, orig_base_type, &low,
&high, bias, stride, byte_stride_p);
}
else
- range_type = create_range_type (NULL, orig_base_type, &low, &high, bias);
+ range_type = create_range_type (alloc, orig_base_type, &low, &high, bias);
if (high_bound_is_count)
range_type->bounds ()->flag_upper_bound_is_count = 1;
array_size = type_stack->pop_int ();
if (array_size != -1)
{
+ struct type *idx_type
+ = parse_f_type (pstate)->builtin_integer;
+ type_allocator alloc (idx_type);
range_type =
- create_static_range_type ((struct type *) NULL,
- parse_f_type (pstate)
- ->builtin_integer,
+ create_static_range_type (alloc, idx_type,
0, array_size - 1);
follow_type =
create_array_type ((struct type *) NULL,
int ndimensions = calc_f77_array_dims (array_type);
/* Allocate a result value of the correct type. */
+ type_allocator alloc (gdbarch);
struct type *range
- = create_static_range_type (nullptr,
+ = create_static_range_type (alloc,
builtin_f_type (gdbarch)->builtin_integer,
1, ndimensions);
struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer;
ndimensions = calc_f77_array_dims (val_type);
/* Allocate a result value of the correct type. */
+ type_allocator alloc (gdbarch);
struct type *range
- = create_static_range_type (nullptr,
+ = create_static_range_type (alloc,
builtin_type (gdbarch)->builtin_int,
1, ndimensions);
struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer;
p_high.set_const_val (d.high);
p_stride.set_const_val (d.stride);
+ type_allocator alloc (d.index->target_type ());
struct type *new_range
- = create_range_type_with_stride ((struct type *) NULL,
+ = create_range_type_with_stride (alloc,
d.index->target_type (),
&p_low, &p_high, 0, &p_stride,
true);
p_high.set_const_val (d.high);
p_stride.set_const_val (repacked_array_type->length ());
+ type_allocator alloc (d.index->target_type ());
struct type *new_range
- = create_range_type_with_stride ((struct type *) NULL,
+ = create_range_type_with_stride (alloc,
d.index->target_type (),
&p_low, &p_high, 0, &p_stride,
true);
#undef FIELD_EQ
}
-/* Create a range type with a dynamic range from LOW_BOUND to
- HIGH_BOUND, inclusive. See create_range_type for further details. */
+/* See gdbtypes.h. */
struct type *
-create_range_type (struct type *result_type, struct type *index_type,
+create_range_type (type_allocator &alloc, struct type *index_type,
const struct dynamic_prop *low_bound,
const struct dynamic_prop *high_bound,
LONGEST bias)
gdb_assert (index_type->code () != TYPE_CODE_VOID);
gdb_assert (index_type->length () > 0);
- if (result_type == NULL)
- result_type = type_allocator (index_type).new_type ();
+ struct type *result_type = alloc.new_type ();
result_type->set_code (TYPE_CODE_RANGE);
result_type->set_target_type (index_type);
if (index_type->is_stub ())
/* See gdbtypes.h. */
struct type *
-create_range_type_with_stride (struct type *result_type,
+create_range_type_with_stride (type_allocator &alloc,
struct type *index_type,
const struct dynamic_prop *low_bound,
const struct dynamic_prop *high_bound,
const struct dynamic_prop *stride,
bool byte_stride_p)
{
- result_type = create_range_type (result_type, index_type, low_bound,
- high_bound, bias);
+ struct type *result_type = create_range_type (alloc, index_type, low_bound,
+ high_bound, bias);
gdb_assert (stride != nullptr);
result_type->bounds ()->stride = *stride;
return result_type;
}
-
-
-/* Create a range type using either a blank type supplied in
- RESULT_TYPE, or creating a new type, inheriting the objfile from
- INDEX_TYPE.
-
- Indices will be of type INDEX_TYPE, and will range from LOW_BOUND
- to HIGH_BOUND, inclusive.
-
- 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 range type? */
+/* See gdbtypes.h. */
struct type *
-create_static_range_type (struct type *result_type, struct type *index_type,
+create_static_range_type (type_allocator &alloc, struct type *index_type,
LONGEST low_bound, LONGEST high_bound)
{
struct dynamic_prop low, high;
low.set_const_val (low_bound);
high.set_const_val (high_bound);
- result_type = create_range_type (result_type, index_type, &low, &high, 0);
+ struct type *result_type = create_range_type (alloc, index_type,
+ &low, &high, 0);
return result_type;
}
struct type *index_type;
struct type *range_type;
+ type_allocator alloc (element_type);
if (element_type->is_objfile_owned ())
index_type = objfile_type (element_type->objfile_owner ())->builtin_int;
else
index_type = builtin_type (element_type->arch_owner ())->builtin_int;
- range_type = create_static_range_type (NULL, index_type,
+ range_type = create_static_range_type (alloc, index_type,
low_bound, high_bound);
return create_array_type (NULL, element_type, range_type);
= resolve_dynamic_type_internal (dyn_range_type->target_type (),
addr_stack, 0);
LONGEST bias = dyn_range_type->bounds ()->bias;
+ type_allocator alloc (dyn_range_type);
static_range_type = create_range_type_with_stride
- (copy_type (dyn_range_type), static_target_type,
+ (alloc, static_target_type,
&low_bound, &high_bound, bias, &stride, byte_stride_p);
static_range_type->bounds ()->flag_bound_evaluated = 1;
return static_range_type;
int,
struct type **);
-extern struct type *create_static_range_type (struct type *, struct type *,
- LONGEST, LONGEST);
+/* Create a range type using ALLOC.
+
+ Indices will be of type INDEX_TYPE, and will range from LOW_BOUND
+ to HIGH_BOUND, inclusive. */
+
+extern struct type *create_static_range_type (type_allocator &alloc,
+ struct type *index_type,
+ LONGEST low_bound,
+ LONGEST high_bound);
extern struct type *create_array_type_with_stride
(struct type *, struct type *, struct type *,
struct dynamic_prop *, unsigned int);
-extern struct type *create_range_type (struct type *, struct type *,
- const struct dynamic_prop *,
- const struct dynamic_prop *,
- LONGEST);
+/* Create a range type using ALLOC with a dynamic range from LOW_BOUND
+ to HIGH_BOUND, inclusive. INDEX_TYPE is the underlying type. BIAS
+ is the bias to be applied when storing or retrieving values of this
+ type. */
+
+extern struct type *create_range_type (type_allocator &alloc,
+ struct type *index_type,
+ const struct dynamic_prop *low_bound,
+ const struct dynamic_prop *high_bound,
+ LONGEST bias);
/* Like CREATE_RANGE_TYPE but also sets up a stride. When BYTE_STRIDE_P
is true the value in STRIDE is a byte stride, otherwise STRIDE is a bit
stride. */
-extern struct type * create_range_type_with_stride
- (struct type *result_type, struct type *index_type,
+extern struct type *create_range_type_with_stride
+ (type_allocator &alloc, struct type *index_type,
const struct dynamic_prop *low_bound,
const struct dynamic_prop *high_bound, LONGEST bias,
const struct dynamic_prop *stride, bool byte_stride_p);
ax++;
rf = AUX_GET_WIDTH (bigend, ax); /* bit size of array element */
- range = create_static_range_type (NULL, indx, lower, upper);
+ {
+ type_allocator alloc (indx);
+ range = create_static_range_type (alloc, indx, lower, upper);
- t = create_array_type (NULL, *tpp, range);
+ t = create_array_type (NULL, *tpp, range);
+ }
/* We used to fill in the supplied array element bitsize
here if the TYPE_LENGTH of the target type was zero.
/* NULL terminate the string. */
string_local[ind] = 0;
+ type_allocator alloc (objfile);
range_type
- = create_static_range_type (NULL,
+ = create_static_range_type (alloc,
objfile_type (objfile)->builtin_int,
0, ind);
sym->set_type
upper = -1;
}
+ type_allocator alloc (objfile);
range_type =
- create_static_range_type (NULL, index_type, lower, upper);
+ create_static_range_type (alloc, index_type, lower, upper);
type = create_array_type (type, element_type, range_type);
return type;
}
result_type
- = create_static_range_type (NULL, index_type, n2, n3);
+ = create_static_range_type (alloc, index_type, n2, n3);
return (result_type);
}
"divide object size in cast"));
/* FIXME-type-allocation: need a way to free this type when
we are done with it. */
- range_type = create_static_range_type (NULL,
+ type_allocator alloc (range_type->target_type ());
+ range_type = create_static_range_type (alloc,
range_type->target_type (),
low_bound,
new_length + low_bound - 1);
/* FIXME-type-allocation: need a way to free this type when we are
done with it. */
- slice_range_type = create_static_range_type (NULL,
+ type_allocator alloc (range_type->target_type ());
+ slice_range_type = create_static_range_type (alloc,
range_type->target_type (),
lowbound,
lowbound + length - 1);