Split out some Ada type resolution code
[deliverable/binutils-gdb.git] / gdb / ada-exp.h
CommitLineData
03070ee9
TT
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
7c15d377
TT
25extern 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);
29extern 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);
33extern 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);
37extern struct value *ada_abs (struct type *expect_type,
38 struct expression *exp,
39 enum noside noside, enum exp_opcode op,
40 struct value *arg1);
95d49dfb
TT
41extern struct value *ada_unop_in_range (struct type *expect_type,
42 struct expression *exp,
43 enum noside noside, enum exp_opcode op,
44 struct value *arg1, struct type *type);
7c15d377 45
03070ee9
TT
46namespace expr
47{
48
49/* In Ada, some generic operations must be wrapped with a handler that
50 handles some Ada-specific type conversions. */
51class ada_wrapped_operation
52 : public tuple_holding_operation<operation_up>
53{
54public:
55
56 using tuple_holding_operation::tuple_holding_operation;
57
58 value *evaluate (struct type *expect_type,
59 struct expression *exp,
60 enum noside noside) override;
61
62 enum exp_opcode opcode () const override
63 { return std::get<0> (m_storage)->opcode (); }
64};
65
42fecb61
TT
66/* An Ada string constant. */
67class ada_string_operation
68 : public string_operation
69{
70public:
71
72 using string_operation::string_operation;
73
74 value *evaluate (struct type *expect_type,
75 struct expression *exp,
76 enum noside noside) override;
77};
78
cc6bd32e
TT
79/* The Ada TYPE'(EXP) construct. */
80class ada_qual_operation
81 : public tuple_holding_operation<operation_up, struct type *>
82{
83public:
84
85 using tuple_holding_operation::tuple_holding_operation;
86
87 value *evaluate (struct type *expect_type,
88 struct expression *exp,
89 enum noside noside) override;
90
91 enum exp_opcode opcode () const override
92 { return UNOP_QUAL; }
93};
94
fc715eb2
TT
95/* Ternary in-range operator. */
96class ada_ternop_range_operation
97 : public tuple_holding_operation<operation_up, operation_up, operation_up>
98{
99public:
100
101 using tuple_holding_operation::tuple_holding_operation;
102
103 value *evaluate (struct type *expect_type,
104 struct expression *exp,
105 enum noside noside) override;
106
107 enum exp_opcode opcode () const override
108 { return TERNOP_IN_RANGE; }
109};
110
7c15d377
TT
111using ada_neg_operation = unop_operation<UNOP_NEG, ada_unop_neg>;
112using ada_atr_tag_operation = unop_operation<OP_ATR_TAG, ada_atr_tag>;
113using ada_atr_size_operation = unop_operation<OP_ATR_SIZE, ada_atr_size>;
114using ada_abs_operation = unop_operation<UNOP_ABS, ada_abs>;
115
95d49dfb
TT
116/* The in-range operation, given a type. */
117class ada_unop_range_operation
118 : public tuple_holding_operation<operation_up, struct type *>
119{
120public:
121
122 using tuple_holding_operation::tuple_holding_operation;
123
124 value *evaluate (struct type *expect_type,
125 struct expression *exp,
126 enum noside noside) override
127 {
128 value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
129 return ada_unop_in_range (expect_type, exp, noside, UNOP_IN_RANGE,
130 val, std::get<1> (m_storage));
131 }
132
133 enum exp_opcode opcode () const override
134 { return UNOP_IN_RANGE; }
135};
136
03070ee9
TT
137} /* namespace expr */
138
139#endif /* ADA_EXP_H */
This page took 0.035561 seconds and 4 git commands to generate.