aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:07 -0700
commitd148f80354c0dbf01823655f82e239dd60250f35 (patch)
tree2be3000eac2926d2f765abe4351f0119e6fd52e1
parent9cbd1c2011286ac8982f9d606390d3359f78f9c8 (diff)
downloadgdb-d148f80354c0dbf01823655f82e239dd60250f35.zip
gdb-d148f80354c0dbf01823655f82e239dd60250f35.tar.gz
gdb-d148f80354c0dbf01823655f82e239dd60250f35.tar.bz2
Change parameters to rust_range
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.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/rust-lang.c27
2 files changed, 21 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e72feb8..407344b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
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.
(evaluate_subexp_f): Use it.
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 80f1f59..329e00d 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -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: