From: Tom Tromey Date: Mon, 8 Mar 2021 14:27:57 +0000 (-0700) Subject: Split out eval_op_rust_ind X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d123f9e4a3936aeff524322e052ce1fd9ff1f19f;p=binutils-gdb.git Split out eval_op_rust_ind This splits UNOP_IND into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey * rust-lang.c (eval_op_rust_ind): New function. (rust_evaluate_subexp): Use it. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7849e59be33..22c017f0ef0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * rust-lang.c (eval_op_rust_ind): New function. + (rust_evaluate_subexp): Use it. + 2021-03-08 Tom Tromey * rust-lang.c (rust_subscript): Change parameters. 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;