2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Data type for unique names.
9 * @author Goetz Lindenmaier
10 * @brief Declarations for identifiers in the firm library
16 #include "firm_types.h"
20 * @defgroup ir_ident Identifiers
25 * Store a string and create an ident.
27 * Stores a string in the ident module and returns a handle for the string.
29 * Copies the string. @p str must be zero terminated
31 * @param str the string which shall be stored
32 * @return id a handle for the generated ident
34 FIRM_API ident *new_id_from_str(const char *str);
36 /** Store a string and create an ident.
38 * Stores a string in the ident module and returns a handle for the string.
39 * Copies the string. This version takes non-zero-terminated strings.
41 * @param str the string (or whatever) which shall be stored
42 * @param len the length of the data in bytes
43 * @return id a handle for the generated ident
45 FIRM_API ident *new_id_from_chars(const char *str, size_t len);
48 * Returns a string represented by an ident.
50 * Returns the string represented by id. This string is
51 * NULL terminated. The string may not be changed.
56 FIRM_API const char *get_id_str(ident *id);
59 * Returns the length of the string represented by an ident.
62 * @return len the length of the string
64 FIRM_API size_t get_id_strlen(ident *id);
67 * Test if @p prefix is a prefix of ident @p id.
69 * @param prefix the prefix
71 * @returns 1 if @p prefix is prefix of @p id, 0 otherwise
73 FIRM_API int id_is_prefix(ident *prefix, ident *id);
76 * Test if @p suffix is a suffix of ident @p id.
78 * @param suffix the suffix
80 * @returns 1 if @p suffix is suffix of @p id, 0 otherwise
82 FIRM_API int id_is_suffix(ident *suffix, ident *id);
85 * Test if identifier contains a given character.
88 * @param c the character
89 * @returns 1 if character is contained, 0 otherwise
91 FIRM_API int id_contains_char(ident *id, char c);
94 * helper function for creating unique idents. It contains an internal counter
95 * and replaces a "%u" inside the tag with the counter.
97 FIRM_API ident *id_unique(const char *tag);
99 /** mangle underscore: Returns a new ident that represents first_scnd. */
100 FIRM_API ident *id_mangle_u(ident *first, ident* scnd);
102 /** mangle dot: Returns a new ident that represents first.scnd. */
103 FIRM_API ident *id_mangle_dot(ident *first, ident* scnd);
105 /** mangle: Returns a new ident that represents firstscnd. */
106 FIRM_API ident *id_mangle(ident *first, ident* scnd);
108 /** Returns a new ident that represents 'prefixscndsuffix'. */
109 FIRM_API ident *id_mangle3(const char *prefix, ident *middle,