gdb: Convert la_name_of_this to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 23 Jun 2020 13:42:14 +0000 (14:42 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 16 Sep 2020 09:16:45 +0000 (10:16 +0100)
Convert language_data::la_name_of_this member variable to a virtual
method language_defn::name_of_this.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_name_of_this
initializer.
* ax-gdb.c (gen_expr): Update call to name_of_this.
* c-exp.y (classify_name): Likewise.
* c-lang.c (c_language_data): Remove la_name_of_this initializer.
(cplus_language_data): Likewise.
(cplus_language::name_of_this): New member function.
(asm_language_data): Remove la_name_of_this initializer.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
(d_language::name_of_this): New member function.
* expprint.c (print_subexp_standard): Update call to name_of_this.
* f-lang.c (f_language_data): Remove la_name_of_this initializer.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(unknown_language::name_of_this): New member function.
(auto_language_data): Remove la_name_of_this initializer.
(auto_language::name_of_this): New member function.
* language.h (language_data): Delete la_name_of_this member
variable.
(language_defn::name_of_this): New member function.
* m2-lang.c (m2_language_data): Remove la_name_of_this
initializer.
* objc-lang.c (objc_language_data): Likewise.
(objc_language::name_of_this): New member function.
* opencl-lang.c (opencl_language_data): Remove la_name_of_this
initializer.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::name_of_this): New member function.
* rust-lang.c (rust_language_data): Remove la_name_of_this
initializer.
* symtab.c (lookup_language_this): Update call to name_of_this.
(lookup_symbol_aux): Likewise.
* valops.c (value_of_this): Likewise.

18 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/ax-gdb.c
gdb/c-exp.y
gdb/c-lang.c
gdb/d-lang.c
gdb/expprint.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
gdb/symtab.c
gdb/valops.c

index ef97ac180de11a263eb7366be9a6f5657cdab3f9..a5d9d3be7e100597f92400a57acaa8f28e6417e3 100644 (file)
@@ -1,3 +1,40 @@
+2020-09-16  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_language_data): Remove la_name_of_this
+       initializer.
+       * ax-gdb.c (gen_expr): Update call to name_of_this.
+       * c-exp.y (classify_name): Likewise.
+       * c-lang.c (c_language_data): Remove la_name_of_this initializer.
+       (cplus_language_data): Likewise.
+       (cplus_language::name_of_this): New member function.
+       (asm_language_data): Remove la_name_of_this initializer.
+       (minimal_language_data): Likewise.
+       * d-lang.c (d_language_data): Likewise.
+       (d_language::name_of_this): New member function.
+       * expprint.c (print_subexp_standard): Update call to name_of_this.
+       * f-lang.c (f_language_data): Remove la_name_of_this initializer.
+       * go-lang.c (go_language_data): Likewise.
+       * language.c (unknown_language_data): Likewise.
+       (unknown_language::name_of_this): New member function.
+       (auto_language_data): Remove la_name_of_this initializer.
+       (auto_language::name_of_this): New member function.
+       * language.h (language_data): Delete la_name_of_this member
+       variable.
+       (language_defn::name_of_this): New member function.
+       * m2-lang.c (m2_language_data): Remove la_name_of_this
+       initializer.
+       * objc-lang.c (objc_language_data): Likewise.
+       (objc_language::name_of_this): New member function.
+       * opencl-lang.c (opencl_language_data): Remove la_name_of_this
+       initializer.
+       * p-lang.c (pascal_language_data): Likewise.
+       (pascal_language::name_of_this): New member function.
+       * rust-lang.c (rust_language_data): Remove la_name_of_this
+       initializer.
+       * symtab.c (lookup_language_this): Update call to name_of_this.
+       (lookup_symbol_aux): Likewise.
+       * valops.c (value_of_this): Likewise.
+
 2020-09-16  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (ada_language_data): Remove
