aboutsummaryrefslogtreecommitdiff
path: root/gdb/expop.h
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/expop.h
parentd8a4ed8ad1b5d93b78efbd635d41f706902e2379 (diff)
downloadgdb-a88c43542dfa0eb5606613cb8ac249bdb1d61b13.zip
gdb-a88c43542dfa0eb5606613cb8ac249bdb1d61b13.tar.gz
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/expop.h')
-rw-r--r--gdb/expop.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/expop.h b/gdb/expop.h
index 44d9d2e..9a9c6bc 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -207,6 +207,8 @@ extern struct value *eval_binop_assign_modify (struct type *expect_type,
namespace expr
{
+class ada_component;
+
/* The check_objfile overloads are used to check whether a particular
component of some operation references an objfile. The passed-in
objfile will never be a debug objfile. */
@@ -306,6 +308,9 @@ check_objfile (const std::pair<S, T> &item, struct objfile *objfile)
|| check_objfile (item.second, objfile));
}
+extern bool check_objfile (const std::unique_ptr<ada_component> &comp,
+ struct objfile *objfile);
+
static inline void
dump_for_expression (struct ui_file *stream, int depth,
const operation_up &op)
@@ -337,6 +342,8 @@ extern void dump_for_expression (struct ui_file *stream, int depth,
enum range_flag flags);
extern void dump_for_expression (struct ui_file *stream, int depth,
objfile *objf);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ const std::unique_ptr<ada_component> &comp);
template<typename T>
void