return NULL;
while (arity > 0)
{
- struct type *range_type = alloc_type_copy (arr->type ());
- struct type *array_type = alloc_type_copy (arr->type ());
+ 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);
else
index_type = type->index_type ();
- new_type = alloc_type_copy (type);
+ new_type = type_allocator (type).new_type ();
new_elt_type =
constrained_packed_array_type (ada_check_typedef (type->target_type ()),
elt_bits);
static struct type *
empty_record (struct type *templ)
{
- struct type *type = alloc_type_copy (templ);
+ struct type *type = type_allocator (templ).new_type ();
type->set_code (TYPE_CODE_STRUCT);
INIT_NONE_SPECIFIC (type);
nfields++;
}
- rtype = alloc_type_copy (type);
+ rtype = type_allocator (type).new_type ();
rtype->set_code (TYPE_CODE_STRUCT);
INIT_NONE_SPECIFIC (rtype);
rtype->set_num_fields (nfields);
/* Clone TYPE0 only the first time we get a new field type. */
if (type == type0)
{
- type = alloc_type_copy (type0);
+ type = type_allocator (type0).new_type ();
type0->set_target_type (type);
type->set_code (type0->code ());
INIT_NONE_SPECIFIC (type);
else
dval = dval0;
- rtype = alloc_type_copy (type);
+ rtype = type_allocator (type).new_type ();
rtype->set_code (TYPE_CODE_STRUCT);
INIT_NONE_SPECIFIC (rtype);
rtype->set_num_fields (nfields);
if (elt_type0 == elt_type && !constrained_packed_array_p)
result = type0;
else
- result = create_array_type (alloc_type_copy (type0),
+ result = create_array_type (type_allocator (type0).new_type (),
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 (alloc_type_copy (elt_type0),
+ result = create_array_type (type_allocator (elt_type0).new_type (),
result, range_type);
elt_type0 = elt_type0->target_type ();
}
if (L < INT_MIN || U > INT_MAX)
return raw_type;
else
- return create_static_range_type (alloc_type_copy (raw_type), raw_type,
- L, U);
+ return create_static_range_type (type_allocator (raw_type).new_type (),
+ raw_type, L, U);
}
else
{
}
}
- type = create_static_range_type (alloc_type_copy (raw_type),
+ type = create_static_range_type (type_allocator (raw_type).new_type (),
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.
return type;
}
-/* If TYPE is objfile-associated, allocate a new type structure
- associated with the same objfile. If TYPE is gdbarch-associated,
- allocate a new type structure associated with the same gdbarch. */
-
-struct type *
-alloc_type_copy (const struct type *type)
-{
- return type_allocator (type).new_type ();
-}
-
/* See gdbtypes.h. */
type *
if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
{
- ntype = alloc_type_copy (type);
+ ntype = type_allocator (type).new_type ();
if (typeptr)
*typeptr = ntype;
}
if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
{
- ntype = alloc_type_copy (type);
+ ntype = type_allocator (type).new_type ();
if (typeptr)
*typeptr = ntype;
}
if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
{
- ntype = alloc_type_copy (type);
+ ntype = type_allocator (type).new_type ();
if (typeptr)
*typeptr = ntype;
}
{
struct type *mtype;
- mtype = alloc_type_copy (type);
+ mtype = type_allocator (type).new_type ();
smash_to_memberptr_type (mtype, domain, type);
return mtype;
}
{
struct type *mtype;
- mtype = alloc_type_copy (to_type);
+ mtype = type_allocator (to_type).new_type ();
smash_to_methodptr_type (mtype, to_type);
return mtype;
}
gdb_assert (index_type->length () > 0);
if (result_type == NULL)
- result_type = alloc_type_copy (index_type);
+ result_type = type_allocator (index_type).new_type ();
result_type->set_code (TYPE_CODE_RANGE);
result_type->set_target_type (index_type);
if (index_type->is_stub ())
}
if (result_type == NULL)
- result_type = alloc_type_copy (range_type);
+ result_type = type_allocator (range_type).new_type ();
result_type->set_code (TYPE_CODE_ARRAY);
result_type->set_target_type (element_type);
create_set_type (struct type *result_type, struct type *domain_type)
{
if (result_type == NULL)
- result_type = alloc_type_copy (domain_type);
+ result_type = type_allocator (domain_type).new_type ();
result_type->set_code (TYPE_CODE_SET);
result_type->set_num_fields (1);
name = new_name;
}
- t = alloc_type_copy (target_type);
+ t = type_allocator (target_type).new_type ();
set_type_code (t, TYPE_CODE_COMPLEX);
t->set_length (2 * target_type->length ());
t->set_name (name);
struct type *
copy_type (const struct type *type)
{
- struct type *new_type = alloc_type_copy (type);
+ struct type *new_type = type_allocator (type).new_type ();
new_type->set_instance_flags (type->instance_flags ());
new_type->set_length (type->length ());
memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type),
#define TYPE_ZALLOC(t,size) (memset (TYPE_ALLOC (t, size), 0, size))
-/* Use alloc_type to allocate a type owned by an objfile. Use
- alloc_type_copy to allocate a type with the same owner as a
- pre-existing template type, no matter whether objfile or
- gdbarch. */
+/* Use alloc_type to allocate a type owned by an objfile. */
extern struct type *alloc_type (struct objfile *);
-extern struct type *alloc_type_copy (const struct type *);
/* * This returns the target type (or NULL) of TYPE, also skipping
past typedefs. */
const char *field1, struct type *type1,
const char *field2, struct type *type2)
{
- struct type *result = alloc_type_copy (original);
+ struct type *result = type_allocator (original).new_type ();
int i, nfields, bitpos;
nfields = 0;
{
struct type *mtype;
- mtype = alloc_type_copy (type);
+ mtype = type_allocator (type).new_type ();
mtype->set_code (TYPE_CODE_METHOD);
mtype->set_length (1);
mtype->set_is_stub (true);