Automatic date update in version.in
[deliverable/binutils-gdb.git] / gdb / dictionary.c
index b5ad71ba064ff3206761f9d22508e27f56776ca6..0d13370b7269924a89d4bdc45b3a858a73872634 100644 (file)
@@ -28,6 +28,7 @@
 #include "dictionary.h"
 #include "safe-ctype.h"
 #include <unordered_map>
+#include "language.h"
 
 /* This file implements dictionaries, which are tables that associate
    symbols to names.  They are represented by an opaque type 'struct
@@ -342,31 +343,14 @@ static void insert_symbol_hashed (struct dictionary *dict,
 
 static void expand_hashtable (struct dictionary *dict);
 
-/* A function to convert a linked list into a vector.  */
-
-static std::vector<symbol *>
-pending_to_vector (const struct pending *symbol_list)
-{
-  std::vector<symbol *> symlist;
-
-  for (const struct pending *list_counter = symbol_list;
-       list_counter != nullptr; list_counter = list_counter->next)
-    {
-      for (int i = list_counter->nsyms - 1; i >= 0; --i)
-       symlist.push_back (list_counter->symbol[i]);
-    }
-
-  return symlist;
-}
-
 /* The creation functions.  */
 
-/* A function to transition dict_create_hashed to new API.  */
+/* Create a hashed dictionary of a given language.  */
 
 static struct dictionary *
