gdb: Convert language la_compute_program field to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 1 Jun 2020 10:07:52 +0000 (11:07 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 17 Jun 2020 08:25:09 +0000 (09:25 +0100)
This commit changes the language_data::la_compute_program 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 (ada_language_data): Delete la_compute_program
initializer.
* c-lang.c (c_language_data): Likewise.
(c_language::compute_program): New member function.
(cplus_language_data): Delete la_compute_program initializer.
(cplus_language::compute_program): New member function.
(asm_language_data): Delete la_compute_program initializer.
(minimal_language_data): Likewise.
* c-lang.h (c_compute_program): Update comment.
(cplus_compute_program): Likewise.
* compile/compile-c-support.c (c_compute_program): Likewise.
(cplus_compute_program): Likewise.
* compile/compile.c (compile_to_object): Update call to
la_compute_program.
* d-lang.c (d_language_data): Delete la_compute_program
initializer.
* 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_compute_program field.
(language_defn::compute_program): New member function.
* m2-lang.c (m2_language_data): Delete la_compute_program
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.

16 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/c-lang.h
gdb/compile/compile-c-support.c
gdb/compile/compile.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/rust-lang.c

index 2aafc0ad8d94edf2bf4e9af86af84e6d9512bbbc..ae93dd6ed6de492dc6231b082d3426e2faf92dde 100644 (file)
@@ -1,3 +1,34 @@
+2020-06-17  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_language_data): Delete la_compute_program
+       initializer.
+       * c-lang.c (c_language_data): Likewise.
+       (c_language::compute_program): New member function.
+       (cplus_language_data): Delete la_compute_program initializer.
+       (cplus_language::compute_program): New member function.
+       (asm_language_data): Delete la_compute_program initializer.
+       (minimal_language_data): Likewise.
+       * c-lang.h (c_compute_program): Update comment.
+       (cplus_compute_program): Likewise.
+       * compile/compile-c-support.c (c_compute_program): Likewise.
+       (cplus_compute_program): Likewise.
+       * compile/compile.c (compile_to_object): Update call to
+       la_compute_program.
+       * d-lang.c (d_language_data): Delete la_compute_program
+       initializer.
+       * 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_compute_program field.
+       (language_defn::compute_program): New member function.
+       * m2-lang.c (m2_language_data): Delete la_compute_program
+       initializer.
+       * objc-lang.c (objc_language_data): Likewise.
+       * opencl-lang.c (opencl_language_data): Likewise.
+       * p-lang.c (pascal_language_data): Likewise.
+       * rust-lang.c (rust_language_data): Likewise.
+
 2020-06-17  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (ada_language_data) Delete
index 96cb8653d59496a17e570d4e009b96b1aebab313..5caa1716b78be79c14b7d73d1e5f13cdcc904b63 100644 (file)
@@ -13922,7 +13922,6 @@ extern const struct language_data ada_language_data =
   ada_watch_location_expression,
   ada_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
   &ada_varobj_ops,
-  NULL,
   ada_is_string_type,
   "(...)"                      /* la_struct_too_deep_ellipsis */
 };
index bb4970628d1a97239f01b6b3ff7f40bc0e706174..9d72c0e324b238d1b5aec6d92cd3894994f6a81e 100644 (file)
@@ -919,7 +919,6 @@ extern const struct language_data c_language_data =
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   &c_varobj_ops,
-  c_compute_program,
   c_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
@@ -946,6 +945,16 @@ public:
     return c_get_compile_context ();
   }
 
+  /* See language.h.  */
+  std::string compute_program (compile_instance *inst,
+                              const char *input,
+                              struct gdbarch *gdbarch,
+                              const struct block *expr_block,
+                              CORE_ADDR expr_pc) const override
+  {
+    return c_compute_program (inst, input, gdbarch, expr_block, expr_pc);
+  }
+
   /* See language.h.  */
 
   void print_type (struct type *type, const char *varstring,
@@ -1025,7 +1034,6 @@ extern const struct language_data cplus_language_data =
   c_watch_location_expression,
   cp_get_symbol_name_matcher,
   &cplus_varobj_ops,
-  cplus_compute_program,
   c_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
@@ -1122,6 +1130,16 @@ public:
     return cplus_get_compile_context ();
   }
 
