Remove .*_ptr variants of firm-types
[libfirm] / include / libfirm / ident.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief    Data type for unique names.
23  * @author   Goetz Lindenmaier
24  * @brief    Declarations for identifiers in the firm library
25  */
26 #ifndef FIRM_IDENT_H
27 #define FIRM_IDENT_H
28
29 #include <stddef.h>
30 #include "firm_types.h"
31 #include "begin.h"
32
33 /**
34  * @defgroup ir_ident  Identifiers
35  * @{
36  */
37
38 /**
39  *  Store a string and create an ident.
40  *
41  *  Stores a string in the ident module and returns a handle for the string.
42  *
43  *  Copies the string. @p str must be zero terminated
44  *
45  * @param str   the string which shall be stored
46  * @return id   a handle for the generated ident
47  * @see get_id_str(), get_id_strlen()
48  */
49 FIRM_API ident *new_id_from_str(const char *str);
50
51 /** Store a string and create an ident.
52  *
53  * Stores a string in the ident module and returns a handle for the string.
54  * Copies the string. This version takes non-zero-terminated strings.
55  *
56  * @param str   the string (or whatever) which shall be stored
57  * @param len   the length of the data in bytes
58  * @return id   a handle for the generated ident
59  * @see new_id_from_str(), get_id_strlen()
60  */
61 FIRM_API ident *new_id_from_chars(const char *str, size_t len);
62
63 /**
64  * Returns a string represented by an ident.
65  *
66  * Returns the string represented by id. This string is
67  * NULL terminated. The string may not be changed.
68  *
69  * @param id   the ident
70  * @return cp   a string
71  * @see new_id_from_str(), new_id_from_chars(), get_id_strlen()
72  */
73 FIRM_API const char *get_id_str(ident *id);
74
75 /**
76  * Returns the length of the string represented by an ident.
77  *
78  * @param id   the ident
79  * @return len   the length of the string
80  * @see new_id_from_str(), new_id_from_chars(), get_id_str()
81  */
82 FIRM_API size_t get_id_strlen(ident *id);
83
84 /**
85  * Returns true if prefix is a prefix of an ident.
86  *
87  * @param prefix   the prefix
88  * @param id       the ident
89  * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
90  */
91 FIRM_API int id_is_prefix(ident *prefix, ident *id);
92
93 /**
94  * Returns true if suffix is a suffix of an ident.
95  *
96  * @param suffix   the suffix
97  * @param id       the ident
98  * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
99  */
100 FIRM_API int id_is_suffix(ident *suffix, ident *id);
101
102 /**
103  * Return true if an ident contains a given character.
104  *
105  * @param id    the ident
106  * @param c     the character
107  * @see new_id_from_str(), new_id_from_chars(), get_id_str()
108  */
109 FIRM_API int id_contains_char(ident *id, char c);
110
111 /**
112  * helper function for creating unique idents. It contains an internal counter
113  * and replaces a "%u" inside the tag with the counter.
114  */
115 FIRM_API ident *id_unique(const char *tag);
116
117 /** Computes a definite name for this entity by concatenating
118    the name of the owner type and the name of the entity with
119    a separating "_". */
120 FIRM_API ident *id_mangle_entity(const ir_entity *ent);
121
122 /** mangle underscore: Returns a new ident that represents first_scnd. */
123 FIRM_API ident *id_mangle_u(ident *first, ident* scnd);
124
125 /** mangle dot: Returns a new ident that represents first.scnd. */
126 FIRM_API ident *id_mangle_dot(ident *first, ident* scnd);
127
128 /** mangle: Returns a new ident that represents firstscnd. */
129 FIRM_API ident *id_mangle(ident *first, ident* scnd);
130
131 /** Returns a new ident that represents 'prefixscndsuffix'. */
132 FIRM_API ident *id_mangle3(const char *prefix, ident *middle,
133                            const char *suffix);
134
135 /** returns a mangled name for a Win32 function using its calling convention */
136 FIRM_API ident *id_decorate_win32_c_fkt(const ir_entity *ent, ident *id);
137
138 /** @} */
139
140 #include "end.h"
141
142 #endif