Re: [PATCH 169/203] Implement Ada resolution

Joel Brobecker
2021-01-03T07:57:57Z

Hi Tom,

Just a tiny question below...

On Fri, Jan 01, 2021 at 02:46:49PM -0700, Tom Tromey wrote:
> Ada has a parser post-pass that implements "resolution". This process
> replaces some opcodes with function calls. For example, a "+"
> operation might be replaced with a call to the appropriate overloaded
> function.
>
> This differs from the approach taken for the same problem in C++.
> However, in this series I chose not to try to make changes outside of
> rewrite the expression data structure. So, resolution remains.
>
> The new approach to resolution is to introduce an interface class,
> that some concrete operations implement. Then, the Ada code will use
> this to resolve the expression tree. Because new-style expressions
> are built as ordinary objects, and don't require rewriting the data
> structure in place, in the new code this processing will be done in
> the parser. By the end of the series, some special cases in this area
> that exist only for Ada will be removed.
>
> gdb/ChangeLog
> 2021-01-01 Tom Tromey <tom@tromey.com>
>
> * ada-lang.c (ada_var_value_operation::resolve)
> (ada_funcall_operation::resolve): New methods.
> * ada-exp.h (struct ada_resolvable): New.
> (class ada_var_value_operation): Derive from ada_resolvable.
> <get_block, resolve>: New methods.
> (class ada_funcall_operation): Derive from ada_resolvable.
> <resolve>: New method.
> ---
> gdb/ChangeLog | 10 ++++++++
> gdb/ada-exp.h | 38 ++++++++++++++++++++++++++++--
> gdb/ada-lang.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 109 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
> index 287ed5cc62c..2c5696cab76 100644
> --- a/gdb/ada-exp.h
> +++ b/gdb/ada-exp.h
> @@ -304,9 +304,27 @@ class ada_unop_atr_operation
> { return std::get<1> (m_storage); }
> };
>
> +/* The base class for Ada type resolution. Ada operations that want
> + to participate in resolution implement this interface. */
> +struct ada_resolvable
> +{
> + /* Resolve this object. EXP is the expression being resolved.
> + DEPROCEDURE_P is true if de-proceduring is desired.

What does it mean "de-proceduring is desired"?

> + PARSE_COMPLETION and TRACKER are passed in from the parser
> + context. CONTEXT_TYPE is the expected type of the expression, or
> + nullptr if none is known. This method should return true if the
> + operation should be replaced by a function call with this object
> + as the callee. */

--
Joel