mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-23 18:14:13 +08:00
gdb: remove TYPE_FIELD_ENUMVAL
Remove TYPE_FIELD_ENUMVAL, replace with type::field + field::loc_enumval. Change-Id: I2ada73e4635aad3363ce2eb22c1dc52698ee2072
This commit is contained in:
parent
b610c04548
commit
970db51860
@ -651,7 +651,7 @@ ada_discrete_type_high_bound (struct type *type)
|
||||
}
|
||||
}
|
||||
case TYPE_CODE_ENUM:
|
||||
return TYPE_FIELD_ENUMVAL (type, type->num_fields () - 1);
|
||||
return type->field (type->num_fields () - 1).loc_enumval ();
|
||||
case TYPE_CODE_BOOL:
|
||||
return 1;
|
||||
case TYPE_CODE_CHAR:
|
||||
@ -686,7 +686,7 @@ ada_discrete_type_low_bound (struct type *type)
|
||||
}
|
||||
}
|
||||
case TYPE_CODE_ENUM:
|
||||
return TYPE_FIELD_ENUMVAL (type, 0);
|
||||
return type->field (0).loc_enumval ();
|
||||
case TYPE_CODE_BOOL:
|
||||
return 0;
|
||||
case TYPE_CODE_CHAR:
|
||||
@ -4617,7 +4617,7 @@ ada_identical_enum_types_p (struct type *type1, struct type *type2)
|
||||
|
||||
/* All enums in the type should have an identical underlying value. */
|
||||
for (i = 0; i < type1->num_fields (); i++)
|
||||
if (TYPE_FIELD_ENUMVAL (type1, i) != TYPE_FIELD_ENUMVAL (type2, i))
|
||||
if (type1->field (i).loc_enumval () != type2->field (i).loc_enumval ())
|
||||
return 0;
|
||||
|
||||
/* All enumerals should also have the same name (modulo any numerical
|
||||
@ -8578,7 +8578,7 @@ val_atr (struct type *type, LONGEST val)
|
||||
{
|
||||
if (val < 0 || val >= type->num_fields ())
|
||||
error (_("argument to 'VAL out of range"));
|
||||
val = TYPE_FIELD_ENUMVAL (type, val);
|
||||
val = type->field (val).loc_enumval ();
|
||||
}
|
||||
return value_from_longest (type, val);
|
||||
}
|
||||
@ -10214,7 +10214,7 @@ convert_char_literal (struct type *type, LONGEST val)
|
||||
size_t elen = strlen (ename);
|
||||
|
||||
if (elen >= len && strcmp (name, ename + elen - len) == 0)
|
||||
return TYPE_FIELD_ENUMVAL (type, f);
|
||||
return type->field (f).loc_enumval ();
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
@ -328,11 +328,11 @@ print_enum_type (struct type *type, struct ui_file *stream)
|
||||
wrap_here (" ");
|
||||
fputs_styled (ada_enum_name (type->field (i).name ()),
|
||||
variable_name_style.style (), stream);
|
||||
if (lastval != TYPE_FIELD_ENUMVAL (type, i))
|
||||
if (lastval != type->field (i).loc_enumval ())
|
||||
{
|
||||
fprintf_filtered (stream, " => %s",
|
||||
plongest (TYPE_FIELD_ENUMVAL (type, i)));
|
||||
lastval = TYPE_FIELD_ENUMVAL (type, i);
|
||||
plongest (type->field (i).loc_enumval ()));
|
||||
lastval = type->field (i).loc_enumval ();
|
||||
}
|
||||
lastval += 1;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ print_optional_low_bound (struct ui_file *stream, struct type *type,
|
||||
case TYPE_CODE_ENUM:
|
||||
if (low_bound == 0)
|
||||
return 0;
|
||||
low_bound = TYPE_FIELD_ENUMVAL (index_type, low_bound);
|
||||
low_bound = index_type->field (low_bound).loc_enumval ();
|
||||
break;
|
||||
case TYPE_CODE_UNDEF:
|
||||
index_type = NULL;
|
||||
@ -381,7 +381,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
|
||||
len = type->num_fields ();
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (TYPE_FIELD_ENUMVAL (type, i) == val)
|
||||
if (type->field (i).loc_enumval () == val)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -835,7 +835,7 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse,
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
QUIT;
|
||||
if (val == TYPE_FIELD_ENUMVAL (type, i))
|
||||
if (val == type->field (i).loc_enumval ())
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1596,11 +1596,11 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
|
||||
wrap_here (" ");
|
||||
fputs_styled (type->field (i).name (),
|
||||
variable_name_style.style (), stream);
|
||||
if (lastval != TYPE_FIELD_ENUMVAL (type, i))
|
||||
if (lastval != type->field (i).loc_enumval ())
|
||||
{
|
||||
fprintf_filtered (stream, " = %s",
|
||||
plongest (TYPE_FIELD_ENUMVAL (type, i)));
|
||||
lastval = TYPE_FIELD_ENUMVAL (type, i);
|
||||
plongest (type->field (i).loc_enumval ()));
|
||||
lastval = type->field (i).loc_enumval ();
|
||||
}
|
||||
lastval++;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ convert_enum (compile_c_instance *context, struct type *type)
|
||||
for (i = 0; i < type->num_fields (); ++i)
|
||||
{
|
||||
context->plugin ().build_add_enum_constant
|
||||
(result, type->field (i).name (), TYPE_FIELD_ENUMVAL (type, i));
|
||||
(result, type->field (i).name (), type->field (i).loc_enumval ());
|
||||
}
|
||||
|
||||
context->plugin ().finish_enum_type (result);
|
||||
|
@ -944,7 +944,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type,
|
||||
continue;
|
||||
|
||||
instance->plugin ().build_enum_constant (result, fname.get (),
|
||||
TYPE_FIELD_ENUMVAL (type, i));
|
||||
type->field (i).loc_enumval ());
|
||||
}
|
||||
|
||||
/* Finish enum definition and pop scopes. */
|
||||
|
@ -9201,7 +9201,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
|
||||
{
|
||||
const char *name
|
||||
= rust_last_path_segment (enum_type->field (i).name ());
|
||||
discriminant_map[name] = TYPE_FIELD_ENUMVAL (enum_type, i);
|
||||
discriminant_map[name] = enum_type->field (i).loc_enumval ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1068,12 +1068,12 @@ get_discrete_low_bound (struct type *type)
|
||||
{
|
||||
/* The enums may not be sorted by value, so search all
|
||||
entries. */
|
||||
LONGEST low = TYPE_FIELD_ENUMVAL (type, 0);
|
||||
LONGEST low = type->field (0).loc_enumval ();
|
||||
|
||||
for (int i = 0; i < type->num_fields (); i++)
|
||||
{
|
||||
if (TYPE_FIELD_ENUMVAL (type, i) < low)
|
||||
low = TYPE_FIELD_ENUMVAL (type, i);
|
||||
if (type->field (i).loc_enumval () < low)
|
||||
low = type->field (i).loc_enumval ();
|
||||
}
|
||||
|
||||
/* Set unsigned indicator if warranted. */
|
||||
@ -1139,12 +1139,12 @@ get_discrete_high_bound (struct type *type)
|
||||
{
|
||||
/* The enums may not be sorted by value, so search all
|
||||
entries. */
|
||||
LONGEST high = TYPE_FIELD_ENUMVAL (type, 0);
|
||||
LONGEST high = type->field (0).loc_enumval ();
|
||||
|
||||
for (int i = 0; i < type->num_fields (); i++)
|
||||
{
|
||||
if (TYPE_FIELD_ENUMVAL (type, i) > high)
|
||||
high = TYPE_FIELD_ENUMVAL (type, i);
|
||||
if (type->field (i).loc_enumval () > high)
|
||||
high = type->field (i).loc_enumval ();
|
||||
}
|
||||
|
||||
return high;
|
||||
@ -1250,7 +1250,7 @@ discrete_position (struct type *type, LONGEST val)
|
||||
|
||||
for (i = 0; i < type->num_fields (); i += 1)
|
||||
{
|
||||
if (val == TYPE_FIELD_ENUMVAL (type, i))
|
||||
if (val == type->field (i).loc_enumval ())
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -5337,7 +5337,7 @@ recursive_dump_type (struct type *type, int spaces)
|
||||
{
|
||||
if (type->code () == TYPE_CODE_ENUM)
|
||||
printf_filtered ("%*s[%d] enumval %s type ", spaces + 2, "",
|
||||
idx, plongest (TYPE_FIELD_ENUMVAL (type, idx)));
|
||||
idx, plongest (type->field (idx).loc_enumval ()));
|
||||
else
|
||||
printf_filtered ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "",
|
||||
idx, plongest (type->field (idx).loc_bitpos ()),
|
||||
@ -5565,7 +5565,7 @@ copy_type_recursive (struct objfile *objfile,
|
||||
new_type->field (i).set_loc_bitpos (type->field (i).loc_bitpos ());
|
||||
break;
|
||||
case FIELD_LOC_KIND_ENUMVAL:
|
||||
new_type->field (i).set_loc_enumval (TYPE_FIELD_ENUMVAL (type, i));
|
||||
new_type->field (i).set_loc_enumval (type->field (i).loc_enumval ());
|
||||
break;
|
||||
case FIELD_LOC_KIND_PHYSADDR:
|
||||
new_type->field (i).set_loc_physaddr
|
||||
|
@ -2128,7 +2128,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
|
||||
#define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
|
||||
#define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
|
||||
|
||||
#define TYPE_FIELD_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ())
|
||||
#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())
|
||||
#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) ((thistype)->field (n).loc_physaddr ())
|
||||
#define TYPE_FIELD_DWARF_BLOCK(thistype, n) ((thistype)->field (n).loc_dwarf_block ())
|
||||
|
@ -611,11 +611,11 @@ m2_enum (struct type *type, struct ui_file *stream, int show, int level)
|
||||
wrap_here (" ");
|
||||
fputs_styled (type->field (i).name (),
|
||||
variable_name_style.style (), stream);
|
||||
if (lastval != TYPE_FIELD_ENUMVAL (type, i))
|
||||
if (lastval != type->field (i).loc_enumval ())
|
||||
{
|
||||
fprintf_filtered (stream, " = %s",
|
||||
plongest (TYPE_FIELD_ENUMVAL (type, i)));
|
||||
lastval = TYPE_FIELD_ENUMVAL (type, i);
|
||||
plongest (type->field (i).loc_enumval ()));
|
||||
lastval = type->field (i).loc_enumval ();
|
||||
}
|
||||
lastval++;
|
||||
}
|
||||
|
@ -711,12 +711,12 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
|
||||
fprintf_filtered (stream, ", ");
|
||||
wrap_here (" ");
|
||||
fputs_filtered (type->field (i).name (), stream);
|
||||
if (lastval != TYPE_FIELD_ENUMVAL (type, i))
|
||||
if (lastval != type->field (i).loc_enumval ())
|
||||
{
|
||||
fprintf_filtered (stream,
|
||||
" := %s",
|
||||
plongest (TYPE_FIELD_ENUMVAL (type, i)));
|
||||
lastval = TYPE_FIELD_ENUMVAL (type, i);
|
||||
plongest (type->field (i).loc_enumval ()));
|
||||
lastval = type->field (i).loc_enumval ();
|
||||
}
|
||||
lastval++;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ convert_field (struct type *type, int field)
|
||||
|
||||
if (type->code () == TYPE_CODE_ENUM)
|
||||
{
|
||||
arg = gdb_py_object_from_longest (TYPE_FIELD_ENUMVAL (type, field));
|
||||
arg = gdb_py_object_from_longest (type->field (field).loc_enumval ());
|
||||
attrstring = "enumval";
|
||||
}
|
||||
else
|
||||
|
@ -626,7 +626,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
|
||||
len = type->num_fields ();
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (TYPE_FIELD_ENUMVAL (type, i) == val)
|
||||
if (type->field (i).loc_enumval () == val)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -3343,7 +3343,7 @@ enum_constant_from_type (struct type *type, const char *name)
|
||||
&& fname[len - name_len - 2] == ':'
|
||||
&& fname[len - name_len - 1] == ':'
|
||||
&& strcmp (&fname[len - name_len], name) == 0)
|
||||
return value_from_longest (type, TYPE_FIELD_ENUMVAL (type, i));
|
||||
return value_from_longest (type, type->field (i).loc_enumval ());
|
||||
}
|
||||
|
||||
error (_("no constant named \"%s\" in enum \"%s\""),
|
||||
|
@ -608,7 +608,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
QUIT;
|
||||
if (val == TYPE_FIELD_ENUMVAL (type, i))
|
||||
if (val == type->field (i).loc_enumval ())
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -630,7 +630,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
|
||||
{
|
||||
QUIT;
|
||||
|
||||
ULONGEST enumval = TYPE_FIELD_ENUMVAL (type, i);
|
||||
ULONGEST enumval = type->field (i).loc_enumval ();
|
||||
int nbits = count_one_bits_ll (enumval);
|
||||
|
||||
gdb_assert (nbits == 0 || nbits == 1);
|
||||
@ -645,7 +645,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
|
||||
else
|
||||
fputs_filtered (" | ", stream);
|
||||
|
||||
val &= ~TYPE_FIELD_ENUMVAL (type, i);
|
||||
val &= ~type->field (i).loc_enumval ();
|
||||
fputs_styled (type->field (i).name (),
|
||||
variable_name_style.style (), stream);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user