]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Convert language la_print_type field to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 14 May 2020 17:41:39 +0000 (18:41 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 2 Jun 2020 12:53:11 +0000 (13:53 +0100)
This commit changes the language_data::la_print_type 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_print_type
initializer.
(ada_language::print_type): New member function.
* c-lang.c (c_language_data): Delete la_print_type initializer.
(c_language::print_type): New member function.
(cplus_language_data): Delete la_print_type initializer.
(cplus_language::print_type): New member function.
(asm_language_data): Delete la_print_type initializer.
(asm_language::print_type): New member function.
(minimal_language_data): Delete la_print_type initializer.
(minimal_language::print_type): New member function.
* d-lang.c (d_language_data): Delete la_print_type initializer.
(d_language::print_type): New member function.
* f-lang.c (f_language_data): Delete la_print_type initializer.
(f_language::print_type): New member function.
* go-lang.c (go_language_data): Delete la_print_type initializer.
(go_language::print_type): New member function.
* language.c (unk_lang_print_type): Delete.
(unknown_language_data): Delete la_print_type initializer.
(unknown_language::print_type): New member function.
(auto_language_data): Delete la_print_type initializer.
(auto_language::print_type): New member function.
* language.h (language_data): Delete la_print_type field.
(language_defn::print_type): New function.
(LA_PRINT_TYPE): Update.
* m2-lang.c (m2_language_data): Delete la_print_type initializer.
(m2_language::print_type): New member function.
* objc-lang.c (objc_language_data): Delete la_print_type
initializer.
(objc_language::print_type): New member function.
* opencl-lang.c (opencl_print_type): Delete, implementation moved
to opencl_language::print_type.
(opencl_language_data): Delete la_print_type initializer.
(opencl_language::print_type): New member function, implementation
from opencl_print_type.
* p-lang.c (pascal_language_data): Delete la_print_type
initializer.
(pascal_language::print_type): New member function.
* rust-lang.c (rust_print_type): Delete, implementation moved to
rust_language::print_type.
(rust_language_data): Delete la_print_type initializer.
(rust_language::print_type): New member function, implementation
from rust_print_type.

13 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/rust-lang.c

index 46ca01139261eb5112de2ffe6f5d449c440d9ad5..bf690af9c4325fc8196acc98591bbac1b8c438fa 100644 (file)
@@ -1,3 +1,49 @@
+2020-06-02  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_language_data): Delete la_print_type
+       initializer.
+       (ada_language::print_type): New member function.
+       * c-lang.c (c_language_data): Delete la_print_type initializer.
+       (c_language::print_type): New member function.
+       (cplus_language_data): Delete la_print_type initializer.
+       (cplus_language::print_type): New member function.
+       (asm_language_data): Delete la_print_type initializer.
+       (asm_language::print_type): New member function.
+       (minimal_language_data): Delete la_print_type initializer.
+       (minimal_language::print_type): New member function.
+       * d-lang.c (d_language_data): Delete la_print_type initializer.
+       (d_language::print_type): New member function.
+       * f-lang.c (f_language_data): Delete la_print_type initializer.
+       (f_language::print_type): New member function.
+       * go-lang.c (go_language_data): Delete la_print_type initializer.
+       (go_language::print_type): New member function.
+       * language.c (unk_lang_print_type): Delete.
+       (unknown_language_data): Delete la_print_type initializer.
+       (unknown_language::print_type): New member function.
+       (auto_language_data): Delete la_print_type initializer.
+       (auto_language::print_type): New member function.
+       * language.h (language_data): Delete la_print_type field.
+       (language_defn::print_type): New function.
+       (LA_PRINT_TYPE): Update.
+       * m2-lang.c (m2_language_data): Delete la_print_type initializer.
+       (m2_language::print_type): New member function.
+       * objc-lang.c (objc_language_data): Delete la_print_type
+       initializer.
+       (objc_language::print_type): New member function.
+       * opencl-lang.c (opencl_print_type): Delete, implementation moved
+       to opencl_language::print_type.
+       (opencl_language_data): Delete la_print_type initializer.
+       (opencl_language::print_type): New member function, implementation
+       from opencl_print_type.
+       * p-lang.c (pascal_language_data): Delete la_print_type
+       initializer.
+       (pascal_language::print_type): New member function.
+       * rust-lang.c (rust_print_type): Delete, implementation moved to
+       rust_language::print_type.
+       (rust_language_data): Delete la_print_type initializer.
+       (rust_language::print_type): New member function, implementation
+       from rust_print_type.
+
 2020-06-02  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (ada_sniff_from_mangled_name): Delete function,
