Implement Ada assignment
Assignment is the most complicated Ada expression, because
implementing aggregate assignment involves several specialized
opcodes.
This patch does this implementation by introducing new abstract
classes that are used to represent the various parts of aggregate
assignment. This makes the code somewhat cleaner, and, by avoiding
the over-use of 'operation' subclasses, avoids the need for dissection
using dynamic_cast (though a few are still needed here).
I believe this patch fixes a latent bug in the handling of
aggregate_assign_from_choices. That code does:
if (op == OP_DISCRETE_RANGE)
{
choice_pos += 1;
lower = value_as_long (ada_evaluate_subexp (NULL, exp, pos,
EVAL_NORMAL));
upper = value_as_long (ada_evaluate_subexp (NULL, exp, pos,
EVAL_NORMAL));
}
However, I think 'choice_pos' should be used in the calls, rather than
'pos'.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* expprint.c (dump_for_expression): New overload.
* expop.h (check_objfile, dump_for_expression): Declare new
overloads.
* ada-lang.c (check_objfile): New overload.
(assign_component, ada_aggregate_component::uses_objfile)
(ada_aggregate_component::dump, ada_aggregate_component::assign)
(ada_aggregate_component::assign_aggregate)
(ada_positional_component::uses_objfile)
(ada_positional_component::dump, ada_positional_component::assign)
(ada_discrete_range_association::uses_objfile)
(ada_discrete_range_association::dump)
(ada_discrete_range_association::assign)
(ada_name_association::uses_objfile, ada_name_association::dump)
(ada_name_association::assign)
(ada_choices_component::uses_objfile, ada_choices_component::dump)
(ada_choices_component::assign)
(ada_others_component::uses_objfile, ada_others_component::dump)
(ada_others_component::assign, ada_assign_operation::evaluate):
New methods.
* ada-exp.h (ada_string_operation) <get_name>: New method.
(class ada_assign_operation): New.
(class ada_component): New.
(ada_component_up): New typedef.
(class ada_aggregate_operation, class ada_aggregate_component)
(class ada_positional_component, class ada_others_component)
(class ada_association): New.
(ada_association_up): New typedef.
(class ada_choices_component)
(class ada_discrete_range_association)
(class ada_name_association): New.