{
const dynamic_prop &high = type->bounds ()->high;
- if (high.kind () == PROP_CONST)
+ if (high.is_constant ())
return high.const_val ();
else
{
{
const dynamic_prop &low = type->bounds ()->low;
- if (low.kind () == PROP_CONST)
+ if (low.is_constant ())
return low.const_val ();
else
{
{
const dynamic_prop &high = type->bounds ()->high;
- if (high.kind () == PROP_CONST)
+ if (high.is_constant ())
return (ULONGEST) high.const_val () + 1;
/* If TYPE is unresolved, the high bound might be a location list. Return
&& eltype->code () == TYPE_CODE_PTR)
idxtype = check_typedef (type->index_type ());
if (idxtype != NULL
- && idxtype->bounds ()->low.kind () != PROP_UNDEFINED
- && idxtype->bounds ()->high.kind () != PROP_UNDEFINED)
+ && idxtype->bounds ()->low.is_constant ()
+ && idxtype->bounds ()->high.is_constant ())
{
data->known_tasks_element = eltype;
data->known_tasks_length =
element_type = context->convert_type (type->target_type ());
- if (range->bounds ()->low.kind () != PROP_CONST)
+ if (!range->bounds ()->low.is_constant ())
return context->plugin ().error (_("array type with non-constant"
" lower bound is not supported"));
if (range->bounds ()->low.const_val () != 0)
struct type *range = type->index_type ();
gcc_type element_type = instance->convert_type (type->target_type ());
- if (range->bounds ()->low.kind () != PROP_CONST)
+ if (!range->bounds ()->low.is_constant ())
{
const char *s = _("array type with non-constant"
" lower bound is not supported");
if (new_target == nullptr)
{
/* Maybe we don't need to rewrite this array. */
- if (current_bounds->low.kind () == PROP_CONST
- && current_bounds->high.kind () == PROP_CONST)
+ if (current_bounds->low.is_constant ()
+ && current_bounds->high.is_constant ())
return nullptr;
}
if (attr_to_dynamic_prop (attr, die, cu, &high, base_type))
{
/* If bounds are constant do the final calculation here. */
- if (low.kind () == PROP_CONST && high.kind () == PROP_CONST)
+ if (low.is_constant () && high.is_constant ())
high.set_const_val (low.const_val () + high.const_val () - 1);
else
high_bound_is_count = 1;
ULONGEST negative_mask
= -((ULONGEST) 1 << (base_type->length () * TARGET_CHAR_BIT - 1));
- if (low.kind () == PROP_CONST
+ if (low.is_constant ()
&& !base_type->is_unsigned () && (low.const_val () & negative_mask))
low.set_const_val (low.const_val () | negative_mask);
- if (high.kind () == PROP_CONST
+ if (high.is_constant ()
&& !base_type->is_unsigned () && (high.const_val () & negative_mask))
high.set_const_val (high.const_val () | negative_mask);
}
else if (type_not_allocated (type))
print_rank_only = true;
else if ((TYPE_ASSOCIATED_PROP (type)
- && PROP_CONST != TYPE_ASSOCIATED_PROP (type)->kind ())
+ && !TYPE_ASSOCIATED_PROP (type)->is_constant ())
|| (TYPE_ALLOCATED_PROP (type)
- && PROP_CONST != TYPE_ALLOCATED_PROP (type)->kind ())
+ && !TYPE_ALLOCATED_PROP (type)->is_constant ())
|| (TYPE_DATA_LOCATION (type)
- && PROP_CONST != TYPE_DATA_LOCATION (type)->kind ()))
+ && !TYPE_DATA_LOCATION (type)->is_constant ()))
{
/* This case exist when we ptype a typename which has the dynamic
properties but cannot be resolved as there is no object. */
asked to print the type of a value with a dynamic type then the
bounds will not have been resolved. */
- if (type->bounds ()->high.kind () == PROP_CONST)
+ if (type->bounds ()->high.is_constant ())
{
LONGEST upper_bound = f77_get_upperbound (type);
LONGEST
f77_get_lowerbound (struct type *type)
{
- if (type->bounds ()->low.kind () != PROP_CONST)
+ if (!type->bounds ()->low.is_constant ())
error (_("Lower bound may not be '*' in F77"));
return type->bounds ()->low.const_val ();
LONGEST
f77_get_upperbound (struct type *type)
{
- if (type->bounds ()->high.kind () != PROP_CONST)
+ if (!type->bounds ()->high.is_constant ())
{
/* We have an assumed size array on our hands. Assume that
upper_bound == lower_bound so that we show at least 1 element.
case, if we copy the underlying type's sign, then reading some
range values will cause an unwanted sign extension. So, we have
some heuristics here instead. */
- else if (low_bound->kind () == PROP_CONST && low_bound->const_val () >= 0)
+ else if (low_bound->is_constant () && low_bound->const_val () >= 0)
{
result_type->set_is_unsigned (true);
/* Ada allows the declaration of range types whose upper bound is
less than the lower bound, so checking the lower bound is not
enough. Make sure we do not mark a range type whose upper bound
is negative as unsigned. */
- if (high_bound->kind () == PROP_CONST && high_bound->const_val () < 0)
+ if (high_bound->is_constant () && high_bound->const_val () < 0)
result_type->set_is_unsigned (false);
}
{
/* If the range doesn't have a defined stride then its stride field will
be initialized to the constant 0. */
- return (bounds->low.kind () == PROP_CONST
- && bounds->high.kind () == PROP_CONST
- && bounds->stride.kind () == PROP_CONST);
+ return (bounds->low.is_constant ()
+ && bounds->high.is_constant ()
+ && bounds->stride.is_constant ());
}
/* See gdbtypes.h. */
case TYPE_CODE_RANGE:
{
/* This function only works for ranges with a constant low bound. */
- if (type->bounds ()->low.kind () != PROP_CONST)
+ if (!type->bounds ()->low.is_constant ())
return {};
LONGEST low = type->bounds ()->low.const_val ();
case TYPE_CODE_RANGE:
{
/* This function only works for ranges with a constant high bound. */
- if (type->bounds ()->high.kind () != PROP_CONST)
+ if (!type->bounds ()->high.is_constant ())
return {};
LONGEST high = type->bounds ()->high.const_val ();
struct dynamic_prop *byte_stride_prop,
unsigned int bit_stride)
{
- if (byte_stride_prop != NULL
- && byte_stride_prop->kind () == PROP_CONST)
+ if (byte_stride_prop != nullptr && byte_stride_prop->is_constant ())
{
/* The byte stride is actually not dynamic. Pretend we were
called with bit_stride set instead of byte_stride_prop.
{
struct dynamic_prop *prop = type->dyn_prop (DYN_PROP_BYTE_STRIDE);
- return (prop != NULL && prop->kind () != PROP_CONST);
+ return prop != nullptr && prop->is_constant ();
}
/* Worker for is_dynamic_type. */
{
struct dynamic_prop *prop = TYPE_ALLOCATED_PROP (type);
- return (prop != nullptr && prop->kind () == PROP_CONST
- && prop->const_val () == 0);
+ return prop != nullptr && prop->is_constant () && prop->const_val () == 0;
}
/* Associated status of type TYPE. Return zero if type TYPE is associated.
{
struct dynamic_prop *prop = TYPE_ASSOCIATED_PROP (type);
- return (prop != nullptr && prop->kind () == PROP_CONST
- && prop->const_val () == 0);
+ return prop != nullptr && prop->is_constant () && prop->const_val () == 0;
}
/* rank_one_type helper for when PARM's type code is TYPE_CODE_PTR. */
m_data.const_val = const_val;
}
+ /* Return true if this property has a constant value, false
+ otherwise. */
+ bool is_constant () const
+ { return m_kind == PROP_CONST; }
+
const dwarf2_property_baton *baton () const
{
gdb_assert (m_kind == PROP_LOCEXPR
case TYPE_CODE_ARRAY:
case TYPE_CODE_STRING:
case TYPE_CODE_RANGE:
- if (type->bounds ()->low.kind () == PROP_CONST)
+ if (type->bounds ()->low.is_constant ())
low = type->bounds ()->low.const_val ();
else
low = 0;
- if (type->bounds ()->high.kind () == PROP_CONST)
+ if (type->bounds ()->high.is_constant ())
high = type->bounds ()->high.const_val ();
else
high = 0;
{
gdb_printf (stream, "ARRAY [");
if (type->target_type ()->length () > 0
- && type->bounds ()->high.kind () != PROP_UNDEFINED)
+ && type->bounds ()->high.is_constant ())
{
if (type->index_type () != 0)
{
gdb_printf (stream, "(");
gdb_printf (stream, "array ");
if (type->target_type ()->length () > 0
- && type->bounds ()->high.kind () != PROP_UNDEFINED)
+ && type->bounds ()->high.is_constant ())
gdb_printf (stream, "[%s..%s] ",
plongest (type->bounds ()->low.const_val ()),
plongest (type->bounds ()->high.const_val ()));
case TYPE_CODE_ARRAY:
case TYPE_CODE_STRING:
case TYPE_CODE_RANGE:
- if (type->bounds ()->low.kind () == PROP_CONST)
+ if (type->bounds ()->low.is_constant ())
low = type->bounds ()->low.const_val ();
else
low = 0;
- if (type->bounds ()->high.kind () == PROP_CONST)
+ if (type->bounds ()->high.is_constant ())
high = type->bounds ()->high.const_val ();
else
high = 0;
return m_parent->address () + m_offset;
if (NULL != TYPE_DATA_LOCATION (type ()))
{
- gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (type ()));
+ gdb_assert (TYPE_DATA_LOCATION (type ())->is_constant ());
return TYPE_DATA_LOCATION_ADDR (type ());
}
update the address of the COMPONENT. */
type = whole->type ();
if (NULL != TYPE_DATA_LOCATION (type)
- && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
+ && TYPE_DATA_LOCATION (type)->is_constant ())
set_address (TYPE_DATA_LOCATION_ADDR (type));
/* Similarly, if the COMPONENT value has a dynamically resolved location
property then update its address. */
type = this->type ();
if (NULL != TYPE_DATA_LOCATION (type)
- && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
+ && TYPE_DATA_LOCATION (type)->is_constant ())
{
/* If the COMPONENT has a dynamic location, and is an
lval_internalvar_component, then we change it to a lval_memory.
gdb_assert (0 == offset);
/* We expect an already resolved data location. */
- gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (type));
+ gdb_assert (TYPE_DATA_LOCATION (type)->is_constant ());
/* For dynamic data types defer memory allocation
until we actual access the value. */
v = value::allocate_lazy (type);
else
v = value_from_contents (resolved_type, valaddr);
if (TYPE_DATA_LOCATION (resolved_type_no_typedef) != NULL
- && TYPE_DATA_LOCATION_KIND (resolved_type_no_typedef) == PROP_CONST)
+ && TYPE_DATA_LOCATION (resolved_type_no_typedef)->is_constant ())
address = TYPE_DATA_LOCATION_ADDR (resolved_type_no_typedef);
v->set_lval (lval_memory);
v->set_address (address);