Introduce typeid_operation
[deliverable/binutils-gdb.git] / gdb / c-exp.h
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"
24 #include "objc-lang.h"
25
26 extern struct value *eval_op_objc_selector (struct type *expect_type,
27 struct expression *exp,
28 enum noside noside,
29 const char *sel);
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
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
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
91 }/* namespace expr */
92
93 #endif /* C_EXP_H */
This page took 0.031548 seconds and 4 git commands to generate.