index 3ad693fe25ec4983ad23c9e1760c675b74a64bbc..b028ccb79f8e8380398e5a6f59edae7090b91dd3 100644 (file)
@@ -13723,7 +13723,6 @@ extern const struct language_data ada_language_data =
   macro_expansion_no,
   ada_extensions,
   &ada_exp_descriptor,
-  NULL,                         /* name_of_this */
   true,                         /* la_store_sym_names_in_linkage_form_p */
   ada_op_print_tab,             /* expression operators for printing */
   0,                            /* c-style arrays */
index 78272f7a8b8bfd51fc367c1516e5992a8823093f..397b92b05ee051dced67969b4a6c81e649101ba5 100644 (file)
@@ -2233,7 +2233,7 @@ gen_expr (struct expression *exp, union exp_element **pc,
 
        sym = lookup_language_this (lang, b).symbol;
        if (!sym)
-         error (_("no `%s' found"), lang->la_name_of_this);
+         error (_("no `%s' found"), lang->name_of_this ());
 
        gen_var_ref (ax, value, sym);
 
index 7fc23c4c8d285e0fed492a783120f68ab1bbb6d1..b03855ba7afa7eb0ac9334b74650b777862051cb 100644 (file)
@@ -3036,7 +3036,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
   memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
 
   bsym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN,
-                       par_state->language ()->la_name_of_this
+                       par_state->language ()->name_of_this ()
                        ? &is_a_field_of_this : NULL);
 
   if (bsym.symbol && SYMBOL_CLASS (bsym.symbol) == LOC_BLOCK)
index 8a704701c91cc0c603f864471784f65e87902698..2e4cf0742d481a96f7b0b0df3398abe6e1a22fa9 100644 (file)
@@ -889,7 +889,6 @@ extern const struct language_data c_language_data =
   macro_expansion_c,
   c_extensions,
   &exp_descriptor_c,
-  NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
@@ -989,7 +988,6 @@ extern const struct language_data cplus_language_data =
   macro_expansion_c,
   cplus_extensions,
   &exp_descriptor_c,
-  "this",                       /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
@@ -1153,6 +1151,11 @@ public:
     return cp_lookup_symbol_nonlocal (this, name, block, domain);
   }
 
+  /* See language.h.  */
+
+  const char *name_of_this () const override
+  { return "this"; }
+
 protected:
 
   /* See language.h.  */
@@ -1186,7 +1189,6 @@ extern const struct language_data asm_language_data =
   macro_expansion_c,
   asm_extensions,
   &exp_descriptor_c,
-  NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
@@ -1241,7 +1243,6 @@ extern const struct language_data minimal_language_data =
   macro_expansion_c,
   NULL,
   &exp_descriptor_c,
-  NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
index 79cb1e478c439a4f3e31a8ed5d38811fa902c025..82d5615b4d8b52007c7d0507802e8d50a68f686a 100644 (file)
@@ -142,7 +142,6 @@ extern const struct language_data d_language_data =
   macro_expansion_no,
   d_extensions,
   &exp_descriptor_c,
-  "this",
   false,                       /* la_store_sym_names_in_linkage_form_p */
   d_op_print_tab,              /* Expression operators for printing.  */
   1,                           /* C-style arrays.  */
@@ -271,6 +270,11 @@ public:
   {
     return d_parse (ps);
   }
+
+  /* See language.h.  */
+
+  const char *name_of_this () const override
+  { return "this"; }
 };
 
 /* Single instance of the D language class.  */
