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"
38 * The ident module interface.
45 * Store a string and create an ident.
46 * This function may be NULL, new_id_from_chars()
47 * is then used to emulate its behavior.
49 * @param str the string which shall be stored
51 ident *(*new_id_from_str)(void *handle, const char *str);
54 * Store a string and create an ident.
56 * @param str the string (or whatever) which shall be stored
57 * @param len the length of the data in bytes
59 ident *(*new_id_from_chars)(void *handle, const char *str, int len);
62 * Returns a string represented by an ident.
64 const char *(*get_id_str)(void *handle, ident *id);
67 * Returns the length of the string represented by an ident.
68 * This function may be NULL, get_id_str() is then used
69 * to emulate its behavior.
73 int (*get_id_strlen)(void *handle, ident *id);
76 * Finish the ident module and frees all idents, may be NULL.
78 void (*finish_ident)(void *handle);
82 * Store a string and create an ident.
84 * Stores a string in the ident module and returns a handle for the string.
86 * Copies the string. @p str must be zero terminated
88 * @param str the string which shall be stored
90 * @return id a handle for the generated ident
92 * @see get_id_str(), get_id_strlen()
94 ident *new_id_from_str(const char *str);
96 /** Store a string and create an ident.
98 * Stores a string in the ident module and returns a handle for the string.
99 * Copies the string. This version takes non-zero-terminated strings.
101 * @param str the string (or whatever) which shall be stored
102 * @param len the length of the data in bytes
104 * @return id a handle for the generated ident
106 * @see new_id_from_str(), get_id_strlen()
108 ident *new_id_from_chars(const char *str, int len);
111 * Returns a string represented by an ident.
113 * Returns the string represented by id. This string is
114 * NULL terminated. The string may not be changed.
116 * @param id the ident
118 * @return cp a string
120 * @see new_id_from_str(), new_id_from_chars(), get_id_strlen()
122 const char *get_id_str(ident *id);
125 * Returns the length of the string represented by an ident.
127 * @param id the ident
129 * @return len the length of the string
131 * @see new_id_from_str(), new_id_from_chars(), get_id_str()
133 int get_id_strlen(ident *id);
136 * Returns true if prefix is a prefix of an ident.
138 * @param prefix the prefix
139 * @param id the ident
141 * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
143 int id_is_prefix(ident *prefix, ident *id);
146 * Returns true if suffix is a suffix of an ident.
148 * @param suffix the suffix
149 * @param id the ident
151 * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
153 int id_is_suffix(ident *suffix, ident *id);
156 * Return true if an ident contains a given character.
158 * @param id the ident
159 * @param c the character
161 * @see new_id_from_str(), new_id_from_chars(), get_id_str()
163 int id_contains_char(ident *id, char c);
166 * helper function for creating unique idents. It contains an internal counter
167 * and replaces a "%u" inside the tag with the counter.
169 ident *id_unique(const char *tag);
171 /** initializes the name mangling code */
172 void firm_init_mangle(void);
174 /** Computes a definite name for this entity by concatenating
175 the name of the owner type and the name of the entity with
177 ident *id_mangle_entity(ir_entity *ent);
179 /** mangle underscore: Returns a new ident that represents first_scnd. */
180 ident *id_mangle_u(ident *first, ident* scnd);
182 /** mangle dot: Returns a new ident that represents first.scnd. */
183 ident *id_mangle_dot(ident *first, ident* scnd);
185 /** mangle: Returns a new ident that represents firstscnd. */
186 ident *id_mangle(ident *first, ident* scnd);
188 /** Returns a new ident that represents 'prefixscndsuffix'. */
189 ident *id_mangle3(const char *prefix, ident *middle, const char *suffix);
191 /** returns a mangled name for a Win32 function using its calling convention */
192 ident *id_decorate_win32_c_fkt(ir_entity *ent, ident *id);