diff options
author | Tom Tromey <tom@tromey.com> | 2021-03-08 07:27:57 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-03-08 07:28:07 -0700 |
commit | 984af2cb260aec903280aa3f1dd47be6d5dc69de (patch) | |
tree | dcd32f4c431fbfa0dcd2159544798c47f7cc38b0 /gdb/rust-lang.c | |
parent | d148f80354c0dbf01823655f82e239dd60250f35 (diff) | |
download | gdb-984af2cb260aec903280aa3f1dd47be6d5dc69de.zip gdb-984af2cb260aec903280aa3f1dd47be6d5dc69de.tar.gz gdb-984af2cb260aec903280aa3f1dd47be6d5dc69de.tar.bz2 |
Change parameters to rust_subscript
This changes the parameters to rust_subscript, making it more suitable
for reuse by the (coming) new expression code. In particular,
rust_subscript no longer evaluates its subexpressions. Instead, they
are passed in.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* rust-lang.c (rust_subscript): Change parameters.
(rust_evaluate_subexp): Update.
Diffstat (limited to 'gdb/rust-lang.c')
-rw-r--r-- | gdb/rust-lang.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 329e00d..5a937d9 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1168,10 +1168,11 @@ rust_compute_range (struct type *type, struct value *range, /* A helper for rust_evaluate_subexp that handles BINOP_SUBSCRIPT. */ static struct value * -rust_subscript (struct expression *exp, int *pos, enum noside noside, - int for_addr) +rust_subscript (struct type *expect_type, struct expression *exp, + enum noside noside, bool for_addr, + struct value *lhs, struct value *rhs) { - struct value *lhs, *rhs, *result; + struct value *result; struct type *rhstype; LONGEST low, high_bound; /* Initialized to appease the compiler. */ @@ -1179,10 +1180,6 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside, LONGEST high = 0; int want_slice = 0; - ++*pos; - lhs = evaluate_subexp (nullptr, exp, pos, noside); - rhs = evaluate_subexp (nullptr, exp, pos, noside); - if (noside == EVAL_SKIP) return lhs; @@ -1374,7 +1371,12 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp, break; case BINOP_SUBSCRIPT: - result = rust_subscript (exp, pos, noside, 0); + { + ++*pos; + struct value *lhs = evaluate_subexp (nullptr, exp, pos, noside); + struct value *rhs = evaluate_subexp (nullptr, exp, pos, noside); + result = rust_subscript (expect_type, exp, noside, false, lhs, rhs); + } break; case OP_FUNCALL: @@ -1628,7 +1630,11 @@ tuple structs, and tuple-like enum variants")); if (exp->elts[*pos + 1].opcode == BINOP_SUBSCRIPT) { ++*pos; - result = rust_subscript (exp, pos, noside, 1); + ++*pos; + struct value *lhs = evaluate_subexp (nullptr, exp, pos, noside); + struct value *rhs = evaluate_subexp (nullptr, exp, pos, noside); + + result = rust_subscript (expect_type, exp, noside, true, lhs, rhs); break; } /* Fall through. */ |