-dict_create_hashed_1 (struct obstack *obstack,
-                     enum language language,
-                     const std::vector<symbol *> &symbol_list)
+dict_create_hashed (struct obstack *obstack,
+                   enum language language,
+                   const std::vector<symbol *> &symbol_list)
 {
   /* Allocate the dictionary.  */
   struct dictionary *retval = XOBNEW (obstack, struct dictionary);
@@ -388,21 +372,9 @@ dict_create_hashed_1 (struct obstack *obstack,
   return retval;
 }
 
-/* See dictionary.h.  */
-
-struct dictionary *
-dict_create_hashed (struct obstack *obstack,
-                   enum language language,
-                   const struct pending *symbol_list)
-{
-  std::vector<symbol *> symlist = pending_to_vector (symbol_list);
-
-  return dict_create_hashed_1 (obstack, language, symlist);
-}
-
-/* See dictionary.h.  */
+/* Create an expandable hashed dictionary of a given language.  */
 
-extern struct dictionary *
+static struct dictionary *
 dict_create_hashed_expandable (enum language language)
 {
   struct dictionary *retval = XNEW (struct dictionary);
@@ -417,12 +389,12 @@ dict_create_hashed_expandable (enum language language)
   return retval;
 }
 
-/* A function to transition dict_create_linear to new API.  */
+/* Create a linear dictionary of a given language.  */
 
 static struct dictionary *
-dict_create_linear_1 (struct obstack *obstack,
-                     enum language language,
-                     const std::vector<symbol *> &symbol_list)
+dict_create_linear (struct obstack *obstack,
+                   enum language language,
+                   const std::vector<symbol *> &symbol_list)
 {
   struct dictionary *retval = XOBNEW (obstack, struct dictionary);
   DICT_VECTOR (retval) = &dict_linear_vector;
@@ -442,21 +414,9 @@ dict_create_linear_1 (struct obstack *obstack,
   return retval;
 }
 
-/* See dictionary.h.  */
+/* Create an expandable linear dictionary of a given language.  */
 
-struct dictionary *
-dict_create_linear (struct obstack *obstack,
-                   enum language language,
-                   const struct pending *symbol_list)
-{
-  std::vector<symbol *> symlist = pending_to_vector (symbol_list);
-
-  return dict_create_linear_1 (obstack, language, symlist);
-}
-
-/* See dictionary.h.  */
-
-struct dictionary *
+static struct dictionary *
 dict_create_linear_expandable (enum language language)
 {
   struct dictionary *retval = XNEW (struct dictionary);
@@ -476,7 +436,7 @@ dict_create_linear_expandable (enum language language)
 /* Free the memory used by a dictionary that's not on an obstack.  (If
    any.)  */
 
-void
+static void
 dict_free (struct dictionary *dict)
 {
   (DICT_VECTOR (dict))->free (dict);
@@ -484,38 +444,28 @@ dict_free (struct dictionary *dict)
 
 /* Add SYM to DICT.  DICT had better be expandable.  */
 
-void
+static void
 dict_add_symbol (struct dictionary *dict, struct symbol *sym)
 {
   (DICT_VECTOR (dict))->add_symbol (dict, sym);
 }
 
-/* A function to transition dict_add_pending to new API.  */
+/* Utility to add a list of symbols to a dictionary.
+   DICT must be an expandable dictionary.  */
 
 static void
-dict_add_pending_1 (struct dictionary *dict,
-                   const std::vector<symbol *> &symbol_list)
+dict_add_pending (struct dictionary *dict,
+                 const std::vector<symbol *> &symbol_list)
 {
   /* Preserve ordering by reversing the list.  */
   for (auto sym = symbol_list.rbegin (); sym != symbol_list.rend (); ++sym)
     dict_add_symbol (dict, *sym);
 }
 
-/* Utility to add a list of symbols to a dictionary.
-   DICT must be an expandable dictionary.  */
-
-void
-dict_add_pending (struct dictionary *dict, const struct pending *symbol_list)
-{
-  std::vector<symbol *> symlist = pending_to_vector (symbol_list);
-
-  dict_add_pending_1 (dict, symlist);
-}
-
 /* Initialize ITERATOR to point at the first symbol in DICT, and
    return that first symbol, or NULL if DICT is empty.  */
 
-struct symbol *
+static struct symbol *
 dict_iterator_first (const struct dictionary *dict,
                     struct dict_iterator *iterator)
 {
@@ -525,14 +475,14 @@ dict_iterator_first (const struct dictionary *dict,
 /* Advance ITERATOR, and return the next symbol, or NULL if there are
    no more symbols.  */
 
-struct symbol *
+static struct symbol *
 dict_iterator_next (struct dict_iterator *iterator)
 {
   return (DICT_VECTOR (DICT_ITERATOR_DICT (iterator)))
     ->iterator_next (iterator);
 }
 
-struct symbol *
+static struct symbol *
 dict_iter_match_first (const struct dictionary *dict,
                       const lookup_name_info &name,
                       struct dict_iterator *iterator)
@@ -540,7 +490,7 @@ dict_iter_match_first (const struct dictionary *dict,
   return (DICT_VECTOR (dict))->iter_match_first (dict, name, iterator);
 }
 
-struct symbol *
+static struct symbol *
 dict_iter_match_next (const lookup_name_info &name,
                      struct dict_iterator *iterator)
 {
@@ -548,7 +498,7 @@ dict_iter_match_next (const lookup_name_info &name,
     ->iter_match_next (name, iterator);
 }
 
-int
+static int
 dict_size (const struct dictionary *dict)
 {
   return (DICT_VECTOR (dict))->size (dict);
@@ -558,16 +508,6 @@ dict_size (const struct dictionary *dict)
    implemented generically by means of the vtable.  Typically, they're
    rarely used.  */
 
-/* Test to see if DICT is empty.  */
-
-int
-dict_empty (struct dictionary *dict)
-{
-  struct dict_iterator iter;
-
-  return (dict_iterator_first (dict, &iter) == NULL);
-}
-
 
 /* The functions implementing the dictionary interface.  */
 
@@ -658,7 +598,7 @@ iter_match_first_hashed (const struct dictionary *dict,
        sym = sym->hash_next)
     {
       /* Warning: the order of arguments to compare matters!  */
-      if (matches_name (SYMBOL_SEARCH_NAME (sym), name, NULL))
+      if (matches_name (sym->search_name (), name, NULL))
        break;
     }
 
@@ -679,7 +619,7 @@ iter_match_next_hashed (const lookup_name_info &name,
        next != NULL;
        next = next->hash_next)
     {
-      if (matches_name (SYMBOL_SEARCH_NAME (next), name, NULL))
+      if (matches_name (next->search_name (), name, NULL))
        break;
     }
 
@@ -702,7 +642,7 @@ insert_symbol_hashed (struct dictionary *dict,
      language.  The two may not use the same hashing algorithm.  */
   gdb_assert (SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language);
 
-  hash = search_name_hash (SYMBOL_LANGUAGE (sym), SYMBOL_SEARCH_NAME (sym));
+  hash = search_name_hash (SYMBOL_LANGUAGE (sym), sym->search_name ());
   hash_index = hash % DICT_HASHED_NBUCKETS (dict);
   sym->hash_next = buckets[hash_index];
   buckets[hash_index] = sym;
@@ -897,7 +837,7 @@ iter_match_next_linear (const lookup_name_info &name,
     {
       sym = DICT_LINEAR_SYM (dict, i);
 
-      if (matches_name (SYMBOL_SEARCH_NAME (sym), name, NULL))
+      if (matches_name (sym->search_name (), name, NULL))
        {
          retval = sym;
          break;
@@ -983,7 +923,7 @@ collate_pending_symbols_by_language (const struct pending *symbol_list)
 {
   std::unordered_map<enum language, std::vector<symbol *>> nsyms;
 
-  for (const struct pending *list_counter = symbol_list;
+  for (const pending *list_counter = symbol_list;
        list_counter != nullptr; list_counter = list_counter->next)
     {
       for (int i = list_counter->nsyms - 1; i >= 0; --i)
@@ -1019,7 +959,7 @@ mdict_create_hashed (struct obstack *obstack,
       std::vector<symbol *> symlist = pair.second;
 
       retval->dictionaries[idx++]
-       = dict_create_hashed_1 (obstack, language, symlist);
+       = dict_create_hashed (obstack, language, symlist);
     }
 
   return retval;
@@ -1064,7 +1004,7 @@ mdict_create_linear (struct obstack *obstack,
       std::vector<symbol *> symlist = pair.second;
 
       retval->dictionaries[idx++]
-       = dict_create_linear_1 (obstack, language, symlist);
+       = dict_create_linear (obstack, language, symlist);
     }
 
   return retval;
@@ -1210,7 +1150,7 @@ mdict_add_pending (struct multidictionary *mdict,
          dict = create_new_language_dictionary (mdict, language);
        }
 
-      dict_add_pending_1 (dict, symlist);
+      dict_add_pending (dict, symlist);
     }
 }
 
@@ -1333,17 +1273,3 @@ mdict_size (const struct multidictionary *mdict)
 
   return size;
 }
-
-/* See dictionary.h.  */
-
-bool
-mdict_empty (const struct multidictionary *mdict)
-{
-  for (unsigned short idx = 0; idx < mdict->n_allocated_dictionaries; ++idx)
-    {
-      if (!dict_empty (mdict->dictionaries[idx]))
-       return false;
-    }
-
-  return true;
-}
This page took 0.027075 seconds and 4 git commands to generate.