- assert(str);
- return set_new_id_from_chars(handle, str, strlen(str));
-}
-
-/**
- * Returns a string represented by an ident.
- *
- * @param handle the handle for the set
- * @param id the ident
- *
- * Default implementation using libfirm sets.
- */
-static const char *set_get_id_str(void *handle, ident *id)
-{
- struct set_entry *entry = (struct set_entry *)id;
- (void) handle;
-
- return (const char *)entry->dptr;
-}
-
-/**
- * Returns the length of the string represented by an ident.
- *
- * @param handle the handle for the set
- * @param id the ident
- *
- * Default implementation using libfirm sets.
- */
-static int set_get_id_strlen(void *handle, ident *id)
-{
- struct set_entry *entry = (struct set_entry *)id;
- (void) handle;
-
- return entry->size;
-}
-
-/**
- * Default implementation using libfirm sets.
- */
-void set_finish_ident(void *handle)
-{
- set *id_set = handle;
-
- del_set(id_set);
-}
-
-/**
- * Default implementation if no new_id_from_str() is provided.
- */
-static ident *def_new_id_from_str(void *handle, const char *str)
-{
- return impl.new_id_from_chars(handle, str, strlen(str));
-}
-
-/**
- * Default implementation if no get_id_strlen() is provided.
- */
-static int def_get_id_strlen(void *handle, ident *id)
-{
- return strlen(impl.get_id_str(handle, id));
-}
-
-/* Initialize the ident module. */
-void init_ident(ident_if_t *id_if, int initial_n_idents)
-{
- if (id_if) {
- memcpy(&impl, id_if, sizeof(impl));
-
- if (! impl.new_id_from_str)
- impl.new_id_from_str = def_new_id_from_str;
- if (! impl.get_id_strlen)
- impl.get_id_strlen = def_get_id_strlen;
- } else {
- impl.new_id_from_str = set_new_id_from_str;
- impl.new_id_from_chars = set_new_id_from_chars;
- impl.get_id_str = set_get_id_str;
- impl.get_id_strlen = set_get_id_strlen;
- impl.finish_ident = set_finish_ident;
-
- /* it's ok to use memcmp here, we check only strings */
- impl.handle = new_set(memcmp, initial_n_idents);
- }