index 5427a56f6ae0323845f44494f24f81d413959b29..24d647e006c0882c535356f1bdf67cf2715ff076 100644 (file)
@@ -504,8 +504,8 @@ print_subexp_standard (struct expression *exp, int *pos,
 
     case OP_THIS:
       ++(*pos);
-      if (exp->language_defn->la_name_of_this)
-       fputs_filtered (exp->language_defn->la_name_of_this, stream);
+      if (exp->language_defn->name_of_this () != NULL)
+       fputs_filtered (exp->language_defn->name_of_this (), stream);
       else
        fprintf_styled (stream, metadata_style.style (),
                        _("<language %s has no 'this'>"),
index 5beaf3d772c1d4d77d624fe745e98b89591092c3..76f5fb5d07761bf76b40af74a881bdbcc81edb17 100644 (file)
@@ -502,7 +502,6 @@ extern const struct language_data f_language_data =
   macro_expansion_no,
   f_extensions,
   &exp_descriptor_f,
-  NULL,                        /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   f_op_print_tab,              /* expression operators for printing */
   0,                           /* arrays are first-class (not c-style) */
index deff33a8abf314ba9faac0fd7f7688e00300d08b..df7cbc79b196689d0edb437d8209778cb00fa767 100644 (file)
@@ -517,7 +517,6 @@ extern const struct language_data go_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_c,
-  NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   go_op_print_tab,             /* Expression operators for printing.  */
   1,                           /* C-style arrays.  */
index 914c75b08e7ca49e100d4f0daef46701d8281fe3..7ccd0ac2b8e924331950c334003236b55a5f6303 100644 (file)
@@ -792,7 +792,6 @@ extern const struct language_data unknown_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_standard,
-  "this",                      /* name_of_this */
   true,                                /* store_sym_names_in_linkage_form_p */
   unk_op_print_tab,            /* expression operators for printing */
   1,                           /* c-style arrays */
@@ -898,6 +897,11 @@ public:
   {
     return default_is_string_type_p (type);
   }
+
+  /* See language.h.  */
+
+  const char *name_of_this () const override
+  { return "this"; }
 };
 
 /* Single instance of the unknown language class.  */
@@ -917,7 +921,6 @@ extern const struct language_data auto_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_standard,
-  "this",                      /* name_of_this */
   false,                       /* store_sym_names_in_linkage_form_p */
   unk_op_print_tab,            /* expression operators for printing */
   1,                           /* c-style arrays */
@@ -1023,6 +1026,11 @@ public:
   {
     return default_is_string_type_p (type);
   }
+
+  /* See language.h.  */
+
+  const char *name_of_this () const override
+  { return "this"; }
 };
 
 /* Single instance of the fake "auto" language.  */
index f2195ed4e8d88060be2d78aa1bf36da2a06c8e9e..4c9453f33cb4dcbcd4a02df1336395ed1825d608 100644 (file)
@@ -227,11 +227,6 @@ struct language_data
 
     /* Now come some hooks for lookup_symbol.  */
 
-    /* If this is non-NULL, specifies the name that of the implicit
-       local variable that refers to the current object instance.  */
-
-    const char *la_name_of_this;
-
     /* True if the symbols names should be stored in GDB's data structures
        for minimal/partial/full symbols using their linkage (aka mangled)
        form; false if the symbol names should be demangled first.
@@ -557,6 +552,14 @@ struct language_defn : language_data
   virtual const char *struct_too_deep_ellipsis () const
   { return "{...}"; }
 
+  /* If this returns non-NULL then the string returned specifies the name
+     of the implicit local variable that refers to the current object
+     instance.  Return NULL (the default) for languages that have no name
+     for the current object instance.  */
+
+  virtual const char *name_of_this () const
+  { return nullptr; }
+
 protected:
 
   /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
index 9e2d0d75f17cae135e5df2f56623fd8682184478..3ba5026b2bc3c9fbcecb8884c89a88755bc8ea98 100644 (file)
@@ -208,7 +208,6 @@ extern const struct language_data m2_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_modula2,
-  NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   m2_op_print_tab,             /* expression operators for printing */
   0,                           /* arrays are first-class (not c-style) */
index 2c49f8d584060e2ba81c2bd6742eb57ae11b21a6..e8d846ea7ac6a921d96fd9e510a3e0f88749c32f 100644 (file)
@@ -337,7 +337,6 @@ extern const struct language_data objc_language_data =
   macro_expansion_c,
   objc_extensions,
   &exp_descriptor_standard,
-  "self",                      /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   objc_op_print_tab,           /* Expression operators for printing */
   1,                           /* C-style arrays */
@@ -418,6 +417,11 @@ public:
 
     return real_stop_pc;
   }
+
+  /* See language.h.  */
+
+  const char *name_of_this () const override
+  { return "self"; }
 };
 
 /* Single instance of the class representing the Objective-C language.  */
index 0df58ee5e1801bfece3f81598c2b5ddbd77091c9..2806bee2f2a7bcbd645a7b260e1191fe727f736b 100644 (file)
@@ -1015,7 +1015,6 @@ extern const struct language_data opencl_language_data =
   macro_expansion_c,
   NULL,
   &exp_descriptor_opencl,
-  NULL,                         /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
index cbde8e1aecc8b121280d9d6993c1db8edb572ce5..2c551399860682205844130cf2525ca3cac36462 100644 (file)
@@ -266,7 +266,6 @@ extern const struct language_data pascal_language_data =
   macro_expansion_no,
   p_extensions,
   &exp_descriptor_standard,
-  "this",                      /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   pascal_op_print_tab,         /* expression operators for printing */
   1,                           /* c-style arrays */
@@ -497,6 +496,11 @@ public:
     return is_pascal_string_type (type, nullptr, nullptr, nullptr,
                                  nullptr, nullptr) > 0;
   }
+
+  /* See language.h.  */
+
+  const char *name_of_this () const override
+  { return "this"; }
 };
 
 /* Single instance of the Pascal language class.  */
index ff0ac7bd42c5617e654ca473ab6c9e7330fa436b..aec430e84ac86f53f84619d016cf98f7040f8dee 100644 (file)
@@ -1915,7 +1915,6 @@ extern const struct language_data rust_language_data =
   macro_expansion_no,
   rust_extensions,
   &exp_descriptor_rust,
-  NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
index f96ad9554d9ea31b2bdcad6f5aa7bba88cf5d3fd..ff88adfe020ec8f9690451997738ae45c2b418fc 100644 (file)
@@ -1912,7 +1912,7 @@ struct block_symbol
 lookup_language_this (const struct language_defn *lang,
                      const struct block *block)
 {
-  if (lang->la_name_of_this == NULL || block == NULL)
+  if (lang->name_of_this () == NULL || block == NULL)
     return {};
 
   if (symbol_lookup_debug > 1)
@@ -1929,7 +1929,7 @@ lookup_language_this (const struct language_defn *lang,
     {
       struct symbol *sym;
 
-      sym = block_lookup_symbol (block, lang->la_name_of_this,
+      sym = block_lookup_symbol (block, lang->name_of_this (),
                                 symbol_name_match_type::SEARCH_NAME,
                                 VAR_DOMAIN);
       if (sym != NULL)
@@ -2069,7 +2069,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
          if (t->code () != TYPE_CODE_STRUCT
              && t->code () != TYPE_CODE_UNION)
            error (_("Internal error: `%s' is not an aggregate"),
-                  langdef->la_name_of_this);
+                  langdef->name_of_this ());
 
          if (check_field (t, name, is_a_field_of_this))
            {
index da2881a3469234b505857bc7c349ba02a318fbb0..6dc2f54b14d52bd8e18bc57aefd87be0924d8acc 100644 (file)
@@ -3716,7 +3716,7 @@ value_of_this (const struct language_defn *lang)
   const struct block *b;
   struct frame_info *frame;
 
-  if (!lang->la_name_of_this)
+  if (lang->name_of_this () == NULL)
     error (_("no `this' in current language"));
 
   frame = get_selected_frame (_("no frame selected"));
@@ -3726,7 +3726,7 @@ value_of_this (const struct language_defn *lang)
   sym = lookup_language_this (lang, b);
   if (sym.symbol == NULL)
     error (_("current stack frame does not contain a variable named `%s'"),
-          lang->la_name_of_this);
+          lang->name_of_this ());
 
   return read_var_value (sym.symbol, sym.block, frame);
 }
This page took 0.042982 seconds and 4 git commands to generate.