]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Convert language la_post_parser field to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 2 Jun 2020 13:57:40 +0000 (14:57 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 23 Jun 2020 12:34:11 +0000 (13:34 +0100)
This commit changes the language_data::la_post_parser function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (resolve): Rename to ada_language::post_parser.
(ada_language_data): Delete la_post_parser initializer.
(ada_language::post_parser): New member function.
* c-lang.c (c_language_data): Delete la_post_parser initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_post_parser field.
(language_defn::post_parser): New member function.
* m2-lang.c (m2_language_data): Delete la_post_parser initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* parse.c (parse_exp_in_context): Update call to post_parser.
(null_post_parser): Delete definition.
* parser-defs.h (null_post_parser): Delete declaration.
* rust-lang.c (rust_language_data): Delete la_post_parser
initializer.

15 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/d-lang.c
gdb/f-lang.c
gdb/go-lang.c
gdb/language.c
gdb/language.h
gdb/m2-lang.c
gdb/objc-lang.c
gdb/opencl-lang.c
gdb/p-lang.c
gdb/parse.c
gdb/parser-defs.h
gdb/rust-lang.c

index a0e120d67666c8764c3ff4bdbe0ef3c053dd19b4..098014a42980d927e3689a5e169815b3e46b5fac 100644 (file)
@@ -1,3 +1,29 @@
+2020-06-23  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (resolve): Rename to ada_language::post_parser.
+       (ada_language_data): Delete la_post_parser initializer.
+       (ada_language::post_parser): New member function.
+       * c-lang.c (c_language_data): Delete la_post_parser initializer.
+       (cplus_language_data): Likewise.
+       (asm_language_data): Likewise.
+       (minimal_language_data): Likewise.
+       * d-lang.c (d_language_data): Likewise.
+       * f-lang.c (f_language_data): Likewise.
+       * go-lang.c (go_language_data): Likewise.
+       * language.c (unknown_language_data): Likewise.
+       (auto_language_data): Likewise.
+       * language.h (language_data): Delete la_post_parser field.
+       (language_defn::post_parser): New member function.
+       * m2-lang.c (m2_language_data): Delete la_post_parser initializer.
+       * objc-lang.c (objc_language_data): Likewise.
+       * opencl-lang.c (opencl_language_data): Likewise.
+       * p-lang.c (pascal_language_data): Likewise.
+       * parse.c (parse_exp_in_context): Update call to post_parser.
+       (null_post_parser): Delete definition.
+       * parser-defs.h (null_post_parser): Delete declaration.
+       * rust-lang.c (rust_language_data): Delete la_post_parser
+       initializer.
+
 2020-06-23  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (parse): Rename to ada_language::parser.
index c4ee79eb8df7b4f02dac29014c41af4f6fef32db..bb6d011e13eea6e8be048ba65219688c5b94807a 100644 (file)
@@ -3360,28 +3360,6 @@ See set/show multiple-symbol."));
   return n_chosen;
 }
 
-/* Same as evaluate_type (*EXP), but resolves ambiguous symbol
-   references (marked by OP_VAR_VALUE nodes in which the symbol has an
-   undefined namespace) and converts operators that are
-   user-defined into appropriate function calls.  If CONTEXT_TYPE is
-   non-null, it provides a preferred result type [at the moment, only
-   type void has any effect---causing procedures to be preferred over
-   functions in calls].  A null CONTEXT_TYPE indicates that a non-void
-   return type is preferred.  May change (expand) *EXP.  */
-
-static void
-resolve (expression_up *expp, int void_context_p, int parse_completion,
-        innermost_block_tracker *tracker)
-{
-  struct type *context_type = NULL;
-  int pc = 0;
-
-  if (void_context_p)
-    context_type = builtin_type ((*expp)->gdbarch)->builtin_void;
-
-  resolve_subexp (expp, &pc, 1, context_type, parse_completion, tracker);
-}
-
 /* Resolve the operator of the subexpression beginning at
    position *POS of *EXPP.  "Resolving" consists of replacing
    the symbols that have undefined namespaces in OP_VAR_VALUE nodes
@@ -13711,7 +13689,6 @@ extern const struct language_data ada_language_data =
   macro_expansion_no,
   ada_extensions,
   &ada_exp_descriptor,
-  resolve,
   ada_printchar,                /* Print a character constant */
   ada_printstr,                 /* Function to print string constant */
   emit_char,                    /* Function to print single char (not used) */