index 6bfc0256b66700d514ccbb9d4f7f0df1ea8c7d00..f84f02f897dc2817b49ff9d77f8b66fc0bf7b325 100644 (file)
@@ -13919,7 +13919,6 @@ extern const struct language_data ada_language_data =
   ada_printchar,                /* Print a character constant */
   ada_printstr,                 /* Function to print string constant */
   emit_char,                    /* Function to print single char (not used) */
-  ada_print_type,               /* Print a type using appropriate syntax */
   ada_print_typedef,            /* Print a typedef using appropriate syntax */
   ada_value_print_inner,       /* la_value_print_inner */
   ada_value_print,              /* Print a top-level value */
@@ -14106,6 +14105,15 @@ public:
 
     return false;
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    ada_print_type (type, varstring, stream, show, level, flags);
+  }
 };
 
 /* Single instance of the Ada language class.  */
index a5f7d822866cc9ef4e89ae01923450845adbc81c..abcdc52886705154a426996eaac171d95fcf26fd 100644 (file)
@@ -905,7 +905,6 @@ extern const struct language_data c_language_data =
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
-  c_print_type,                        /* Print a type using appropriate syntax */
   c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_value_print_inner,         /* la_value_print_inner */
   c_value_print,               /* Print a top-level value */
@@ -950,6 +949,15 @@ public:
   {
     return c_get_compile_context ();
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    c_print_type (type, varstring, stream, show, level, flags);
+  }
 };
 
 /* Single instance of the C language class.  */
@@ -1007,7 +1015,6 @@ extern const struct language_data cplus_language_data =
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
-  c_print_type,                        /* Print a type using appropriate syntax */
   c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_value_print_inner,         /* la_value_print_inner */
   c_value_print,               /* Print a top-level value */
@@ -1136,6 +1143,15 @@ public:
     *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
     return *demangled != NULL;
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    c_print_type (type, varstring, stream, show, level, flags);
+  }
 };
 
 /* The single instance of the C++ language class.  */
@@ -1165,7 +1181,6 @@ extern const struct language_data asm_language_data =
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
-  c_print_type,                        /* Print a type using appropriate syntax */
   c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_value_print_inner,         /* la_value_print_inner */
   c_value_print,               /* Print a top-level value */
@@ -1206,6 +1221,15 @@ public:
   {
     c_language_arch_info (gdbarch, lai);
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    c_print_type (type, varstring, stream, show, level, flags);
+  }
 };
 
 /* The single instance of the ASM language class.  */
@@ -1232,7 +1256,6 @@ extern const struct language_data minimal_language_data =
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
-  c_print_type,                        /* Print a type using appropriate syntax */
   c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_value_print_inner,         /* la_value_print_inner */
   c_value_print,               /* Print a top-level value */
@@ -1271,6 +1294,15 @@ public:
   {
     c_language_arch_info (gdbarch, lai);
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    c_print_type (type, varstring, stream, show, level, flags);
+  }
 };
 
 /* The single instance of the minimal language class.  */
index 23b9464cb58998bb96d6d1b629cb8ab49af6a526..815b59734e0dff62709e7b9379cb29df88edd754 100644 (file)
@@ -147,7 +147,6 @@ extern const struct language_data d_language_data =
   c_printchar,                 /* Print a character constant.  */
   c_printstr,                  /* Function to print string constant.  */
   c_emit_char,                 /* Print a single char.  */
