Fix building Loongarch BFD with a 32-bit compiler
[binutils-gdb.git] / gdb / ada-exp.h
blob94e4ea0f47ed7cf8611fe1e7cd96e74add9fc2b6
1 /* Definitions for Ada expressions
3 Copyright (C) 2020-2024 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/>. */
20 #ifndef ADA_EXP_H
21 #define ADA_EXP_H
23 #include "expop.h"
25 extern struct value *ada_unop_neg (struct type *expect_type,
26 struct expression *exp,
27 enum noside noside, enum exp_opcode op,
28 struct value *arg1);
29 extern struct value *ada_atr_tag (struct type *expect_type,
30 struct expression *exp,
31 enum noside noside, enum exp_opcode op,
32 struct value *arg1);
33 extern struct value *ada_atr_size (struct type *expect_type,
34 struct expression *exp,
35 enum noside noside, enum exp_opcode op,
36 struct value *arg1);
37 extern struct value *ada_abs (struct type *expect_type,
38 struct expression *exp,
39 enum noside noside, enum exp_opcode op,
40 struct value *arg1);
41 extern struct value *ada_unop_in_range (struct type *expect_type,
42 struct expression *exp,
43 enum noside noside, enum exp_opcode op,
44 struct value *arg1, struct type *type);
45 extern struct value *ada_mult_binop (struct type *expect_type,
46 struct expression *exp,
47 enum noside noside, enum exp_opcode op,
48 struct value *arg1, struct value *arg2);
49 extern struct value *ada_equal_binop (struct type *expect_type,
50 struct expression *exp,
51 enum noside noside, enum exp_opcode op,
52 struct value *arg1, struct value *arg2);
53 extern struct value *ada_ternop_slice (struct expression *exp,
54 enum noside noside,
55 struct value *array,
56 struct value *low_bound_val,
57 struct value *high_bound_val);
58 extern struct value *ada_binop_in_bounds (struct expression *exp,
59 enum noside noside,
60 struct value *arg1,
61 struct value *arg2,
62 int n);
63 extern struct value *ada_binop_minmax (struct type *expect_type,
64 struct expression *exp,
65 enum noside noside, enum exp_opcode op,
66 struct value *arg1,
67 struct value *arg2);
68 extern struct value *ada_pos_atr (struct type *expect_type,
69 struct expression *exp,
70 enum noside noside, enum exp_opcode op,
71 struct value *arg);
72 extern struct value *ada_atr_enum_rep (struct expression *exp,
73 enum noside noside, struct type *type,
74 struct value *arg);
75 extern struct value *ada_atr_enum_val (struct expression *exp,
76 enum noside noside, struct type *type,
77 struct value *arg);
78 extern struct value *ada_val_atr (struct expression *exp,
79 enum noside noside, struct type *type,
80 struct value *arg);
81 extern struct value *ada_binop_exp (struct type *expect_type,
82 struct expression *exp,
83 enum noside noside, enum exp_opcode op,
84 struct value *arg1, struct value *arg2);
86 namespace expr
89 /* The base class for Ada type resolution. Ada operations that want
90 to participate in resolution implement this interface. */
91 struct ada_resolvable
93 /* Resolve this object. EXP is the expression being resolved.
94 DEPROCEDURE_P is true if a symbol that refers to a zero-argument
95 function may be turned into a function call. PARSE_COMPLETION
96 and TRACKER are passed in from the parser context. CONTEXT_TYPE
97 is the expected type of the expression, or nullptr if none is
98 known. This method should return true if the operation should be
99 replaced by a function call with this object as the callee. */
100 virtual bool resolve (struct expression *exp,
101 bool deprocedure_p,
102 bool parse_completion,
103 innermost_block_tracker *tracker,
104 struct type *context_type) = 0;
106 /* Possibly replace this object with some other expression object.
107 This is like 'resolve', but can return a replacement.
109 The default implementation calls 'resolve' and wraps this object
110 in a function call if that call returns true. OWNER is a
111 reference to the unique pointer that owns the 'this'; it can be
112 'move'd from to construct the replacement.
114 This should either return a new object, or OWNER -- never
115 nullptr. */
117 virtual operation_up replace (operation_up &&owner,
118 struct expression *exp,
119 bool deprocedure_p,
120 bool parse_completion,
121 innermost_block_tracker *tracker,
122 struct type *context_type);
125 /* In Ada, some generic operations must be wrapped with a handler that
126 handles some Ada-specific type conversions. */
127 class ada_wrapped_operation
128 : public tuple_holding_operation<operation_up>
130 public:
132 using tuple_holding_operation::tuple_holding_operation;
134 value *evaluate (struct type *expect_type,
135 struct expression *exp,
136 enum noside noside) override;
138 enum exp_opcode opcode () const override
139 { return std::get<0> (m_storage)->opcode (); }
141 protected:
143 void do_generate_ax (struct expression *exp,
144 struct agent_expr *ax,
145 struct axs_value *value,
146 struct type *cast_type)
147 override;
150 /* An Ada string constant. */
151 class ada_string_operation
152 : public string_operation
154 public:
156 using string_operation::string_operation;
158 /* Return the underlying string. */
159 const char *get_name () const
161 return std::get<0> (m_storage).c_str ();
164 value *evaluate (struct type *expect_type,
165 struct expression *exp,
166 enum noside noside) override;
169 /* The Ada TYPE'(EXP) construct. */
170 class ada_qual_operation
171 : public tuple_holding_operation<operation_up, struct type *>
173 public:
175 using tuple_holding_operation::tuple_holding_operation;
177 value *evaluate (struct type *expect_type,
178 struct expression *exp,
179 enum noside noside) override;
181 enum exp_opcode opcode () const override
182 { return UNOP_QUAL; }
185 /* Ternary in-range operator. */
186 class ada_ternop_range_operation
187 : public tuple_holding_operation<operation_up, operation_up, operation_up>
189 public:
191 using tuple_holding_operation::tuple_holding_operation;
193 value *evaluate (struct type *expect_type,
194 struct expression *exp,
195 enum noside noside) override;
197 enum exp_opcode opcode () const override
198 { return TERNOP_IN_RANGE; }
201 using ada_neg_operation = unop_operation<UNOP_NEG, ada_unop_neg>;
202 using ada_atr_tag_operation = unop_operation<OP_ATR_TAG, ada_atr_tag>;
203 using ada_atr_size_operation = unop_operation<OP_ATR_SIZE, ada_atr_size>;
204 using ada_abs_operation = unop_operation<UNOP_ABS, ada_abs>;
205 using ada_pos_operation = unop_operation<OP_ATR_POS, ada_pos_atr>;
207 /* The in-range operation, given a type. */
208 class ada_unop_range_operation
209 : public tuple_holding_operation<operation_up, struct type *>
211 public:
213 using tuple_holding_operation::tuple_holding_operation;
215 value *evaluate (struct type *expect_type,
216 struct expression *exp,
217 enum noside noside) override
219 value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
220 return ada_unop_in_range (expect_type, exp, noside, UNOP_IN_RANGE,
221 val, std::get<1> (m_storage));
224 enum exp_opcode opcode () const override
225 { return UNOP_IN_RANGE; }
228 /* The Ada + and - operators. */
229 class ada_binop_addsub_operation
230 : public tuple_holding_operation<enum exp_opcode, operation_up, operation_up>
232 public:
234 using tuple_holding_operation::tuple_holding_operation;
236 value *evaluate (struct type *expect_type,
237 struct expression *exp,
238 enum noside noside) override;
240 enum exp_opcode opcode () const override
241 { return std::get<0> (m_storage); }
244 using ada_binop_mul_operation = binop_operation<BINOP_MUL, ada_mult_binop>;
245 using ada_binop_div_operation = binop_operation<BINOP_DIV, ada_mult_binop>;
246 using ada_binop_rem_operation = binop_operation<BINOP_REM, ada_mult_binop>;
247 using ada_binop_mod_operation = binop_operation<BINOP_MOD, ada_mult_binop>;
249 using ada_binop_min_operation = binop_operation<BINOP_MIN, ada_binop_minmax>;
250 using ada_binop_max_operation = binop_operation<BINOP_MAX, ada_binop_minmax>;
252 using ada_binop_exp_operation = binop_operation<BINOP_EXP, ada_binop_exp>;
254 /* Implement the equal and not-equal operations for Ada. */
255 class ada_binop_equal_operation
256 : public tuple_holding_operation<enum exp_opcode, operation_up, operation_up>
258 public:
260 using tuple_holding_operation::tuple_holding_operation;
262 value *evaluate (struct type *expect_type,
263 struct expression *exp,
264 enum noside noside) override
266 value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
267 value *arg2 = std::get<2> (m_storage)->evaluate (arg1->type (),
268 exp, noside);
269 return ada_equal_binop (expect_type, exp, noside, std::get<0> (m_storage),
270 arg1, arg2);
273 void do_generate_ax (struct expression *exp,
274 struct agent_expr *ax,
275 struct axs_value *value,
276 struct type *cast_type)
277 override
279 gen_expr_binop (exp, opcode (),
280 std::get<1> (this->m_storage).get (),
281 std::get<2> (this->m_storage).get (),
282 ax, value);
285 enum exp_opcode opcode () const override
286 { return std::get<0> (m_storage); }
289 /* Ada array- or string-slice operation. */
290 class ada_ternop_slice_operation
291 : public maybe_constant_operation<operation_up, operation_up, operation_up>,
292 public ada_resolvable
294 public:
296 using maybe_constant_operation::maybe_constant_operation;
298 value *evaluate (struct type *expect_type,
299 struct expression *exp,
300 enum noside noside) override
302 value *array = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
303 value *low = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
304 value *high = std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
305 return ada_ternop_slice (exp, noside, array, low, high);
308 enum exp_opcode opcode () const override
309 { return TERNOP_SLICE; }
311 bool resolve (struct expression *exp,
312 bool deprocedure_p,
313 bool parse_completion,
314 innermost_block_tracker *tracker,
315 struct type *context_type) override;
318 /* Implement BINOP_IN_BOUNDS for Ada. */
319 class ada_binop_in_bounds_operation
320 : public maybe_constant_operation<operation_up, operation_up, int>
322 public:
324 using maybe_constant_operation::maybe_constant_operation;
326 value *evaluate (struct type *expect_type,
327 struct expression *exp,
328 enum noside noside) override
330 value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
331 value *arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
332 return ada_binop_in_bounds (exp, noside, arg1, arg2,
333 std::get<2> (m_storage));
336 enum exp_opcode opcode () const override
337 { return BINOP_IN_BOUNDS; }
340 /* Implement several unary Ada OP_ATR_* operations. */
341 class ada_unop_atr_operation
342 : public maybe_constant_operation<operation_up, enum exp_opcode, int>
344 public:
346 using maybe_constant_operation::maybe_constant_operation;
348 value *evaluate (struct type *expect_type,
349 struct expression *exp,
350 enum noside noside) override;
352 enum exp_opcode opcode () const override
353 { return std::get<1> (m_storage); }
356 /* Variant of var_value_operation for Ada. */
357 class ada_var_value_operation
358 : public var_value_operation, public ada_resolvable
360 public:
362 using var_value_operation::var_value_operation;
364 value *evaluate (struct type *expect_type,
365 struct expression *exp,
366 enum noside noside) override;
368 value *evaluate_for_cast (struct type *expect_type,
369 struct expression *exp,
370 enum noside noside) override;
372 const block *get_block () const
373 { return std::get<0> (m_storage).block; }
375 bool resolve (struct expression *exp,
376 bool deprocedure_p,
377 bool parse_completion,
378 innermost_block_tracker *tracker,
379 struct type *context_type) override;
381 protected:
383 void do_generate_ax (struct expression *exp,
384 struct agent_expr *ax,
385 struct axs_value *value,
386 struct type *cast_type)
387 override;
390 /* Variant of var_msym_value_operation for Ada. */
391 class ada_var_msym_value_operation
392 : public var_msym_value_operation
394 public:
396 using var_msym_value_operation::var_msym_value_operation;
398 value *evaluate_for_cast (struct type *expect_type,
399 struct expression *exp,
400 enum noside noside) override;
402 protected:
404 using operation::do_generate_ax;
407 typedef struct value *ada_atr_ftype (struct expression *exp,
408 enum noside noside,
409 struct type *type,
410 struct value *arg);
412 /* Implement several Ada attributes. */
413 template<ada_atr_ftype FUNC>
414 class ada_atr_operation
415 : public tuple_holding_operation<struct type *, operation_up>
417 public:
419 using tuple_holding_operation::tuple_holding_operation;
421 value *evaluate (struct type *expect_type,
422 struct expression *exp,
423 enum noside noside) override
425 value *arg = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
426 return FUNC (exp, noside, std::get<0> (m_storage), arg);
429 enum exp_opcode opcode () const override
431 /* The value here generally doesn't matter. */
432 return OP_ATR_VAL;
436 using ada_atr_val_operation = ada_atr_operation<ada_val_atr>;
437 using ada_atr_enum_rep_operation = ada_atr_operation<ada_atr_enum_rep>;
438 using ada_atr_enum_val_operation = ada_atr_operation<ada_atr_enum_val>;
440 /* The indirection operator for Ada. */
441 class ada_unop_ind_operation
442 : public unop_ind_base_operation
444 public:
446 using unop_ind_base_operation::unop_ind_base_operation;
448 value *evaluate (struct type *expect_type,
449 struct expression *exp,
450 enum noside noside) override;
453 /* Implement STRUCTOP_STRUCT for Ada. */
454 class ada_structop_operation
455 : public structop_base_operation
457 public:
459 using structop_base_operation::structop_base_operation;
461 value *evaluate (struct type *expect_type,
462 struct expression *exp,
463 enum noside noside) override;
465 enum exp_opcode opcode () const override
466 { return STRUCTOP_STRUCT; }
468 /* Set the completion prefix. */
469 void set_prefix (std::string &&prefix)
471 m_prefix = std::move (prefix);
474 bool complete (struct expression *exp, completion_tracker &tracker) override
476 return structop_base_operation::complete (exp, tracker, m_prefix.c_str ());
479 void dump (struct ui_file *stream, int depth) const override
481 structop_base_operation::dump (stream, depth);
482 dump_for_expression (stream, depth + 1, m_prefix);
485 private:
487 /* We may need to provide a prefix to field name completion. See
488 ada-exp.y:find_completion_bounds for details. */
489 std::string m_prefix;
492 /* Function calls for Ada. */
493 class ada_funcall_operation
494 : public tuple_holding_operation<operation_up, std::vector<operation_up>>,
495 public ada_resolvable
497 public:
499 using tuple_holding_operation::tuple_holding_operation;
501 value *evaluate (struct type *expect_type,
502 struct expression *exp,
503 enum noside noside) override;
505 bool resolve (struct expression *exp,
506 bool deprocedure_p,
507 bool parse_completion,
508 innermost_block_tracker *tracker,
509 struct type *context_type) override;
511 enum exp_opcode opcode () const override
512 { return OP_FUNCALL; }
515 /* An Ada assignment operation. */
516 class ada_assign_operation
517 : public assign_operation
519 public:
521 using assign_operation::assign_operation;
523 value *evaluate (struct type *expect_type,
524 struct expression *exp,
525 enum noside noside) override;
527 enum exp_opcode opcode () const override
528 { return BINOP_ASSIGN; }
530 value *current ()
531 { return m_current; }
533 /* A helper function for the parser to evaluate just the LHS of the
534 assignment. */
535 value *eval_for_resolution (struct expression *exp)
537 return std::get<0> (m_storage)->evaluate (nullptr, exp,
538 EVAL_AVOID_SIDE_EFFECTS);
541 /* The parser must construct the assignment node before parsing the
542 RHS, so that '@' can access the assignment, so this helper
543 function is needed to set the RHS after construction. */
544 void set_rhs (operation_up rhs)
546 std::get<1> (m_storage) = std::move (rhs);
549 private:
551 /* Temporary storage for the value of the left-hand-side. */
552 value *m_current = nullptr;
555 /* Implement the Ada target name symbol ('@'). This is used to refer
556 to the LHS of an assignment from the RHS. */
557 class ada_target_operation : public operation
559 public:
561 explicit ada_target_operation (ada_assign_operation *lhs)
562 : m_lhs (lhs)
565 value *evaluate (struct type *expect_type,
566 struct expression *exp,
567 enum noside noside) override
569 if (noside == EVAL_AVOID_SIDE_EFFECTS)
570 return m_lhs->eval_for_resolution (exp);
571 return m_lhs->current ();
574 enum exp_opcode opcode () const override
576 /* It doesn't really matter. */
577 return OP_VAR_VALUE;
580 void dump (struct ui_file *stream, int depth) const override
582 gdb_printf (stream, _("%*sAda target symbol '@'\n"), depth, "");
585 private:
587 /* The left hand side of the assignment. */
588 ada_assign_operation *m_lhs;
591 /* When constructing an aggregate, an object of this type is created
592 to track the needed state. */
594 struct aggregate_assigner
596 /* An lvalue containing LHS (possibly LHS itself). */
597 value *container;
599 /* An lvalue of record or array type; this is the object being
600 assigned to. */
601 value *lhs;
603 /* The expression being evaluated. */
604 expression *exp;
606 /* The bounds of LHS. This is used by the 'others' component. */
607 LONGEST low;
608 LONGEST high;
610 /* This indicates which sub-components have already been assigned
611 to. */
612 std::vector<LONGEST> indices;
614 private:
616 /* The current index value. This is only valid during the 'assign'
617 operation and is part of the implementation of iterated component
618 association. */
619 LONGEST m_current_index = 0;
621 public:
623 /* Assign the result of evaluating ARG to the INDEXth component of
624 LHS (a simple array or a record). Does not modify the inferior's
625 memory, nor does it modify LHS (unless LHS == CONTAINER). */
626 void assign (LONGEST index, operation_up &arg);
628 /* Add the interval [FROM .. TO] to the sorted set of intervals
629 [ INDICES[0] .. INDICES[1] ],... The resulting intervals do not
630 overlap. */
631 void add_interval (LONGEST low, LONGEST high);
633 /* Return the current index as a value, using the index type of
634 LHS. */
635 value *current_value () const;
638 /* This abstract class represents a single component in an Ada
639 aggregate assignment. */
640 class ada_component
642 public:
644 /* Assign to ASSIGNER. */
645 virtual void assign (aggregate_assigner &assigner) = 0;
647 /* Same as operation::uses_objfile. */
648 virtual bool uses_objfile (struct objfile *objfile) = 0;
650 /* Same as operation::dump. */
651 virtual void dump (ui_file *stream, int depth) = 0;
653 virtual ~ada_component () = default;
655 protected:
657 ada_component () = default;
658 DISABLE_COPY_AND_ASSIGN (ada_component);
661 /* Unique pointer specialization for Ada assignment components. */
662 typedef std::unique_ptr<ada_component> ada_component_up;
664 /* An operation that holds a single component. */
665 class ada_aggregate_operation
666 : public tuple_holding_operation<ada_component_up>
668 public:
670 using tuple_holding_operation::tuple_holding_operation;
672 /* Assuming that LHS represents an lvalue having a record or array
673 type, evaluate an assignment of this aggregate's value to LHS.
674 CONTAINER is an lvalue containing LHS (possibly LHS itself).
675 Does not modify the inferior's memory, nor does it modify the
676 contents of LHS (unless == CONTAINER). Returns the modified
677 CONTAINER. */
679 value *assign_aggregate (struct value *container,
680 struct value *lhs,
681 struct expression *exp);
683 value *evaluate (struct type *expect_type,
684 struct expression *exp,
685 enum noside noside) override
687 error (_("Aggregates only allowed on the right of an assignment"));
690 enum exp_opcode opcode () const override
691 { return OP_AGGREGATE; }
694 /* A component holding a vector of other components to assign. */
695 class ada_aggregate_component : public ada_component
697 public:
699 explicit ada_aggregate_component (std::vector<ada_component_up> &&components)
700 : m_components (std::move (components))
704 /* This is the "with delta" form -- BASE is the base expression. */
705 ada_aggregate_component (operation_up &&base,
706 std::vector<ada_component_up> &&components);
708 void assign (aggregate_assigner &assigner) override;
710 bool uses_objfile (struct objfile *objfile) override;
712 void dump (ui_file *stream, int depth) override;
714 private:
716 /* If the assignment has a "with delta" clause, this is the
717 base expression. */
718 operation_up m_base;
719 /* The individual components to assign. */
720 std::vector<ada_component_up> m_components;
723 /* A component that assigns according to a provided index (which is
724 relative to the "low" value). */
725 class ada_positional_component : public ada_component
727 public:
729 ada_positional_component (int index, operation_up &&op)
730 : m_index (index),
731 m_op (std::move (op))
735 void assign (aggregate_assigner &assigner) override;
737 bool uses_objfile (struct objfile *objfile) override;
739 void dump (ui_file *stream, int depth) override;
741 private:
743 int m_index;
744 operation_up m_op;
747 /* A component which handles an "others" clause. */
748 class ada_others_component : public ada_component
750 public:
752 explicit ada_others_component (operation_up &&op)
753 : m_op (std::move (op))
757 void assign (aggregate_assigner &assigner) override;
759 bool uses_objfile (struct objfile *objfile) override;
761 void dump (ui_file *stream, int depth) override;
763 private:
765 operation_up m_op;
768 /* An interface that represents an association that is used in
769 aggregate assignment. */
770 class ada_association
772 public:
774 /* Like ada_component::assign, but takes an operation as a
775 parameter. The operation is evaluated and then assigned into
776 ASSIGNER according to the rules of the concrete
777 implementation. */
778 virtual void assign (aggregate_assigner &assigner, operation_up &op) = 0;
780 /* Same as operation::uses_objfile. */
781 virtual bool uses_objfile (struct objfile *objfile) = 0;
783 /* Same as operation::dump. */
784 virtual void dump (ui_file *stream, int depth) = 0;
786 virtual ~ada_association () = default;
788 protected:
790 ada_association () = default;
791 DISABLE_COPY_AND_ASSIGN (ada_association);
794 /* Unique pointer specialization for Ada assignment associations. */
795 typedef std::unique_ptr<ada_association> ada_association_up;
797 /* A component that holds a vector of associations and an operation.
798 The operation is re-evaluated for each choice. */
799 class ada_choices_component : public ada_component
801 public:
803 explicit ada_choices_component (operation_up &&op)
804 : m_op (std::move (op))
808 /* Set the vector of associations. This is done separately from the
809 constructor because it was simpler for the implementation of the
810 parser. */
811 void set_associations (std::vector<ada_association_up> &&assoc)
813 m_assocs = std::move (assoc);
816 /* Set the underlying operation */
817 void set_operation (operation_up op)
818 { m_op = std::move (op); }
820 /* Set the index variable name for an iterated association. */
821 void set_name (std::string &&name)
822 { m_name = std::move (name); }
824 /* The name of this choice component. This is empty unless this is
825 an iterated association. */
826 const std::string &name () const
827 { return m_name; }
829 void assign (aggregate_assigner &assigner) override;
831 bool uses_objfile (struct objfile *objfile) override;
833 void dump (ui_file *stream, int depth) override;
835 /* Return the current value of the index variable. This may only be
836 called underneath a call to 'assign'. */
837 value *current_value () const
838 { return m_assigner->current_value (); }
840 private:
842 std::vector<ada_association_up> m_assocs;
843 operation_up m_op;
845 /* Name of the variable used for iteration. This isn't needed for
846 evaluation, only for debug dumping. This is the empty string for
847 ordinary (non-iterated) choices. */
848 std::string m_name;
850 /* A pointer to the current assignment operation; only valid when in
851 a call to the 'assign' method. This is used to find the index
852 variable value during the evaluation of the RHS of the =>, via
853 ada_index_var_operation. */
854 const aggregate_assigner *m_assigner = nullptr;
857 /* Implement the index variable for iterated component
858 association. */
859 class ada_index_var_operation : public operation
861 public:
863 ada_index_var_operation ()
866 /* Link this variable to the choices object. May only be called
867 once. */
868 void set_choices (ada_choices_component *var)
870 gdb_assert (m_var == nullptr && var != nullptr);
871 m_var = var;
874 value *evaluate (struct type *expect_type,
875 struct expression *exp,
876 enum noside noside) override;
878 enum exp_opcode opcode () const override
880 /* It doesn't really matter. */
881 return OP_VAR_VALUE;
884 void dump (struct ui_file *stream, int depth) const override;
886 private:
888 /* The choices component that introduced the index variable. */
889 ada_choices_component *m_var = nullptr;
892 /* An association that uses a discrete range. */
893 class ada_discrete_range_association : public ada_association
895 public:
897 ada_discrete_range_association (operation_up &&low, operation_up &&high)
898 : m_low (std::move (low)),
899 m_high (std::move (high))
903 void assign (aggregate_assigner &assigner, operation_up &op) override;
905 bool uses_objfile (struct objfile *objfile) override;
907 void dump (ui_file *stream, int depth) override;
909 private:
911 operation_up m_low;
912 operation_up m_high;
915 /* An association that uses a name. The name may be an expression
916 that evaluates to an integer (for arrays), or an Ada string or
917 variable value operation. */
918 class ada_name_association : public ada_association
920 public:
922 explicit ada_name_association (operation_up val)
923 : m_val (std::move (val))
927 void assign (aggregate_assigner &assigner, operation_up &op) override;
929 bool uses_objfile (struct objfile *objfile) override;
931 void dump (ui_file *stream, int depth) override;
933 private:
935 operation_up m_val;
938 /* A character constant expression. This is a separate operation so
939 that it can participate in resolution, so that TYPE'(CST) can
940 work correctly for enums with character enumerators. */
941 class ada_char_operation : public long_const_operation,
942 public ada_resolvable
944 public:
946 using long_const_operation::long_const_operation;
948 bool resolve (struct expression *exp,
949 bool deprocedure_p,
950 bool parse_completion,
951 innermost_block_tracker *tracker,
952 struct type *context_type) override
954 /* This should never be called, because this class also implements
955 'replace'. */
956 gdb_assert_not_reached ("unexpected call");
959 operation_up replace (operation_up &&owner,
960 struct expression *exp,
961 bool deprocedure_p,
962 bool parse_completion,
963 innermost_block_tracker *tracker,
964 struct type *context_type) override;
966 value *evaluate (struct type *expect_type,
967 struct expression *exp,
968 enum noside noside) override;
971 class ada_concat_operation : public concat_operation
973 public:
975 using concat_operation::concat_operation;
977 value *evaluate (struct type *expect_type,
978 struct expression *exp,
979 enum noside noside) override;
982 } /* namespace expr */
984 #endif /* ADA_EXP_H */