1 /* Definitions for expressions in GDB
3 Copyright (C) 2020 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
26 #include "expression.h"
28 #include "gdbsupport/traits.h"
29 #include "gdbsupport/enum-flags.h"
34 extern void gen_expr_binop (struct expression
*exp
,
36 expr::operation
*lhs
, expr::operation
*rhs
,
37 struct agent_expr
*ax
, struct axs_value
*value
);
38 extern void gen_expr_structop (struct expression
*exp
,
42 struct agent_expr
*ax
, struct axs_value
*value
);
43 extern void gen_expr_unop (struct expression
*exp
,
46 struct agent_expr
*ax
, struct axs_value
*value
);
48 extern struct value
*eval_op_scope (struct type
*expect_type
,
49 struct expression
*exp
,
51 struct type
*type
, const char *string
);
52 extern struct value
*eval_op_var_msym_value (struct type
*expect_type
,
53 struct expression
*exp
,
56 minimal_symbol
*msymbol
,
57 struct objfile
*objfile
);
58 extern struct value
*eval_op_var_entry_value (struct type
*expect_type
,
59 struct expression
*exp
,
60 enum noside noside
, symbol
*sym
);
61 extern struct value
*eval_op_func_static_var (struct type
*expect_type
,
62 struct expression
*exp
,
64 value
*func
, const char *var
);
65 extern struct value
*eval_op_register (struct type
*expect_type
,
66 struct expression
*exp
,
67 enum noside noside
, const char *name
);
68 extern struct value
*eval_op_string (struct type
*expect_type
,
69 struct expression
*exp
,
70 enum noside noside
, int len
,
72 extern struct value
*eval_op_ternop (struct type
*expect_type
,
73 struct expression
*exp
,
75 struct value
*array
, struct value
*low
,
77 extern struct value
*eval_op_structop_struct (struct type
*expect_type
,
78 struct expression
*exp
,
82 extern struct value
*eval_op_structop_ptr (struct type
*expect_type
,
83 struct expression
*exp
,
87 extern struct value
*eval_op_member (struct type
*expect_type
,
88 struct expression
*exp
,
90 struct value
*arg1
, struct value
*arg2
);
91 extern struct value
*eval_op_concat (struct type
*expect_type
,
92 struct expression
*exp
,
94 struct value
*arg1
, struct value
*arg2
);
95 extern struct value
*eval_op_add (struct type
*expect_type
,
96 struct expression
*exp
,
98 struct value
*arg1
, struct value
*arg2
);
99 extern struct value
*eval_op_sub (struct type
*expect_type
,
100 struct expression
*exp
,
102 struct value
*arg1
, struct value
*arg2
);
103 extern struct value
*eval_op_binary (struct type
*expect_type
,
104 struct expression
*exp
,
105 enum noside noside
, enum exp_opcode op
,
106 struct value
*arg1
, struct value
*arg2
);
107 extern struct value
*eval_op_subscript (struct type
*expect_type
,
108 struct expression
*exp
,
109 enum noside noside
, enum exp_opcode op
,
112 extern struct value
*eval_op_equal (struct type
*expect_type
,
113 struct expression
*exp
,
114 enum noside noside
, enum exp_opcode op
,
117 extern struct value
*eval_op_notequal (struct type
*expect_type
,
118 struct expression
*exp
,
119 enum noside noside
, enum exp_opcode op
,
122 extern struct value
*eval_op_less (struct type
*expect_type
,
123 struct expression
*exp
,
124 enum noside noside
, enum exp_opcode op
,
127 extern struct value
*eval_op_gtr (struct type
*expect_type
,
128 struct expression
*exp
,
129 enum noside noside
, enum exp_opcode op
,
132 extern struct value
*eval_op_geq (struct type
*expect_type
,
133 struct expression
*exp
,
134 enum noside noside
, enum exp_opcode op
,
137 extern struct value
*eval_op_leq (struct type
*expect_type
,
138 struct expression
*exp
,
139 enum noside noside
, enum exp_opcode op
,
142 extern struct value
*eval_op_repeat (struct type
*expect_type
,
143 struct expression
*exp
,
144 enum noside noside
, enum exp_opcode op
,
147 extern struct value
*eval_op_plus (struct type
*expect_type
,
148 struct expression
*exp
,
149 enum noside noside
, enum exp_opcode op
,
151 extern struct value
*eval_op_neg (struct type
*expect_type
,
152 struct expression
*exp
,
153 enum noside noside
, enum exp_opcode op
,
155 extern struct value
*eval_op_complement (struct type
*expect_type
,
156 struct expression
*exp
,
160 extern struct value
*eval_op_lognot (struct type
*expect_type
,
161 struct expression
*exp
,
165 extern struct value
*eval_op_preinc (struct type
*expect_type
,
166 struct expression
*exp
,
170 extern struct value
*eval_op_predec (struct type
*expect_type
,
171 struct expression
*exp
,
175 extern struct value
*eval_op_postinc (struct type
*expect_type
,
176 struct expression
*exp
,
180 extern struct value
*eval_op_postdec (struct type
*expect_type
,
181 struct expression
*exp
,
185 extern struct value
*eval_op_ind (struct type
*expect_type
,
186 struct expression
*exp
,
189 extern struct value
*eval_op_type (struct type
*expect_type
,
190 struct expression
*exp
,
191 enum noside noside
, struct type
*type
);
192 extern struct value
*eval_op_alignof (struct type
*expect_type
,
193 struct expression
*exp
,
196 extern struct value
*eval_op_memval (struct type
*expect_type
,
197 struct expression
*exp
,
199 struct value
*arg1
, struct type
*type
);
200 extern struct value
*eval_binop_assign_modify (struct type
*expect_type
,
201 struct expression
*exp
,
210 /* The check_objfile overloads are used to check whether a particular
211 component of some operation references an objfile. The passed-in
212 objfile will never be a debug objfile. */
214 /* See if EXP_OBJFILE matches OBJFILE. */
216 check_objfile (struct objfile
*exp_objfile
, struct objfile
*objfile
)
218 if (exp_objfile
->separate_debug_objfile_backlink
)
219 exp_objfile
= exp_objfile
->separate_debug_objfile_backlink
;
220 return exp_objfile
== objfile
;
224 check_objfile (struct type
*type
, struct objfile
*objfile
)
226 struct objfile
*ty_objfile
= type
->objfile_owner ();
227 if (ty_objfile
!= nullptr)
228 return check_objfile (ty_objfile
, objfile
);
233 check_objfile (struct symbol
*sym
, struct objfile
*objfile
)
235 return check_objfile (symbol_objfile (sym
), objfile
);
239 check_objfile (const struct block
*block
, struct objfile
*objfile
)
241 return check_objfile (block_objfile (block
), objfile
);
245 check_objfile (minimal_symbol
*minsym
, struct objfile
*objfile
)
247 /* This may seem strange but minsyms are only used with an objfile
253 check_objfile (internalvar
*ivar
, struct objfile
*objfile
)
259 check_objfile (const std::string
&str
, struct objfile
*objfile
)
265 check_objfile (const operation_up
&op
, struct objfile
*objfile
)
267 return op
->uses_objfile (objfile
);
271 check_objfile (enum exp_opcode val
, struct objfile
*objfile
)
277 check_objfile (ULONGEST val
, struct objfile
*objfile
)
284 check_objfile (enum_flags
<T
> val
, struct objfile
*objfile
)
291 check_objfile (const std::vector
<T
> &collection
, struct objfile
*objfile
)
293 for (const auto &item
: collection
)
295 if (check_objfile (item
, objfile
))
301 template<typename S
, typename T
>
303 check_objfile (const std::pair
<S
, T
> &item
, struct objfile
*objfile
)
305 return (check_objfile (item
.first
, objfile
)
306 || check_objfile (item
.second
, objfile
));
310 dump_for_expression (struct ui_file
*stream
, int depth
,
311 const operation_up
&op
)
313 op
->dump (stream
, depth
);
316 extern void dump_for_expression (struct ui_file
*stream
, int depth
,
318 extern void dump_for_expression (struct ui_file
*stream
, int depth
,
319 const std::string
&str
);
320 extern void dump_for_expression (struct ui_file
*stream
, int depth
,
322 extern void dump_for_expression (struct ui_file
*stream
, int depth
,
324 extern void dump_for_expression (struct ui_file
*stream
, int depth
,
326 extern void dump_for_expression (struct ui_file
*stream
, int depth
,
328 extern void dump_for_expression (struct ui_file
*stream
, int depth
,
329 minimal_symbol
*msym
);
330 extern void dump_for_expression (struct ui_file
*stream
, int depth
,
332 extern void dump_for_expression (struct ui_file
*stream
, int depth
,
333 type_instance_flags flags
);
334 extern void dump_for_expression (struct ui_file
*stream
, int depth
,
335 enum c_string_type_values flags
);
336 extern void dump_for_expression (struct ui_file
*stream
, int depth
,
337 enum range_flag flags
);
338 extern void dump_for_expression (struct ui_file
*stream
, int depth
,
343 dump_for_expression (struct ui_file
*stream
, int depth
,
344 const std::vector
<T
> &vals
)
346 fprintf_filtered (stream
, _("%*sVector:\n"), depth
, "");
347 for (auto &item
: vals
)
348 dump_for_expression (stream
, depth
+ 1, item
);
351 template<typename X
, typename Y
>
353 dump_for_expression (struct ui_file
*stream
, int depth
,
354 const std::pair
<X
, Y
> &vals
)
356 dump_for_expression (stream
, depth
, vals
.first
);
357 dump_for_expression (stream
, depth
, vals
.second
);
360 /* Base class for most concrete operations. This class holds data,
361 specified via template parameters, and supplies generic
362 implementations of the 'dump' and 'uses_objfile' methods. */
363 template<typename
... Arg
>
364 class tuple_holding_operation
: public operation
368 explicit tuple_holding_operation (Arg
... args
)
369 : m_storage (std::forward
<Arg
> (args
)...)
373 DISABLE_COPY_AND_ASSIGN (tuple_holding_operation
);
375 bool uses_objfile (struct objfile
*objfile
) const override
377 return do_check_objfile
<0, Arg
...> (objfile
, m_storage
);
380 void dump (struct ui_file
*stream
, int depth
) const override
382 dump_for_expression (stream
, depth
, opcode ());
383 do_dump
<0, Arg
...> (stream
, depth
+ 1, m_storage
);
388 /* Storage for the data. */
389 std::tuple
<Arg
...> m_storage
;
393 /* do_dump does the work of dumping the data. */
394 template<int I
, typename
... T
>
395 typename
std::enable_if
<I
== sizeof... (T
), void>::type
396 do_dump (struct ui_file
*stream
, int depth
, const std::tuple
<T
...> &value
)
401 template<int I
, typename
... T
>
402 typename
std::enable_if
<I
< sizeof... (T
), void>::type
403 do_dump (struct ui_file
*stream
, int depth
, const std::tuple
<T
...> &value
)
406 dump_for_expression (stream
, depth
, std::get
<I
> (value
));
407 do_dump
<I
+ 1, T
...> (stream
, depth
, value
);
410 /* do_check_objfile does the work of checking whether this object
411 refers to OBJFILE. */
412 template<int I
, typename
... T
>
413 typename
std::enable_if
<I
== sizeof... (T
), bool>::type
414 do_check_objfile (struct objfile
*objfile
, const std::tuple
<T
...> &value
)
420 template<int I
, typename
... T
>
421 typename
std::enable_if
<I
< sizeof... (T
), bool>::type
422 do_check_objfile (struct objfile
*objfile
, const std::tuple
<T
...> &value
)
425 if (check_objfile (std::get
<I
> (value
), objfile
))
427 return do_check_objfile
<I
+ 1, T
...> (objfile
, value
);
431 /* The check_constant overloads are used to decide whether a given
432 concrete operation is a constant. This is done by checking the
436 check_constant (const operation_up
&item
)
438 return item
->constant_p ();
442 check_constant (struct minimal_symbol
*msym
)
448 check_constant (struct type
*type
)
454 check_constant (const struct block
*block
)
460 check_constant (const std::string
&str
)
466 check_constant (struct objfile
*objfile
)
472 check_constant (ULONGEST cst
)
478 check_constant (struct symbol
*sym
)
480 enum address_class sc
= SYMBOL_CLASS (sym
);
481 return (sc
== LOC_BLOCK
483 || sc
== LOC_CONST_BYTES
489 check_constant (const std::vector
<T
> &collection
)
491 for (const auto &item
: collection
)
492 if (!check_constant (item
))
497 template<typename S
, typename T
>
499 check_constant (const std::pair
<S
, T
> &item
)
501 return check_constant (item
.first
) && check_constant (item
.second
);
504 /* Base class for concrete operations. This class supplies an
505 implementation of 'constant_p' that works by checking the
507 template<typename
... Arg
>
508 class maybe_constant_operation
509 : public tuple_holding_operation
<Arg
...>
513 using tuple_holding_operation
<Arg
...>::tuple_holding_operation
;
515 bool constant_p () const override
517 return do_check_constant
<0, Arg
...> (this->m_storage
);
522 template<int I
, typename
... T
>
523 typename
std::enable_if
<I
== sizeof... (T
), bool>::type
524 do_check_constant (const std::tuple
<T
...> &value
) const
529 template<int I
, typename
... T
>
530 typename
std::enable_if
<I
< sizeof... (T
), bool>::type
531 do_check_constant (const std::tuple
<T
...> &value
) const
533 if (!check_constant (std::get
<I
> (value
)))
535 return do_check_constant
<I
+ 1, T
...> (value
);
539 /* A floating-point constant. The constant is encoded in the target
542 typedef std::array
<gdb_byte
, 16> float_data
;
544 /* An operation that holds a floating-point constant of a given
547 This does not need the facilities provided by
548 tuple_holding_operation, so it does not use it. */
549 class float_const_operation
554 float_const_operation (struct type
*type
, float_data data
)
560 value
*evaluate (struct type
*expect_type
,
561 struct expression
*exp
,
562 enum noside noside
) override
564 return value_from_contents (m_type
, m_data
.data ());
567 enum exp_opcode
opcode () const override
570 bool constant_p () const override
573 void dump (struct ui_file
*stream
, int depth
) const override
;
581 class scope_operation
582 : public maybe_constant_operation
<struct type
*, std::string
>
586 using maybe_constant_operation::maybe_constant_operation
;
588 value
*evaluate (struct type
*expect_type
,
589 struct expression
*exp
,
590 enum noside noside
) override
592 return eval_op_scope (expect_type
, exp
, noside
,
593 std::get
<0> (m_storage
),
594 std::get
<1> (m_storage
).c_str ());
597 value
*evaluate_for_address (struct expression
*exp
,
598 enum noside noside
) override
;
600 enum exp_opcode
opcode () const override
605 void do_generate_ax (struct expression
*exp
,
606 struct agent_expr
*ax
,
607 struct axs_value
*value
,
608 struct type
*cast_type
)
612 class long_const_operation
613 : public tuple_holding_operation
<struct type
*, LONGEST
>
617 using tuple_holding_operation::tuple_holding_operation
;
619 value
*evaluate (struct type
*expect_type
,
620 struct expression
*exp
,
621 enum noside noside
) override
623 return value_from_longest (std::get
<0> (m_storage
),
624 std::get
<1> (m_storage
));
627 enum exp_opcode
opcode () const override
630 bool constant_p () const override
635 void do_generate_ax (struct expression
*exp
,
636 struct agent_expr
*ax
,
637 struct axs_value
*value
,
638 struct type
*cast_type
)
642 class var_msym_value_operation
643 : public maybe_constant_operation
<minimal_symbol
*, struct objfile
*>
647 using maybe_constant_operation::maybe_constant_operation
;
649 value
*evaluate (struct type
*expect_type
,
650 struct expression
*exp
,
651 enum noside noside
) override
653 return eval_op_var_msym_value (expect_type
, exp
, noside
, m_outermost
,
654 std::get
<0> (m_storage
),
655 std::get
<1> (m_storage
));
658 value
*evaluate_for_sizeof (struct expression
*exp
, enum noside noside
)
661 value
*evaluate_for_address (struct expression
*exp
, enum noside noside
)
664 value
*evaluate_for_cast (struct type
*expect_type
,
665 struct expression
*exp
,
666 enum noside noside
) override
;
668 enum exp_opcode
opcode () const override
669 { return OP_VAR_MSYM_VALUE
; }
671 void set_outermost () override
678 /* True if this is the outermost operation in the expression. */
679 bool m_outermost
= false;
681 void do_generate_ax (struct expression
*exp
,
682 struct agent_expr
*ax
,
683 struct axs_value
*value
,
684 struct type
*cast_type
)
688 class var_entry_value_operation
689 : public tuple_holding_operation
<symbol
*>
693 using tuple_holding_operation::tuple_holding_operation
;
695 value
*evaluate (struct type
*expect_type
,
696 struct expression
*exp
,
697 enum noside noside
) override
699 return eval_op_var_entry_value (expect_type
, exp
, noside
,
700 std::get
<0> (m_storage
));
703 enum exp_opcode
opcode () const override
704 { return OP_VAR_ENTRY_VALUE
; }
707 class func_static_var_operation
708 : public maybe_constant_operation
<operation_up
, std::string
>
712 using maybe_constant_operation::maybe_constant_operation
;
714 value
*evaluate (struct type
*expect_type
,
715 struct expression
*exp
,
716 enum noside noside
) override
718 value
*func
= std::get
<0> (m_storage
)->evaluate (nullptr, exp
, noside
);
719 return eval_op_func_static_var (expect_type
, exp
, noside
, func
,
720 std::get
<1> (m_storage
).c_str ());
723 enum exp_opcode
opcode () const override
724 { return OP_FUNC_STATIC_VAR
; }
728 : public tuple_holding_operation
<int>
732 using tuple_holding_operation::tuple_holding_operation
;
734 value
*evaluate (struct type
*expect_type
,
735 struct expression
*exp
,
736 enum noside noside
) override
738 return access_value_history (std::get
<0> (m_storage
));
741 enum exp_opcode
opcode () const override
745 class register_operation
746 : public tuple_holding_operation
<std::string
>
750 using tuple_holding_operation::tuple_holding_operation
;
752 value
*evaluate (struct type
*expect_type
,
753 struct expression
*exp
,
754 enum noside noside
) override
756 return eval_op_register (expect_type
, exp
, noside
,
757 std::get
<0> (m_storage
).c_str ());
760 enum exp_opcode
opcode () const override
761 { return OP_REGISTER
; }
765 void do_generate_ax (struct expression
*exp
,
766 struct agent_expr
*ax
,
767 struct axs_value
*value
,
768 struct type
*cast_type
)
773 : public tuple_holding_operation
<bool>
777 using tuple_holding_operation::tuple_holding_operation
;
779 value
*evaluate (struct type
*expect_type
,
780 struct expression
*exp
,
781 enum noside noside
) override
783 struct type
*type
= language_bool_type (exp
->language_defn
, exp
->gdbarch
);
784 return value_from_longest (type
, std::get
<0> (m_storage
));
787 enum exp_opcode
opcode () const override
790 bool constant_p () const override
794 class internalvar_operation
795 : public tuple_holding_operation
<internalvar
*>
799 using tuple_holding_operation::tuple_holding_operation
;
801 value
*evaluate (struct type
*expect_type
,
802 struct expression
*exp
,
803 enum noside noside
) override
805 return value_of_internalvar (exp
->gdbarch
,
806 std::get
<0> (m_storage
));
809 internalvar
*get_internalvar () const
811 return std::get
<0> (m_storage
);
814 enum exp_opcode
opcode () const override
815 { return OP_INTERNALVAR
; }
819 void do_generate_ax (struct expression
*exp
,
820 struct agent_expr
*ax
,
821 struct axs_value
*value
,
822 struct type
*cast_type
)
826 class string_operation
827 : public tuple_holding_operation
<std::string
>
831 using tuple_holding_operation::tuple_holding_operation
;
833 value
*evaluate (struct type
*expect_type
,
834 struct expression
*exp
,
835 enum noside noside
) override
837 const std::string
&str
= std::get
<0> (m_storage
);
838 return eval_op_string (expect_type
, exp
, noside
,
839 str
.size (), str
.c_str ());
842 enum exp_opcode
opcode () const override
843 { return OP_STRING
; }
846 class ternop_slice_operation
847 : public maybe_constant_operation
<operation_up
, operation_up
, operation_up
>
851 using maybe_constant_operation::maybe_constant_operation
;
853 value
*evaluate (struct type
*expect_type
,
854 struct expression
*exp
,
855 enum noside noside
) override
858 = std::get
<0> (m_storage
)->evaluate (nullptr, exp
, noside
);
860 = std::get
<1> (m_storage
)->evaluate (nullptr, exp
, noside
);
862 = std::get
<2> (m_storage
)->evaluate (nullptr, exp
, noside
);
863 return eval_op_ternop (expect_type
, exp
, noside
, array
, low
, upper
);
866 enum exp_opcode
opcode () const override
867 { return TERNOP_SLICE
; }
870 class ternop_cond_operation
871 : public maybe_constant_operation
<operation_up
, operation_up
, operation_up
>
875 using maybe_constant_operation::maybe_constant_operation
;
877 value
*evaluate (struct type
*expect_type
,
878 struct expression
*exp
,
879 enum noside noside
) override
882 = std::get
<0> (m_storage
)->evaluate (nullptr, exp
, noside
);
884 if (value_logical_not (val
))
885 return std::get
<2> (m_storage
)->evaluate (nullptr, exp
, noside
);
886 return std::get
<1> (m_storage
)->evaluate (nullptr, exp
, noside
);
889 enum exp_opcode
opcode () const override
890 { return TERNOP_COND
; }
894 void do_generate_ax (struct expression
*exp
,
895 struct agent_expr
*ax
,
896 struct axs_value
*value
,
897 struct type
*cast_type
)
901 class complex_operation
902 : public maybe_constant_operation
<operation_up
, operation_up
, struct type
*>
906 using maybe_constant_operation::maybe_constant_operation
;
908 value
*evaluate (struct type
*expect_type
,
909 struct expression
*exp
,
910 enum noside noside
) override
912 value
*real
= std::get
<0> (m_storage
)->evaluate (nullptr, exp
, noside
);
913 value
*imag
= std::get
<1> (m_storage
)->evaluate (nullptr, exp
, noside
);
914 return value_literal_complex (real
, imag
,
915 std::get
<2> (m_storage
));
918 enum exp_opcode
opcode () const override
919 { return OP_COMPLEX
; }
922 class structop_base_operation
923 : public tuple_holding_operation
<operation_up
, std::string
>
927 /* Used for completion. Return the field name. */
928 const std::string
&get_string () const
930 return std::get
<1> (m_storage
);
933 /* Used for completion. Evaluate the LHS for type. */
934 value
*evaluate_lhs (struct expression
*exp
)
936 return std::get
<0> (m_storage
)->evaluate (nullptr, exp
,
937 EVAL_AVOID_SIDE_EFFECTS
);
942 using tuple_holding_operation::tuple_holding_operation
;
945 class structop_operation
946 : public structop_base_operation
950 using structop_base_operation::structop_base_operation
;
952 value
*evaluate (struct type
*expect_type
,
953 struct expression
*exp
,
954 enum noside noside
) override
956 value
*val
=std::get
<0> (m_storage
)->evaluate (nullptr, exp
, noside
);
957 return eval_op_structop_struct (expect_type
, exp
, noside
, val
,
958 std::get
<1> (m_storage
).c_str ());
961 enum exp_opcode
opcode () const override
962 { return STRUCTOP_STRUCT
; }
966 void do_generate_ax (struct expression
*exp
,
967 struct agent_expr
*ax
,
968 struct axs_value
*value
,
969 struct type
*cast_type
)
972 gen_expr_structop (exp
, STRUCTOP_STRUCT
,
973 std::get
<0> (this->m_storage
).get (),
974 std::get
<1> (this->m_storage
).c_str (),
979 class structop_ptr_operation
980 : public structop_base_operation
984 using structop_base_operation::structop_base_operation
;
986 value
*evaluate (struct type
*expect_type
,
987 struct expression
*exp
,
988 enum noside noside
) override
990 value
*val
= std::get
<0> (m_storage
)->evaluate (nullptr, exp
, noside
);
991 return eval_op_structop_ptr (expect_type
, exp
, noside
, val
,
992 std::get
<1> (m_storage
).c_str ());
995 enum exp_opcode
opcode () const override
996 { return STRUCTOP_PTR
; }
1000 void do_generate_ax (struct expression
*exp
,
1001 struct agent_expr
*ax
,
1002 struct axs_value
*value
,
1003 struct type
*cast_type
)
1006 gen_expr_structop (exp
, STRUCTOP_PTR
,
1007 std::get
<0> (this->m_storage
).get (),
1008 std::get
<1> (this->m_storage
).c_str (),
1013 class structop_member_operation
1014 : public tuple_holding_operation
<operation_up
, operation_up
>
1018 using tuple_holding_operation::tuple_holding_operation
;
1020 value
*evaluate (struct type
*expect_type
,
1021 struct expression
*exp
,
1022 enum noside noside
) override
1025 = std::get
<0> (m_storage
)->evaluate_for_address (exp
, noside
);
1027 = std::get
<1> (m_storage
)->evaluate (nullptr, exp
, noside
);
1028 return eval_op_member (expect_type
, exp
, noside
, lhs
, rhs
);
1031 enum exp_opcode
opcode () const override
1032 { return STRUCTOP_MEMBER
; }
1035 class structop_mptr_operation
1036 : public tuple_holding_operation
<operation_up
, operation_up
>
1040 using tuple_holding_operation::tuple_holding_operation
;
1042 value
*evaluate (struct type
*expect_type
,
1043 struct expression
*exp
,
1044 enum noside noside
) override
1047 = std::get
<0> (m_storage
)->evaluate (nullptr, exp
, noside
);
1049 = std::get
<1> (m_storage
)->evaluate (nullptr, exp
, noside
);
1050 return eval_op_member (expect_type
, exp
, noside
, lhs
, rhs
);
1053 enum exp_opcode
opcode () const override
1054 { return STRUCTOP_MPTR
; }
1057 class concat_operation
1058 : public maybe_constant_operation
<operation_up
, operation_up
>
1062 using maybe_constant_operation::maybe_constant_operation
;
1064 value
*evaluate (struct type
*expect_type
,
1065 struct expression
*exp
,
1066 enum noside noside
) override
1069 = std::get
<0> (m_storage
)->evaluate_with_coercion (exp
, noside
);
1071 = std::get
<1> (m_storage
)->evaluate_with_coercion (exp
, noside
);
1072 return eval_op_concat (expect_type
, exp
, noside
, lhs
, rhs
);
1075 enum exp_opcode
opcode () const override
1076 { return BINOP_CONCAT
; }
1080 : public maybe_constant_operation
<operation_up
, operation_up
>
1084 using maybe_constant_operation::maybe_constant_operation
;
1086 value
*evaluate (struct type
*expect_type
,
1087 struct expression
*exp
,
1088 enum noside noside
) override
1091 = std::get
<0> (m_storage
)->evaluate_with_coercion (exp
, noside
);
1093 = std::get
<1> (m_storage
)->evaluate_with_coercion (exp
, noside
);
1094 return eval_op_add (expect_type
, exp
, noside
, lhs
, rhs
);
1097 enum exp_opcode
opcode () const override
1098 { return BINOP_ADD
; }
1102 void do_generate_ax (struct expression
*exp
,
1103 struct agent_expr
*ax
,
1104 struct axs_value
*value
,
1105 struct type
*cast_type
)
1108 gen_expr_binop (exp
, BINOP_ADD
,
1109 std::get
<0> (this->m_storage
).get (),
1110 std::get
<1> (this->m_storage
).get (),
1116 : public maybe_constant_operation
<operation_up
, operation_up
>
1120 using maybe_constant_operation::maybe_constant_operation
;
1122 value
*evaluate (struct type
*expect_type
,
1123 struct expression
*exp
,
1124 enum noside noside
) override
1127 = std::get
<0> (m_storage
)->evaluate_with_coercion (exp
, noside
);
1129 = std::get
<1> (m_storage
)->evaluate_with_coercion (exp
, noside
);
1130 return eval_op_sub (expect_type
, exp
, noside
, lhs
, rhs
);
1133 enum exp_opcode
opcode () const override
1134 { return BINOP_SUB
; }
1138 void do_generate_ax (struct expression
*exp
,
1139 struct agent_expr
*ax
,
1140 struct axs_value
*value
,
1141 struct type
*cast_type
)
1144 gen_expr_binop (exp
, BINOP_SUB
,
1145 std::get
<0> (this->m_storage
).get (),
1146 std::get
<1> (this->m_storage
).get (),
1151 typedef struct value
*binary_ftype (struct type
*expect_type
,
1152 struct expression
*exp
,
1153 enum noside noside
, enum exp_opcode op
,
1154 struct value
*arg1
, struct value
*arg2
);
1156 template<enum exp_opcode OP
, binary_ftype FUNC
>
1157 class binop_operation
1158 : public maybe_constant_operation
<operation_up
, operation_up
>
1162 using maybe_constant_operation::maybe_constant_operation
;
1164 value
*evaluate (struct type
*expect_type
,
1165 struct expression
*exp
,
1166 enum noside noside
) override
1169 = std::get
<0> (m_storage
)->evaluate (nullptr, exp
, noside
);
1171 = std::get
<1> (m_storage
)->evaluate (nullptr, exp
, noside
);
1172 return FUNC (expect_type
, exp
, noside
, OP
, lhs
, rhs
);
1175 enum exp_opcode
opcode () const override
1179 template<enum exp_opcode OP
, binary_ftype FUNC
>
1180 class usual_ax_binop_operation
1181 : public binop_operation
<OP
, FUNC
>
1185 using binop_operation
<OP
, FUNC
>::binop_operation
;
1189 void do_generate_ax (struct expression
*exp
,
1190 struct agent_expr
*ax
,
1191 struct axs_value
*value
,
1192 struct type
*cast_type
)
1195 gen_expr_binop (exp
, OP
,
1196 std::get
<0> (this->m_storage
).get (),
1197 std::get
<1> (this->m_storage
).get (),
1202 using exp_operation
= binop_operation
<BINOP_EXP
, eval_op_binary
>;
1203 using intdiv_operation
= binop_operation
<BINOP_INTDIV
, eval_op_binary
>;
1204 using mod_operation
= binop_operation
<BINOP_MOD
, eval_op_binary
>;
1206 using mul_operation
= usual_ax_binop_operation
<BINOP_MUL
, eval_op_binary
>;
1207 using div_operation
= usual_ax_binop_operation
<BINOP_DIV
, eval_op_binary
>;
1208 using rem_operation
= usual_ax_binop_operation
<BINOP_REM
, eval_op_binary
>;
1209 using lsh_operation
= usual_ax_binop_operation
<BINOP_LSH
, eval_op_binary
>;
1210 using rsh_operation
= usual_ax_binop_operation
<BINOP_RSH
, eval_op_binary
>;
1211 using bitwise_and_operation
1212 = usual_ax_binop_operation
<BINOP_BITWISE_AND
, eval_op_binary
>;
1213 using bitwise_ior_operation
1214 = usual_ax_binop_operation
<BINOP_BITWISE_IOR
, eval_op_binary
>;
1215 using bitwise_xor_operation
1216 = usual_ax_binop_operation
<BINOP_BITWISE_XOR
, eval_op_binary
>;
1218 class subscript_operation
1219 : public usual_ax_binop_operation
<BINOP_SUBSCRIPT
, eval_op_subscript
>
1222 using usual_ax_binop_operation
<BINOP_SUBSCRIPT
,
1223 eval_op_subscript
>::usual_ax_binop_operation
;
1225 value
*evaluate_for_sizeof (struct expression
*exp
,
1226 enum noside noside
) override
;
1229 /* Implementation of comparison operations. */
1230 template<enum exp_opcode OP
, binary_ftype FUNC
>
1231 class comparison_operation
1232 : public usual_ax_binop_operation
<OP
, FUNC
>
1236 using usual_ax_binop_operation
<OP
, FUNC
>::usual_ax_binop_operation
;
1238 value
*evaluate (struct type
*expect_type
,
1239 struct expression
*exp
,
1240 enum noside noside
) override
1243 = std::get
<0> (this->m_storage
)->evaluate (nullptr, exp
, noside
);
1245 = std::get
<1> (this->m_storage
)->evaluate (value_type (lhs
), exp
,
1247 return FUNC (expect_type
, exp
, noside
, OP
, lhs
, rhs
);
1251 using equal_operation
= comparison_operation
<BINOP_EQUAL
, eval_op_equal
>;
1252 using notequal_operation
1253 = comparison_operation
<BINOP_NOTEQUAL
, eval_op_notequal
>;
1254 using less_operation
= comparison_operation
<BINOP_LESS
, eval_op_less
>;
1255 using gtr_operation
= comparison_operation
<BINOP_GTR
, eval_op_gtr
>;
1256 using geq_operation
= comparison_operation
<BINOP_GEQ
, eval_op_geq
>;
1257 using leq_operation
= comparison_operation
<BINOP_LEQ
, eval_op_leq
>;
1259 /* Implement the GDB '@' repeat operator. */
1260 class repeat_operation
1261 : public binop_operation
<BINOP_REPEAT
, eval_op_repeat
>
1263 using binop_operation
<BINOP_REPEAT
, eval_op_repeat
>::binop_operation
;
1267 void do_generate_ax (struct expression
*exp
,
1268 struct agent_expr
*ax
,
1269 struct axs_value
*value
,
1270 struct type
*cast_type
)
1274 /* C-style comma operator. */
1275 class comma_operation
1276 : public maybe_constant_operation
<operation_up
, operation_up
>
1280 using maybe_constant_operation::maybe_constant_operation
;
1282 value
*evaluate (struct type
*expect_type
,
1283 struct expression
*exp
,
1284 enum noside noside
) override
1286 /* The left-hand-side is only evaluated for side effects, so don't
1287 bother in other modes. */
1288 if (noside
== EVAL_NORMAL
)
1289 std::get
<0> (m_storage
)->evaluate (nullptr, exp
, noside
);
1290 return std::get
<1> (m_storage
)->evaluate (nullptr, exp
, noside
);
1293 enum exp_opcode
opcode () const override
1294 { return BINOP_COMMA
; }
1298 void do_generate_ax (struct expression
*exp
,
1299 struct agent_expr
*ax
,
1300 struct axs_value
*value
,
1301 struct type
*cast_type
)
1305 typedef struct value
*unary_ftype (struct type
*expect_type
,
1306 struct expression
*exp
,
1307 enum noside noside
, enum exp_opcode op
,
1308 struct value
*arg1
);
1310 /* Base class for unary operations. */
1311 template<enum exp_opcode OP
, unary_ftype FUNC
>
1312 class unop_operation
1313 : public maybe_constant_operation
<operation_up
>
1317 using maybe_constant_operation::maybe_constant_operation
;
1319 value
*evaluate (struct type
*expect_type
,
1320 struct expression
*exp
,
1321 enum noside noside
) override
1323 value
*val
= std::get
<0> (m_storage
)->evaluate (nullptr, exp
, noside
);
1324 return FUNC (expect_type
, exp
, noside
, OP
, val
);
1327 enum exp_opcode
opcode () const override
1331 /* Unary operations that can also be turned into agent expressions in
1333 template<enum exp_opcode OP
, unary_ftype FUNC
>
1334 class usual_ax_unop_operation
1335 : public unop_operation
<OP
, FUNC
>
1337 using unop_operation
<OP
, FUNC
>::unop_operation
;
1341 void do_generate_ax (struct expression
*exp
,
1342 struct agent_expr
*ax
,
1343 struct axs_value
*value
,
1344 struct type
*cast_type
)
1347 gen_expr_unop (exp
, OP
,
1348 std::get
<0> (this->m_storage
).get (),
1353 using unary_plus_operation
= usual_ax_unop_operation
<UNOP_PLUS
, eval_op_plus
>;
1354 using unary_neg_operation
= usual_ax_unop_operation
<UNOP_NEG
, eval_op_neg
>;
1355 using unary_complement_operation
1356 = usual_ax_unop_operation
<UNOP_COMPLEMENT
, eval_op_complement
>;
1357 using unary_logical_not_operation
1358 = usual_ax_unop_operation
<UNOP_LOGICAL_NOT
, eval_op_lognot
>;
1360 /* Handle pre- and post- increment and -decrement. */
1361 template<enum exp_opcode OP
, unary_ftype FUNC
>
1362 class unop_incr_operation
1363 : public tuple_holding_operation
<operation_up
>
1367 using tuple_holding_operation::tuple_holding_operation
;
1369 value
*evaluate (struct type
*expect_type
,
1370 struct expression
*exp
,
1371 enum noside noside
) override
1373 value
*val
= std::get
<0> (m_storage
)->evaluate (expect_type
, exp
, noside
);
1374 return FUNC (expect_type
, exp
, noside
, OP
, val
);
1377 enum exp_opcode
opcode () const override
1381 using preinc_operation
1382 = unop_incr_operation
<UNOP_PREINCREMENT
, eval_op_preinc
>;
1383 using predec_operation
1384 = unop_incr_operation
<UNOP_PREDECREMENT
, eval_op_predec
>;
1385 using postinc_operation
1386 = unop_incr_operation
<UNOP_POSTINCREMENT
, eval_op_postinc
>;
1387 using postdec_operation
1388 = unop_incr_operation
<UNOP_POSTDECREMENT
, eval_op_postdec
>;
1390 /* Base class for implementations of UNOP_IND. */
1391 class unop_ind_base_operation
1392 : public tuple_holding_operation
<operation_up
>
1396 using tuple_holding_operation::tuple_holding_operation
;
1398 value
*evaluate (struct type
*expect_type
,
1399 struct expression
*exp
,
1400 enum noside noside
) override
1402 if (expect_type
!= nullptr && expect_type
->code () == TYPE_CODE_PTR
)
1403 expect_type
= TYPE_TARGET_TYPE (check_typedef (expect_type
));
1404 value
*val
= std::get
<0> (m_storage
)->evaluate (expect_type
, exp
, noside
);
1405 return eval_op_ind (expect_type
, exp
, noside
, val
);
1408 value
*evaluate_for_address (struct expression
*exp
,
1409 enum noside noside
) override
;
1411 value
*evaluate_for_sizeof (struct expression
*exp
,
1412 enum noside noside
) override
;
1414 enum exp_opcode
opcode () const override
1415 { return UNOP_IND
; }
1418 /* Ordinary UNOP_IND implementation. */
1419 class unop_ind_operation
1420 : public unop_ind_base_operation
1424 using unop_ind_base_operation::unop_ind_base_operation
;
1428 void do_generate_ax (struct expression
*exp
,
1429 struct agent_expr
*ax
,
1430 struct axs_value
*value
,
1431 struct type
*cast_type
)
1434 gen_expr_unop (exp
, UNOP_IND
,
1435 std::get
<0> (this->m_storage
).get (),
1440 /* Implement OP_TYPE. */
1441 class type_operation
1442 : public tuple_holding_operation
<struct type
*>
1446 using tuple_holding_operation::tuple_holding_operation
;
1448 value
*evaluate (struct type
*expect_type
,
1449 struct expression
*exp
,
1450 enum noside noside
) override
1452 return eval_op_type (expect_type
, exp
, noside
, std::get
<0> (m_storage
));
1455 enum exp_opcode
opcode () const override
1458 bool constant_p () const override
1462 /* Implement the "typeof" operation. */
1463 class typeof_operation
1464 : public maybe_constant_operation
<operation_up
>
1468 using maybe_constant_operation::maybe_constant_operation
;
1470 value
*evaluate (struct type
*expect_type
,
1471 struct expression
*exp
,
1472 enum noside noside
) override
1474 if (noside
== EVAL_SKIP
)
1475 return eval_skip_value (exp
);
1476 else if (noside
== EVAL_AVOID_SIDE_EFFECTS
)
1477 return std::get
<0> (m_storage
)->evaluate (nullptr, exp
,
1478 EVAL_AVOID_SIDE_EFFECTS
);
1480 error (_("Attempt to use a type as an expression"));
1483 enum exp_opcode
opcode () const override
1484 { return OP_TYPEOF
; }
1487 /* Implement 'decltype'. */
1488 class decltype_operation
1489 : public maybe_constant_operation
<operation_up
>
1493 using maybe_constant_operation::maybe_constant_operation
;
1495 value
*evaluate (struct type
*expect_type
,
1496 struct expression
*exp
,
1497 enum noside noside
) override
1499 if (noside
== EVAL_SKIP
)
1500 return eval_skip_value (exp
);
1501 else if (noside
== EVAL_AVOID_SIDE_EFFECTS
)
1504 = std::get
<0> (m_storage
)->evaluate (nullptr, exp
,
1505 EVAL_AVOID_SIDE_EFFECTS
);
1506 enum exp_opcode sub_op
= std::get
<0> (m_storage
)->opcode ();
1507 if (sub_op
== BINOP_SUBSCRIPT
1508 || sub_op
== STRUCTOP_MEMBER
1509 || sub_op
== STRUCTOP_MPTR
1510 || sub_op
== UNOP_IND
1511 || sub_op
== STRUCTOP_STRUCT
1512 || sub_op
== STRUCTOP_PTR
1513 || sub_op
== OP_SCOPE
)
1515 struct type
*type
= value_type (result
);
1517 if (!TYPE_IS_REFERENCE (type
))
1519 type
= lookup_lvalue_reference_type (type
);
1520 result
= allocate_value (type
);
1527 error (_("Attempt to use a type as an expression"));
1530 enum exp_opcode
opcode () const override
1531 { return OP_DECLTYPE
; }
1534 /* Implement 'typeid'. */
1535 class typeid_operation
1536 : public tuple_holding_operation
<operation_up
>
1540 using tuple_holding_operation::tuple_holding_operation
;
1542 value
*evaluate (struct type
*expect_type
,
1543 struct expression
*exp
,
1544 enum noside noside
) override
1546 enum exp_opcode sub_op
= std::get
<0> (m_storage
)->opcode ();
1547 enum noside sub_noside
1548 = ((sub_op
== OP_TYPE
|| sub_op
== OP_DECLTYPE
|| sub_op
== OP_TYPEOF
)
1549 ? EVAL_AVOID_SIDE_EFFECTS
1552 value
*result
= std::get
<0> (m_storage
)->evaluate (nullptr, exp
,
1554 if (noside
!= EVAL_NORMAL
)
1555 return allocate_value (cplus_typeid_type (exp
->gdbarch
));
1556 return cplus_typeid (result
);
1559 enum exp_opcode
opcode () const override
1560 { return OP_TYPEID
; }
1563 /* Implement the address-of operation. */
1564 class unop_addr_operation
1565 : public maybe_constant_operation
<operation_up
>
1569 using maybe_constant_operation::maybe_constant_operation
;
1571 value
*evaluate (struct type
*expect_type
,
1572 struct expression
*exp
,
1573 enum noside noside
) override
1575 /* C++: check for and handle pointer to members. */
1576 if (noside
== EVAL_SKIP
)
1577 return eval_skip_value (exp
);
1579 return std::get
<0> (m_storage
)->evaluate_for_address (exp
, noside
);
1582 enum exp_opcode
opcode () const override
1583 { return UNOP_ADDR
; }
1587 void do_generate_ax (struct expression
*exp
,
1588 struct agent_expr
*ax
,
1589 struct axs_value
*value
,
1590 struct type
*cast_type
)
1593 gen_expr_unop (exp
, UNOP_ADDR
,
1594 std::get
<0> (this->m_storage
).get (),
1599 /* Implement 'sizeof'. */
1600 class unop_sizeof_operation
1601 : public maybe_constant_operation
<operation_up
>
1605 using maybe_constant_operation::maybe_constant_operation
;
1607 value
*evaluate (struct type
*expect_type
,
1608 struct expression
*exp
,
1609 enum noside noside
) override
1611 if (noside
== EVAL_SKIP
)
1612 return eval_skip_value (exp
);
1613 return std::get
<0> (m_storage
)->evaluate_for_sizeof (exp
, noside
);
1616 enum exp_opcode
opcode () const override
1617 { return UNOP_SIZEOF
; }
1621 void do_generate_ax (struct expression
*exp
,
1622 struct agent_expr
*ax
,
1623 struct axs_value
*value
,
1624 struct type
*cast_type
)
1628 /* Implement 'alignof'. */
1629 class unop_alignof_operation
1630 : public maybe_constant_operation
<operation_up
>
1634 using maybe_constant_operation::maybe_constant_operation
;
1636 value
*evaluate (struct type
*expect_type
,
1637 struct expression
*exp
,
1638 enum noside noside
) override
1640 value
*val
= std::get
<0> (m_storage
)->evaluate (nullptr, exp
,
1641 EVAL_AVOID_SIDE_EFFECTS
);
1642 return eval_op_alignof (expect_type
, exp
, noside
, val
);
1645 enum exp_opcode
opcode () const override
1646 { return UNOP_ALIGNOF
; }
1649 /* Implement UNOP_MEMVAL. */
1650 class unop_memval_operation
1651 : public tuple_holding_operation
<operation_up
, struct type
*>
1655 using tuple_holding_operation::tuple_holding_operation
;
1657 value
*evaluate (struct type
*expect_type
,
1658 struct expression
*exp
,
1659 enum noside noside
) override
1661 value
*val
= std::get
<0> (m_storage
)->evaluate (expect_type
, exp
, noside
);
1662 return eval_op_memval (expect_type
, exp
, noside
, val
,
1663 std::get
<1> (m_storage
));
1666 value
*evaluate_for_sizeof (struct expression
*exp
,
1667 enum noside noside
) override
;
1669 value
*evaluate_for_address (struct expression
*exp
,
1670 enum noside noside
) override
;
1672 enum exp_opcode
opcode () const override
1673 { return UNOP_MEMVAL
; }
1677 void do_generate_ax (struct expression
*exp
,
1678 struct agent_expr
*ax
,
1679 struct axs_value
*value
,
1680 struct type
*cast_type
)
1684 /* Implement UNOP_MEMVAL_TYPE. */
1685 class unop_memval_type_operation
1686 : public tuple_holding_operation
<operation_up
, operation_up
>
1690 using tuple_holding_operation::tuple_holding_operation
;
1692 value
*evaluate (struct type
*expect_type
,
1693 struct expression
*exp
,
1694 enum noside noside
) override
1697 = std::get
<0> (m_storage
)->evaluate (expect_type
, exp
,
1698 EVAL_AVOID_SIDE_EFFECTS
);
1699 struct type
*type
= value_type (typeval
);
1700 value
*val
= std::get
<1> (m_storage
)->evaluate (expect_type
, exp
, noside
);
1701 return eval_op_memval (expect_type
, exp
, noside
, val
, type
);
1704 value
*evaluate_for_sizeof (struct expression
*exp
,
1705 enum noside noside
) override
;
1707 value
*evaluate_for_address (struct expression
*exp
,
1708 enum noside noside
) override
;
1710 enum exp_opcode
opcode () const override
1711 { return UNOP_MEMVAL_TYPE
; }
1715 void do_generate_ax (struct expression
*exp
,
1716 struct agent_expr
*ax
,
1717 struct axs_value
*value
,
1718 struct type
*cast_type
)
1722 /* Implement the 'this' expression. */
1723 class op_this_operation
1724 : public tuple_holding_operation
<>
1728 using tuple_holding_operation::tuple_holding_operation
;
1730 value
*evaluate (struct type
*expect_type
,
1731 struct expression
*exp
,
1732 enum noside noside
) override
1734 return value_of_this (exp
->language_defn
);
1737 enum exp_opcode
opcode () const override
1742 void do_generate_ax (struct expression
*exp
,
1743 struct agent_expr
*ax
,
1744 struct axs_value
*value
,
1745 struct type
*cast_type
)
1749 /* Implement the "type instance" operation. */
1750 class type_instance_operation
1751 : public tuple_holding_operation
<type_instance_flags
, std::vector
<type
*>,
1756 using tuple_holding_operation::tuple_holding_operation
;
1758 value
*evaluate (struct type
*expect_type
,
1759 struct expression
*exp
,
1760 enum noside noside
) override
;
1762 enum exp_opcode
opcode () const override
1763 { return TYPE_INSTANCE
; }
1766 /* The assignment operator. */
1767 class assign_operation
1768 : public tuple_holding_operation
<operation_up
, operation_up
>
1772 using tuple_holding_operation::tuple_holding_operation
;
1774 value
*evaluate (struct type
*expect_type
,
1775 struct expression
*exp
,
1776 enum noside noside
) override
1778 value
*lhs
= std::get
<0> (m_storage
)->evaluate (nullptr, exp
, noside
);
1779 /* Special-case assignments where the left-hand-side is a
1780 convenience variable -- in these, don't bother setting an
1781 expected type. This avoids a weird case where re-assigning a
1782 string or array to an internal variable could error with "Too
1783 many array elements". */
1784 struct type
*xtype
= (VALUE_LVAL (lhs
) == lval_internalvar
1786 : value_type (lhs
));
1787 value
*rhs
= std::get
<1> (m_storage
)->evaluate (xtype
, exp
, noside
);
1789 if (noside
== EVAL_SKIP
|| noside
== EVAL_AVOID_SIDE_EFFECTS
)
1791 if (binop_user_defined_p (BINOP_ASSIGN
, lhs
, rhs
))
1792 return value_x_binop (lhs
, rhs
, BINOP_ASSIGN
, OP_NULL
, noside
);
1794 return value_assign (lhs
, rhs
);
1797 enum exp_opcode
opcode () const override
1798 { return BINOP_ASSIGN
; }
1802 void do_generate_ax (struct expression
*exp
,
1803 struct agent_expr
*ax
,
1804 struct axs_value
*value
,
1805 struct type
*cast_type
)
1809 /* Assignment with modification, like "+=". */
1810 class assign_modify_operation
1811 : public tuple_holding_operation
<exp_opcode
, operation_up
, operation_up
>
1815 using tuple_holding_operation::tuple_holding_operation
;
1817 value
*evaluate (struct type
*expect_type
,
1818 struct expression
*exp
,
1819 enum noside noside
) override
1821 value
*lhs
= std::get
<1> (m_storage
)->evaluate (nullptr, exp
, noside
);
1822 value
*rhs
= std::get
<2> (m_storage
)->evaluate (expect_type
, exp
, noside
);
1823 return eval_binop_assign_modify (expect_type
, exp
, noside
,
1824 std::get
<0> (m_storage
), lhs
, rhs
);
1827 enum exp_opcode
opcode () const override
1828 { return BINOP_ASSIGN_MODIFY
; }
1832 void do_generate_ax (struct expression
*exp
,
1833 struct agent_expr
*ax
,
1834 struct axs_value
*value
,
1835 struct type
*cast_type
)
1840 class unop_cast_operation
1841 : public maybe_constant_operation
<operation_up
, struct type
*>
1845 using maybe_constant_operation::maybe_constant_operation
;
1847 value
*evaluate (struct type
*expect_type
,
1848 struct expression
*exp
,
1849 enum noside noside
) override
1851 return std::get
<0> (m_storage
)->evaluate_for_cast (std::get
<1> (m_storage
),
1855 enum exp_opcode
opcode () const override
1856 { return UNOP_CAST
; }
1860 void do_generate_ax (struct expression
*exp
,
1861 struct agent_expr
*ax
,
1862 struct axs_value
*value
,
1863 struct type
*cast_type
)
1867 } /* namespace expr */
1869 #endif /* EXPOP_H */