@@ -14116,6 +14093,29 @@ public:
     return ada_parse (ps);
   }
 
+  /* See language.h.
+
+     Same as evaluate_type (*EXP), but resolves ambiguous symbol references
+     (marked by OP_VAR_VALUE nodes in which the symbol has an undefined
+     namespace) and converts operators that are user-defined into
+     appropriate function calls.  If CONTEXT_TYPE is non-null, it provides
+     a preferred result type [at the moment, only type void has any
+     effect---causing procedures to be preferred over functions in calls].
+     A null CONTEXT_TYPE indicates that a non-void return type is
+     preferred.  May change (expand) *EXP.  */
+
+  void post_parser (expression_up *expp, int void_context_p, int completing,
+                   innermost_block_tracker *tracker) const override
+  {
+    struct type *context_type = NULL;
+    int pc = 0;
+
+    if (void_context_p)
+      context_type = builtin_type ((*expp)->gdbarch)->builtin_void;
+
+    resolve_subexp (expp, &pc, 1, context_type, completing, tracker);
+  }
+
 protected:
   /* See language.h.  */
 
index 37e69d433f0d782f779150f02ac3623031b915ff..363c896b7a931f8d6cf7d6a5f596860eed67a1f1 100644 (file)
@@ -889,7 +889,6 @@ extern const struct language_data c_language_data =
   macro_expansion_c,
   c_extensions,
   &exp_descriptor_c,
-  null_post_parser,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
@@ -996,7 +995,6 @@ extern const struct language_data cplus_language_data =
   macro_expansion_c,
   cplus_extensions,
   &exp_descriptor_c,
-  null_post_parser,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
@@ -1200,7 +1198,6 @@ extern const struct language_data asm_language_data =
   macro_expansion_c,
   asm_extensions,
   &exp_descriptor_c,
-  null_post_parser,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
@@ -1262,7 +1259,6 @@ extern const struct language_data minimal_language_data =
   macro_expansion_c,
   NULL,
   &exp_descriptor_c,
-  null_post_parser,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
index e2765b5671e66f42da122cf4599b67e44d5e0f08..facc82c2019d9cc815d5bb39a8d6e8af7ad4df23 100644 (file)
@@ -142,7 +142,6 @@ extern const struct language_data d_language_data =
   macro_expansion_no,
   d_extensions,
   &exp_descriptor_c,
-  null_post_parser,
   c_printchar,                 /* Print a character constant.  */
   c_printstr,                  /* Function to print string constant.  */
   c_emit_char,                 /* Print a single char.  */
index 918a8cfd3dc9bb60843c1eb6a08206f2d16929a9..1b545b27b3b9273cb217bdd102189202d731dd88 100644 (file)
@@ -564,7 +564,6 @@ extern const struct language_data f_language_data =
   macro_expansion_no,
   f_extensions,
   &exp_descriptor_f,
-  null_post_parser,
   f_printchar,                 /* Print character constant */
   f_printstr,                  /* function to print string constant */
   f_emit_char,                 /* Function to print a single character */
index f2553bb3992b9a98d4531808ceee5569d1f193f1..c26dee9a063c79f1d86ecf351e37e4c24933e4c6 100644 (file)
@@ -527,7 +527,6 @@ extern const struct language_data go_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_c,
-  null_post_parser,
   c_printchar,                 /* Print a character constant.  */
   c_printstr,                  /* Function to print string constant.  */
   c_emit_char,                 /* Print a single char.  */
index 828d21dc7e08f0bda301a5496b66f5344b45df00..72fa1e451343d2644cc7fbbbd65eed566520972c 100644 (file)
@@ -777,7 +777,6 @@ extern const struct language_data unknown_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_standard,
-  null_post_parser,
   unk_lang_printchar,          /* Print character constant */
   unk_lang_printstr,
   unk_lang_emit_char,
@@ -868,7 +867,6 @@ extern const struct language_data auto_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_standard,
-  null_post_parser,
   unk_lang_printchar,          /* Print character constant */
   unk_lang_printstr,
   unk_lang_emit_char,
index 7434d74523be90a5592657f3a66f6d35c880c123..d5b106d84e914a681365e822737f2cbc87677ca9 100644 (file)
@@ -225,17 +225,6 @@ struct language_data
 
     const struct exp_descriptor *la_exp_desc;
 
