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:11 -0700 |
commit | d05e24e61a7dc22076568a59b3d4bbbd63ca764c (patch) | |
tree | e7a93c232f07d09a7ffca38fef5f1915f475fafe /gdb | |
parent | 68c757358fc3d41ec26b2159cdbcac4f757dc3a2 (diff) | |
download | gdb-d05e24e61a7dc22076568a59b3d4bbbd63ca764c.zip gdb-d05e24e61a7dc22076568a59b3d4bbbd63ca764c.tar.gz gdb-d05e24e61a7dc22076568a59b3d4bbbd63ca764c.tar.bz2 |
Split out ada_abs
This splits UNOP_ABS into a new function for future use.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* ada-lang.c (ada_abs): New function.
(ada_evaluate_subexp): Use it.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/ada-lang.c | 21 |
2 files changed, 21 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2a20313..7fb5e9b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2021-03-08 Tom Tromey <tom@tromey.com> + * ada-lang.c (ada_abs): New function. + (ada_evaluate_subexp): Use it. + +2021-03-08 Tom Tromey <tom@tromey.com> + * ada-lang.c (ada_atr_size): New function. (ada_evaluate_subexp): Use it. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index cfd85d3..cf84cf0 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10050,6 +10050,21 @@ ada_atr_size (struct type *expect_type, TARGET_CHAR_BIT * TYPE_LENGTH (type)); } +/* A helper function for UNOP_ABS. */ + +static value * +ada_abs (struct type *expect_type, + struct expression *exp, + enum noside noside, enum exp_opcode op, + struct value *arg1) +{ + unop_promote (exp->language_defn, exp->gdbarch, &arg1); + if (value_less (arg1, value_zero (value_type (arg1), not_lval))) + return value_neg (arg1); + else + return arg1; +} + /* Implement the evaluate_exp routine in the exp_descriptor structure for the Ada language. */ @@ -10870,11 +10885,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, arg1 = evaluate_subexp (nullptr, exp, pos, noside); if (noside == EVAL_SKIP) goto nosideret; - unop_promote (exp->language_defn, exp->gdbarch, &arg1); - if (value_less (arg1, value_zero (value_type (arg1), not_lval))) - return value_neg (arg1); - else - return arg1; + return ada_abs (expect_type, exp, noside, op, arg1); case UNOP_IND: preeval_pos = *pos; |