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:12 -0700 |
commit | 38dc70cfeea6bf0cc97ac08dc61878726cb60204 (patch) | |
tree | 38e6161e3bf8ba63fe2e24193f4be9403a5510f8 | |
parent | b84564fc8cecceb0d289e671169391f896382e5e (diff) | |
download | gdb-38dc70cfeea6bf0cc97ac08dc61878726cb60204.zip gdb-38dc70cfeea6bf0cc97ac08dc61878726cb60204.tar.gz gdb-38dc70cfeea6bf0cc97ac08dc61878726cb60204.tar.bz2 |
Split out ada_binop_minmax
This splits OP_ATR_MIN and OP_ATR_MAX into a new function for future
use.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* ada-lang.c (ada_binop_minmax): New function.
(ada_evaluate_subexp): Use it.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/ada-lang.c | 27 |
2 files changed, 24 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 91d8c44..6863877 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2021-03-08 Tom Tromey <tom@tromey.com> + * ada-lang.c (ada_binop_minmax): New function. + (ada_evaluate_subexp): Use it. + +2021-03-08 Tom Tromey <tom@tromey.com> + * ada-lang.c (ada_unop_atr): New function. (ada_evaluate_subexp): Use it. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 59dff43..aa2912f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10345,6 +10345,24 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, } } +/* A helper function for OP_ATR_MIN and OP_ATR_MAX. */ + +static struct value * +ada_binop_minmax (struct type *expect_type, + struct expression *exp, + enum noside noside, enum exp_opcode op, + struct value *arg1, struct value *arg2) +{ + if (noside == EVAL_AVOID_SIDE_EFFECTS) + return value_zero (value_type (arg1), not_lval); + else + { + binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); + return value_binop (arg1, arg2, + op == OP_ATR_MIN ? BINOP_MIN : BINOP_MAX); + } +} + /* Implement the evaluate_exp routine in the exp_descriptor structure for the Ada language. */ @@ -10861,14 +10879,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, arg2 = evaluate_subexp (nullptr, exp, pos, noside); if (noside == EVAL_SKIP) goto nosideret; - else if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (value_type (arg1), not_lval); - else - { - binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); - return value_binop (arg1, arg2, - op == OP_ATR_MIN ? BINOP_MIN : BINOP_MAX); - } + return ada_binop_minmax (expect_type, exp, noside, op, arg1, arg2); case OP_ATR_MODULUS: { |