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:10 -0700 |
commit | 62d4bd947e056a28c2b5086fa82a84b0721b3c97 (patch) | |
tree | 1c7a39d10d6d54b9e1ee371f96cbf1e802508ab0 /gdb | |
parent | 3634f66996bef21692e4343d5271c4c7e5fe5f52 (diff) | |
download | gdb-62d4bd947e056a28c2b5086fa82a84b0721b3c97.zip gdb-62d4bd947e056a28c2b5086fa82a84b0721b3c97.tar.gz gdb-62d4bd947e056a28c2b5086fa82a84b0721b3c97.tar.bz2 |
Split out eval_ternop_in_range
This splits TERNOP_IN_RANGE into a new function for future use.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* ada-lang.c (eval_ternop_in_range): New function.
(ada_evaluate_subexp): Use it.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/ada-lang.c | 34 |
2 files changed, 27 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e2a8d6b..6eddb9f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2021-03-08 Tom Tromey <tom@tromey.com> + * ada-lang.c (eval_ternop_in_range): New function. + (ada_evaluate_subexp): Use it. + +2021-03-08 Tom Tromey <tom@tromey.com> + * opencl-lang.c (eval_opencl_assign): New function. (evaluate_subexp_opencl): Use it. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 8f27f3c..b311609 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -9939,6 +9939,27 @@ ada_evaluate_subexp_for_cast (expression *exp, int *pos, return ada_value_cast (to_type, val); } +/* A helper function for TERNOP_IN_RANGE. */ + +static value * +eval_ternop_in_range (struct type *expect_type, struct expression *exp, + enum noside noside, + value *arg1, value *arg2, value *arg3) +{ + if (noside == EVAL_SKIP) + return eval_skip_value (exp); + + binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); + binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3); + struct type *type = language_bool_type (exp->language_defn, exp->gdbarch); + return + value_from_longest (type, + (value_less (arg1, arg3) + || value_equal (arg1, arg3)) + && (value_less (arg2, arg1) + || value_equal (arg2, arg1))); +} + /* Implement the evaluate_exp routine in the exp_descriptor structure for the Ada language. */ @@ -10551,18 +10572,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, arg2 = evaluate_subexp (nullptr, exp, pos, noside); arg3 = evaluate_subexp (nullptr, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - - binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); - binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3); - type = language_bool_type (exp->language_defn, exp->gdbarch); - return - value_from_longest (type, - (value_less (arg1, arg3) - || value_equal (arg1, arg3)) - && (value_less (arg2, arg1) - || value_equal (arg2, arg1))); + return eval_ternop_in_range (expect_type, exp, noside, arg1, arg2, arg3); case OP_ATR_FIRST: case OP_ATR_LAST: |