gdb: Convert language la_lookup_symbol_nonlocal field to a method
[deliverable/binutils-gdb.git] / gdb / language.c
index f4e99fc392f6d46fd0ad279a43bd01d2edf6d22b..0cbc7f0540238add1f6c4b4a6b89c9ad3732f7e6 100644 (file)
@@ -57,9 +57,6 @@ static void unk_lang_emit_char (int c, struct type *type,
 static void unk_lang_printchar (int c, struct type *type,
                                struct ui_file *stream);
 
-static void unk_lang_value_print (struct value *, struct ui_file *,
-                                 const struct value_print_options *);
-
 /* The current (default at startup) state of type and range checking.
    (If the modes are set to "auto", though, these are changed based
    on the default language at startup, and then again based on the
@@ -622,6 +619,38 @@ language_defn::print_array_index (struct type *index_type, LONGEST index,
   fprintf_filtered (stream, "] = ");
 }
 
+/* See language.h.  */
+
+gdb::unique_xmalloc_ptr<char>
+language_defn::watch_location_expression (struct type *type,
+                                         CORE_ADDR addr) const
+{
+  /* Generates an expression that assumes a C like syntax is valid.  */
+  type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
+  std::string name = type_to_string (type);
+  return gdb::unique_xmalloc_ptr<char>
+    (xstrprintf ("* (%s *) %s", name.c_str (), core_addr_to_string (addr)));
+}
+
+/* See language.h.  */
+
+void
+language_defn::value_print (struct value *val, struct ui_file *stream,
+              const struct value_print_options *options) const
+{
+  return c_value_print (val, stream, options);
+}
+
+/* See language.h.  */
+
+void
+language_defn::value_print_inner
+       (struct value *val, struct ui_file *stream, int recurse,
+        const struct value_print_options *options) const
+{
+  return c_value_print_inner (val, stream, recurse, options);
+}
+
 /* The default implementation of the get_symbol_name_matcher_inner method
    from the language_defn class.  Matches with strncmp_iw.  */
 
@@ -720,23 +749,6 @@ unk_lang_printstr (struct ui_file *stream, struct type *type,
           "function unk_lang_printstr called."));
 }
 
-static void
-unk_lang_value_print_inner (struct value *val,
-                           struct ui_file *stream, int recurse,
-                           const struct value_print_options *options)
-{
-  error (_("internal error - unimplemented "
-          "function unk_lang_value_print_inner called."));
-}
-
-static void
-unk_lang_value_print (struct value *val, struct ui_file *stream,
-                     const struct value_print_options *options)
-{
-  error (_("internal error - unimplemented "
-          "function unk_lang_value_print called."));
-}
-
 static const struct op_print unk_op_print_tab[] =
 {
   {NULL, OP_NULL, PREC_NULL, 0}
@@ -771,15 +783,11 @@ extern const struct language_data unknown_language_data =
   unk_lang_printstr,
   unk_lang_emit_char,
   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 */
   "this",                      /* name_of_this */
   true,                                /* store_sym_names_in_linkage_form_p */
-  basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
   unk_op_print_tab,            /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
-  c_watch_location_expression,
   &default_varobj_ops,
   default_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
@@ -817,6 +825,23 @@ public:
     /* The unknown language just uses the C++ demangler.  */
     return gdb_demangle (mangled, options);
   }
+
+  /* See language.h.  */
+
+  void value_print (struct value *val, struct ui_file *stream,
+                   const struct value_print_options *options) const override
+  {
+    error (_("unimplemented unknown_language::value_print called"));
+  }
+
+  /* See language.h.  */
+
+  void value_print_inner
+       (struct value *val, struct ui_file *stream, int recurse,
+        const struct value_print_options *options) const override
+  {
+    error (_("unimplemented unknown_language::value_print_inner called"));
+  }
 };
 
 /* Single instance of the unknown language class.  */
@@ -842,15 +867,11 @@ extern const struct language_data auto_language_data =
   unk_lang_printstr,
   unk_lang_emit_char,
   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 */
   "this",                      /* name_of_this */
   false,                       /* store_sym_names_in_linkage_form_p */
-  basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   unk_op_print_tab,            /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
-  c_watch_location_expression,
   &default_varobj_ops,
   default_is_string_type_p,
   "{...}"                      /* la_struct_too_deep_ellipsis */
@@ -888,6 +909,23 @@ public:
     /* The auto language just uses the C++ demangler.  */
     return gdb_demangle (mangled, options);
   }
+
+  /* See language.h.  */
+
+  void value_print (struct value *val, struct ui_file *stream,
+                   const struct value_print_options *options) const override
+  {
+    error (_("unimplemented auto_language::value_print called"));
+  }
+
+  /* See language.h.  */
+
+  void value_print_inner
+       (struct value *val, struct ui_file *stream, int recurse,
+        const struct value_print_options *options) const override
+  {
+    error (_("unimplemented auto_language::value_print_inner called"));
+  }
 };
 
 /* Single instance of the fake "auto" language.  */
This page took 0.024451 seconds and 4 git commands to generate.