From: Tom Tromey Date: Mon, 8 Mar 2021 14:27:57 +0000 (-0700) Subject: Introduce ada_unop_range_operation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=95d49dfbba00253382d0f7ad0ea2052b2b7bc445;p=binutils-gdb.git Introduce ada_unop_range_operation This adds class ada_unop_range_operation, which implements UNOP_IN_RANGE. gdb/ChangeLog 2021-03-08 Tom Tromey * ada-lang.c (ada_unop_in_range): No longer static. * ada-exp.h (class ada_unop_range_operation): New. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 08a962775ba..1969ec57004 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * ada-lang.c (ada_unop_in_range): No longer static. + * ada-exp.h (class ada_unop_range_operation): New. + 2021-03-08 Tom Tromey * ada-lang.c (ada_unop_neg, ada_atr_tag, ada_atr_size, ada_abs): diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h index 8f114b3a145..de69210bd2a 100644 --- a/gdb/ada-exp.h +++ b/gdb/ada-exp.h @@ -38,6 +38,10 @@ extern struct value *ada_abs (struct type *expect_type, struct expression *exp, enum noside noside, enum exp_opcode op, struct value *arg1); +extern struct value *ada_unop_in_range (struct type *expect_type, + struct expression *exp, + enum noside noside, enum exp_opcode op, + struct value *arg1, struct type *type); namespace expr { @@ -109,6 +113,27 @@ using ada_atr_tag_operation = unop_operation; using ada_atr_size_operation = unop_operation; using ada_abs_operation = unop_operation; +/* The in-range operation, given a type. */ +class ada_unop_range_operation + : public tuple_holding_operation +{ +public: + + using tuple_holding_operation::tuple_holding_operation; + + value *evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) override + { + value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); + return ada_unop_in_range (expect_type, exp, noside, UNOP_IN_RANGE, + val, std::get<1> (m_storage)); + } + + enum exp_opcode opcode () const override + { return UNOP_IN_RANGE; } +}; + } /* namespace expr */ #endif /* ADA_EXP_H */ diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index ed691f56584..0b4ef8b13b0 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -9978,7 +9978,7 @@ ada_unop_neg (struct type *expect_type, /* A helper function for UNOP_IN_RANGE. */ -static value * +value * ada_unop_in_range (struct type *expect_type, struct expression *exp, enum noside noside, enum exp_opcode op,