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:25 -0700 |
commit | 03070ee9c77877655051c073cf060585f7cb2ff2 (patch) | |
tree | bc8dfd2a72ea6b5324ac40ca94a460d93bdfd573 /gdb/ada-lang.c | |
parent | 821e72d77536b201b3e6b801d8f0d9c5b624ec96 (diff) | |
download | binutils-03070ee9c77877655051c073cf060585f7cb2ff2.zip binutils-03070ee9c77877655051c073cf060585f7cb2ff2.tar.gz binutils-03070ee9c77877655051c073cf060585f7cb2ff2.tar.bz2 |
Introduce ada_wrapped_operation
This adds class ada_wrapped_operation, which is used to wrap some
generic operations with a bit of Ada-specific handling. This
corresponds to the old "default" case in ada_evaluate_subexp.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* ada-lang.c (ada_wrapped_operation::evaluate): New method.
* ada-exp.h: New file.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index be1827c..4db5823 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -57,6 +57,7 @@ #include "gdbsupport/function-view.h" #include "gdbsupport/byte-vector.h" #include <algorithm> +#include "ada-exp.h" /* Define whether or not the C operator '/' truncates towards zero for differently signed operands (truncation direction is undefined in C). @@ -10387,6 +10388,34 @@ ada_binop_exp (struct type *expect_type, } } +namespace expr +{ + +value * +ada_wrapped_operation::evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) +{ + value *result = std::get<0> (m_storage)->evaluate (expect_type, exp, noside); + if (noside == EVAL_NORMAL) + result = unwrap_value (result); + + /* If evaluating an OP_FLOAT and an EXPECT_TYPE was provided, + then we need to perform the conversion manually, because + evaluate_subexp_standard doesn't do it. This conversion is + necessary in Ada because the different kinds of float/fixed + types in Ada have different representations. + + Similarly, we need to perform the conversion from OP_LONG + ourselves. */ + if ((opcode () == OP_FLOAT || opcode () == OP_LONG) && expect_type != NULL) + result = ada_value_cast (expect_type, result); + + return result; +} + +} + /* Implement the evaluate_exp routine in the exp_descriptor structure for the Ada language. */ |