static struct value *
rust_range (struct expression *exp, int *pos, enum noside noside)
{
- enum range_type kind;
struct value *low = NULL, *high = NULL;
struct value *addrval, *result;
CORE_ADDR addr;
struct type *temp_type;
const char *name;
- kind = (enum range_type) longest_to_int (exp->elts[*pos + 1].longconst);
+ auto kind
+ = (enum range_flag) longest_to_int (exp->elts[*pos + 1].longconst);
*pos += 3;
- if (kind == HIGH_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT
- || kind == NONE_BOUND_DEFAULT_EXCLUSIVE)
+ if (!(kind & RANGE_LOW_BOUND_DEFAULT))
low = evaluate_subexp (nullptr, exp, pos, noside);
- if (kind == LOW_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT_EXCLUSIVE
- || kind == NONE_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT_EXCLUSIVE)
+ if (!(kind & RANGE_HIGH_BOUND_DEFAULT))
high = evaluate_subexp (nullptr, exp, pos, noside);
- bool inclusive = (kind == NONE_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT);
+ bool inclusive = !(kind & RANGE_HIGH_BOUND_EXCLUSIVE);
if (noside == EVAL_SKIP)
return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
static void
rust_compute_range (struct type *type, struct value *range,
LONGEST *low, LONGEST *high,
- enum range_type *kind)
+ range_flags *kind)
{
int i;
*low = 0;
*high = 0;
- *kind = BOTH_BOUND_DEFAULT;
+ *kind = RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT;
if (type->num_fields () == 0)
return;
i = 0;
if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0)
{
- *kind = HIGH_BOUND_DEFAULT;
+ *kind = RANGE_HIGH_BOUND_DEFAULT;
*low = value_as_long (value_field (range, 0));
++i;
}
if (type->num_fields () > i
&& strcmp (TYPE_FIELD_NAME (type, i), "end") == 0)
{
- *kind = (*kind == BOTH_BOUND_DEFAULT
- ? LOW_BOUND_DEFAULT : NONE_BOUND_DEFAULT);
+ *kind = (*kind == (RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT)
+ ? RANGE_LOW_BOUND_DEFAULT : RANGE_STANDARD);
*high = value_as_long (value_field (range, i));
if (rust_inclusive_range_type_p (type))
struct type *rhstype;
LONGEST low, high_bound;
/* Initialized to appease the compiler. */
- enum range_type kind = BOTH_BOUND_DEFAULT;
+ range_flags kind = RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT;
LONGEST high = 0;
int want_slice = 0;
else
error (_("Cannot subscript non-array type"));
- if (want_slice
- && (kind == BOTH_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT))
+ if (want_slice && (kind & RANGE_LOW_BOUND_DEFAULT))
low = low_bound;
if (low < 0)
error (_("Index less than zero"));
CORE_ADDR addr;
struct value *addrval, *tem;
- if (kind == BOTH_BOUND_DEFAULT || kind == HIGH_BOUND_DEFAULT)
+ if (kind & RANGE_HIGH_BOUND_DEFAULT)
high = high_bound;
if (high < 0)
error (_("High index less than zero"));
rust_evaluate_subexp
};
-/* Constant data representing the Rust language. */
-
-extern const struct language_data rust_language_data =
-{
- &exp_descriptor_rust,
- c_op_print_tab, /* expression operators for printing */
-};
-
/* Class representing the Rust language. */
class rust_language : public language_defn
{
public:
rust_language ()
- : language_defn (language_rust, rust_language_data)
+ : language_defn (language_rust)
{ /* Nothing. */ }
/* See language.h. */
/* See language.h. */
- char *demangle (const char *mangled, int options) const override
+ char *demangle_symbol (const char *mangled, int options) const override
{
return gdb_demangle (mangled, options);
}
bool range_checking_on_by_default () const override
{ return true; }
+
+ /* See language.h. */
+
+ const struct exp_descriptor *expression_ops () const override
+ { return &exp_descriptor_rust; }
+
+ /* See language.h. */
+
+ const struct op_print *opcode_print_table () const override
+ { return c_op_print_tab; }
};
/* Single instance of the Rust language class. */