struct symbol * dict_iter_match_next (const char *name, symbol_compare_ftype *compare, struct dict_iterator *iterator) { return (DICT_VECTOR (DICT_ITERATOR_DICT (iterator))) ->iter_match_next (name, compare, iterator); }
struct symbol * dict_iter_name_first (const struct dictionary *dict, const char *name, struct dict_iterator *iterator) { return (DICT_VECTOR (dict))->iter_name_first (dict, name, iterator); }
struct symbol * dict_iter_match_first (const struct dictionary *dict, const char *name, symbol_compare_ftype *compare, struct dict_iterator *iterator) { return (DICT_VECTOR (dict))->iter_match_first (dict, name, compare, iterator); }
extern struct dictionary * dict_create_hashed_expandable (void) { struct dictionary *retval; retval = xmalloc (sizeof (struct dictionary)); DICT_VECTOR (retval) = &dict_hashed_expandable_vector; DICT_HASHED_NBUCKETS (retval) = DICT_EXPANDABLE_INITIAL_CAPACITY; DICT_HASHED_BUCKETS (retval) = xcalloc (DICT_EXPANDABLE_INITIAL_CAPACITY, sizeof (struct symbol *)); DICT_HASHED_EXPANDABLE_NSYMS (retval) = 0; return retval; }
struct dictionary * dict_create_linear_expandable (void) { struct dictionary *retval; retval = xmalloc (sizeof (struct dictionary)); DICT_VECTOR (retval) = &dict_linear_expandable_vector; DICT_LINEAR_NSYMS (retval) = 0; DICT_LINEAR_EXPANDABLE_CAPACITY (retval) = DICT_EXPANDABLE_INITIAL_CAPACITY; DICT_LINEAR_SYMS (retval) = xmalloc (DICT_LINEAR_EXPANDABLE_CAPACITY (retval) * sizeof (struct symbol *)); return retval; }
struct dictionary * dict_create_linear (struct obstack *obstack, const struct pending *symbol_list) { struct dictionary *retval; int nsyms = 0, i, j; struct symbol **syms; const struct pending *list_counter; retval = obstack_alloc (obstack, sizeof (struct dictionary)); DICT_VECTOR (retval) = &dict_linear_vector; /* Calculate the number of symbols, and allocate space for them. */ for (list_counter = symbol_list; list_counter != NULL; list_counter = list_counter->next) { nsyms += list_counter->nsyms; } DICT_LINEAR_NSYMS (retval) = nsyms; syms = obstack_alloc (obstack, nsyms * sizeof (struct symbol *)); DICT_LINEAR_SYMS (retval) = syms; /* Now fill in the symbols. Start filling in from the back, so as to preserve the original order of the symbols. */ for (list_counter = symbol_list, j = nsyms - 1; list_counter != NULL; list_counter = list_counter->next) { for (i = list_counter->nsyms - 1; i >= 0; --i, --j) { syms[j] = list_counter->symbol[i]; } } return retval; }
struct dictionary * dict_create_hashed (struct obstack *obstack, const struct pending *symbol_list) { struct dictionary *retval; int nsyms = 0, nbuckets, i; struct symbol **buckets; const struct pending *list_counter; retval = obstack_alloc (obstack, sizeof (struct dictionary)); DICT_VECTOR (retval) = &dict_hashed_vector; /* Calculate the number of symbols, and allocate space for them. */ for (list_counter = symbol_list; list_counter != NULL; list_counter = list_counter->next) { nsyms += list_counter->nsyms; } nbuckets = DICT_HASHTABLE_SIZE (nsyms); DICT_HASHED_NBUCKETS (retval) = nbuckets; buckets = obstack_alloc (obstack, nbuckets * sizeof (struct symbol *)); memset (buckets, 0, nbuckets * sizeof (struct symbol *)); DICT_HASHED_BUCKETS (retval) = buckets; /* Now fill the buckets. */ for (list_counter = symbol_list; list_counter != NULL; list_counter = list_counter->next) { for (i = list_counter->nsyms - 1; i >= 0; --i) { insert_symbol_hashed (retval, list_counter->symbol[i]); } } return retval; }
int dict_size (const struct dictionary *dict) { return (DICT_VECTOR (dict))->size (dict); }
struct symbol * dict_iterator_next (struct dict_iterator *iterator) { return (DICT_VECTOR (DICT_ITERATOR_DICT (iterator))) ->iterator_next (iterator); }
struct symbol * dict_iterator_first (const struct dictionary *dict, struct dict_iterator *iterator) { return (DICT_VECTOR (dict))->iterator_first (dict, iterator); }
void dict_add_symbol (struct dictionary *dict, struct symbol *sym) { (DICT_VECTOR (dict))->add_symbol (dict, sym); }
void dict_free (struct dictionary *dict) { (DICT_VECTOR (dict))->free (dict); }
struct symbol * dict_iter_name_next (const char *name, struct dict_iterator *iterator) { return (DICT_VECTOR (DICT_ITERATOR_DICT (iterator))) ->iter_name_next (name, iterator); }