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:26 -0700 |
commit | 6fab435953629ec50e2c367a0fbe305e4e5abf3f (patch) | |
tree | f392b67237130fa83e6b99751075e9fe2c39c1d6 /gdb/rust-lang.c | |
parent | 9dcd3e295774f93ec0cdcd687481c98e2d5e606c (diff) | |
download | gdb-6fab435953629ec50e2c367a0fbe305e4e5abf3f.zip gdb-6fab435953629ec50e2c367a0fbe305e4e5abf3f.tar.gz gdb-6fab435953629ec50e2c367a0fbe305e4e5abf3f.tar.bz2 |
Implement some Rust operations
This implements some straightforward Rust operations, using existing
template classes.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* rust-lang.c (eval_op_rust_complement, eval_op_rust_array): No
longer static. Add "opcode" parameter.
(rust_evaluate_subexp): Update.
* rust-exp.h: New file.
Diffstat (limited to 'gdb/rust-lang.c')
-rw-r--r-- | gdb/rust-lang.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 3b86382..63ea21b 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -39,6 +39,7 @@ #include <vector> #include "cli/cli-style.h" #include "parser-defs.h" +#include "rust-exp.h" /* See rust-lang.h. */ @@ -1339,9 +1340,10 @@ eval_op_rust_ind (struct type *expect_type, struct expression *exp, /* A helper function for UNOP_COMPLEMENT. */ -static struct value * +struct value * eval_op_rust_complement (struct type *expect_type, struct expression *exp, enum noside noside, + enum exp_opcode opcode, struct value *value) { if (noside == EVAL_SKIP) @@ -1356,9 +1358,10 @@ eval_op_rust_complement (struct type *expect_type, struct expression *exp, /* A helper function for OP_ARRAY. */ -static struct value * +struct value * eval_op_rust_array (struct type *expect_type, struct expression *exp, enum noside noside, + enum exp_opcode opcode, struct value *elt, struct value *ncopies) { int copies = value_as_long (ncopies); @@ -1505,8 +1508,9 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp, int *pos, enum noside noside) { struct value *result; + enum exp_opcode op = exp->elts[*pos].opcode; - switch (exp->elts[*pos].opcode) + switch (op) { case UNOP_IND: { @@ -1528,7 +1532,7 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp, ++*pos; value = evaluate_subexp (nullptr, exp, pos, noside); - result = eval_op_rust_complement (expect_type, exp, noside, value); + result = eval_op_rust_complement (expect_type, exp, noside, op, value); } break; @@ -1621,7 +1625,7 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp, elt = rust_evaluate_subexp (NULL, exp, pos, noside); ncopies = rust_evaluate_subexp (NULL, exp, pos, noside); - return eval_op_rust_array (expect_type, exp, noside, elt, ncopies); + return eval_op_rust_array (expect_type, exp, noside, op, elt, ncopies); } break; |