From: Tom Tromey Date: Wed, 16 Dec 2020 22:49:40 +0000 (-0700) Subject: Change parameters to language_defn::post_parser X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c5c412054ebeb9e9c9dcbb36692b1d6235eb6106;p=binutils-gdb.git Change parameters to language_defn::post_parser In the expression rewrite, Ada type resolution will be done at parse time rather than in a post-parse pass. At this point, language_defn::post_parser will be removed. However, for this to work, the information available to post_parser must be made available during the actual parse. This patch refactors this code slightly to make this possible. In particular, "void_context_p" is passed to the parser_state constructor, and the parser state is then passed to the post_parser method. gdb/ChangeLog 2020-12-16 Tom Tromey * rust-exp.y (rust_lex_tests): Update. * parser-defs.h (parser_state): Add void_p parameter. : New member. * parse.c (parse_exp_in_context): Update. * language.h (language_defn::post_parser): Remove void_context_p, completing, tracker parameters. Add parser state. * ada-lang.c (ada_language::post_parser): Update. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7b8e727b58c..8066c76b9f0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2020-12-16 Tom Tromey + + * rust-exp.y (rust_lex_tests): Update. + * parser-defs.h (parser_state): Add void_p parameter. + : New member. + * parse.c (parse_exp_in_context): Update. + * language.h (language_defn::post_parser): Remove void_context_p, + completing, tracker parameters. Add parser state. + * ada-lang.c (ada_language::post_parser): Update. + 2020-12-16 Tom Tromey * parse.c (parse_exp_1, parse_expression_for_completion): Update. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 23d7a164609..75ad33344f8 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -14124,16 +14124,17 @@ public: A null CONTEXT_TYPE indicates that a non-void return type is preferred. May change (expand) *EXP. */ - void post_parser (expression_up *expp, bool void_context_p, int completing, - innermost_block_tracker *tracker) const override + void post_parser (expression_up *expp, struct parser_state *ps) + const override { struct type *context_type = NULL; int pc = 0; - if (void_context_p) + if (ps->void_context_p) context_type = builtin_type ((*expp)->gdbarch)->builtin_void; - resolve_subexp (expp, &pc, 1, context_type, completing, tracker); + resolve_subexp (expp, &pc, 1, context_type, ps->parse_completion, + ps->block_tracker); } /* See language.h. */ diff --git a/gdb/language.h b/gdb/language.h index 5bc99d5f241..73ddd24f228 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -522,14 +522,10 @@ struct language_defn /* Given an expression *EXPP created by prefixifying the result of la_parser, perform any remaining processing necessary to complete its translation. *EXPP may change; la_post_parser is responsible for - releasing its previous contents, if necessary. If VOID_CONTEXT_P, - then no value is expected from the expression. If COMPLETING is - non-zero, then the expression has been parsed for completion, not - evaluation. */ - - virtual void post_parser (expression_up *expp, bool void_context_p, - int completing, - innermost_block_tracker *tracker) const + releasing its previous contents, if necessary. */ + + virtual void post_parser (expression_up *expp, struct parser_state *ps) + const { /* By default the post-parser does nothing. */ } diff --git a/gdb/parse.c b/gdb/parse.c index a27ae86c001..80a67c6c707 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -1113,7 +1113,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc, parser_state ps (lang, get_current_arch (), expression_context_block, expression_context_pc, comma, *stringptr, - cstate != nullptr, tracker); + cstate != nullptr, tracker, void_context_p); scoped_restore_current_language lang_saver; set_language (lang->la_language); @@ -1147,7 +1147,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc, if (out_subexp) *out_subexp = subexp; - lang->post_parser (&result, void_context_p, ps.parse_completion, tracker); + lang->post_parser (&result, &ps); if (expressiondebug) dump_prefix_expression (result.get (), gdb_stdlog); diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index 17216057b18..56ac5edf627 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -109,14 +109,16 @@ struct parser_state : public expr_builder int comma, const char *input, int completion, - innermost_block_tracker *tracker) + innermost_block_tracker *tracker, + bool void_p) : expr_builder (lang, gdbarch), expression_context_block (context_block), expression_context_pc (context_pc), comma_terminates (comma), lexptr (input), parse_completion (completion), - block_tracker (tracker) + block_tracker (tracker), + void_context_p (void_p) { } @@ -192,6 +194,9 @@ struct parser_state : public expr_builder /* The innermost block tracker. */ innermost_block_tracker *block_tracker; + /* True if no value is expected from the expression. */ + bool void_context_p; + private: /* Data structure for saving values of arglist_len for function calls whose diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y index 1207d1d6f42..c354b7fbab2 100644 --- a/gdb/rust-exp.y +++ b/gdb/rust-exp.y @@ -2732,7 +2732,7 @@ rust_lex_tests (void) /* Set up dummy "parser", so that rust_type works. */ struct parser_state ps (language_def (language_rust), target_gdbarch (), - nullptr, 0, 0, nullptr, 0, nullptr); + nullptr, 0, 0, nullptr, 0, nullptr, false); rust_parser parser (&ps); rust_lex_test_one (&parser, "", 0);