[04/11] Simplify parser_state constructor

Message ID 20230504-frameless-v1-4-4191201740b0@adacore.com
State New
Headers
Series Fix frame-less expression evaluation in DAP |

Commit Message

Tom Tromey May 4, 2023, 2:21 p.m. UTC
  This simplifies the parser_state constructor by having it accept a
parser_flags parameter.
---
 gdb/parse.c       | 7 ++-----
 gdb/parser-defs.h | 9 ++++-----
 gdb/rust-parse.c  | 2 +-
 3 files changed, 7 insertions(+), 11 deletions(-)
  

Patch

diff --git a/gdb/parse.c b/gdb/parse.c
index ed0d0b8a880..2f014dd2172 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -398,11 +398,8 @@  parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
      to the value matching SELECTED_FRAME as set by get_current_arch.  */
 
   parser_state ps (lang, get_current_arch (), expression_context_block,
-		   expression_context_pc,
-		   (flags & PARSER_COMMA_TERMINATES) != 0,
-		   *stringptr,
-		   completer != nullptr, tracker,
-		   (flags & PARSER_VOID_CONTEXT) != 0);
+		   expression_context_pc, flags, *stringptr,
+		   completer != nullptr, tracker);
 
   scoped_restore_current_language lang_saver;
   set_language (lang->la_language);
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 5c6bc222b6b..2a246ff38f0 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -146,19 +146,18 @@  struct parser_state : public expr_builder
 		struct gdbarch *gdbarch,
 		const struct block *context_block,
 		CORE_ADDR context_pc,
-		int comma,
+		parser_flags flags,
 		const char *input,
 		bool completion,
-		innermost_block_tracker *tracker,
-		bool void_p)
+		innermost_block_tracker *tracker)
     : expr_builder (lang, gdbarch),
       expression_context_block (context_block),
       expression_context_pc (context_pc),
-      comma_terminates (comma),
+      comma_terminates ((flags & PARSER_COMMA_TERMINATES) != 0),
       lexptr (input),
       parse_completion (completion),
       block_tracker (tracker),
-      void_context_p (void_p)
+      void_context_p ((flags & PARSER_VOID_CONTEXT) != 0)
   {
   }
 
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index 648e48dda40..6ba959065c9 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -2300,7 +2300,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, false);
+			  nullptr, 0, 0, nullptr, 0, nullptr);
   rust_parser parser (&ps);
 
   rust_lex_test_one (&parser, "", 0);