-  c_print_type,                        /* Print a type using appropriate syntax.  */
   c_print_typedef,             /* Print a typedef using appropriate
                                   syntax.  */
   d_value_print_inner,         /* la_value_print_inner */
@@ -252,6 +251,15 @@ public:
     *demangled = d_demangle (mangled, 0);
     return *demangled != NULL;
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    c_print_type (type, varstring, stream, show, level, flags);
+  }
 };
 
 /* Single instance of the D language class.  */
index 804b2823f31e907cd163461bb0e61ebdcd75dbd9..1b0fec68c0ef50c67624490aecacd3f3ec03bb67 100644 (file)
@@ -608,7 +608,6 @@ extern const struct language_data f_language_data =
   f_printchar,                 /* Print character constant */
   f_printstr,                  /* function to print string constant */
   f_emit_char,                 /* Function to print a single character */
-  f_print_type,                        /* Print a type using appropriate syntax */
   f_print_typedef,             /* Print a typedef using appropriate syntax */
   f_value_print_innner,                /* la_value_print_inner */
   c_value_print,               /* FIXME */
@@ -690,6 +689,15 @@ public:
   {
     return cp_search_name_hash (name);
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    f_print_type (type, varstring, stream, show, level, flags);
+  }
 };
 
 /* Single instance of the Fortran language class.  */
index dce7e6ab76968f6b13cf2447470868ee85790f85..1ec53474cf005f9181e91930aa15c5ad3ad93bed 100644 (file)
@@ -532,7 +532,6 @@ extern const struct language_data go_language_data =
   c_printchar,                 /* Print a character constant.  */
   c_printstr,                  /* Function to print string constant.  */
   c_emit_char,                 /* Print a single char.  */
-  go_print_type,               /* Print a type using appropriate syntax.  */
   c_print_typedef,             /* Print a typedef using appropriate
                                   syntax.  */
   go_value_print_inner,                /* la_value_print_inner */
@@ -626,6 +625,15 @@ public:
     *demangled = go_demangle (mangled, 0);
     return *demangled != NULL;
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    go_print_type (type, varstring, stream, show, level, flags);
+  }
 };
 
 /* Single instance of the Go language class.  */
index 2a66f1fd6eaf8ff9c1aa4cde9a1616e2f6f46061..c8f0349901bd897cc223e32c946a0813973f8bcb 100644 (file)
@@ -727,15 +727,6 @@ unk_lang_printstr (struct ui_file *stream, struct type *type,
           "function unk_lang_printstr called."));
 }
 
-static void
-unk_lang_print_type (struct type *type, const char *varstring,
-                    struct ui_file *stream, int show, int level,
-                    const struct type_print_options *flags)
-{
-  error (_("internal error - unimplemented "
-          "function unk_lang_print_type called."));
-}
-
 static void
 unk_lang_value_print_inner (struct value *val,
                            struct ui_file *stream, int recurse,
@@ -802,7 +793,6 @@ extern const struct language_data unknown_language_data =
   unk_lang_printchar,          /* Print character constant */
   unk_lang_printstr,
   unk_lang_emit_char,
-  unk_lang_print_type,         /* Print a type using appropriate syntax */
   default_print_typedef,       /* Print a typedef using appropriate syntax */
   unk_lang_value_print_inner,  /* la_value_print_inner */
   unk_lang_value_print,                /* Print a top-level value */
@@ -841,6 +831,15 @@ public:
   {
     unknown_language_arch_info (gdbarch, lai);
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    error (_("unimplemented unknown_language::print_type called"));
+  }
 };
 
 /* Single instance of the unknown language class.  */
@@ -865,7 +864,6 @@ extern const struct language_data auto_language_data =
   unk_lang_printchar,          /* Print character constant */
   unk_lang_printstr,
   unk_lang_emit_char,
