}
fn->set_num_fields (nparams);
- TYPE_FIELDS (fn)
- = (struct field *) TYPE_ZALLOC (fn, nparams * sizeof (struct field));
+ fn->set_fields
+ ((struct field *) TYPE_ZALLOC (fn, nparams * sizeof (struct field)));
for (i = 0; i < nparams; ++i)
TYPE_FIELD_TYPE (fn, i) = param_types[i];
case TYPE_CODE_RANGE:
*lowp = TYPE_LOW_BOUND (type);
*highp = TYPE_HIGH_BOUND (type);
+ if (TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_ENUM)
+ {
+ if (!discrete_position (TYPE_TARGET_TYPE (type), *lowp, lowp)
+ || ! discrete_position (TYPE_TARGET_TYPE (type), *highp, highp))
+ return 0;
+ }
return 1;
case TYPE_CODE_ENUM:
if (type->num_fields () > 0)
int
discrete_position (struct type *type, LONGEST val, LONGEST *pos)
{
+ if (type->code () == TYPE_CODE_RANGE)
+ type = TYPE_TARGET_TYPE (type);
+
if (type->code () == TYPE_CODE_ENUM)
{
int i;
TYPE_TARGET_TYPE (result_type) = element_type;
result_type->set_num_fields (1);
- TYPE_FIELDS (result_type) =
- (struct field *) TYPE_ZALLOC (result_type, sizeof (struct field));
+ result_type->set_fields
+ ((struct field *) TYPE_ZALLOC (result_type, sizeof (struct field)));
TYPE_INDEX_TYPE (result_type) = range_type;
if (byte_stride_prop != NULL)
result_type->add_dyn_prop (DYN_PROP_BYTE_STRIDE, *byte_stride_prop);
result_type->set_code (TYPE_CODE_SET);
result_type->set_num_fields (1);
- TYPE_FIELDS (result_type)
- = (struct field *) TYPE_ZALLOC (result_type, sizeof (struct field));
+ result_type->set_fields
+ ((struct field *) TYPE_ZALLOC (result_type, sizeof (struct field)));
if (!TYPE_STUB (domain_type))
{
type->set_code (TYPE_CODE_METHOD);
TYPE_TARGET_TYPE (type) = to_type;
set_type_self_type (type, self_type);
- TYPE_FIELDS (type) = args;
+ type->set_fields (args);
type->set_num_fields (nargs);
if (varargs)
TYPE_VARARGS (type) = 1;
if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
{
- return {&TYPE_FIELD (type, i), TYPE_FIELD_BITPOS (type, i)};
+ return {&type->field (i), TYPE_FIELD_BITPOS (type, i)};
}
else if (!t_field_name || *t_field_name == '\0')
{
for (i = 0; i < type->num_fields (); ++i)
{
/* Static fields can be ignored here. */
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
continue;
/* If the field has dynamic type, then so does TYPE. */
if (is_dynamic_type_internal (TYPE_FIELD_TYPE (type, i), 0))
gdb_assert (type->code () == TYPE_CODE_UNION);
resolved_type = copy_type (type);
- TYPE_FIELDS (resolved_type)
- = (struct field *) TYPE_ALLOC (resolved_type,
- resolved_type->num_fields ()
- * sizeof (struct field));
- memcpy (TYPE_FIELDS (resolved_type),
- TYPE_FIELDS (type),
+ resolved_type->set_fields
+ ((struct field *)
+ TYPE_ALLOC (resolved_type,
+ resolved_type->num_fields () * sizeof (struct field)));
+ memcpy (resolved_type->fields (),
+ type->fields (),
resolved_type->num_fields () * sizeof (struct field));
for (i = 0; i < resolved_type->num_fields (); ++i)
{
struct type *t;
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
continue;
t = resolve_dynamic_type_internal (TYPE_FIELD_TYPE (resolved_type, i),
resolved_type->set_num_fields
(std::count (flags.begin (), flags.end (), true));
- TYPE_FIELDS (resolved_type)
- = (struct field *) TYPE_ALLOC (resolved_type,
- resolved_type->num_fields ()
- * sizeof (struct field));
+ resolved_type->set_fields
+ ((struct field *)
+ TYPE_ALLOC (resolved_type,
+ resolved_type->num_fields () * sizeof (struct field)));
+
int out = 0;
for (int i = 0; i < type->num_fields (); ++i)
{
if (!flags[i])
continue;
- TYPE_FIELD (resolved_type, out) = TYPE_FIELD (type, i);
+ resolved_type->field (out) = type->field (i);
++out;
}
}
}
else
{
- TYPE_FIELDS (resolved_type)
- = (struct field *) TYPE_ALLOC (resolved_type,
- resolved_type->num_fields ()
- * sizeof (struct field));
- memcpy (TYPE_FIELDS (resolved_type),
- TYPE_FIELDS (type),
+ resolved_type->set_fields
+ ((struct field *)
+ TYPE_ALLOC (resolved_type,
+ resolved_type->num_fields () * sizeof (struct field)));
+ memcpy (resolved_type->fields (),
+ type->fields (),
resolved_type->num_fields () * sizeof (struct field));
}
unsigned new_bit_length;
struct property_addr_info pinfo;
- if (field_is_static (&TYPE_FIELD (resolved_type, i)))
+ if (field_is_static (&resolved_type->field (i)))
continue;
if (TYPE_FIELD_LOC_KIND (resolved_type, i) == FIELD_LOC_KIND_DWARF_BLOCK)
CORE_ADDR addr;
if (dwarf2_evaluate_property (&prop, nullptr, addr_stack, &addr,
true))
- SET_FIELD_BITPOS (TYPE_FIELD (resolved_type, i),
+ SET_FIELD_BITPOS (resolved_type->field (i),
TARGET_CHAR_BIT * (addr - addr_stack->addr));
}
int number_of_non_static_fields = 0;
for (unsigned i = 0; i < type->num_fields (); ++i)
{
- if (!field_is_static (&TYPE_FIELD (type, i)))
+ if (!field_is_static (&type->field (i)))
{
number_of_non_static_fields++;
ULONGEST f_align = type_align (TYPE_FIELD_TYPE (type, i));
for (i = 0; i < type1->num_fields (); ++i)
{
- const struct field *field1 = &TYPE_FIELD (type1, i);
- const struct field *field2 = &TYPE_FIELD (type2, i);
+ const struct field *field1 = &type1->field (i);
+ const struct field *field2 = &type2->field (i);
if (FIELD_ARTIFICIAL (*field1) != FIELD_ARTIFICIAL (*field2)
|| FIELD_BITSIZE (*field1) != FIELD_BITSIZE (*field2)
}
puts_filtered ("\n");
printfi_filtered (spaces, "nfields %d ", type->num_fields ());
- gdb_print_host_address (TYPE_FIELDS (type), gdb_stdout);
+ gdb_print_host_address (type->fields (), gdb_stdout);
puts_filtered ("\n");
for (idx = 0; idx < type->num_fields (); idx++)
{
int i, nfields;
nfields = type->num_fields ();
- TYPE_FIELDS (new_type) = (struct field *)
- TYPE_ZALLOC (new_type, nfields * sizeof (struct field));
+ new_type->set_fields
+ ((struct field *)
+ TYPE_ZALLOC (new_type, nfields * sizeof (struct field)));
+
for (i = 0; i < nfields; i++)
{
TYPE_FIELD_ARTIFICIAL (new_type, i) =
switch (TYPE_FIELD_LOC_KIND (type, i))
{
case FIELD_LOC_KIND_BITPOS:
- SET_FIELD_BITPOS (TYPE_FIELD (new_type, i),
+ SET_FIELD_BITPOS (new_type->field (i),
TYPE_FIELD_BITPOS (type, i));
break;
case FIELD_LOC_KIND_ENUMVAL:
- SET_FIELD_ENUMVAL (TYPE_FIELD (new_type, i),
+ SET_FIELD_ENUMVAL (new_type->field (i),
TYPE_FIELD_ENUMVAL (type, i));
break;
case FIELD_LOC_KIND_PHYSADDR:
- SET_FIELD_PHYSADDR (TYPE_FIELD (new_type, i),
+ SET_FIELD_PHYSADDR (new_type->field (i),
TYPE_FIELD_STATIC_PHYSADDR (type, i));
break;
case FIELD_LOC_KIND_PHYSNAME:
- SET_FIELD_PHYSNAME (TYPE_FIELD (new_type, i),
+ SET_FIELD_PHYSNAME (new_type->field (i),
xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type,
i)));
break;
TYPE_UNSIGNED (type) = 1;
type->set_num_fields (0);
/* Pre-allocate enough space assuming every field is one bit. */
- TYPE_FIELDS (type)
- = (struct field *) TYPE_ZALLOC (type, bit * sizeof (struct field));
+ type->set_fields
+ ((struct field *) TYPE_ZALLOC (type, bit * sizeof (struct field)));
return type;
}
TYPE_FIELD_NAME (type, field_nr) = xstrdup (name);
TYPE_FIELD_TYPE (type, field_nr) = field_type;
- SET_FIELD_BITPOS (TYPE_FIELD (type, field_nr), start_bitpos);
+ SET_FIELD_BITPOS (type->field (field_nr), start_bitpos);
TYPE_FIELD_BITSIZE (type, field_nr) = nr_bits;
type->set_num_fields (type->num_fields () + 1);
}
struct field *f;
t->set_num_fields (t->num_fields () + 1);
- TYPE_FIELDS (t) = XRESIZEVEC (struct field, TYPE_FIELDS (t),
- t->num_fields ());
- f = &(TYPE_FIELDS (t)[t->num_fields () - 1]);
+ t->set_fields (XRESIZEVEC (struct field, t->fields (),
+ t->num_fields ()));
+ f = &t->field (t->num_fields () - 1);
memset (f, 0, sizeof f[0]);
FIELD_TYPE (f[0]) = field;
FIELD_NAME (f[0]) = name;