]> Git Repo - binutils.git/blob - gdb/m2-exp.h
Automatic date update in version.in
[binutils.git] / gdb / m2-exp.h
1 /* Definitions for Modula-2 expressions
2
3    Copyright (C) 2020-2022 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 M2_EXP_H
21 #define M2_EXP_H
22
23 #include "expop.h"
24
25 extern struct value *eval_op_m2_high (struct type *expect_type,
26                                       struct expression *exp,
27                                       enum noside noside,
28                                       struct value *arg1);
29 extern struct value *eval_op_m2_subscript (struct type *expect_type,
30                                            struct expression *exp,
31                                            enum noside noside,
32                                            struct value *arg1,
33                                            struct value *arg2);
34
35 namespace expr
36 {
37
38 /* The Modula-2 "HIGH" operation.  */
39 class m2_unop_high_operation
40   : public tuple_holding_operation<operation_up>
41 {
42 public:
43
44   using tuple_holding_operation::tuple_holding_operation;
45
46   value *evaluate (struct type *expect_type,
47                    struct expression *exp,
48                    enum noside noside) override
49   {
50     value *arg1 = std::get<0> (m_storage)->evaluate_with_coercion (exp,
51                                                                    noside);
52     return eval_op_m2_high (expect_type, exp, noside, arg1);
53   }
54
55   enum exp_opcode opcode () const override
56   { return UNOP_HIGH; }
57 };
58
59 /* Subscripting for Modula-2.  */
60 class m2_binop_subscript_operation
61   : public tuple_holding_operation<operation_up, operation_up>
62 {
63 public:
64
65   using tuple_holding_operation::tuple_holding_operation;
66
67   value *evaluate (struct type *expect_type,
68                    struct expression *exp,
69                    enum noside noside) override
70   {
71     value *arg1 = std::get<0> (m_storage)->evaluate_with_coercion (exp,
72                                                                    noside);
73     value *arg2 = std::get<1> (m_storage)->evaluate_with_coercion (exp,
74                                                                    noside);
75     return eval_op_m2_subscript (expect_type, exp, noside, arg1, arg2);
76   }
77
78   enum exp_opcode opcode () const override
79   { return BINOP_SUBSCRIPT; }
80 };
81
82 } /* namespace expr */
83
84 #endif /* M2_EXP_H */
This page took 0.028461 seconds and 4 git commands to generate.