gdbsupport: re-indent ptrace.m4
[deliverable/binutils-gdb.git] / gdb / rust-lang.c
index 96abca182415c9b7dda5e719005b496cd229abe1..5edf4aad0fd507e03507a0d29315114b0134151c 100644 (file)
@@ -1065,7 +1065,6 @@ rust_evaluate_funcall (struct expression *exp, int *pos, enum noside noside)
 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;
@@ -1074,16 +1073,15 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
   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);
@@ -1166,13 +1164,13 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
 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;
@@ -1180,15 +1178,15 @@ rust_compute_range (struct type *type, struct value *range,
   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))
@@ -1206,7 +1204,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
   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;
 
@@ -1303,8 +1301,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
       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"));
@@ -1322,7 +1319,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
          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"));
@@ -1897,21 +1894,13 @@ static const struct exp_descriptor exp_descriptor_rust =
   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.  */
@@ -1983,7 +1972,7 @@ public:
 
   /* 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);
   }
@@ -2149,6 +2138,16 @@ public:
 
   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.  */
This page took 0.026142 seconds and 4 git commands to generate.