gdb: Convert language la_demangle field to a method
[deliverable/binutils-gdb.git] / gdb / language.c
index b3cbd6aadef333b4f7ac4344ad43bb6d455da4e8..c447eaba0c5540a64cdf10715eb2628d687e729c 100644 (file)
@@ -589,28 +589,11 @@ char *
 language_demangle (const struct language_defn *current_language, 
                                const char *mangled, int options)
 {
-  if (current_language != NULL && current_language->la_demangle)
-    return current_language->la_demangle (mangled, options);
+  if (current_language != NULL)
+    return current_language->demangle (mangled, options);
   return NULL;
 }
 
-/* See language.h.  */
-
-int
-language_sniff_from_mangled_name (const struct language_defn *lang,
-                                 const char *mangled, char **demangled)
-{
-  gdb_assert (lang != NULL);
-
-  if (lang->la_sniff_from_mangled_name == NULL)
-    {
-      *demangled = NULL;
-      return 0;
-    }
-
-  return lang->la_sniff_from_mangled_name (mangled, demangled);
-}
-
 /* Return class name from physname or NULL.  */
 char *
 language_class_name_from_physname (const struct language_defn *lang,
@@ -627,17 +610,7 @@ language_class_name_from_physname (const struct language_defn *lang,
 struct language_pass_by_ref_info
 language_pass_by_reference (struct type *type)
 {
-  return current_language->la_pass_by_reference (type);
-}
-
-/* Return a default struct that provides pass-by-reference information
-   about the given TYPE.  Languages should update the default values
-   as appropriate.  */
-
-struct language_pass_by_ref_info
-default_pass_by_reference (struct type *type)
-{
-  return {};
+  return current_language->pass_by_reference_info (type);
 }
 
 /* Return the default string containing the list of characters
@@ -650,12 +623,12 @@ default_word_break_characters (void)
   return " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,-";
 }
 
-/* Print the index of array elements using the C99 syntax.  */
+/* See language.h.  */
 
 void
-default_print_array_index (struct type *index_type, LONGEST index,
-                          struct ui_file *stream,
-                          const struct value_print_options *options)
+language_defn::print_array_index (struct type *index_type, LONGEST index,
+                                 struct ui_file *stream,
+                                 const value_print_options *options) const
 {
   struct value *index_value = value_from_longest (index_type, index);
 
@@ -754,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,
@@ -785,12 +749,6 @@ static CORE_ADDR unk_lang_trampoline (struct frame_info *frame, CORE_ADDR pc)
   return 0;
 }
 
-/* Unknown languages just use the cplus demangler.  */
-static char *unk_lang_demangle (const char *mangled, int options)
-{
-  return gdb_demangle (mangled, options);
-}
-
 static char *unk_lang_class_name (const char *mangled)
 {
   return NULL;
@@ -829,18 +787,13 @@ 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 */
-  default_read_var_value,      /* la_read_var_value */
   unk_lang_trampoline,         /* Language specific skip_trampoline */
   "this",                      /* name_of_this */
   true,                                /* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
-  basic_lookup_transparent_type,/* lookup_transparent_type */
-  unk_lang_demangle,           /* Language specific symbol demangler */
-  NULL,
   unk_lang_class_name,         /* Language specific
                                   class_name_from_physname */
   unk_op_print_tab,            /* expression operators for printing */
@@ -848,16 +801,10 @@ extern const struct language_data unknown_language_data =
   0,                           /* String lower bound */
   default_word_break_characters,
   default_collect_symbol_completion_matches,
-  unknown_language_arch_info,  /* la_language_arch_info.  */
-  default_print_array_index,
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
-  iterate_over_symbols,
-  default_search_name_hash,
   &default_varobj_ops,
   NULL,
-  NULL,
   default_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
@@ -870,6 +817,30 @@ public:
   unknown_language ()
     : language_defn (language_unknown, unknown_language_data)
   { /* Nothing.  */ }
+
+  /* See language.h.  */
+  void language_arch_info (struct gdbarch *gdbarch,
+                          struct language_arch_info *lai) const override
+  {
+    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"));
+  }
+
+  /* See language.h.  */
+
+  char *demangle (const char *mangled, int options) const override
+  {
+    /* The unknown language just uses the C++ demangler.  */
+    return gdb_demangle (mangled, options);
+  }
 };
 
 /* Single instance of the unknown language class.  */
@@ -894,18 +865,13 @@ 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 */
-  default_read_var_value,      /* la_read_var_value */
   unk_lang_trampoline,         /* Language specific skip_trampoline */
   "this",                      /* name_of_this */
   false,                       /* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
-  basic_lookup_transparent_type,/* lookup_transparent_type */
-  unk_lang_demangle,           /* Language specific symbol demangler */
-  NULL,
   unk_lang_class_name,         /* Language specific
                                   class_name_from_physname */
   unk_op_print_tab,            /* expression operators for printing */
@@ -913,16 +879,10 @@ extern const struct language_data auto_language_data =
   0,                           /* String lower bound */
   default_word_break_characters,
   default_collect_symbol_completion_matches,
-  unknown_language_arch_info,  /* la_language_arch_info.  */
-  default_print_array_index,
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
-  iterate_over_symbols,
-  default_search_name_hash,
   &default_varobj_ops,
   NULL,
-  NULL,
   default_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
 };
@@ -935,6 +895,30 @@ public:
   auto_language ()
     : language_defn (language_auto, auto_language_data)
   { /* Nothing.  */ }
+
+  /* See language.h.  */
+  void language_arch_info (struct gdbarch *gdbarch,
+                          struct language_arch_info *lai) const override
+  {
+    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"));
+  }
+
+  /* See language.h.  */
+
+  char *demangle (const char *mangled, int options) const override
+  {
+    /* The auto language just uses the C++ demangler.  */
+    return gdb_demangle (mangled, options);
+  }
 };
 
 /* Single instance of the fake "auto" language.  */
@@ -960,11 +944,11 @@ language_gdbarch_post_init (struct gdbarch *gdbarch)
 
   l = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct language_gdbarch);
   for (const auto &lang : language_defn::languages)
-    if (lang != NULL && lang->la_language_arch_info != NULL)
-      {
-       lang->la_language_arch_info (gdbarch,
-                                    l->arch_info + lang->la_language);
-      }
+    {
+      gdb_assert (lang != nullptr);
+      lang->language_arch_info (gdbarch,
+                               l->arch_info + lang->la_language);
+    }
 
   return l;
 }
This page took 0.02665 seconds and 4 git commands to generate.