+2020-05-22 Simon Marchi <simon.marchi@efficios.com>
+
+ * gdbtypes.h (TYPE_NFIELDS): Remove. Change all cal sites to use
+ type::num_fields instead.
+
2020-05-22 Simon Marchi <simon.marchi@efficios.com>
* gdbtypes.h (struct type) <num_fields, set_num_fields>: New
{
int count = 0;
- for (int i = 0; i < TYPE_NFIELDS (type); i++)
+ for (int i = 0; i < type->num_fields (); i++)
{
/* Ignore any static fields. */
if (field_is_static (&TYPE_FIELD (type, i)))
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
- for (int i = 0; i < TYPE_NFIELDS (arg_type); i++)
+ for (int i = 0; i < arg_type->num_fields (); i++)
{
/* Don't include static fields. */
if (field_is_static (&TYPE_FIELD (arg_type, i)))
else
xsnprintf (name, sizeof (name), "QU%02x", (int) val);
size_t len = strlen (name);
- for (f = 0; f < TYPE_NFIELDS (type); f += 1)
+ for (f = 0; f < type->num_fields (); f += 1)
{
/* Check the suffix because an enum constant in a package will
have a name like "pkg__QUxx". This is safe enough because we
int fieldno;
struct type *struct_type = check_typedef ((struct type *) type);
- for (fieldno = 0; fieldno < TYPE_NFIELDS (struct_type); fieldno++)
+ for (fieldno = 0; fieldno < struct_type->num_fields (); fieldno++)
if (field_name_match (TYPE_FIELD_NAME (struct_type, fieldno), field_name))
return fieldno;
case TYPE_CODE_RANGE:
return TYPE_HIGH_BOUND (type);
case TYPE_CODE_ENUM:
- return TYPE_FIELD_ENUMVAL (type, TYPE_NFIELDS (type) - 1);
+ return TYPE_FIELD_ENUMVAL (type, type->num_fields () - 1);
case TYPE_CODE_BOOL:
return 1;
case TYPE_CODE_CHAR:
if (index_desc_type == NULL)
return;
- gdb_assert (TYPE_NFIELDS (index_desc_type) > 0);
+ gdb_assert (index_desc_type->num_fields () > 0);
/* Check if INDEX_DESC_TYPE follows the older encoding (it is sufficient
to check one field only, no need to check them all). If not, return
return;
/* Fixup each field of INDEX_DESC_TYPE. */
- for (i = 0; i < TYPE_NFIELDS (index_desc_type); i++)
+ for (i = 0; i < index_desc_type->num_fields (); i++)
{
const char *name = TYPE_FIELD_NAME (index_desc_type, i);
struct type *raw_type = ada_check_typedef (ada_find_any_type (name));
type = desc_base_type (type);
if (type != NULL)
- return TYPE_NFIELDS (type) / 2;
+ return type->num_fields () / 2;
return 0;
}
|| type->code () != TYPE_CODE_FUNC)
return;
- if (TYPE_NFIELDS (type) > 0)
+ if (type->num_fields () > 0)
{
int i;
fprintf_filtered (stream, " (");
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (i = 0; i < type->num_fields (); ++i)
{
if (i > 0)
fprintf_filtered (stream, "; ");
else if (func_type == NULL || func_type->code () != TYPE_CODE_FUNC)
return 0;
- if (TYPE_NFIELDS (func_type) != n_actuals)
+ if (func_type->num_fields () != n_actuals)
return 0;
for (i = 0; i < n_actuals; i += 1)
This function assumes that TYPE1 and TYPE2 are both TYPE_CODE_ENUM
types and that their number of enumerals is identical (in other
- words, TYPE_NFIELDS (type1) == TYPE_NFIELDS (type2)). */
+ words, type1->num_fields () == type2->num_fields ()). */
static int
ada_identical_enum_types_p (struct type *type1, struct type *type2)
underlying value and name. */
/* All enums in the type should have an identical underlying value. */
- for (i = 0; i < TYPE_NFIELDS (type1); i++)
+ for (i = 0; i < type1->num_fields (); i++)
if (TYPE_FIELD_ENUMVAL (type1, i) != TYPE_FIELD_ENUMVAL (type2, i))
return 0;
/* All enumerals should also have the same name (modulo any numerical
suffix). */
- for (i = 0; i < TYPE_NFIELDS (type1); i++)
+ for (i = 0; i < type1->num_fields (); i++)
{
const char *name_1 = TYPE_FIELD_NAME (type1, i);
const char *name_2 = TYPE_FIELD_NAME (type2, i);
/* Quick check: They should all have the same number of enumerals. */
for (i = 1; i < syms.size (); i++)
- if (TYPE_NFIELDS (SYMBOL_TYPE (syms[i].symbol))
- != TYPE_NFIELDS (SYMBOL_TYPE (syms[0].symbol)))
+ if (SYMBOL_TYPE (syms[i].symbol)->num_fields ()
+ != SYMBOL_TYPE (syms[0].symbol)->num_fields ())
return 0;
/* All the sanity checks passed, so we might have a set of
int
ada_is_ignored_field (struct type *type, int field_num)
{
- if (field_num < 0 || field_num > TYPE_NFIELDS (type))
+ if (field_num < 0 || field_num > type->num_fields ())
return 1;
/* Check the name of that field. */
if (type == NULL || type->code () != TYPE_CODE_STRUCT)
return NULL;
- for (i = 0; i < TYPE_NFIELDS (type); i += 1)
+ for (i = 0; i < type->num_fields (); i += 1)
if (ada_is_parent_field (type, i))
{
struct type *parent_type = TYPE_FIELD_TYPE (type, i);
if (bit_size_p != NULL)
*bit_size_p = 0;
- for (i = 0; i < TYPE_NFIELDS (type); i += 1)
+ for (i = 0; i < type->num_fields (); i += 1)
{
int bit_pos = TYPE_FIELD_BITPOS (type, i);
int fld_offset = offset + bit_pos / 8;
struct type *field_type
= ada_check_typedef (TYPE_FIELD_TYPE (type, i));
- for (j = 0; j < TYPE_NFIELDS (field_type); j += 1)
+ for (j = 0; j < field_type->num_fields (); j += 1)
{
if (find_struct_field (name, TYPE_FIELD_TYPE (field_type, j),
fld_offset
int parent_offset = -1;
type = ada_check_typedef (type);
- for (i = 0; i < TYPE_NFIELDS (type); i += 1)
+ for (i = 0; i < type->num_fields (); i += 1)
{
const char *t_field_name = TYPE_FIELD_NAME (type, i);
i));
int var_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8;
- for (j = 0; j < TYPE_NFIELDS (field_type); j += 1)
+ for (j = 0; j < field_type->num_fields (); j += 1)
{
struct value *v = ada_search_struct_field /* Force line
break. */
int i;
type = ada_check_typedef (type);
- for (i = 0; i < TYPE_NFIELDS (type); i += 1)
+ for (i = 0; i < type->num_fields (); i += 1)
{
if (TYPE_FIELD_NAME (type, i) == NULL)
continue;
type = to_static_fixed_type (type);
- for (i = 0; i < TYPE_NFIELDS (type); i += 1)
+ for (i = 0; i < type->num_fields (); i += 1)
{
const char *t_field_name = TYPE_FIELD_NAME (type, i);
struct type *t;
struct type *field_type = ada_check_typedef (TYPE_FIELD_TYPE (type,
i));
- for (j = TYPE_NFIELDS (field_type) - 1; j >= 0; j -= 1)
+ for (j = field_type->num_fields () - 1; j >= 0; j -= 1)
{
/* FIXME pnh 2008/01/26: We check for a field that is
NOT wrapped in a struct, since the compiler sometimes
discrim_val = value_as_long (discrim);
others_clause = -1;
- for (i = 0; i < TYPE_NFIELDS (var_type); i += 1)
+ for (i = 0; i < var_type->num_fields (); i += 1)
{
if (ada_is_others_clause (var_type, i))
others_clause = i;
if (type == NULL || type->code () != TYPE_CODE_STRUCT)
return -1;
- for (f = 0; f < TYPE_NFIELDS (type); f += 1)
+ for (f = 0; f < type->num_fields (); f += 1)
{
if (ada_is_variant_part (type, f))
return f;
to be processed: unless keep_dynamic_fields, this includes only
fields whose position and length are static will be processed. */
if (keep_dynamic_fields)
- nfields = TYPE_NFIELDS (type);
+ nfields = type->num_fields ();
else
{
nfields = 0;
- while (nfields < TYPE_NFIELDS (type)
+ while (nfields < type->num_fields ()
&& !ada_is_variant_part (type, nfields)
&& !is_dynamic_field (type, nfields))
nfields++;
cond_offset_target (address, off / TARGET_CHAR_BIT), dval);
if (branch_type == NULL)
{
- for (f = variant_field + 1; f < TYPE_NFIELDS (rtype); f += 1)
+ for (f = variant_field + 1; f < rtype->num_fields (); f += 1)
TYPE_FIELDS (rtype)[f - 1] = TYPE_FIELDS (rtype)[f];
rtype->set_num_fields (rtype->num_fields () - 1);
}
/* Don't clone TYPE0 until we are sure we are going to need a copy. */
type = type0;
- nfields = TYPE_NFIELDS (type0);
+ nfields = type0->num_fields ();
/* Whether or not we cloned TYPE0, cache the result so that we don't do
recompute all over next time. */
struct value *dval;
struct type *rtype;
struct type *branch_type;
- int nfields = TYPE_NFIELDS (type);
+ int nfields = type->num_fields ();
int variant_field = variant_field_index (type);
if (variant_field == -1)
struct type *this_layer = check_typedef (array_type);
int i;
- for (i = 0; i < TYPE_NFIELDS (desc_type); i++)
+ for (i = 0; i < desc_type->num_fields (); i++)
{
if (!ada_is_redundant_range_encoding (TYPE_INDEX_TYPE (this_layer),
TYPE_FIELD_TYPE (desc_type, i)))
struct type *elt_type0;
elt_type0 = type0;
- for (i = TYPE_NFIELDS (index_type_desc); i > 0; i -= 1)
+ for (i = index_type_desc->num_fields (); i > 0; i -= 1)
elt_type0 = TYPE_TARGET_TYPE (elt_type0);
/* NOTE: result---the fixed version of elt_type0---should never
ada_to_fixed_type (ada_check_typedef (elt_type0), 0, 0, dval, 1);
elt_type0 = type0;
- for (i = TYPE_NFIELDS (index_type_desc) - 1; i >= 0; i -= 1)
+ for (i = index_type_desc->num_fields () - 1; i >= 0; i -= 1)
{
struct type *range_type =
to_fixed_range_type (TYPE_FIELD_TYPE (index_type_desc, i), dval);
{
long pos = value_as_long (arg);
- if (pos < 0 || pos >= TYPE_NFIELDS (type))
+ if (pos < 0 || pos >= type->num_fields ())
error (_("argument to 'VAL out of range"));
return value_from_longest (type, TYPE_FIELD_ENUMVAL (type, pos));
}
return 0;
return (type->code () == TYPE_CODE_STRUCT
- && TYPE_NFIELDS (type) == 1
+ && type->num_fields () == 1
&& strcmp (TYPE_FIELD_NAME (type, 0), "F") == 0);
}
real_type_namer = ada_find_parallel_type (raw_type, "___XVS");
if (real_type_namer == NULL
|| real_type_namer->code () != TYPE_CODE_STRUCT
- || TYPE_NFIELDS (real_type_namer) != 1)
+ || real_type_namer->num_fields () != 1)
return raw_type;
if (TYPE_FIELD_TYPE (real_type_namer, 0)->code () != TYPE_CODE_REF)
static void
print_enum_type (struct type *type, struct ui_file *stream)
{
- int len = TYPE_NFIELDS (type);
+ int len = type->num_fields ();
int i;
LONGEST lastval;
{
int k;
- n_indices = TYPE_NFIELDS (range_desc_type);
+ n_indices = range_desc_type->num_fields ();
for (k = 0, arr_type = type;
k < n_indices;
k += 1, arr_type = TYPE_TARGET_TYPE (arr_type))
if (par_type != NULL)
var_type = par_type;
- for (i = 0; i < TYPE_NFIELDS (var_type); i += 1)
+ for (i = 0; i < var_type->num_fields (); i += 1)
{
fprintf_filtered (stream, "\n%*swhen ", level + 4, "");
if (print_choices (var_type, i, stream, discr_type))
}
gdb_assert (prop->kind == PROP_VARIANT_PARTS);
print_record_field_types_dynamic (*prop->data.variant_parts,
- 0, TYPE_NFIELDS (type),
+ 0, type->num_fields (),
type, stream, show, level, flags);
- return TYPE_NFIELDS (type);
+ return type->num_fields ();
}
return print_selected_record_field_types (type, outer_type,
- 0, TYPE_NFIELDS (type) - 1,
+ 0, type->num_fields () - 1,
stream, show, level, flags);
}
{
if (show < 0)
fprintf_filtered (stream, "record (?) is ... end record");
- else if (TYPE_NFIELDS (type) == 0)
+ else if (type->num_fields () == 0)
fprintf_filtered (stream, "record (?) is null; end record");
else
{
fprintf_filtered (stream, "record (?) is\n%*scase ? is", level + 4, "");
- for (i = 0; i < TYPE_NFIELDS (type); i += 1)
+ for (i = 0; i < type->num_fields (); i += 1)
{
fprintf_filtered (stream, "\n%*swhen ? =>\n%*s", level + 8, "",
level + 12, "");
print_func_type (struct type *type, struct ui_file *stream, const char *name,
const struct type_print_options *flags)
{
- int i, len = TYPE_NFIELDS (type);
+ int i, len = type->num_fields ();
if (TYPE_TARGET_TYPE (type) != NULL
&& TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_VOID)
{
case TYPE_CODE_ENUM:
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
for (i = 0; i < len; i++)
{
if (TYPE_FIELD_ENUMVAL (type, i) == val)
int i, len;
struct type *type = value_type (value);
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
for (i = 0; i < len; i += 1)
{
const gdb_byte *valaddr = value_contents_for_printing (value);
int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr;
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
val = unpack_long (type, valaddr + offset_aligned);
for (i = 0; i < len; i++)
{
gdb_assert (parent_type->code () == TYPE_CODE_STRUCT
|| parent_type->code () == TYPE_CODE_UNION);
- for (i = 0; i < TYPE_NFIELDS (parent_type); i++)
+ for (i = 0; i < parent_type->num_fields (); i++)
{
if (ada_is_ignored_field (parent_type, i))
continue;
gdb_assert (parent_type->code () == TYPE_CODE_STRUCT
|| parent_type->code () == TYPE_CODE_UNION);
- for (fieldno = 0; fieldno < TYPE_NFIELDS (parent_type); fieldno++)
+ for (fieldno = 0; fieldno < parent_type->num_fields (); fieldno++)
{
if (ada_is_ignored_field (parent_type, fieldno))
continue;
if (type->code () == TYPE_CODE_STRUCT
|| type->code () == TYPE_CODE_UNION)
{
- for (int i = 0; i < TYPE_NFIELDS (type); i++)
+ for (int i = 0; i < type->num_fields (); i++)
{
struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
int bitpos = TYPE_FIELD_BITPOS (type, i);
{
/* Each field of an object is classified recursively. */
int j;
- for (j = 0; j < TYPE_NFIELDS (subtype); j++)
+ for (j = 0; j < subtype->num_fields (); j++)
amd64_classify_aggregate_field (subtype, j, theclass, bitpos);
return;
}
gdb_assert (type->code () == TYPE_CODE_STRUCT
|| type->code () == TYPE_CODE_UNION);
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
amd64_classify_aggregate_field (type, i, theclass, 0);
}
int count = 0;
unsigned unitlen;
int i;
- for (i = 0; i < TYPE_NFIELDS (t); i++)
+ for (i = 0; i < t->num_fields (); i++)
{
int sub_count = 0;
int count = 0;
unsigned unitlen;
int i;
- for (i = 0; i < TYPE_NFIELDS (t); i++)
+ for (i = 0; i < t->num_fields (); i++)
{
int sub_count = arm_vfp_cprc_sub_candidate (TYPE_FIELD_TYPE (t, i),
base_type);
--> yes, nRc = 1
*/
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
enum type_code field_type_code;
type = check_typedef (type);
- for (i = TYPE_NFIELDS (type) - 1; i >= nbases; i--)
+ for (i = type->num_fields () - 1; i >= nbases; i--)
{
if (field_is_static (&TYPE_FIELD (type, i)))
{
type = check_typedef (type);
- for (i = TYPE_NFIELDS (type) - 1; i >= nbases; i--)
+ for (i = type->num_fields () - 1; i >= nbases; i--)
{
const char *this_name = TYPE_FIELD_NAME (type, i);
internal_error (__FILE__, __LINE__,
_("non-aggregate type to gen_struct_elt_for_reference"));
- for (i = TYPE_NFIELDS (t) - 1; i >= TYPE_N_BASECLASSES (t); i--)
+ for (i = t->num_fields () - 1; i >= TYPE_N_BASECLASSES (t); i--)
{
const char *t_field_name = TYPE_FIELD_NAME (t, i);
SYMBOL_BLOCK_VALUE (symbol) = block;
BLOCK_FUNCTION (block) = symbol;
- if (TYPE_NFIELDS (ftype) <= 0)
+ if (ftype->num_fields () <= 0)
{
/* No parameter type information is recorded with the
function's type. Set that from the type of the
{
/* If we know the size of the array, we can use it as a limit on
the number of characters to be fetched. */
- if (TYPE_NFIELDS (type) == 1
+ if (type->num_fields () == 1
&& TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_RANGE)
{
LONGEST low_bound, high_bound;
const struct type_print_options *flags)
{
struct field *args = TYPE_FIELDS (mtype);
- int nargs = TYPE_NFIELDS (mtype);
+ int nargs = mtype->num_fields ();
int varargs = TYPE_VARARGS (mtype);
int i;
fprintf_filtered (stream, "(");
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
struct type *param_type;
if (TYPE_DECLARED_CLASS (type))
{
QUIT;
- for (int i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++)
+ for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++)
if (!TYPE_FIELD_PRIVATE (type, i))
return true;
QUIT;
else
{
QUIT;
- for (int i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++)
+ for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++)
if (TYPE_FIELD_PRIVATE (type, i) || TYPE_FIELD_PROTECTED (type, i))
return true;
QUIT;
fprintf_filtered (stream, "{\n");
- if (TYPE_NFIELDS (type) == 0 && TYPE_NFN_FIELDS (type) == 0
+ if (type->num_fields () == 0 && TYPE_NFN_FIELDS (type) == 0
&& TYPE_TYPEDEF_FIELD_COUNT (type) == 0)
{
if (TYPE_STUB (type))
/* If there is a base class for this type,
do not print the field that it occupies. */
- int len = TYPE_NFIELDS (type);
+ int len = type->num_fields ();
vptr_fieldno = get_vptr_fieldno (type, &basetype);
struct print_offset_data local_podata;
if (semi_local_flags.print_nested_type_limit > 0)
--semi_local_flags.print_nested_type_limit;
- if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0)
+ if (type->num_fields () != 0 || TYPE_NFN_FIELDS (type) != 0)
fprintf_filtered (stream, "\n");
for (int i = 0; i < TYPE_NESTED_TYPES_COUNT (type); ++i)
if (TYPE_TYPEDEF_FIELD_COUNT (type) != 0 && flags->print_typedefs)
{
- if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0
+ if (type->num_fields () != 0 || TYPE_NFN_FIELDS (type) != 0
|| TYPE_NESTED_TYPES_COUNT (type) != 0)
fprintf_filtered (stream, "\n");
}
fprintf_filtered (stream, "{");
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
for (i = 0; i < len; i++)
{
QUIT;
{
fputs_filtered (" ", stream);
fprintf_filtered (stream, "{\n");
- if (TYPE_NFIELDS (type) == 0)
+ if (type->num_fields () == 0)
{
if (TYPE_STUB (type))
fprintfi_filtered (level + 4, stream,
_("%p[<no data fields>%p]\n"),
metadata_style.style ().ptr (), nullptr);
}
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
for (i = 0; i < len; i++)
{
QUIT;
{
const char *field_name;
- gdb_assert (var->index < TYPE_NFIELDS (parent_type));
+ gdb_assert (var->index < parent_type->num_fields ());
field_name = TYPE_FIELD_NAME (parent_type, var->index);
return !(field_name == NULL || *field_name == '\0');
}
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
- children = TYPE_NFIELDS (type);
+ children = type->num_fields ();
break;
case TYPE_CODE_PTR:
children[v_protected] = 0;
vptr_fieldno = get_vptr_fieldno (type, &basetype);
- for (i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++)
+ for (i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++)
{
/* If we have a virtual table pointer, omit it. Even if virtual
table pointers are not specifically marked in the debug info,
{
struct type *target = TYPE_TARGET_TYPE (type);
struct type *real_target = TYPE_TARGET_TYPE (real_type);
- int field_size = TYPE_NFIELDS (real_target) * sizeof (struct field);
+ int field_size = real_target->num_fields () * sizeof (struct field);
TYPE_LENGTH (target) = TYPE_LENGTH (real_target);
- target->set_num_fields (TYPE_NFIELDS (real_target));
+ target->set_num_fields (real_target->num_fields ());
TYPE_FIELDS (target) = (struct field *) TYPE_ALLOC (target,
field_size);
{
int i;
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (i = 0; i < type->num_fields (); ++i)
if (!field_is_static (&TYPE_FIELD (type, i)))
generate_vla_size (compiler, stream, gdbarch, registers_used, pc,
TYPE_FIELD_TYPE (type, i), sym);
}
context->insert_type (type, result);
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (i = 0; i < type->num_fields (); ++i)
{
gcc_type field_type;
unsigned long bitsize = TYPE_FIELD_BITSIZE (type, i);
TYPE_LENGTH (type));
result = context->plugin ().build_enum_type (int_type);
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (i = 0; i < type->num_fields (); ++i)
{
context->plugin ().build_add_enum_constant
(result, TYPE_FIELD_NAME (type, i), TYPE_FIELD_ENUMVAL (type, i));
types. Those are impossible in C, though. */
return_type = context->convert_type (target_type);
- array.n_elements = TYPE_NFIELDS (type);
- array.elements = XNEWVEC (gcc_type, TYPE_NFIELDS (type));
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ array.n_elements = type->num_fields ();
+ array.elements = XNEWVEC (gcc_type, type->num_fields ());
+ for (i = 0; i < type->num_fields (); ++i)
array.elements[i] = context->convert_type (TYPE_FIELD_TYPE (type, i));
result = context->plugin ().build_function_type (return_type,
compile_cplus_convert_struct_or_union_members
(compile_cplus_instance *instance, struct type *type, gcc_type comp_type)
{
- for (int i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); ++i)
+ for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); ++i)
{
const char *field_name = TYPE_FIELD_NAME (type, i);
? GCC_CP_FLAG_ENUM_SCOPED
: GCC_CP_FLAG_ENUM_NOFLAG),
nullptr, 0);
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
gdb::unique_xmalloc_ptr<char> fname
= compile_cplus_instance::decl_name (TYPE_FIELD_NAME (type, i));
gcc_type return_type = instance->convert_type (target_type);
struct gcc_type_array array =
- { TYPE_NFIELDS (type), XNEWVEC (gcc_type, TYPE_NFIELDS (type)) };
+ { type->num_fields (), XNEWVEC (gcc_type, type->num_fields ()) };
int artificials = 0;
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
if (strip_artificial && TYPE_FIELD_ARTIFICIAL (type, i))
{
struct type *regsp_type, *regs_type;
/* No register parameter present. */
- if (TYPE_NFIELDS (func_type) == 0)
+ if (func_type->num_fields () == 0)
return NULL;
regsp_type = check_typedef (TYPE_FIELD_TYPE (func_type, 0));
struct gdbarch *gdbarch = target_gdbarch ();
int fieldno;
- for (fieldno = 0; fieldno < TYPE_NFIELDS (regs_type); fieldno++)
+ for (fieldno = 0; fieldno < regs_type->num_fields (); fieldno++)
{
const char *reg_name = TYPE_FIELD_NAME (regs_type, fieldno);
ULONGEST reg_bitpos = TYPE_FIELD_BITPOS (regs_type, fieldno);
default:
internal_error (__FILE__, __LINE__, _("invalid scope %d"), scope);
}
- if (TYPE_NFIELDS (func_type) != expect_parameters)
+ if (func_type->num_fields () != expect_parameters)
error (_("Invalid %d parameters of function \"%s\" in compiled "
"module \"%s\"."),
- TYPE_NFIELDS (func_type), GCC_FE_WRAPPER_FUNCTION,
+ func_type->num_fields (), GCC_FE_WRAPPER_FUNCTION,
objfile_name (objfile));
if (!types_deeply_equal (expect_return_type, TYPE_TARGET_TYPE (func_type)))
error (_("Invalid return type of function \"%s\" in compiled "
func_val = value_from_pointer (lookup_pointer_type (func_type),
BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (func_sym)));
- vargs = XALLOCAVEC (struct value *, TYPE_NFIELDS (func_type));
- if (TYPE_NFIELDS (func_type) >= 1)
+ vargs = XALLOCAVEC (struct value *, func_type->num_fields ());
+ if (func_type->num_fields () >= 1)
{
gdb_assert (regs_addr != 0);
vargs[current_arg] = value_from_pointer
(TYPE_FIELD_TYPE (func_type, current_arg), regs_addr);
++current_arg;
}
- if (TYPE_NFIELDS (func_type) >= 2)
+ if (func_type->num_fields () >= 2)
{
gdb_assert (data->out_value_addr != 0);
vargs[current_arg] = value_from_pointer
(TYPE_FIELD_TYPE (func_type, current_arg), data->out_value_addr);
++current_arg;
}
- gdb_assert (current_arg == TYPE_NFIELDS (func_type));
- auto args = gdb::make_array_view (vargs, TYPE_NFIELDS (func_type));
+ gdb_assert (current_arg == func_type->num_fields ());
+ auto args = gdb::make_array_view (vargs, func_type->num_fields ());
call_function_by_hand_dummy (func_val, NULL, args,
do_module_cleanup, data);
}
const char *type_name = NULL;
type = check_typedef (type);
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (i = 0; i < type->num_fields (); ++i)
{
if (i < TYPE_N_BASECLASSES (type))
add_struct_fields (TYPE_BASECLASS (type, i),
}
fprintf_filtered (stream, "{");
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
n_baseclasses = TYPE_N_BASECLASSES (type);
/* First, print out baseclasses such that we don't print
*self_p = check_typedef (*self_p);
self = *self_p;
- len = TYPE_NFIELDS (self);
+ len = self->num_fields ();
for (i = TYPE_N_BASECLASSES (self); i < len; i++)
{
struct value *val,
const struct value_print_options *options)
{
- if (TYPE_NFIELDS (type) == 2
+ if (type->num_fields () == 2
&& TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_INT
&& strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0
&& strcmp (TYPE_FIELD_NAME (type, 1), "ptr") == 0
/* When DISCRIMINANT_INDEX == -1, we have a univariant enum. Those
must be handled by the caller. */
gdb_assert (discriminant_index >= 0
- && discriminant_index < TYPE_NFIELDS (type));
+ && discriminant_index < type->num_fields ());
gdb_assert (default_index == -1
- || (default_index >= 0 && default_index < TYPE_NFIELDS (type)));
+ || (default_index >= 0 && default_index < type->num_fields ()));
/* We have one variant for each non-discriminant field. */
- int n_variants = TYPE_NFIELDS (type) - 1;
+ int n_variants = type->num_fields () - 1;
variant *variants = new (obstack) variant[n_variants];
int var_idx = 0;
int range_idx = 0;
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
if (i == discriminant_index)
continue;
gdb_assert (type->code () == TYPE_CODE_UNION);
/* We don't need to deal with empty enums. */
- if (TYPE_NFIELDS (type) == 0)
+ if (type->num_fields () == 0)
return;
#define RUST_ENUM_PREFIX "RUST$ENCODED$ENUM$"
- if (TYPE_NFIELDS (type) == 1
+ if (type->num_fields () == 1
&& startswith (TYPE_FIELD_NAME (type, 0), RUST_ENUM_PREFIX))
{
const char *name = TYPE_FIELD_NAME (type, 0) + strlen (RUST_ENUM_PREFIX);
unsigned long index = strtoul (name, &tail, 10);
name = tail;
if (*name != '$'
- || index >= TYPE_NFIELDS (field_type)
+ || index >= field_type->num_fields ()
|| (TYPE_FIELD_LOC_KIND (field_type, index)
!= FIELD_LOC_KIND_BITPOS))
{
}
/* A union with a single anonymous field is probably an old-style
univariant enum. */
- else if (TYPE_NFIELDS (type) == 1 && streq (TYPE_FIELD_NAME (type, 0), ""))
+ else if (type->num_fields () == 1 && streq (TYPE_FIELD_NAME (type, 0), ""))
{
/* Smash this type to be a structure type. We have to do this
because the type has already been recorded. */
else
{
struct type *disr_type = nullptr;
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
disr_type = TYPE_FIELD_TYPE (type, i);
/* All fields of a true enum will be structs. */
return;
}
- else if (TYPE_NFIELDS (disr_type) == 0)
+ else if (disr_type->num_fields () == 0)
{
/* Could be data-less variant, so keep going. */
disr_type = nullptr;
/* Make space for the discriminant field. */
struct field *disr_field = &TYPE_FIELD (disr_type, 0);
field *new_fields
- = (struct field *) TYPE_ZALLOC (type, ((TYPE_NFIELDS (type) + 1)
+ = (struct field *) TYPE_ZALLOC (type, ((type->num_fields () + 1)
* sizeof (struct field)));
memcpy (new_fields + 1, TYPE_FIELDS (type),
- TYPE_NFIELDS (type) * sizeof (struct field));
+ type->num_fields () * sizeof (struct field));
TYPE_FIELDS (type) = new_fields;
- type->set_num_fields (TYPE_NFIELDS (type) + 1);
+ type->set_num_fields (type->num_fields () + 1);
/* Install the discriminant at index 0 in the union. */
TYPE_FIELD (type, 0) = *disr_field;
variant name. For convenience we build a map here. */
struct type *enum_type = FIELD_TYPE (*disr_field);
std::unordered_map<std::string, ULONGEST> discriminant_map;
- for (int i = 0; i < TYPE_NFIELDS (enum_type); ++i)
+ for (int i = 0; i < enum_type->num_fields (); ++i)
{
if (TYPE_FIELD_LOC_KIND (enum_type, i) == FIELD_LOC_KIND_ENUMVAL)
{
}
}
- int n_fields = TYPE_NFIELDS (type);
+ int n_fields = type->num_fields ();
/* We don't need a range entry for the discriminant, but we do
need one for every other field, as there is no default
variant. */
/* Remove the discriminant field, if it exists. */
struct type *sub_type = TYPE_FIELD_TYPE (type, i);
- if (TYPE_NFIELDS (sub_type) > 0)
+ if (sub_type->num_fields () > 0)
{
sub_type->set_num_fields (sub_type->num_fields () - 1);
++TYPE_FIELDS (sub_type);
marks unnamed (and thus unused) parameters as
artificial; there is no way to differentiate
the two cases. */
- if (TYPE_NFIELDS (type) > 0
+ if (type->num_fields () > 0
&& TYPE_FIELD_ARTIFICIAL (type, 0)
&& TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_PTR
&& TYPE_CONST (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type,
this_type = read_type_die (die, cu);
if (this_type && this_type->code () == TYPE_CODE_FUNC)
{
- int nparams = TYPE_NFIELDS (this_type);
+ int nparams = this_type->num_fields ();
/* TYPE is the domain of this method, and THIS_TYPE is the type
of the method itself (TYPE_CODE_METHOD). */
smash_to_method_type (fnp->type, type,
TYPE_TARGET_TYPE (this_type),
TYPE_FIELDS (this_type),
- TYPE_NFIELDS (this_type),
+ this_type->num_fields (),
TYPE_VARARGS (this_type));
/* Handle static member functions.
/* If there is no `this' field and no DW_AT_containing_type,
we cannot actually find a base class context for the
vtable! */
- if (TYPE_NFIELDS (this_type) == 0
+ if (this_type->num_fields () == 0
|| !TYPE_FIELD_ARTIFICIAL (this_type, 0))
{
complaint (_("cannot determine context for virtual member "
struct type *pfn_type, *self_type, *new_type;
/* Check for a structure with no name and two children. */
- if (type->code () != TYPE_CODE_STRUCT || TYPE_NFIELDS (type) != 2)
+ if (type->code () != TYPE_CODE_STRUCT || type->num_fields () != 2)
return;
/* Check for __pfn and __delta members. */
/* Look for the "this" argument. */
pfn_type = TYPE_TARGET_TYPE (pfn_type);
- if (TYPE_NFIELDS (pfn_type) == 0
+ if (pfn_type->num_fields () == 0
/* || TYPE_FIELD_TYPE (pfn_type, 0) == NULL */
|| TYPE_FIELD_TYPE (pfn_type, 0)->code () != TYPE_CODE_PTR)
return;
self_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (pfn_type, 0));
new_type = alloc_type (objfile);
smash_to_method_type (new_type, self_type, TYPE_TARGET_TYPE (pfn_type),
- TYPE_FIELDS (pfn_type), TYPE_NFIELDS (pfn_type),
+ TYPE_FIELDS (pfn_type), pfn_type->num_fields (),
TYPE_VARARGS (pfn_type));
smash_to_methodptr_type (type, new_type);
}
int i;
/* Our own class provides vtbl ptr. */
- for (i = TYPE_NFIELDS (t) - 1;
+ for (i = t->num_fields () - 1;
i >= TYPE_N_BASECLASSES (t);
--i)
{
int i;
- for (i = TYPE_NFIELDS (type) - 1;
+ for (i = type->num_fields () - 1;
i >= TYPE_N_BASECLASSES (type);
--i)
{
= alloc_type (cu->per_cu->dwarf2_per_objfile->objfile);
smash_to_method_type (new_type, domain, TYPE_TARGET_TYPE (to_type),
- TYPE_FIELDS (to_type), TYPE_NFIELDS (to_type),
+ TYPE_FIELDS (to_type), to_type->num_fields (),
TYPE_VARARGS (to_type));
type = lookup_methodptr_type (new_type);
}
fieldno++;
/* Skip static fields. */
- while (fieldno < TYPE_NFIELDS (struct_type)
+ while (fieldno < struct_type->num_fields ()
&& field_is_static (&TYPE_FIELD (struct_type,
fieldno)))
fieldno++;
- if (fieldno >= TYPE_NFIELDS (struct_type))
+ if (fieldno >= struct_type->num_fields ())
error (_("too many initializers"));
field_type = TYPE_FIELD_TYPE (struct_type, fieldno);
if (field_type->code () == TYPE_CODE_UNION
type = TYPE_TARGET_TYPE (type);
if (type && type->code () == TYPE_CODE_FUNC)
{
- for (; tem <= nargs && tem <= TYPE_NFIELDS (type); tem++)
+ for (; tem <= nargs && tem <= type->num_fields (); tem++)
{
argvec[tem] = evaluate_subexp (TYPE_FIELD_TYPE (type,
tem - 1),
case TYPE_CODE_FUNC:
{
- int i, nfields = TYPE_NFIELDS (type);
+ int i, nfields = type->num_fields ();
f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
passed_a_ptr, 0,
if (show > 0)
{
fputs_filtered ("\n", stream);
- for (index = 0; index < TYPE_NFIELDS (type); index++)
+ for (index = 0; index < type->num_fields (); index++)
{
f_type_print_base (TYPE_FIELD_TYPE (type, index), stream,
show - 1, level + 4);
/* Starting from the Fortran 90 standard, Fortran supports derived
types. */
fprintf_filtered (stream, "( ");
- for (index = 0; index < TYPE_NFIELDS (type); index++)
+ for (index = 0; index < type->num_fields (); index++)
{
struct value *field = value_field (val, index);
*highp = TYPE_HIGH_BOUND (type);
return 1;
case TYPE_CODE_ENUM:
- if (TYPE_NFIELDS (type) > 0)
+ if (type->num_fields () > 0)
{
/* The enums may not be sorted by value, so search all
entries. */
int i;
*lowp = *highp = TYPE_FIELD_ENUMVAL (type, 0);
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
if (TYPE_FIELD_ENUMVAL (type, i) < *lowp)
*lowp = TYPE_FIELD_ENUMVAL (type, i);
{
int i;
- for (i = 0; i < TYPE_NFIELDS (type); i += 1)
+ for (i = 0; i < type->num_fields (); i += 1)
{
if (val == TYPE_FIELD_ENUMVAL (type, i))
{
type_name.c_str ());
}
- for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
+ for (i = type->num_fields () - 1; i >= TYPE_N_BASECLASSES (type); i--)
{
const char *t_field_name = TYPE_FIELD_NAME (type, i);
treated as one here. */
case TYPE_CODE_ARRAY:
{
- gdb_assert (TYPE_NFIELDS (type) == 1);
+ gdb_assert (type->num_fields () == 1);
/* The array is dynamic if either the bounds are dynamic... */
if (is_dynamic_type_internal (TYPE_INDEX_TYPE (type), 0))
bool is_cplus = HAVE_CPLUS_STRUCT (type);
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (i = 0; i < type->num_fields (); ++i)
{
/* Static fields can be ignored here. */
if (field_is_static (&TYPE_FIELD (type, i)))
resolved_type = copy_type (type);
TYPE_FIELDS (resolved_type)
= (struct field *) TYPE_ALLOC (resolved_type,
- TYPE_NFIELDS (resolved_type)
+ resolved_type->num_fields ()
* sizeof (struct field));
memcpy (TYPE_FIELDS (resolved_type),
TYPE_FIELDS (type),
- TYPE_NFIELDS (resolved_type) * sizeof (struct field));
- for (i = 0; i < TYPE_NFIELDS (resolved_type); ++i)
+ resolved_type->num_fields () * sizeof (struct field));
+ for (i = 0; i < resolved_type->num_fields (); ++i)
{
struct type *t;
const gdb::array_view<variant_part> &parts)
{
/* Assume all fields are included by default. */
- std::vector<bool> flags (TYPE_NFIELDS (resolved_type), true);
+ std::vector<bool> flags (resolved_type->num_fields (), true);
/* Now disable fields based on the variants that control them. */
for (const auto &part : parts)
(std::count (flags.begin (), flags.end (), true));
TYPE_FIELDS (resolved_type)
= (struct field *) TYPE_ALLOC (resolved_type,
- TYPE_NFIELDS (resolved_type)
+ resolved_type->num_fields ()
* sizeof (struct field));
int out = 0;
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
if (!flags[i])
continue;
unsigned resolved_type_bit_length = 0;
gdb_assert (type->code () == TYPE_CODE_STRUCT);
- gdb_assert (TYPE_NFIELDS (type) > 0);
+ gdb_assert (type->num_fields () > 0);
resolved_type = copy_type (type);
{
TYPE_FIELDS (resolved_type)
= (struct field *) TYPE_ALLOC (resolved_type,
- TYPE_NFIELDS (resolved_type)
+ resolved_type->num_fields ()
* sizeof (struct field));
memcpy (TYPE_FIELDS (resolved_type),
TYPE_FIELDS (type),
- TYPE_NFIELDS (resolved_type) * sizeof (struct field));
+ resolved_type->num_fields () * sizeof (struct field));
}
- for (i = 0; i < TYPE_NFIELDS (resolved_type); ++i)
+ for (i = 0; i < resolved_type->num_fields (); ++i)
{
unsigned new_bit_length;
struct property_addr_info pinfo;
case TYPE_CODE_UNION:
{
int number_of_non_static_fields = 0;
- for (unsigned i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (unsigned i = 0; i < type->num_fields (); ++i)
{
if (!field_is_static (&TYPE_FIELD (type, i)))
{
return 1;
/* Are we dealing with an array or string of known dimensions? */
else if ((t->code () == TYPE_CODE_ARRAY
- || t->code () == TYPE_CODE_STRING) && TYPE_NFIELDS (t) == 1
+ || t->code () == TYPE_CODE_STRING) && t->num_fields () == 1
&& TYPE_INDEX_TYPE(t)->code () == TYPE_CODE_RANGE)
{
LONGEST low_bound, high_bound;
return high_bound == low_bound && is_scalar_type_recursive (elt_type);
}
/* Are we dealing with a struct with one element? */
- else if (t->code () == TYPE_CODE_STRUCT && TYPE_NFIELDS (t) == 1)
+ else if (t->code () == TYPE_CODE_STRUCT && t->num_fields () == 1)
return is_scalar_type_recursive (TYPE_FIELD_TYPE (t, 0));
else if (t->code () == TYPE_CODE_UNION)
{
- int i, n = TYPE_NFIELDS (t);
+ int i, n = t->num_fields ();
/* If all elements of the union are scalar, then the union is scalar. */
for (i = 0; i < n; i++)
{
int i;
- if (TYPE_NFIELDS (a) != TYPE_NFIELDS (b))
+ if (a->num_fields () != b->num_fields ())
return false;
if (!types_equal (TYPE_TARGET_TYPE (a), TYPE_TARGET_TYPE (b)))
return false;
- for (i = 0; i < TYPE_NFIELDS (a); ++i)
+ for (i = 0; i < a->num_fields (); ++i)
if (!types_equal (TYPE_FIELD_TYPE (a, i), TYPE_FIELD_TYPE (b, i)))
return false;
|| TYPE_VECTOR (type1) != TYPE_VECTOR (type2)
|| TYPE_NOTTEXT (type1) != TYPE_NOTTEXT (type2)
|| TYPE_INSTANCE_FLAGS (type1) != TYPE_INSTANCE_FLAGS (type2)
- || TYPE_NFIELDS (type1) != TYPE_NFIELDS (type2))
+ || type1->num_fields () != type2->num_fields ())
return false;
if (!compare_maybe_null_strings (type1->name (), type2->name ()))
{
int i;
- for (i = 0; i < TYPE_NFIELDS (type1); ++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);
gdb_stdout);
printf_filtered ("\n");
print_args (TYPE_FN_FIELD_ARGS (f, overload_idx),
- TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f, overload_idx)),
+ TYPE_FN_FIELD_TYPE (f, overload_idx)->num_fields (),
spaces + 8 + 2);
printfi_filtered (spaces + 8, "fcontext ");
gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx),
TYPE_N_BASECLASSES (type));
puts_filtered ("\n");
}
- if (TYPE_NFIELDS (type) > 0)
+ if (type->num_fields () > 0)
{
if (TYPE_FIELD_PRIVATE_BITS (type) != NULL)
{
printfi_filtered (spaces,
"private_field_bits (%d bits at *",
- TYPE_NFIELDS (type));
+ type->num_fields ());
gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type),
gdb_stdout);
printf_filtered (")");
print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type),
- TYPE_NFIELDS (type));
+ type->num_fields ());
puts_filtered ("\n");
}
if (TYPE_FIELD_PROTECTED_BITS (type) != NULL)
{
printfi_filtered (spaces,
"protected_field_bits (%d bits at *",
- TYPE_NFIELDS (type));
+ type->num_fields ());
gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type),
gdb_stdout);
printf_filtered (")");
print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type),
- TYPE_NFIELDS (type));
+ type->num_fields ());
puts_filtered ("\n");
}
}
if (spaces == 0)
obstack_begin (&dont_print_type_obstack, 0);
- if (TYPE_NFIELDS (type) > 0
+ if (type->num_fields () > 0
|| (HAVE_CPLUS_STRUCT (type) && TYPE_NFN_FIELDS (type) > 0))
{
struct type **first_dont_print
puts_filtered (" TYPE_NOTTEXT");
}
puts_filtered ("\n");
- printfi_filtered (spaces, "nfields %d ", TYPE_NFIELDS (type));
+ printfi_filtered (spaces, "nfields %d ", type->num_fields ());
gdb_print_host_address (TYPE_FIELDS (type), gdb_stdout);
puts_filtered ("\n");
- for (idx = 0; idx < TYPE_NFIELDS (type); idx++)
+ for (idx = 0; idx < type->num_fields (); idx++)
{
if (type->code () == TYPE_CODE_ENUM)
printfi_filtered (spaces + 2,
TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
/* Copy the fields. */
- if (TYPE_NFIELDS (type))
+ if (type->num_fields ())
{
int i, nfields;
- nfields = TYPE_NFIELDS (type);
+ nfields = type->num_fields ();
TYPE_FIELDS (new_type) = (struct field *)
TYPE_ZALLOC (new_type, nfields * sizeof (struct field));
for (i = 0; i < nfields; i++)
struct type *field_type, const char *name)
{
int type_bitsize = TYPE_LENGTH (type) * TARGET_CHAR_BIT;
- int field_nr = TYPE_NFIELDS (type);
+ int field_nr = type->num_fields ();
gdb_assert (type->code () == TYPE_CODE_FLAGS);
- gdb_assert (TYPE_NFIELDS (type) + 1 <= type_bitsize);
+ gdb_assert (type->num_fields () + 1 <= type_bitsize);
gdb_assert (start_bitpos >= 0 && start_bitpos < type_bitsize);
gdb_assert (nr_bits >= 1 && nr_bits <= type_bitsize);
gdb_assert (name != NULL);
{
struct field *f;
- t->set_num_fields (TYPE_NFIELDS (t) + 1);
+ t->set_num_fields (t->num_fields () + 1);
TYPE_FIELDS (t) = XRESIZEVEC (struct field, TYPE_FIELDS (t),
- TYPE_NFIELDS (t));
- f = &(TYPE_FIELDS (t)[TYPE_NFIELDS (t) - 1]);
+ t->num_fields ());
+ f = &(TYPE_FIELDS (t)[t->num_fields () - 1]);
memset (f, 0, sizeof f[0]);
FIELD_TYPE (f[0]) = field;
FIELD_NAME (f[0]) = name;
else if (t->code () == TYPE_CODE_STRUCT)
{
TYPE_LENGTH (t) = TYPE_LENGTH (t) + TYPE_LENGTH (field);
- if (TYPE_NFIELDS (t) > 1)
+ if (t->num_fields () > 1)
{
SET_FIELD_BITPOS (f[0],
(FIELD_BITPOS (f[-1])
space in struct type. */
extern bool set_type_align (struct type *, ULONGEST);
-#define TYPE_NFIELDS(thistype) ((thistype)->num_fields ())
#define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields
#define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
#define TYPE_IS_OPAQUE(thistype) \
((((thistype)->code () == TYPE_CODE_STRUCT) \
|| ((thistype)->code () == TYPE_CODE_UNION)) \
- && (TYPE_NFIELDS (thistype) == 0) \
+ && ((thistype)->num_fields () == 0) \
&& (!HAVE_CPLUS_STRUCT (thistype) \
|| TYPE_NFN_FIELDS (thistype) == 0) \
&& (TYPE_STUB (thistype) || !TYPE_STUB_SUPPORTED (thistype)))
if (BASETYPE_VIA_VIRTUAL (type, index))
{
/* Must hunt for the pointer to this virtual baseclass. */
- int i, len = TYPE_NFIELDS (type);
+ int i, len = type->num_fields ();
int n_baseclasses = TYPE_N_BASECLASSES (type);
/* First look for the virtual baseclass pointer
type_code expected)
{
/* The method should take at least two arguments... */
- if (TYPE_NFIELDS (method_type) < 2)
+ if (method_type->num_fields () < 2)
return false;
/* ...and the second argument should be the same as the class
/* ...and if any of the remaining arguments don't have a default value
then this is not a copy or move constructor, but just a
constructor. */
- for (int i = 2; i < TYPE_NFIELDS (method_type); i++)
+ for (int i = 2; i < method_type->num_fields (); i++)
{
arg_type = TYPE_FIELD_TYPE (method_type, i);
/* FIXME aktemur/2019-10-31: As of this date, neither
are constructed whenever this class is. We do not need to worry
about recursive loops here, since we are only looking at members
of complete class type. Also ignore any static members. */
- for (fieldnum = 0; fieldnum < TYPE_NFIELDS (type); fieldnum++)
+ for (fieldnum = 0; fieldnum < type->num_fields (); fieldnum++)
if (!field_is_static (&TYPE_FIELD (type, fieldnum)))
{
struct type *field_type = TYPE_FIELD_TYPE (type, fieldnum);
{
/* gccgo strings don't necessarily have a name we can use. */
- if (TYPE_NFIELDS (type) == 2)
+ if (type->num_fields () == 2)
{
struct type *type0 = TYPE_FIELD_TYPE (type, 0);
struct type *type1 = TYPE_FIELD_TYPE (type, 1);
static int
sixg_string_p (struct type *type)
{
- if (TYPE_NFIELDS (type) == 2
+ if (type->num_fields () == 2
&& type->name () != NULL
&& strcmp (type->name (), "string") == 0)
return 1;
containing_type_scm = tyscm_scm_from_type (containing_type);
result = SCM_EOL;
- for (i = 0; i < TYPE_NFIELDS (containing_type); ++i)
+ for (i = 0; i < containing_type->num_fields (); ++i)
result = scm_cons (tyscm_make_field_smob (containing_type_scm, i), result);
return scm_reverse_x (result, SCM_EOL);
gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self,
_(not_composite_error));
- return scm_from_long (TYPE_NFIELDS (type));
+ return scm_from_long (type->num_fields ());
}
/* (type-field <gdb:type> string) -> <gdb:field>
{
gdb::unique_xmalloc_ptr<char> field = gdbscm_scm_to_c_string (field_scm);
- for (int i = 0; i < TYPE_NFIELDS (type); i++)
+ for (int i = 0; i < type->num_fields (); i++)
{
const char *t_field_name = TYPE_FIELD_NAME (type, i);
gdb::unique_xmalloc_ptr<char> field
= gdbscm_scm_to_c_string (field_scm);
- for (int i = 0; i < TYPE_NFIELDS (type); i++)
+ for (int i = 0; i < type->num_fields (); i++)
{
const char *t_field_name = TYPE_FIELD_NAME (type, i);
type = t_smob->type;
SCM_ASSERT_TYPE (scm_is_signed_integer (progress,
- 0, TYPE_NFIELDS (type)),
+ 0, type->num_fields ()),
progress, SCM_ARG1, FUNC_NAME, _("integer"));
field = scm_to_int (progress);
- if (field < TYPE_NFIELDS (type))
+ if (field < type->num_fields ())
{
result = tyscm_make_field_smob (object, field);
itscm_set_iterator_smob_progress_x (i_smob, scm_from_int (field + 1));
{
int i;
int res = 4;
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
int align
= i386_darwin_arg_type_alignment (TYPE_FIELD_TYPE (type, i));
|| type->code () == TYPE_CODE_UNION)
{
int i;
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
if (i386_16_byte_align_p (TYPE_FIELD_TYPE (type, i)))
return 1;
/* Structures consisting of a single `float', `double' or 'long
double' member are returned in %st(0). */
- if (code == TYPE_CODE_STRUCT && TYPE_NFIELDS (type) == 1)
+ if (code == TYPE_CODE_STRUCT && type->num_fields () == 1)
{
type = check_typedef (TYPE_FIELD_TYPE (type, 0));
if (type->code () == TYPE_CODE_FLT)
the structure. Since that should work for all structures that
have only one member, we don't bother to check the member's type
here. */
- if (code == TYPE_CODE_STRUCT && TYPE_NFIELDS (type) == 1)
+ if (code == TYPE_CODE_STRUCT && type->num_fields () == 1)
{
type = check_typedef (TYPE_FIELD_TYPE (type, 0));
return i386_return_value (gdbarch, function, type, regcache,
/* read_subroutine_type sets for non-static member functions the
artificial flag of the first parameter ('this' pointer). */
if (type->code () == TYPE_CODE_METHOD
- && TYPE_NFIELDS (type) > 0
+ && type->num_fields () > 0
&& TYPE_FIELD_ARTIFICIAL (type, 0)
&& TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_PTR)
thiscall = 1;
{
int i;
- for (i = 0; i < TYPE_NFIELDS (t); i++)
+ for (i = 0; i < t->num_fields (); i++)
if (!is_float_or_hfa_type_recurse
(check_typedef (TYPE_FIELD_TYPE (t, i)), etp))
return 0;
{
int i;
- for (i = 0; i < TYPE_NFIELDS (t); i++)
+ for (i = 0; i < t->num_fields (); i++)
if (slot_alignment_is_next_even
(check_typedef (TYPE_FIELD_TYPE (t, i))))
return 1;
values_type = check_typedef (values_type);
- if (args.size () < TYPE_NFIELDS (ftype))
+ if (args.size () < ftype->num_fields ())
error (_("Too few arguments in function call."));
/* A holder for the inferior status.
prototyped. Can we respect TYPE_VARARGS? Probably not. */
if (ftype->code () == TYPE_CODE_METHOD)
prototyped = 1;
- if (TYPE_TARGET_TYPE (ftype) == NULL && TYPE_NFIELDS (ftype) == 0
+ if (TYPE_TARGET_TYPE (ftype) == NULL && ftype->num_fields () == 0
&& default_return_type != NULL)
{
/* Calling a no-debug function with the return type
*/
prototyped = 1;
}
- else if (i < TYPE_NFIELDS (ftype))
+ else if (i < ftype->num_fields ())
prototyped = TYPE_PROTOTYPED (ftype);
else
prototyped = 0;
- if (i < TYPE_NFIELDS (ftype))
+ if (i < ftype->num_fields ())
param_type = TYPE_FIELD_TYPE (ftype, i);
else
param_type = NULL;
&& type->code () != TYPE_CODE_UNION)
return 0;
/* Structs with more than 1 field are always passed by address. */
- if (TYPE_NFIELDS (type) != 1)
+ if (type->num_fields () != 1)
return 1;
/* Get field type. */
ftype = (TYPE_FIELDS (type))[0].type;
if (TYPE_TARGET_TYPE (type) == NULL
|| TYPE_TARGET_TYPE (type)->code () != TYPE_CODE_VOID)
{
- int i, len = TYPE_NFIELDS (type);
+ int i, len = type->num_fields ();
fprintf_filtered (stream, " (");
for (i = 0; i < len; i++)
{
struct type *target = TYPE_TARGET_TYPE (type);
- if (TYPE_NFIELDS(type) == 0)
+ if (type->num_fields () == 0)
return;
if (print_high)
/* check if all fields of the RECORD are consecutive sets. */
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
for (i = TYPE_N_BASECLASSES (type); i < len; i++)
{
if (TYPE_FIELD_TYPE (type, i) == NULL)
if (type->code () == TYPE_CODE_STRUCT)
{
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
i = TYPE_N_BASECLASSES (type);
if (len == 0)
return 0;
{
struct type *of_type;
int i;
- int len = TYPE_NFIELDS (type);
+ int len = type->num_fields ();
LONGEST low;
LONGEST high;
* type of _m2_contents is a pointer. The TYPE_TARGET_TYPE
* of the pointer determines the unbounded ARRAY OF type.
*/
- if (TYPE_NFIELDS (type) != 2)
+ if (type->num_fields () != 2)
return 0;
if (strcmp (TYPE_FIELD_NAME (type, 0), "_m2_contents") != 0)
return 0;
else if (show > 0)
{
int i;
- int len = TYPE_NFIELDS (type);
+ int len = type->num_fields ();
if (type->code () == TYPE_CODE_STRUCT)
fprintf_filtered (stream, "RECORD\n");
else if (show > 0 || type->name () == NULL)
{
fprintf_filtered (stream, "(");
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
lastval = 0;
for (i = 0; i < len; i++)
{
if (type->code () == TYPE_CODE_STRUCT)
{
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
i = TYPE_N_BASECLASSES (type);
if (len == 0)
return 0;
type = check_typedef (type);
fprintf_filtered (stream, "{");
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
if (get_long_set_bounds (type, &low_bound, &high_bound))
{
field = TYPE_N_BASECLASSES (type);
separately, but the code in GCC doesn't actually do so. */
if (TYPE_PROTOTYPED (func_type))
#endif
- num_prototyped_args = TYPE_NFIELDS (func_type);
+ num_prototyped_args = func_type->num_fields ();
}
/* First, if the function returns an aggregate by value, push a
changing TYPE into the type of the first member of the structure.
Since that should work for all structures that have only one
member, we don't bother to check the member's type here. */
- if (code == TYPE_CODE_STRUCT && TYPE_NFIELDS (type) == 1)
+ if (code == TYPE_CODE_STRUCT && type->num_fields () == 1)
{
type = check_typedef (TYPE_FIELD_TYPE (type, 0));
return m68k_svr4_return_value (gdbarch, function, type, regcache,
are hopefully rare enough.
Alpha cc -migrate has a sh.value field of zero, we adjust
that too. */
- if (TYPE_LENGTH (t) == TYPE_NFIELDS (t)
+ if (TYPE_LENGTH (t) == t->num_fields ()
|| TYPE_LENGTH (t) == 0)
TYPE_LENGTH (t) = gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT;
for (ext_tsym = ext_sh + external_sym_size;
/* gcc puts out an empty struct for an opaque struct definitions,
do not create a symbol for it either. */
- if (TYPE_NFIELDS (t) == 0)
+ if (t->num_fields () == 0)
{
TYPE_STUB (t) = 1;
break;
}
}
- if (TYPE_NFIELDS (ftype) <= 0)
+ if (ftype->num_fields () <= 0)
{
/* No parameter type information is recorded with the function's
type. Set that from the type of the parameter symbols. */
/* Incomplete definitions of structs should not get a name. */
if (SYMBOL_TYPE (s)->name () == NULL
- && (TYPE_NFIELDS (SYMBOL_TYPE (s)) != 0
+ && (SYMBOL_TYPE (s)->num_fields () != 0
|| (SYMBOL_TYPE (s)->code () != TYPE_CODE_STRUCT
&& SYMBOL_TYPE (s)->code () != TYPE_CODE_UNION)))
{
|| (MIPS_EABI (gdbarch)
&& (typecode == TYPE_CODE_STRUCT
|| typecode == TYPE_CODE_UNION)
- && TYPE_NFIELDS (arg_type) == 1
+ && arg_type->num_fields () == 1
&& check_typedef (TYPE_FIELD_TYPE (arg_type, 0))->code ()
== TYPE_CODE_FLT))
&& MIPS_FPU_TYPE(gdbarch) != MIPS_FPU_NONE);
return 1;
else if (typecode == TYPE_CODE_STRUCT)
{
- if (TYPE_NFIELDS (type) < 1)
+ if (type->num_fields () < 1)
return 0;
return mips_type_needs_double_align (TYPE_FIELD_TYPE (type, 0));
}
{
int i, n;
- n = TYPE_NFIELDS (type);
+ n = type->num_fields ();
for (i = 0; i < n; i++)
if (mips_type_needs_double_align (TYPE_FIELD_TYPE (type, i)))
return 1;
are returned in a floating point register. */
if ((type->code () == TYPE_CODE_STRUCT
|| type->code () == TYPE_CODE_UNION)
- && TYPE_NFIELDS (type) == 1)
+ && type->num_fields () == 1)
{
struct type *fieldtype = TYPE_FIELD_TYPE (type, 0);
if (TYPE_LENGTH (arg_type) < offset + MIPS64_REGSIZE)
return 0;
- for (i = 0; i < TYPE_NFIELDS (arg_type); i++)
+ for (i = 0; i < arg_type->num_fields (); i++)
{
int pos;
struct type *field_type;
return RETURN_VALUE_REGISTER_CONVENTION;
}
else if (type->code () == TYPE_CODE_STRUCT
- && TYPE_NFIELDS (type) <= 2
- && TYPE_NFIELDS (type) >= 1
- && ((TYPE_NFIELDS (type) == 1
+ && type->num_fields () <= 2
+ && type->num_fields () >= 1
+ && ((type->num_fields () == 1
&& (check_typedef (TYPE_FIELD_TYPE (type, 0))->code ()
== TYPE_CODE_FLT))
- || (TYPE_NFIELDS (type) == 2
+ || (type->num_fields () == 2
&& (check_typedef (TYPE_FIELD_TYPE (type, 0))->code ()
== TYPE_CODE_FLT)
&& (check_typedef (TYPE_FIELD_TYPE (type, 1))->code ()
for (field = 0, regnum = (tdep->mips_fpu_type != MIPS_FPU_NONE
? mips_regnum (gdbarch)->fp0
: MIPS_V0_REGNUM);
- field < TYPE_NFIELDS (type); field++, regnum += 2)
+ field < type->num_fields (); field++, regnum += 2)
{
int offset = (FIELD_BITPOS (TYPE_FIELDS (type)[field])
/ TARGET_CHAR_BIT);
}
#if 0
else if (type->code () == TYPE_CODE_STRUCT
- && TYPE_NFIELDS (type) <= 2
- && TYPE_NFIELDS (type) >= 1
- && ((TYPE_NFIELDS (type) == 1
+ && type->num_fields () <= 2
+ && type->num_fields () >= 1
+ && ((type->num_fields () == 1
&& (TYPE_CODE (TYPE_FIELD_TYPE (type, 0))
== TYPE_CODE_FLT))
- || (TYPE_NFIELDS (type) == 2
+ || (type->num_fields () == 2
&& (TYPE_CODE (TYPE_FIELD_TYPE (type, 0))
== TYPE_CODE_FLT)
&& (TYPE_CODE (TYPE_FIELD_TYPE (type, 1))
int regnum;
int field;
for (field = 0, regnum = mips_regnum (gdbarch)->fp0;
- field < TYPE_NFIELDS (type); field++, regnum += 2)
+ field < type->num_fields (); field++, regnum += 2)
{
int offset = (FIELD_BITPOS (TYPE_FIELDS (type)[field])
/ TARGET_CHAR_BIT);
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
int falign = mn10300_type_align (TYPE_FIELD_TYPE (type, i));
while (align < falign)
case TYPE_CODE_UNION:
/* Structures with a single field are handled as the field
itself. */
- if (TYPE_NFIELDS (type) == 1)
+ if (type->num_fields () == 1)
return mn10300_use_struct_convention (TYPE_FIELD_TYPE (type, 0));
/* Structures with word or double-word size are passed in memory, as
typecode = t->code ();
if (typecode != TYPE_CODE_STRUCT)
break;
- else if (TYPE_NFIELDS (t) != 1)
+ else if (t->num_fields () != 1)
return 0;
else
t = TYPE_FIELD_TYPE (t, 0);
and pushes all unnamed arguments in stack. */
if (abi_use_fpr && TYPE_VARARGS (func_type)
- && i >= TYPE_NFIELDS (func_type))
+ && i >= func_type->num_fields ())
goto use_stack;
/* Try to use FPRs to pass arguments only when
int len = TYPE_LENGTH (arg_type);
enum type_code typecode = arg_type->code ();
- if (TYPE_VARARGS (func_type) && argnum >= TYPE_NFIELDS (func_type))
+ if (TYPE_VARARGS (func_type) && argnum >= func_type->num_fields ())
break; /* end or regular args, varargs go to stack. */
/* Extract the value, either a reference or the data. */
{
/* Old Borland type pascal strings from Free Pascal Compiler. */
/* Two fields: length and st. */
- if (TYPE_NFIELDS (type) == 2
+ if (type->num_fields () == 2
&& TYPE_FIELD_NAME (type, 0)
&& strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0
&& TYPE_FIELD_NAME (type, 1)
};
/* GNU pascal strings. */
/* Three fields: Capacity, length and schema$ or _p_schema. */
- if (TYPE_NFIELDS (type) == 3
+ if (type->num_fields () == 3
&& TYPE_FIELD_NAME (type, 0)
&& strcmp (TYPE_FIELD_NAME (type, 0), "Capacity") == 0
&& TYPE_FIELD_NAME (type, 1)
pascal_print_func_args (struct type *type, struct ui_file *stream,
const struct type_print_options *flags)
{
- int i, len = TYPE_NFIELDS (type);
+ int i, len = type->num_fields ();
if (len)
{
pascal_type_print_derivation_info (stream, type);
fprintf_filtered (stream, "\n");
- if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0))
+ if ((type->num_fields () == 0) && (TYPE_NFN_FIELDS (type) == 0))
{
if (TYPE_STUB (type))
fprintfi_filtered (level + 4, stream, "<incomplete type>\n");
/* If there is a base class for this type,
do not print the field that it occupies. */
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
for (i = TYPE_N_BASECLASSES (type); i < len; i++)
{
QUIT;
else if (show > 0 || type->name () == NULL)
{
fprintf_filtered (stream, "(");
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
lastval = 0;
for (i = 0; i < len; i++)
{
struct type *type = check_typedef (value_type (val));
fprintf_filtered (stream, "{");
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
n_baseclasses = TYPE_N_BASECLASSES (type);
/* Print out baseclasses such that we don't print
LONGEST count = 0;
int i;
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
LONGEST sub_count;
single floating-point value, at any level of nesting of
single-member structs, are passed in floating-point registers. */
if (type->code () == TYPE_CODE_STRUCT
- && TYPE_NFIELDS (type) == 1)
+ && type->num_fields () == 1)
{
while (type->code () == TYPE_CODE_STRUCT
- && TYPE_NFIELDS (type) == 1)
+ && type->num_fields () == 1)
type = check_typedef (TYPE_FIELD_TYPE (type, 0));
if (type->code () == TYPE_CODE_FLT)
if (type == NULL)
return -1;
- return TYPE_NFIELDS (type);
+ return type->num_fields ();
}
/* Implements boolean evaluation of gdb.Type. Handle this like other
if (type == NULL)
return NULL;
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
const char *t_field_name = TYPE_FIELD_NAME (type, i);
if (type == NULL)
return NULL;
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
const char *t_field_name = TYPE_FIELD_NAME (type, i);
typy_iterator_object *iter_obj = (typy_iterator_object *) self;
struct type *type = iter_obj->source->type;
- if (iter_obj->field < TYPE_NFIELDS (type))
+ if (iter_obj->field < type->num_fields ())
{
gdbpy_ref<> result = make_fielditem (type, iter_obj->field,
iter_obj->kind);
if (regtype->code () == TYPE_CODE_FLT
|| (regtype->code () == TYPE_CODE_UNION
- && TYPE_NFIELDS (regtype) == 2
+ && regtype->num_fields () == 2
&& TYPE_FIELD_TYPE (regtype, 0)->code () == TYPE_CODE_FLT
&& TYPE_FIELD_TYPE (regtype, 1)->code () == TYPE_CODE_FLT)
|| (regtype->code () == TYPE_CODE_UNION
- && TYPE_NFIELDS (regtype) == 3
+ && regtype->num_fields () == 3
&& TYPE_FIELD_TYPE (regtype, 0)->code () == TYPE_CODE_FLT
&& TYPE_FIELD_TYPE (regtype, 1)->code () == TYPE_CODE_FLT
&& TYPE_FIELD_TYPE (regtype, 2)->code () == TYPE_CODE_FLT))
void
riscv_struct_info::analyse_inner (struct type *type, int offset)
{
- unsigned int count = TYPE_NFIELDS (type);
+ unsigned int count = type->num_fields ();
unsigned int i;
for (i = 0; i < count; ++i)
arg_type = check_typedef (value_type (arg_value));
riscv_arg_location (gdbarch, info, &call_info, arg_type,
- TYPE_VARARGS (ftype) && i >= TYPE_NFIELDS (ftype));
+ TYPE_VARARGS (ftype) && i >= ftype->num_fields ());
if (info->type != arg_type)
arg_value = value_cast (info->type, arg_value);
if (!want_type
&& type->code () == TYPE_CODE_STRUCT
- && TYPE_NFIELDS (type) == 0)
+ && type->num_fields () == 0)
{
/* A unit-like struct. */
write_exp_elt_opcode (pstate, OP_AGGREGATE);
static bool
rust_empty_enum_p (const struct type *type)
{
- return TYPE_NFIELDS (type) == 0;
+ return type->num_fields () == 0;
}
/* Given an already-resolved enum type and contents, find which
rust_enum_variant (struct type *type)
{
/* The active variant is simply the first non-artificial field. */
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
if (!TYPE_FIELD_ARTIFICIAL (type, i))
return i;
if (type->code () != TYPE_CODE_STRUCT)
return false;
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (i = 0; i < type->num_fields (); ++i)
{
if (!field_is_static (&TYPE_FIELD (type, i)))
{
/* This is just an approximation until DWARF can represent Rust more
precisely. We exclude zero-length structs because they may not
be tuple structs, and there's no way to tell. */
- return TYPE_NFIELDS (type) > 0 && rust_underscore_fields (type);
+ return type->num_fields () > 0 && rust_underscore_fields (type);
}
/* Return true if TYPE is a slice type, otherwise false. */
int i;
if (type->code () != TYPE_CODE_STRUCT
- || TYPE_NFIELDS (type) > 2
+ || type->num_fields () > 2
|| type->name () == NULL
|| strstr (type->name (), "::Range") == NULL)
return false;
- if (TYPE_NFIELDS (type) == 0)
+ if (type->num_fields () == 0)
return true;
i = 0;
if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0)
{
- if (TYPE_NFIELDS (type) == 1)
+ if (type->num_fields () == 1)
return true;
i = 1;
}
- else if (TYPE_NFIELDS (type) == 2)
+ else if (type->num_fields () == 2)
{
/* First field had to be "start". */
return false;
{
struct type *type = check_typedef (value_type (value));
- if (type->code () != TYPE_CODE_STRUCT || TYPE_NFIELDS (type) != 2)
+ if (type->code () != TYPE_CODE_STRUCT || type->num_fields () != 2)
return NULL;
/* Try to be a bit resilient if the ABI changes. */
if (type->name () != NULL)
fprintf_filtered (stream, "%s", type->name ());
- if (TYPE_NFIELDS (type) == 0)
+ if (type->num_fields () == 0)
return;
if (type->name () != NULL)
opts.deref_ref = 0;
first_field = 1;
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (i = 0; i < type->num_fields (); ++i)
{
if (field_is_static (&TYPE_FIELD (type, i)))
continue;
val = value_field (val, variant_fieldno);
struct type *variant_type = TYPE_FIELD_TYPE (type, variant_fieldno);
- int nfields = TYPE_NFIELDS (variant_type);
+ int nfields = variant_type->num_fields ();
bool is_tuple = rust_tuple_struct_type_p (variant_type);
}
bool first_field = true;
- for (int j = 0; j < TYPE_NFIELDS (variant_type); j++)
+ for (int j = 0; j < variant_type->num_fields (); j++)
{
if (!first_field)
fputs_filtered (", ", stream);
fputs_filtered (tagname, stream);
}
- if (TYPE_NFIELDS (type) == 0 && !is_tuple)
+ if (type->num_fields () == 0 && !is_tuple)
return;
if (for_rust_enum && !flags->print_offsets)
fputs_filtered (is_tuple_struct ? "(" : "{", stream);
field indices here because it simplifies calls to
print_offset_data::update below. */
std::vector<int> fields;
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
if (field_is_static (&TYPE_FIELD (type, i)))
continue;
/* Note that this check of "I" is ok because we only sorted the
fields by offset when print_offsets was set, so we won't take
this branch in that case. */
- else if (i + 1 < TYPE_NFIELDS (type))
+ else if (i + 1 < type->num_fields ())
fputs_filtered (", ", stream);
}
if (varstring != NULL)
fputs_filtered (varstring, stream);
fputs_filtered ("(", stream);
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
QUIT;
if (i > 0)
}
fputs_filtered ("{\n", stream);
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
const char *name = TYPE_FIELD_NAME (type, i);
error (_("Could not find function named '%s'"), name.c_str ());
fn_type = SYMBOL_TYPE (sym.symbol);
- if (TYPE_NFIELDS (fn_type) == 0)
+ if (fn_type->num_fields () == 0)
error (_("Function '%s' takes no arguments"), name.c_str ());
if (TYPE_FIELD_TYPE (fn_type, 0)->code () == TYPE_CODE_PTR)
*high = 0;
*kind = BOTH_BOUND_DEFAULT;
- if (TYPE_NFIELDS (type) == 0)
+ if (type->num_fields () == 0)
return;
i = 0;
*low = value_as_long (value_field (range, 0));
++i;
}
- if (TYPE_NFIELDS (type) > i
+ if (type->num_fields () > i
&& strcmp (TYPE_FIELD_NAME (type, i), "end") == 0)
{
*kind = (*kind == BOTH_BOUND_DEFAULT
base_type = TYPE_TARGET_TYPE (type);
else if (rust_slice_type_p (type))
{
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
if (strcmp (TYPE_FIELD_NAME (type, i), "data_ptr") == 0)
{
}
/* Tuples and tuple structs */
- nfields = TYPE_NFIELDS (type);
+ nfields = type->num_fields ();
if (field_number >= nfields || field_number < 0)
{
of the ``arg_reg'' variable to get these other details correct. */
if (TYPE_VARARGS (func_type))
- num_register_candidate_args = TYPE_NFIELDS (func_type) - 1;
+ num_register_candidate_args = func_type->num_fields () - 1;
else
num_register_candidate_args = 4;
int p_arg_size = 4;
if (TYPE_PROTOTYPED (func_type)
- && i < TYPE_NFIELDS (func_type))
+ && i < func_type->num_fields ())
{
struct type *p_arg_type =
TYPE_FIELD_TYPE (func_type, i);
/* Find a non-static field, if any. Unless there's exactly one,
abort the unwrapping. */
- for (int i = 0; i < TYPE_NFIELDS (type); i++)
+ for (int i = 0; i < type->num_fields (); i++)
{
struct field f = TYPE_FIELD (type, i);
and arg_state.argp with the size of the parameter area. */
for (i = 0; i < nargs; i++)
s390_handle_arg (&arg_state, args[i], tdep, word_size, byte_order,
- TYPE_VARARGS (ftype) && i >= TYPE_NFIELDS (ftype));
+ TYPE_VARARGS (ftype) && i >= ftype->num_fields ());
param_area_start = align_down (arg_state.copy - arg_state.argp, 8);
/* Write all parameters. */
for (i = 0; i < nargs; i++)
s390_handle_arg (&arg_state, args[i], tdep, word_size, byte_order,
- TYPE_VARARGS (ftype) && i >= TYPE_NFIELDS (ftype));
+ TYPE_VARARGS (ftype) && i >= ftype->num_fields ());
/* Store return PSWA. In 31-bit mode, keep addressing mode bit. */
if (word_size == 4)
{
int i, n;
- n = TYPE_NFIELDS (type);
+ n = type->num_fields ();
for (i = 0; i < n; i++)
if (score_type_needs_double_align (TYPE_FIELD_TYPE (type, i)))
return 1;
sh_use_struct_convention (int renesas_abi, struct type *type)
{
int len = TYPE_LENGTH (type);
- int nelem = TYPE_NFIELDS (type);
+ int nelem = type->num_fields ();
/* The Renesas ABI returns aggregate types always on stack. */
if (renesas_abi && (type->code () == TYPE_CODE_STRUCT
sh_use_struct_convention_nofpu (int renesas_abi, struct type *type)
{
/* The Renesas ABI returns long longs/doubles etc. always on stack. */
- if (renesas_abi && TYPE_NFIELDS (type) == 0 && TYPE_LENGTH (type) >= 8)
+ if (renesas_abi && type->num_fields () == 0 && TYPE_LENGTH (type) >= 8)
return 1;
return sh_use_struct_convention (renesas_abi, type);
}
if (type->code () != TYPE_CODE_STRUCT)
return 0;
/* Otherwise structs with more than one member are not treated as float. */
- if (TYPE_NFIELDS (type) != 1)
+ if (type->num_fields () != 1)
return 0;
/* Otherwise if the type of that member is float, the whole type is
treated as float. */
registers have been used so far. */
if (sh_is_renesas_calling_convention (func_type)
&& TYPE_VARARGS (func_type))
- last_reg_arg = TYPE_NFIELDS (func_type) - 2;
+ last_reg_arg = func_type->num_fields () - 2;
/* First force sp to a 4-byte alignment. */
sp = sh_frame_align (gdbarch, sp);
registers have been used so far. */
if (sh_is_renesas_calling_convention (func_type)
&& TYPE_VARARGS (func_type))
- last_reg_arg = TYPE_NFIELDS (func_type) - 2;
+ last_reg_arg = func_type->num_fields () - 2;
/* First force sp to a 4-byte alignment. */
sp = sh_frame_align (gdbarch, sp);
{
int i;
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
{
int i;
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
int subpos = bitpos + TYPE_FIELD_BITPOS (type, i);
probably in older releases to. To appease GCC, if a
structure has only a single `float' member, we store its
value in %f1 too (we already have stored in %f0). */
- if (TYPE_NFIELDS (type) == 1)
+ if (type->num_fields () == 1)
{
struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, 0));
{
int i;
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
int subpos = bitpos + TYPE_FIELD_BITPOS (type, i);
set_type_vptr_basetype (type, t);
if (type == t) /* Our own class provides vtbl ptr. */
{
- for (i = TYPE_NFIELDS (t) - 1;
+ for (i = t->num_fields () - 1;
i >= TYPE_N_BASECLASSES (t);
--i)
{
/* The type may be a stub. */
type = check_typedef (type);
- for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
+ for (i = type->num_fields () - 1; i >= TYPE_N_BASECLASSES (type); i--)
{
const char *t_field_name = TYPE_FIELD_NAME (type, i);
int j;
if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT)
- for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++)
+ for (j = TYPE_N_BASECLASSES (t); j < t->num_fields (); j++)
if (TYPE_FIELD_NAME (t, j))
completion_list_add_name (tracker, sym->language (),
TYPE_FIELD_NAME (t, j),
/* For a variadic C function, the last explicitly declared argument and all
remaining arguments are passed on the stack. */
if (TYPE_VARARGS (func_type))
- first_arg_on_stack = TYPE_NFIELDS (func_type) - 1;
+ first_arg_on_stack = func_type->num_fields () - 1;
/* Now make space on the stack for the args. */
for (argnum = 0; argnum < nargs; argnum++)
{
case TYPE_CODE_ENUM:
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
for (i = 0; i < len; i++)
{
if (TYPE_FIELD_ENUMVAL (type, i) == val)
type whose size is greater than or equal to 4 -> returned in register. */
if ((type->code () == TYPE_CODE_STRUCT
|| type->code () == TYPE_CODE_UNION)
- && TYPE_NFIELDS (type) == 1)
+ && type->num_fields () == 1)
{
fld_type = TYPE_FIELD_TYPE (type, 0);
if (v850_type_is_scalar (fld_type) && TYPE_LENGTH (fld_type) >= 4)
&& v850_type_is_scalar (TYPE_FIELD_TYPE (type, 0))
&& TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) == 4)
{
- for (i = 1; i < TYPE_NFIELDS (type); ++i)
+ for (i = 1; i < type->num_fields (); ++i)
{
fld_type = TYPE_FIELD_TYPE (type, 0);
if (fld_type->code () == TYPE_CODE_ARRAY)
returned in register. */
if (type->code () == TYPE_CODE_UNION)
{
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (i = 0; i < type->num_fields (); ++i)
{
fld_type = TYPE_FIELD_TYPE (type, 0);
if (!v850_use_struct_convention (gdbarch, fld_type))
{
int i;
- for (i = 0; i < TYPE_NFIELDS (type); i++)
+ for (i = 0; i < type->num_fields (); i++)
{
if (v850_eight_byte_align_p (TYPE_FIELD_TYPE (type, i)))
return 1;
nbases = TYPE_N_BASECLASSES (type);
if (!looking_for_baseclass)
- for (i = TYPE_NFIELDS (type) - 1; i >= nbases; i--)
+ for (i = type->num_fields () - 1; i >= nbases; i--)
{
const char *t_field_name = TYPE_FIELD_NAME (type, i);
bitpos is zero in an anonymous union field, so we
have to add the offset of the union here. */
if (field_type->code () == TYPE_CODE_STRUCT
- || (TYPE_NFIELDS (field_type) > 0
+ || (field_type->num_fields () > 0
&& TYPE_FIELD_BITPOS (field_type, 0) == 0))
new_offset += TYPE_FIELD_BITPOS (type, i) / 8;
{
if (!typecmp (TYPE_FN_FIELD_STATIC_P (f, j),
TYPE_VARARGS (TYPE_FN_FIELD_TYPE (f, j)),
- TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f, j)),
+ TYPE_FN_FIELD_TYPE (f, j)->num_fields (),
TYPE_FN_FIELD_ARGS (f, j), args))
{
if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
error (_("Attempt to extract a component of a value that is not a %s."),
err);
- for (i = TYPE_N_BASECLASSES (t); i < TYPE_NFIELDS (t); i++)
+ for (i = TYPE_N_BASECLASSES (t); i < t->num_fields (); i++)
{
if (!field_is_static (&TYPE_FIELD (t, i))
&& bitpos == TYPE_FIELD_BITPOS (t, i)
if (methods != NULL)
{
- nparms = TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (methods, ix));
+ nparms = TYPE_FN_FIELD_TYPE (methods, ix)->num_fields ();
static_offset = oload_method_static_p (methods, ix);
}
else
- nparms = TYPE_NFIELDS (SYMBOL_TYPE (functions[ix]));
+ nparms = SYMBOL_TYPE (functions[ix])->num_fields ();
parm_types.reserve (nparms);
for (jj = 0; jj < nparms; jj++)
gdb_assert (type->code () == TYPE_CODE_ENUM
&& TYPE_DECLARED_CLASS (type));
- for (i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); ++i)
+ for (i = TYPE_N_BASECLASSES (type); i < type->num_fields (); ++i)
{
const char *fname = TYPE_FIELD_NAME (type, i);
int len;
{
int start = 0;
- if (TYPE_NFIELDS (t1) > 0 && TYPE_FIELD_ARTIFICIAL (t1, 0))
+ if (t1->num_fields () > 0 && TYPE_FIELD_ARTIFICIAL (t1, 0))
++start;
/* If skipping artificial fields, find the first real field
in T1. */
if (skip_artificial)
{
- while (start < TYPE_NFIELDS (t1)
+ while (start < t1->num_fields ()
&& TYPE_FIELD_ARTIFICIAL (t1, start))
++start;
}
/* Special case: a method taking void. T1 will contain no
non-artificial fields, and T2 will contain TYPE_CODE_VOID. */
- if ((TYPE_NFIELDS (t1) - start) == 0 && TYPE_NFIELDS (t2) == 1
+ if ((t1->num_fields () - start) == 0 && t2->num_fields () == 1
&& TYPE_FIELD_TYPE (t2, 0)->code () == TYPE_CODE_VOID)
return 1;
- if ((TYPE_NFIELDS (t1) - start) == TYPE_NFIELDS (t2))
+ if ((t1->num_fields () - start) == t2->num_fields ())
{
int i;
- for (i = 0; i < TYPE_NFIELDS (t2); ++i)
+ for (i = 0; i < t2->num_fields (); ++i)
{
if (compare_ranks (rank_one_type (TYPE_FIELD_TYPE (t1, start + i),
TYPE_FIELD_TYPE (t2, i), NULL),
error (_("Internal error: non-aggregate type "
"to value_struct_elt_for_reference"));
- for (i = TYPE_NFIELDS (t) - 1; i >= TYPE_N_BASECLASSES (t); i--)
+ for (i = t->num_fields () - 1; i >= TYPE_N_BASECLASSES (t); i--)
{
const char *t_field_name = TYPE_FIELD_NAME (t, i);
unsigned int i;
unsigned int len;
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
for (i = 0; i < len; i++)
{
QUIT;
const gdb_byte *valaddr = (value_contents_for_printing (original_value)
+ embedded_offset);
ULONGEST val = unpack_long (type, valaddr);
- int field, nfields = TYPE_NFIELDS (type);
+ int field, nfields = type->num_fields ();
struct gdbarch *gdbarch = get_type_arch (type);
struct type *bool_type = builtin_type (gdbarch)->builtin_bool;