Change parameters to rust_range
authorTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:28:07 +0000 (07:28 -0700)
This changes the parameters to rust_range, making it more suitable for
reuse by the (coming) new expression code.  In particular, rust_range
no longer evaluates its subexpressions.  Instead, they are passed in.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

* rust-lang.c (rust_range): Change parameters.
(rust_evaluate_subexp): Update.

gdb/ChangeLog
gdb/rust-lang.c

index e72feb8addb00835822208908eb2d2efe50a5cd8..407344bedaf074d76db17d1314119f3ef9d30013 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * rust-lang.c (rust_range): Change parameters.
+       (rust_evaluate_subexp): Update.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * f-lang.c (eval_op_f_allocated): New function.
index 80f1f59dd64c2c9a8064a57857fb2df50b65f885..329e00d9497eef0e2f5e856b88db51a7ebbf331f 100644 (file)
@@ -1041,9 +1041,10 @@ rust_evaluate_funcall (struct expression *exp, int *pos, enum noside noside)
 /* A helper for rust_evaluate_subexp that handles OP_RANGE.  */
 
 static struct value *
-rust_range (struct expression *exp, int *pos, enum noside noside)
+rust_range (struct type *expect_type, struct expression *exp,
+           enum noside noside, enum range_flag kind,
+           struct value *low, struct value *high)
 {
-  struct value *low = NULL, *high = NULL;
   struct value *addrval, *result;
   CORE_ADDR addr;
   struct type *range_type;
@@ -1051,14 +1052,6 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
   struct type *temp_type;
   const char *name;
 
-  auto kind
-    = (enum range_flag) longest_to_int (exp->elts[*pos + 1].longconst);
-  *pos += 3;
-
-  if (!(kind & RANGE_LOW_BOUND_DEFAULT))
-    low = evaluate_subexp (nullptr, exp, pos, noside);
-  if (!(kind & RANGE_HIGH_BOUND_DEFAULT))
-    high = evaluate_subexp (nullptr, exp, pos, noside);
   bool inclusive = !(kind & RANGE_HIGH_BOUND_EXCLUSIVE);
 
   if (noside == EVAL_SKIP)
@@ -1614,7 +1607,19 @@ tuple structs, and tuple-like enum variants"));
       break;
 
     case OP_RANGE:
-      result = rust_range (exp, pos, noside);
+      {
+       struct value *low = NULL, *high = NULL;
+       auto kind
+         = (enum range_flag) longest_to_int (exp->elts[*pos + 1].longconst);
+       *pos += 3;
+
+       if (!(kind & RANGE_LOW_BOUND_DEFAULT))
+         low = evaluate_subexp (nullptr, exp, pos, noside);
+       if (!(kind & RANGE_HIGH_BOUND_DEFAULT))
+         high = evaluate_subexp (nullptr, exp, pos, noside);
+
+       result = rust_range (expect_type, exp, noside, kind, low, high);
+      }
       break;
 
     case UNOP_ADDR:
This page took 0.026958 seconds and 4 git commands to generate.