Commit | Line | Data |
---|---|---|
72d0a711 TT |
1 | /* Definitions for C 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 C_EXP_H | |
21 | #define C_EXP_H | |
22 | ||
23 | #include "expop.h" | |
06dc61b9 | 24 | #include "objc-lang.h" |
72d0a711 | 25 | |
09db3700 TT |
26 | extern struct value *eval_op_objc_selector (struct type *expect_type, |
27 | struct expression *exp, | |
28 | enum noside noside, | |
29 | const char *sel); | |
72d0a711 TT |
30 | namespace expr |
31 | { | |
32 | ||
33 | class c_string_operation | |
34 | : public tuple_holding_operation<enum c_string_type_values, | |
35 | std::vector<std::string>> | |
36 | { | |
37 | public: | |
38 | ||
39 | using tuple_holding_operation::tuple_holding_operation; | |
40 | ||
41 | value *evaluate (struct type *expect_type, | |
42 | struct expression *exp, | |
43 | enum noside noside) override; | |
44 | ||
45 | enum exp_opcode opcode () const override | |
46 | { return OP_STRING; } | |
47 | }; | |
48 | ||
06dc61b9 TT |
49 | class objc_nsstring_operation |
50 | : public tuple_holding_operation<std::string> | |
51 | { | |
52 | public: | |
53 | ||
54 | using tuple_holding_operation::tuple_holding_operation; | |
55 | ||
56 | value *evaluate (struct type *expect_type, | |
57 | struct expression *exp, | |
58 | enum noside noside) override | |
59 | { | |
60 | if (noside == EVAL_SKIP) | |
61 | return eval_skip_value (exp); | |
62 | const std::string &str = std::get<0> (m_storage); | |
63 | return value_nsstring (exp->gdbarch, str.c_str (), str.size () + 1); | |
64 | } | |
65 | ||
66 | enum exp_opcode opcode () const override | |
67 | { return OP_OBJC_NSSTRING; } | |
68 | }; | |
69 | ||
09db3700 TT |
70 | class objc_selector_operation |
71 | : public tuple_holding_operation<std::string> | |
72 | { | |
73 | public: | |
74 | ||
75 | using tuple_holding_operation::tuple_holding_operation; | |
76 | ||
77 | value *evaluate (struct type *expect_type, | |
78 | struct expression *exp, | |
79 | enum noside noside) override | |
80 | { | |
81 | if (noside == EVAL_SKIP) | |
82 | return eval_skip_value (exp); | |
83 | return eval_op_objc_selector (expect_type, exp, noside, | |
84 | std::get<0> (m_storage).c_str ()); | |
85 | } | |
86 | ||
87 | enum exp_opcode opcode () const override | |
88 | { return OP_OBJC_SELECTOR; } | |
89 | }; | |
90 | ||
085734dd TT |
91 | /* An Objective C message call. */ |
92 | class objc_msgcall_operation | |
93 | : public tuple_holding_operation<CORE_ADDR, operation_up, | |
94 | std::vector<operation_up>> | |
95 | { | |
96 | public: | |
97 | ||
98 | using tuple_holding_operation::tuple_holding_operation; | |
99 | ||
100 | value *evaluate (struct type *expect_type, | |
101 | struct expression *exp, | |
102 | enum noside noside) override; | |
103 | ||
104 | enum exp_opcode opcode () const override | |
105 | { return OP_OBJC_MSGCALL; } | |
106 | }; | |
107 | ||
72d0a711 TT |
108 | }/* namespace expr */ |
109 | ||
110 | #endif /* C_EXP_H */ |