1*6881a400Schristos /* Definitions for Modula-2 expressions 2*6881a400Schristos 3*6881a400Schristos Copyright (C) 2020-2023 Free Software Foundation, Inc. 4*6881a400Schristos 5*6881a400Schristos This file is part of GDB. 6*6881a400Schristos 7*6881a400Schristos This program is free software; you can redistribute it and/or modify 8*6881a400Schristos it under the terms of the GNU General Public License as published by 9*6881a400Schristos the Free Software Foundation; either version 3 of the License, or 10*6881a400Schristos (at your option) any later version. 11*6881a400Schristos 12*6881a400Schristos This program is distributed in the hope that it will be useful, 13*6881a400Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 14*6881a400Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*6881a400Schristos GNU General Public License for more details. 16*6881a400Schristos 17*6881a400Schristos You should have received a copy of the GNU General Public License 18*6881a400Schristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19*6881a400Schristos 20*6881a400Schristos #ifndef M2_EXP_H 21*6881a400Schristos #define M2_EXP_H 22*6881a400Schristos 23*6881a400Schristos #include "expop.h" 24*6881a400Schristos 25*6881a400Schristos extern struct value *eval_op_m2_high (struct type *expect_type, 26*6881a400Schristos struct expression *exp, 27*6881a400Schristos enum noside noside, 28*6881a400Schristos struct value *arg1); 29*6881a400Schristos extern struct value *eval_op_m2_subscript (struct type *expect_type, 30*6881a400Schristos struct expression *exp, 31*6881a400Schristos enum noside noside, 32*6881a400Schristos struct value *arg1, 33*6881a400Schristos struct value *arg2); 34*6881a400Schristos 35*6881a400Schristos namespace expr 36*6881a400Schristos { 37*6881a400Schristos 38*6881a400Schristos /* The Modula-2 "HIGH" operation. */ 39*6881a400Schristos class m2_unop_high_operation 40*6881a400Schristos : public tuple_holding_operation<operation_up> 41*6881a400Schristos { 42*6881a400Schristos public: 43*6881a400Schristos 44*6881a400Schristos using tuple_holding_operation::tuple_holding_operation; 45*6881a400Schristos 46*6881a400Schristos value *evaluate (struct type *expect_type, 47*6881a400Schristos struct expression *exp, 48*6881a400Schristos enum noside noside) override 49*6881a400Schristos { 50*6881a400Schristos value *arg1 = std::get<0> (m_storage)->evaluate_with_coercion (exp, 51*6881a400Schristos noside); 52*6881a400Schristos return eval_op_m2_high (expect_type, exp, noside, arg1); 53*6881a400Schristos } 54*6881a400Schristos 55*6881a400Schristos enum exp_opcode opcode () const override 56*6881a400Schristos { return UNOP_HIGH; } 57*6881a400Schristos }; 58*6881a400Schristos 59*6881a400Schristos /* Subscripting for Modula-2. */ 60*6881a400Schristos class m2_binop_subscript_operation 61*6881a400Schristos : public tuple_holding_operation<operation_up, operation_up> 62*6881a400Schristos { 63*6881a400Schristos public: 64*6881a400Schristos 65*6881a400Schristos using tuple_holding_operation::tuple_holding_operation; 66*6881a400Schristos 67*6881a400Schristos value *evaluate (struct type *expect_type, 68*6881a400Schristos struct expression *exp, 69*6881a400Schristos enum noside noside) override 70*6881a400Schristos { 71*6881a400Schristos value *arg1 = std::get<0> (m_storage)->evaluate_with_coercion (exp, 72*6881a400Schristos noside); 73*6881a400Schristos value *arg2 = std::get<1> (m_storage)->evaluate_with_coercion (exp, 74*6881a400Schristos noside); 75*6881a400Schristos return eval_op_m2_subscript (expect_type, exp, noside, arg1, arg2); 76*6881a400Schristos } 77*6881a400Schristos 78*6881a400Schristos enum exp_opcode opcode () const override 79*6881a400Schristos { return BINOP_SUBSCRIPT; } 80*6881a400Schristos }; 81*6881a400Schristos 82*6881a400Schristos } /* namespace expr */ 83*6881a400Schristos 84*6881a400Schristos #endif /* M2_EXP_H */ 85