[PATCH 138/203] Implement some Ada unary operations

Tom Tromey
2021-01-01T21:49:08Z

This implements a few Ada unary operations, using the existing
unop_operation template class.

gdb/ChangeLog
2021-01-01 Tom Tromey <tom@tromey.com>

* ada-lang.c (ada_unop_neg, ada_atr_tag, ada_atr_size, ada_abs):
No longer static.
* ada-exp.h (ada_neg_operation, ada_atr_tag_operation)
(ada_atr_size_operation, ada_abs_operation): New typedefs.
---
gdb/ChangeLog | 7 +++++++
gdb/ada-exp.h | 22 ++++++++++++++++++++++
gdb/ada-lang.c | 8 ++++----
3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 17a04ea15c6..8f114b3a145 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -22,6 +22,23 @@

#include "expop.h"

+extern struct value *ada_unop_neg (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1);
+extern struct value *ada_atr_tag (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1);
+extern struct value *ada_atr_size (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1);
+extern struct value *ada_abs (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1);
+
namespace expr
{

@@ -87,6 +104,11 @@ class ada_ternop_range_operation
{ return TERNOP_IN_RANGE; }
};

+using ada_neg_operation = unop_operation<UNOP_NEG, ada_unop_neg>;
+using ada_atr_tag_operation = unop_operation<OP_ATR_TAG, ada_atr_tag>;
+using ada_atr_size_operation = unop_operation<OP_ATR_SIZE, ada_atr_size>;
+using ada_abs_operation = unop_operation<UNOP_ABS, ada_abs>;
+
} /* namespace expr */

#endif /* ADA_EXP_H */
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 90592d5f2b9..32a64916d0e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10110,7 +10110,7 @@ eval_ternop_in_range (struct type *expect_type, struct expression *exp,

/* A helper function for UNOP_NEG. */

-static value *
+value *
ada_unop_neg (struct type *expect_type,
struct expression *exp,
enum noside noside, enum exp_opcode op,
@@ -10166,7 +10166,7 @@ ada_unop_in_range (struct type *expect_type,

/* A helper function for OP_ATR_TAG. */

-static value *
+value *
ada_atr_tag (struct type *expect_type,
struct expression *exp,
enum noside noside, enum exp_opcode op,
@@ -10180,7 +10180,7 @@ ada_atr_tag (struct type *expect_type,

/* A helper function for OP_ATR_SIZE. */

-static value *
+value *
ada_atr_size (struct type *expect_type,
struct expression *exp,
enum noside noside, enum exp_opcode op,
@@ -10205,7 +10205,7 @@ ada_atr_size (struct type *expect_type,

/* A helper function for UNOP_ABS. */

-static value *
+value *
ada_abs (struct type *expect_type,
struct expression *exp,
enum noside noside, enum exp_opcode op,
--
2.26.2