summaryrefslogtreecommitdiff
path: root/gdb/rust-lang.c
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
commitd123f9e4a3936aeff524322e052ce1fd9ff1f19f (patch)
tree2b2654bbb78263a46a1a7193c4f731fb9e7b5fdf /gdb/rust-lang.c
parent984af2cb260aec903280aa3f1dd47be6d5dc69de (diff)
downloadbinutils-gdb-d123f9e4a3936aeff524322e052ce1fd9ff1f19f.tar.gz
Split out eval_op_rust_ind
This splits UNOP_IND into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * rust-lang.c (eval_op_rust_ind): New function. (rust_evaluate_subexp): Use it.
Diffstat (limited to 'gdb/rust-lang.c')
-rw-r--r--gdb/rust-lang.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 5a937d95efa..173b418e2f5 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1322,6 +1322,21 @@ rust_subscript (struct type *expect_type, struct expression *exp,
return result;
}
+/* A helper function for UNOP_IND. */
+
+static struct value *
+eval_op_rust_ind (struct type *expect_type, struct expression *exp,
+ enum noside noside,
+ struct value *value)
+{
+ gdb_assert (noside == EVAL_NORMAL);
+ struct value *trait_ptr = rust_get_trait_object_pointer (value);
+ if (trait_ptr != NULL)
+ value = trait_ptr;
+
+ return value_ind (value);
+}
+
/* evaluate_exp implementation for Rust. */
static struct value *
@@ -1341,12 +1356,7 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp,
++*pos;
struct value *value = evaluate_subexp (expect_type, exp, pos,
noside);
-
- struct value *trait_ptr = rust_get_trait_object_pointer (value);
- if (trait_ptr != NULL)
- value = trait_ptr;
-
- result = value_ind (value);
+ result = eval_op_rust_ind (expect_type, exp, noside, value);
}
}
break;