+  /* See language.h.  */
+  std::string compute_program (compile_instance *inst,
+                              const char *input,
+                              struct gdbarch *gdbarch,
+                              const struct block *expr_block,
+                              CORE_ADDR expr_pc) const override
+  {
+    return cplus_compute_program (inst, input, gdbarch, expr_block, expr_pc);
+  }
+
   /* See language.h.  */
   unsigned int search_name_hash (const char *name) const override
   {
@@ -1209,7 +1227,6 @@ extern const struct language_data asm_language_data =
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   c_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
@@ -1280,7 +1297,6 @@ extern const struct language_data minimal_language_data =
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   c_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
index 3e07dc9c88d11569a489a8913ad3457adc183d5d..31ec6f2cf74c41fb302e5c25be9131bf20f70831 100644 (file)
@@ -172,7 +172,7 @@ extern compile_instance *cplus_get_compile_context ();
 /* This takes the user-supplied text and returns a new bit of code to
    compile.
 
-   This is used as the la_compute_program language method; see that
+   This is used as the compute_program language method; see that
    for a description of the arguments.  */
 
 extern std::string c_compute_program (compile_instance *inst,
@@ -183,7 +183,7 @@ extern std::string c_compute_program (compile_instance *inst,
 
 /* This takes the user-supplied text and returns a new bit of code to compile.
 
-   This is used as the la_compute_program language method; see that
+   This is used as the compute_program language method; see that
    for a description of the arguments.  */
 
 extern std::string cplus_compute_program (compile_instance *inst,
index 8499300179c06e121540a9743516c16a0a8874e2..5e4da6703a62e067874ed620f7cb77c1524a9c39 100644 (file)
@@ -660,7 +660,7 @@ typedef compile_program<compile_cplus_instance,
                        cplus_add_code_header, c_add_code_footer,
                        cplus_add_input> cplus_compile_program;
 
-/* The la_compute_program method for C.  */
+/* The compute_program method for C.  */
 
 std::string
 c_compute_program (compile_instance *inst,
@@ -675,7 +675,7 @@ c_compute_program (compile_instance *inst,
   return program.compute (input, expr_block, expr_pc);
 }
 
-/* The la_compute_program method for C++.  */
+/* The compute_program method for C++.  */
 
 std::string
 cplus_compute_program (compile_instance *inst,
index 3a3afa85736c7d676912ee49aa5047f11add9d0c..0c29a0476e7c65c5ffb60e659387f12e6dec6cc1 100644 (file)
@@ -724,8 +724,8 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
     error (_("Neither a simple expression, or a multi-line specified."));
 
   std::string code
-    = current_language->la_compute_program (compiler.get (), input, gdbarch,
-                                           expr_block, expr_pc);
+    = current_language->compute_program (compiler.get (), input, gdbarch,
+                                        expr_block, expr_pc);
   if (compile_debug)
     fprintf_unfiltered (gdb_stdlog, "debug output:\n\n%s", code.c_str ());
 
index 6dacf8ca4a435c20f84815dd37173eaa6eccecd0..ad16f991dd375e8aedada1b4d96cb2595d9c9d18 100644 (file)
@@ -162,7 +162,6 @@ extern const struct language_data d_language_data =
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   c_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
index 07ee2c8e6c632448f935511e9c953643fff8654b..d748db82e4ff33c1f4c0fe2a6f685423f51760cc 100644 (file)
@@ -622,7 +622,6 @@ extern const struct language_data f_language_data =
   c_watch_location_expression,
   cp_get_symbol_name_matcher,  /* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   f_is_string_type_p,
   "(...)"                      /* la_struct_too_deep_ellipsis */
 };
index 7b8d4a5e6eeddb57943c4f9972f43660fe471748..9196cd3c52bea692a5ef5ccb7628165e3f380f9e 100644 (file)
@@ -547,7 +547,6 @@ extern const struct language_data go_language_data =
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   go_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
index ade5109c9dc6acfcc7e297061d0b318bcf9ceb94..2b2584f49768996d846428bb296ee15972a1caa8 100644 (file)
@@ -776,7 +776,6 @@ extern const struct language_data unknown_language_data =
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   default_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
@@ -851,7 +850,6 @@ extern const struct language_data auto_language_data =
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   default_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
index 36fc2c55c583c338a6b6d3e1ade3a9d4d3f96396..523a7a923beb3b5db93f799c8e77deec59c73cac 100644 (file)
@@ -354,26 +354,6 @@ struct language_data
     /* Various operations on varobj.  */
     const struct lang_varobj_ops *la_varobj_ops;
 
-    /* This method must be defined if 'la_get_gcc_context' is defined.
-       If 'la_get_gcc_context' is not defined, then this method is
-       ignored.
-
-       This takes the user-supplied text and returns a new bit of code
-       to compile.
-
-       INST is the compiler instance being used.
-       INPUT is the user's input text.
-       GDBARCH is the architecture to use.
-       EXPR_BLOCK is the block in which the expression is being
-       parsed.
-       EXPR_PC is the PC at which the expression is being parsed.  */
-
-    std::string (*la_compute_program) (compile_instance *inst,
-                                      const char *input,
-                                      struct gdbarch *gdbarch,
-                                      const struct block *expr_block,
-                                      CORE_ADDR expr_pc);
-
     /* Return true if TYPE is a string type.  */
     bool (*la_is_string_type_p) (struct type *type);
 
@@ -476,6 +456,28 @@ struct language_defn : language_data
     return nullptr;
   }
 
+  /* This method must be overridden if 'get_compile_instance' is
+     overridden.
+
+     This takes the user-supplied text and returns a new bit of code
+     to compile.
+
+     INST is the compiler instance being used.
+     INPUT is the user's input text.
+     GDBARCH is the architecture to use.
+     EXPR_BLOCK is the block in which the expression is being
+     parsed.
+     EXPR_PC is the PC at which the expression is being parsed.  */
+
+  virtual std::string compute_program (compile_instance *inst,
+                                      const char *input,
+                                      struct gdbarch *gdbarch,
+                                      const struct block *expr_block,
+                                      CORE_ADDR expr_pc) const
+  {
+    gdb_assert_not_reached ("language_defn::compute_program");
+  }
+
   /* Hash the given symbol search name.  */
   virtual unsigned int search_name_hash (const char *name) const;
 
index 6cb3f7ddf61e944dc8069e010df861719da1a41a..87bf1eb63d58935e8ccc0d99bc6ab1d56971cb6f 100644 (file)
@@ -381,7 +381,6 @@ extern const struct language_data m2_language_data =
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   m2_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
index 631b2051f889176531a615f123ad6238a602a2fa..8b23c557984ad7bc63b84767d161b3a00a265d4e 100644 (file)
@@ -356,7 +356,6 @@ extern const struct language_data objc_language_data =
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   c_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
index ab19acfa4e47bb9cb33cd5e354444d986df694ad..00f88c60373a1de5ca63cf8f64b558ed2d8a08bf 100644 (file)
@@ -1035,7 +1035,6 @@ extern const struct language_data opencl_language_data =
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   c_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
index 2f77d7ae0ea8622fb76da4e806359f13f81799e0..869c89e926a6f1260e9e20638ba65d408f403765 100644 (file)
@@ -412,7 +412,6 @@ extern const struct language_data pascal_language_data =
   c_watch_location_expression,
   NULL,                                /* la_compare_symbol_for_completion */
   &default_varobj_ops,
-  NULL,
   pascal_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
index ada721f532785cbd21ce6b8ca13ffdab8978c822..296bfe1dcf7afce844c989b8a730734605d8c260 100644 (file)
@@ -2067,7 +2067,6 @@ extern const struct language_data rust_language_data =
   rust_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   rust_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };