(lookup_string_range_type): Likewise.
* gdbtypes.c (lookup_array_range_type): New function.
(lookup_string_range_type): Likewise.
* ax-gdb.c (gen_repeat): Use lookup_array_range_type.
* parse.c (follow_types): Likewise.
* jv-lang.c (java_array_type): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
* mt-tdep.c (mt_register_type): Likewise.
* sh-tdep.c (sh_sh4_build_float_register_type): Likewise.
* sh64-tdep.c (sh64_build_float_register_type): Likewise.
* value.c (allocate_repeat_value): Likewise.
* valops.c (value_array, value_cstring): Likewise.
* valops.c (value_string): Use lookup_string_range_type.
+2009-07-02 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * gdbtypes.c (lookup_array_range_type): Add prototype.
+ (lookup_string_range_type): Likewise.
+ * gdbtypes.c (lookup_array_range_type): New function.
+ (lookup_string_range_type): Likewise.
+
+ * ax-gdb.c (gen_repeat): Use lookup_array_range_type.
+ * parse.c (follow_types): Likewise.
+ * jv-lang.c (java_array_type): Likewise.
+ * gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
+ * mt-tdep.c (mt_register_type): Likewise.
+ * sh-tdep.c (sh_sh4_build_float_register_type): Likewise.
+ * sh64-tdep.c (sh64_build_float_register_type): Likewise.
+ * value.c (allocate_repeat_value): Likewise.
+ * valops.c (value_array, value_cstring): Likewise.
+ * valops.c (value_string): Use lookup_string_range_type.
+
2009-07-02 Ulrich Weigand <uweigand@de.ibm.com>
* m2-typeprint.c (m2_print_bounds, m2_is_long_set_of_type): Remove
{
/* FIXME-type-allocation: need a way to free this type when we are
done with it. */
- struct type *range
- = create_range_type (0, builtin_type_int32, 0, length - 1);
- struct type *array = create_array_type (0, value1.type, range);
+ struct type *array
+ = lookup_array_range_type (value1.type, 0, length - 1);
value->kind = axs_lvalue_memory;
value->type = array;
return result_type;
}
+struct type *
+lookup_array_range_type (struct type *element_type,
+ int low_bound, int high_bound)
+{
+ struct gdbarch *gdbarch = current_gdbarch;
+ struct type *index_type = builtin_type (gdbarch)->builtin_int;
+ struct type *range_type
+ = create_range_type (NULL, index_type, low_bound, high_bound);
+ return create_array_type (NULL, 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
return result_type;
}
+struct type *
+lookup_string_range_type (struct type *string_char_type,
+ int low_bound, int high_bound)
+{
+ struct type *result_type;
+ result_type = lookup_array_range_type (string_char_type,
+ low_bound, high_bound);
+ TYPE_CODE (result_type) = TYPE_CODE_STRING;
+ return result_type;
+}
+
struct type *
create_set_type (struct type *result_type, struct type *domain_type)
{
init_vector_type (struct type *elt_type, int n)
{
struct type *array_type;
-
- array_type = create_array_type (0, elt_type,
- create_range_type (0,
- builtin_type_int32,
- 0, n-1));
+ array_type = lookup_array_range_type (elt_type, 0, n - 1);
make_vector_type (array_type);
return array_type;
}
extern struct type *create_array_type (struct type *, struct type *,
struct type *);
+extern struct type *lookup_array_range_type (struct type *, int, int);
extern struct type *create_string_type (struct type *, struct type *,
struct type *);
+extern struct type *lookup_string_range_type (struct type *, int, int);
extern struct type *create_set_type (struct type *, struct type *);
/* ptrdiff_t vcall_and_vbase_offsets[0]; */
FIELD_NAME (*field) = "vcall_and_vbase_offsets";
- FIELD_TYPE (*field)
- = create_array_type (0, ptrdiff_type,
- create_range_type (0, builtin_type_int32, 0, -1));
+ FIELD_TYPE (*field) = lookup_array_range_type (ptrdiff_type, 0, -1);
FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT;
offset += TYPE_LENGTH (FIELD_TYPE (*field));
field++;
/* void (*virtual_functions[0]) (); */
FIELD_NAME (*field) = "virtual_functions";
- FIELD_TYPE (*field)
- = create_array_type (0, ptr_to_void_fn_type,
- create_range_type (0, builtin_type_int32, 0, -1));
+ FIELD_TYPE (*field) = lookup_array_range_type (ptr_to_void_fn_type, 0, -1);
FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT;
offset += TYPE_LENGTH (FIELD_TYPE (*field));
field++;
struct type *
java_array_type (struct type *type, int dims)
{
- struct type *range_type;
-
while (dims-- > 0)
{
- range_type = create_range_type (NULL, builtin_type_int32, 0, 0);
/* FIXME This is bogus! Java arrays are not gdb arrays! */
- type = create_array_type (NULL, type, range_type);
+ type = lookup_array_range_type (type, 0, 0);
}
return type;
if (regnum >= 0 && regnum < MT_NUM_REGS + MT_NUM_PSEUDO_REGS)
{
if (copro_type == NULL)
- {
- struct type *temp;
- temp = create_range_type (NULL, builtin_type_int32, 0, 1);
- copro_type = create_array_type (NULL, builtin_type_int16, temp);
- }
+ copro_type = lookup_array_range_type (builtin_type_int16, 0, 1);
switch (regnum)
{
case MT_PC_REGNUM:
int make_volatile = 0;
int make_addr_space = 0;
int array_size;
- struct type *range_type;
while (!done)
switch (pop_type ())
array_size = pop_type_int ();
/* FIXME-type-allocation: need a way to free this type when we are
done with it. */
- range_type =
- create_range_type ((struct type *) NULL,
- builtin_type_int32, 0,
- array_size >= 0 ? array_size - 1 : 0);
follow_type =
- create_array_type ((struct type *) NULL,
- follow_type, range_type);
+ lookup_array_range_type (follow_type,
+ 0, array_size >= 0 ? array_size - 1 : 0);
if (array_size < 0)
TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (follow_type) = 1;
break;
static struct type *
sh_sh4_build_float_register_type (struct gdbarch *gdbarch, int high)
{
- struct type *temp;
-
- temp = create_range_type (NULL, builtin_type_int32, 0, high);
- return create_array_type (NULL, builtin_type (gdbarch)->builtin_float, temp);
+ return lookup_array_range_type (builtin_type (gdbarch)->builtin_float,
+ 0, high);
}
static struct type *
static struct type *
sh64_build_float_register_type (struct gdbarch *gdbarch, int high)
{
- struct type *temp;
-
- temp = create_range_type (NULL, builtin_type_int32, 0, high);
- return create_array_type (NULL, builtin_type (gdbarch)->builtin_float, temp);
+ return lookup_array_range_type (builtin_type (gdbarch)->builtin_float,
+ 0, high);
}
/* Return the GDB type object for the "standard" data type
int idx;
unsigned int typelength;
struct value *val;
- struct type *rangetype;
struct type *arraytype;
CORE_ADDR addr;
}
}
- rangetype = create_range_type ((struct type *) NULL,
- builtin_type_int32,
- lowbound, highbound);
- arraytype = create_array_type ((struct type *) NULL,
- value_enclosing_type (elemvec[0]),
- rangetype);
+ arraytype = lookup_array_range_type (value_enclosing_type (elemvec[0]),
+ lowbound, highbound);
if (!current_language->c_style_arrays)
{
struct value *val;
int lowbound = current_language->string_lower_bound;
int highbound = len / TYPE_LENGTH (char_type);
- struct type *rangetype = create_range_type ((struct type *) NULL,
- builtin_type_int32,
- lowbound,
- highbound + lowbound - 1);
struct type *stringtype
- = create_array_type ((struct type *) NULL, char_type, rangetype);
+ = lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1);
val = allocate_value (stringtype);
memcpy (value_contents_raw (val), ptr, len);
struct value *val;
int lowbound = current_language->string_lower_bound;
int highbound = len / TYPE_LENGTH (char_type);
- struct type *rangetype = create_range_type ((struct type *) NULL,
- builtin_type_int32,
- lowbound,
- highbound + lowbound - 1);
struct type *stringtype
- = create_string_type ((struct type *) NULL, char_type, rangetype);
+ = lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1);
val = allocate_value (stringtype);
memcpy (value_contents_raw (val), ptr, len);
int low_bound = current_language->string_lower_bound; /* ??? */
/* FIXME-type-allocation: need a way to free this type when we are
done with it. */
- struct type *range_type
- = create_range_type ((struct type *) NULL, builtin_type_int32,
- low_bound, count + low_bound - 1);
- /* FIXME-type-allocation: need a way to free this type when we are
- done with it. */
- return allocate_value (create_array_type ((struct type *) NULL,
- type, range_type));
+ struct type *array_type
+ = lookup_array_range_type (type, low_bound, count + low_bound - 1);
+ return allocate_value (array_type);
}
/* Needed if another module needs to maintain its on list of values. */