-  unk_lang_print_type,         /* Print a type using appropriate syntax */
   default_print_typedef,       /* Print a typedef using appropriate syntax */
   unk_lang_value_print_inner,  /* la_value_print_inner */
   unk_lang_value_print,                /* Print a top-level value */
@@ -904,6 +902,15 @@ public:
   {
     unknown_language_arch_info (gdbarch, lai);
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    error (_("unimplemented auto_language::print_type called"));
+  }
 };
 
 /* Single instance of the fake "auto" language.  */
index d5013bf83244bc8d443384b680092fb4aca74f6c..8defe9590159ab8794f36f108b5110412fb00abd 100644 (file)
@@ -248,11 +248,6 @@ struct language_data
     void (*la_emitchar) (int ch, struct type *chtype,
                         struct ui_file * stream, int quoter);
 
-    /* Print a type using syntax appropriate for this language.  */
-
-    void (*la_print_type) (struct type *, const char *, struct ui_file *, int,
-                          int, const struct type_print_options *);
-
     /* Print a typedef using syntax appropriate for this language.
        TYPE is the underlying type.  NEW_SYMBOL is the symbol naming
        the type.  STREAM is the output stream on which to print.  */
@@ -517,6 +512,11 @@ struct language_defn : language_data
     return false;
   }
 
+  /* Print a type using syntax appropriate for this language.  */
+
+  virtual void print_type (struct type *, const char *, struct ui_file *, int,
+                          int, const struct type_print_options *) const = 0;
+
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
 };
@@ -605,7 +605,7 @@ extern enum language set_language (enum language);
    with the "set language" command.  */
 
 #define LA_PRINT_TYPE(type,varstring,stream,show,level,flags)          \
-  (current_language->la_print_type(type,varstring,stream,show,level,flags))
+  (current_language->print_type(type,varstring,stream,show,level,flags))
 
 #define LA_PRINT_TYPEDEF(type,new_symbol,stream) \
   (current_language->la_print_typedef(type,new_symbol,stream))
index fbfdcff71f38bb80706bd0793a6d6f63b5d10d10..098a2aadd954bab90d3a48139a7f7647ee8fcbe3 100644 (file)
@@ -367,7 +367,6 @@ extern const struct language_data m2_language_data =
   m2_printchar,                        /* Print character constant */
   m2_printstr,                 /* function to print string constant */
   m2_emit_char,                        /* Function to print a single character */
-  m2_print_type,               /* Print a type using appropriate syntax */
   m2_print_typedef,            /* Print a typedef using appropriate syntax */
   m2_value_print_inner,                /* la_value_print_inner */
   c_value_print,               /* Print a top-level value */
@@ -425,6 +424,15 @@ public:
     lai->bool_type_symbol = "BOOLEAN";
     lai->bool_type_default = builtin->builtin_bool;
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    m2_print_type (type, varstring, stream, show, level, flags);
+  }
 };
 
 /* Single instance of the M2 language.  */
index 3082a5d058a0c6b3f1e2f313fd0de49ff55e93e5..0566ce8f1886e50df4cc6f3de8f011cfc45dd3c1 100644 (file)
@@ -373,7 +373,6 @@ extern const struct language_data objc_language_data =
   c_printchar,                /* Print a character constant */
   c_printstr,                 /* Function to print string constant */
   c_emit_char,
-  c_print_type,                        /* Print a type using appropriate syntax */
   c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_value_print_inner,         /* la_value_print_inner */
   c_value_print,               /* Print a top-level value */
@@ -420,6 +419,15 @@ public:
     *demangled = objc_demangle (mangled, 0);
     return *demangled != NULL;
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    c_print_type (type, varstring, stream, show, level, flags);
+  }
 };
 
 /* Single instance of the class representing the Objective-C language.  */
index 4080c51854f722f957a3885afbd98a655c983dfd..d1ca29d32f700c9304561f13ad9c20a6ae80e481 100644 (file)
@@ -994,27 +994,6 @@ Cannot perform conditional operation on vectors with different sizes"));
   return evaluate_subexp_c (expect_type, exp, pos, noside);
 }
 
