Implement some Ada unary operations
[deliverable/binutils-gdb.git] / gdb / ada-exp.h
1 /* Definitions for Ada expressions
2
3 Copyright (C) 2020 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #ifndef ADA_EXP_H
21 #define ADA_EXP_H
22
23 #include "expop.h"
24
25 extern struct value *ada_unop_neg (struct type *expect_type,
26 struct expression *exp,
27 enum noside noside, enum exp_opcode op,
28 struct value *arg1);
29 extern struct value *ada_atr_tag (struct type *expect_type,
30 struct expression *exp,
31 enum noside noside, enum exp_opcode op,
32 struct value *arg1);
33 extern struct value *ada_atr_size (struct type *expect_type,
34 struct expression *exp,
35 enum noside noside, enum exp_opcode op,
36 struct value *arg1);
37 extern struct value *ada_abs (struct type *expect_type,
38 struct expression *exp,
39 enum noside noside, enum exp_opcode op,
40 struct value *arg1);
41
42 namespace expr
43 {
44
45 /* In Ada, some generic operations must be wrapped with a handler that
46 handles some Ada-specific type conversions. */
47 class ada_wrapped_operation
48 : public tuple_holding_operation<operation_up>
49 {
50 public:
51
52 using tuple_holding_operation::tuple_holding_operation;
53
54 value *evaluate (struct type *expect_type,
55 struct expression *exp,
56 enum noside noside) override;
57
58 enum exp_opcode opcode () const override
59 { return std::get<0> (m_storage)->opcode (); }
60 };
61
62 /* An Ada string constant. */
63 class ada_string_operation
64 : public string_operation
65 {
66 public:
67
68 using string_operation::string_operation;
69
70 value *evaluate (struct type *expect_type,
71 struct expression *exp,
72 enum noside noside) override;
73 };
74
75 /* The Ada TYPE'(EXP) construct. */
76 class ada_qual_operation
77 : public tuple_holding_operation<operation_up, struct type *>
78 {
79 public:
80
81 using tuple_holding_operation::tuple_holding_operation;
82
83 value *evaluate (struct type *expect_type,
84 struct expression *exp,
85 enum noside noside) override;
86
87 enum exp_opcode opcode () const override
88 { return UNOP_QUAL; }
89 };
90
91 /* Ternary in-range operator. */
92 class ada_ternop_range_operation
93 : public tuple_holding_operation<operation_up, operation_up, operation_up>
94 {
95 public:
96
97 using tuple_holding_operation::tuple_holding_operation;
98
99 value *evaluate (struct type *expect_type,
100 struct expression *exp,
101 enum noside noside) override;
102
103 enum exp_opcode opcode () const override
104 { return TERNOP_IN_RANGE; }
105 };
106
107 using ada_neg_operation = unop_operation<UNOP_NEG, ada_unop_neg>;
108 using ada_atr_tag_operation = unop_operation<OP_ATR_TAG, ada_atr_tag>;
109 using ada_atr_size_operation = unop_operation<OP_ATR_SIZE, ada_atr_size>;
110 using ada_abs_operation = unop_operation<UNOP_ABS, ada_abs>;
111
112 } /* namespace expr */
113
114 #endif /* ADA_EXP_H */
This page took 0.032305 seconds and 5 git commands to generate.