2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Data type for unique names.
23 * @author Goetz Lindenmaier
26 * Declarations for identifiers in the firm library
28 * Identifiers are used in the firm library. This is the interface to it.
30 #ifndef FIRM_IDENT_IDENT_H
31 #define FIRM_IDENT_IDENT_H
33 #include "firm_types.h"
39 * The ident module interface.
46 * Store a string and create an ident.
47 * This function may be NULL, new_id_from_chars()
48 * is then used to emulate its behavior.
50 * @param str the string which shall be stored
52 ident *(*new_id_from_str)(void *handle, const char *str);
55 * Store a string and create an ident.
57 * @param str the string (or whatever) which shall be stored
58 * @param len the length of the data in bytes
60 ident *(*new_id_from_chars)(void *handle, const char *str, int len);
63 * Returns a string represented by an ident.
65 const char *(*get_id_str)(void *handle, ident *id);
68 * Returns the length of the string represented by an ident.
69 * This function may be NULL, get_id_str() is then used
70 * to emulate its behavior.
74 int (*get_id_strlen)(void *handle, ident *id);
77 * Finish the ident module and frees all idents, may be NULL.
79 void (*finish_ident)(void *handle);
83 * Store a string and create an ident.
85 * Stores a string in the ident module and returns a handle for the string.
87 * Copies the string. @p str must be zero terminated
89 * @param str the string which shall be stored
91 * @return id a handle for the generated ident
93 * @see get_id_str(), get_id_strlen()
95 FIRM_DLL ident *new_id_from_str(const char *str);
97 /** Store a string and create an ident.
99 * Stores a string in the ident module and returns a handle for the string.
100 * Copies the string. This version takes non-zero-terminated strings.
102 * @param str the string (or whatever) which shall be stored
103 * @param len the length of the data in bytes
105 * @return id a handle for the generated ident
107 * @see new_id_from_str(), get_id_strlen()
109 FIRM_DLL ident *new_id_from_chars(const char *str, int len);
112 * Returns a string represented by an ident.
114 * Returns the string represented by id. This string is
115 * NULL terminated. The string may not be changed.
117 * @param id the ident
119 * @return cp a string
121 * @see new_id_from_str(), new_id_from_chars(), get_id_strlen()
123 FIRM_DLL const char *get_id_str(ident *id);
126 * Returns the length of the string represented by an ident.
128 * @param id the ident
130 * @return len the length of the string
132 * @see new_id_from_str(), new_id_from_chars(), get_id_str()
134 FIRM_DLL int get_id_strlen(ident *id);
137 * Returns true if prefix is a prefix of an ident.
139 * @param prefix the prefix
140 * @param id the ident
142 * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
144 FIRM_DLL int id_is_prefix(ident *prefix, ident *id);
147 * Returns true if suffix is a suffix of an ident.
149 * @param suffix the suffix
150 * @param id the ident
152 * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
154 FIRM_DLL int id_is_suffix(ident *suffix, ident *id);
157 * Return true if an ident contains a given character.
159 * @param id the ident
160 * @param c the character
162 * @see new_id_from_str(), new_id_from_chars(), get_id_str()
164 FIRM_DLL int id_contains_char(ident *id, char c);
167 * helper function for creating unique idents. It contains an internal counter
168 * and replaces a "%u" inside the tag with the counter.
170 FIRM_DLL ident *id_unique(const char *tag);
172 /** initializes the name mangling code */
173 FIRM_DLL void firm_init_mangle (void);
175 /** Computes a definite name for this entity by concatenating
176 the name of the owner type and the name of the entity with
178 FIRM_DLL ident *id_mangle_entity(ir_entity *ent);
180 /** mangle underscore: Returns a new ident that represents first_scnd. */
181 FIRM_DLL ident *id_mangle_u(ident *first, ident* scnd);
183 /** mangle dot: Returns a new ident that represents first.scnd. */
184 FIRM_DLL ident *id_mangle_dot(ident *first, ident* scnd);
186 /** mangle: Returns a new ident that represents firstscnd. */
187 FIRM_DLL ident *id_mangle(ident *first, ident* scnd);
189 /** Returns a new ident that represents 'prefixscndsuffix'. */
190 FIRM_DLL ident *id_mangle3(const char *prefix, ident *middle,
193 /** returns a mangled name for a Win32 function using its calling convention */
194 FIRM_DLL ident *id_decorate_win32_c_fkt(ir_entity *ent, ident *id);