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.
This commit is contained in:
Tom Tromey 2021-03-08 07:27:57 -07:00
parent 984af2cb26
commit d123f9e4a3
2 changed files with 21 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2021-03-08 Tom Tromey <tom@tromey.com>
* rust-lang.c (eval_op_rust_ind): New function.
(rust_evaluate_subexp): Use it.
2021-03-08 Tom Tromey <tom@tromey.com>
* rust-lang.c (rust_subscript): Change parameters.

View File

@ -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;