aboutsummaryrefslogtreecommitdiff
path: root/gdb/expprint.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:36 -0700
commita88c43542dfa0eb5606613cb8ac249bdb1d61b13 (patch)
tree3952527b944f4c96bf06b909e2e2dff3bcfb1ac9 /gdb/expprint.c
parentd8a4ed8ad1b5d93b78efbd635d41f706902e2379 (diff)
downloadfsf-binutils-gdb-a88c43542dfa0eb5606613cb8ac249bdb1d61b13.zip
fsf-binutils-gdb-a88c43542dfa0eb5606613cb8ac249bdb1d61b13.tar.gz
fsf-binutils-gdb-a88c43542dfa0eb5606613cb8ac249bdb1d61b13.tar.bz2
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.
Diffstat (limited to 'gdb/expprint.c')
-rw-r--r--gdb/expprint.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 5826108..92a3ab8 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -32,6 +32,7 @@
#include "cli/cli-style.h"
#include "c-lang.h"
#include "expop.h"
+#include "ada-exp.h"
#include <ctype.h>
@@ -1284,6 +1285,13 @@ dump_for_expression (struct ui_file *stream, int depth,
}
void
+dump_for_expression (struct ui_file *stream, int depth,
+ const std::unique_ptr<ada_component> &comp)
+{
+ comp->dump (stream, depth);
+}
+
+void
float_const_operation::dump (struct ui_file *stream, int depth) const
{
fprintf_filtered (stream, _("%*sFloat: "), depth, "");