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