-    /* 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.  */
-
-    void (*la_post_parser) (expression_up *expp, int void_context_p,
-                           int completing, innermost_block_tracker *tracker);
-
     void (*la_printchar) (int ch, struct type *chtype,
                          struct ui_file * stream);
 
@@ -540,6 +529,21 @@ struct language_defn : language_data
 
   virtual int parser (struct parser_state *ps) const;
 
+  /* 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, int void_context_p,
+                           int completing,
+                           innermost_block_tracker *tracker) const
+  {
+    /* By default the post-parser does nothing.  */
+  }
+
 protected:
 
   /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
index 189f513605781c0b0a1fbe0335d7692567bf98c3..5aca83349618392522bcb204caf6141188b50717 100644 (file)
@@ -362,7 +362,6 @@ extern const struct language_data m2_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_modula2,
-  null_post_parser,
   m2_printchar,                        /* Print character constant */
   m2_printstr,                 /* function to print string constant */
   m2_emit_char,                        /* Function to print a single character */
index 90804acc16504ca5b4b2a4e6d1c541cf7b5cb183..2ec87774f439b2d525fb2a0ce7daa1516002b29c 100644 (file)
@@ -337,7 +337,6 @@ extern const struct language_data objc_language_data =
   macro_expansion_c,
   objc_extensions,
   &exp_descriptor_standard,
-  null_post_parser,
   c_printchar,                /* Print a character constant */
   c_printstr,                 /* Function to print string constant */
   c_emit_char,
index 7c9965814ff2734747137e2c84d30552affdace8..f314eff55f3e480dad7baa499f992538f2c6f556 100644 (file)
@@ -1016,7 +1016,6 @@ extern const struct language_data opencl_language_data =
   macro_expansion_c,
   NULL,
   &exp_descriptor_opencl,
-  null_post_parser,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
index ce812d1d3062acb6a20566493143125d0598ea76..14ca5d78338ae0661bb1a90abe1ab09f6f23c964 100644 (file)
@@ -393,7 +393,6 @@ extern const struct language_data pascal_language_data =
   macro_expansion_no,
   p_extensions,
   &exp_descriptor_standard,
-  null_post_parser,
   pascal_printchar,            /* Print a character constant */
   pascal_printstr,             /* Function to print string constant */
   pascal_emit_char,            /* Print a single char */
index f003a30bafaf3950cf0c31755da76ad84b05f578..2fb474e27f1d2db651afbe876f2c94bdbadc7b1a 100644 (file)
@@ -1146,8 +1146,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
   if (out_subexp)
     *out_subexp = subexp;
 
-  lang->la_post_parser (&result, void_context_p, ps.parse_completion,
-                       tracker);
+  lang->post_parser (&result, void_context_p, ps.parse_completion, tracker);
 
   if (expressiondebug)
     dump_prefix_expression (result.get (), gdb_stdlog);
@@ -1241,14 +1240,6 @@ parse_expression_for_completion (const char *string,
   return value_type (val);
 }
 
-/* A post-parser that does nothing.  */
-
-void
-null_post_parser (expression_up *exp, int void_context_p, int completin,
-                 innermost_block_tracker *tracker)
-{
-}
-
 /* Parse floating point value P of length LEN.
    Return false if invalid, true if valid.
    The successfully parsed number is stored in DATA in
index d6c3b068978efed010263ad85cdea2460344fd50..a9b8a12959b29e258d6ed73bbe949e762634f724 100644 (file)
@@ -350,9 +350,6 @@ extern int operator_check_standard (struct expression *exp, int pos,
 
 extern const char *op_name_standard (enum exp_opcode);
 
-extern void null_post_parser (expression_up *, int, int,
-                             innermost_block_tracker *);
-
 extern bool parse_float (const char *p, int len,
                         const struct type *type, gdb_byte *data);
 \f
index 2153323cff05303062d86c173746ff1561a9759d..846fe1fa40a4dd52fc42919ec7f907e4cc24f133 100644 (file)
@@ -1989,7 +1989,6 @@ extern const struct language_data rust_language_data =
   macro_expansion_no,
   rust_extensions,
   &exp_descriptor_rust,
-  null_post_parser,
   rust_printchar,              /* Print a character constant */
   rust_printstr,               /* Function to print string constant */
   rust_emitchar,               /* Print a single char */