-/* Print OpenCL types.  */
-
-static void
-opencl_print_type (struct type *type, const char *varstring,
-                  struct ui_file *stream, int show, int level,
-                  const struct type_print_options *flags)
-{
-  /* We nearly always defer to C type printing, except that vector
-     types are considered primitive in OpenCL, and should always
-     be printed using their TYPE_NAME.  */
-  if (show > 0)
-    {
-      type = check_typedef (type);
-      if (type->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type)
-         && type->name () != NULL)
-       show = 0;
-    }
-
-  c_print_type (type, varstring, stream, show, level, flags); 
-}
-
 const struct exp_descriptor exp_descriptor_opencl =
 {
   print_subexp_standard,
@@ -1042,7 +1021,6 @@ extern const struct language_data opencl_language_data =
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
-  opencl_print_type,           /* Print a type using appropriate syntax */
   c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_value_print_inner,         /* la_value_print_inner */
   c_value_print,               /* Print a top-level value */
@@ -1091,6 +1069,26 @@ public:
     lai->bool_type_symbol = "int";
     lai->bool_type_default = types [opencl_primitive_type_int];
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    /* We nearly always defer to C type printing, except that vector types
+       are considered primitive in OpenCL, and should always be printed
+       using their TYPE_NAME.  */
+    if (show > 0)
+      {
+       type = check_typedef (type);
+       if (type->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type)
+           && type->name () != NULL)
+         show = 0;
+      }
+
+    c_print_type (type, varstring, stream, show, level, flags);
+  }
 };
 
 /* Single instance of the OpenCL language class.  */
index 8d96dd15832608433febd68afba4b1e96e6db04d..9aa03de6a59f617d51f847bf32660ff68b689c98 100644 (file)
@@ -398,7 +398,6 @@ extern const struct language_data pascal_language_data =
   pascal_printchar,            /* Print a character constant */
   pascal_printstr,             /* Function to print string constant */
   pascal_emit_char,            /* Print a single char */
-  pascal_print_type,           /* Print a type using appropriate syntax */
   pascal_print_typedef,                /* Print a typedef using appropriate syntax */
   pascal_value_print_inner,    /* la_value_print_inner */
   pascal_value_print,          /* Print a top-level value */
@@ -478,6 +477,15 @@ public:
     lai->bool_type_symbol = "boolean";
     lai->bool_type_default = builtin->builtin_bool;
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    pascal_print_type (type, varstring, stream, show, level, flags);
+  }
 };
 
 /* Single instance of the Pascal language class.  */
index d75f34d0d9a4c39019540086046be4bbe7507703..f78686ae1c8d0b70d5b2139492ad01a09a46aa63 100644 (file)
@@ -951,16 +951,6 @@ rust_internal_print_type (struct type *type, const char *varstring,
     }
 }
 
-static void
-rust_print_type (struct type *type, const char *varstring,
-                struct ui_file *stream, int show, int level,
-                const struct type_print_options *flags)
-{
-  print_offset_data podata;
-  rust_internal_print_type (type, varstring, stream, show, level,
-                           flags, false, &podata);
-}
-
 \f
 
 /* Like arch_composite_type, but uses TYPE to decide how to allocate
@@ -2063,7 +2053,6 @@ extern const struct language_data rust_language_data =
   rust_printchar,              /* Print a character constant */
   rust_printstr,               /* Function to print string constant */
   rust_emitchar,               /* Print a single char */
-  rust_print_type,             /* Print a type using appropriate syntax */
   rust_print_typedef,          /* Print a typedef using appropriate syntax */
   rust_value_print_inner,      /* la_value_print_inner */
   c_value_print,               /* Print a top-level value */
@@ -2144,6 +2133,17 @@ public:
     *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
     return *demangled != NULL;
   }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    print_offset_data podata;
+    rust_internal_print_type (type, varstring, stream, show, level,
+                             flags, false, &podata);
+  }
 };
 
 /* Single instance of the Rust language class.  */