751481dd2de1df03a523ba8e3610e6ff99e60a09
[libfirm] / ir / ident / ident.h
1 /* Declarations for ident.
2    Copyright (C) 1995, 1996 Markus Armbruster */
3
4 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
5 ** All rights reserved.
6 **
7 ** Authors: Martin Trapp, Christian Schaefer
8 */
9
10 /* $Id$ */
11
12 # ifndef _IDENT_H_
13 # define _IDENT_H_
14
15 # include <stdio.h>
16 # include "assert.h"
17 # include "common.h"
18
19 /****h* libfirm/ident
20  *
21  * NAME
22  *   ident -- identifiers in the firm library
23  * NOTES
24  *  Identifiers are used in the firm library. This is the interface to it.
25  *  @@@ we need comparison of the prefis of two idents! (strncmp);
26  ******
27  */
28
29 /* Identifiers */
30 /****s* ident/ident
31  *
32  * NAME
33  *  ident - the abstract data type ident
34  * SOURCE
35  */
36 typedef const struct set_entry ident;
37 /*****/
38
39 /****f* ident/id_from_str
40  *
41  * NAME
42  *  id_from_str - store a string and create an ident
43  * SYNOPSIS
44  *  ident *id = id_from_str (const char *str, int len);
45  * FUNCTION
46  *  Stores a string in the ident module and returns a handle for the string.
47  *  Copies the string.
48  * INPUTS
49  *  str - the string (or whatever) which shall be stored
50  *  len - the length of the data in bytes
51  * RESULT
52  *  id - a handle for the generated ident
53  * SEE ALSO
54  *  id_to_str, id_to_strlen
55  ***
56  */
57 INLINE ident      *id_from_str (const char *str, int len);
58
59 /****f* ident/id_to_str
60  *
61  * NAME
62  *  id_to_str - return a string represented by an ident
63  * SYNOPSIS
64  *  char *cp = id_to_str (ident *id);
65  * FUNCTION
66  *  Returns the string cp represented by id. This string cp is not
67  *  Null terminated!  The string may not be changed.
68  * INPUTS
69  *  id - the ident
70  * RESULT
71  *  cp - a string
72  * SEE ALSO
73  *  id_from_str, id_to_strlen
74  ***
75  */
76 INLINE const char *id_to_str   (ident *id);
77
78 /****f* ident/id_to_strlen
79  *
80  * NAME
81  *  id_to_strlen - return the length of a string represented by an ident
82  * SYNOPSIS
83  *  int len = id_to_strlen (ident *id);
84  * FUNCTION
85  *  Returns the length of string represented by id.
86  * INPUTS
87  *  id - the ident
88  * RESULT
89  *  len - the length of the string
90  * SEE ALSO
91  *  id_from_str, id_to_str
92  ***
93  */
94 INLINE int  id_to_strlen(ident *id);
95
96 /****f* ident/id_is_suffix
97  *
98  * NAME
99  *
100  * SYNOPSIS
101  *  int id_is_prefix (ident *prefix, ident *id);
102  * FUNCTION
103  *  Returns true if prefix is prefix of id.
104  * INPUTS
105  *  prefix - the prefix
106  *  id - the ident
107  * SEE ALSO
108  *  id_from_str, id_to_str, id_is_prefix
109  ***
110  */
111 /*  */
112 int id_is_prefix (ident *prefix, ident *id);
113
114 /****f* ident/id_is_suffix
115  *
116  * NAME
117  *
118  * SYNOPSIS
119  *  int id_is_suffix (ident *suffix, ident *id);
120  * FUNCTION
121  *  Returns true if suffix is suffix of id.
122  * INPUTS
123  *  suffix - the suffix
124  *  id - the ident
125  * SEE ALSO
126  *  id_from_str, id_to_str, id_is_prefix
127  ***
128  */
129 /*  */
130 int id_is_suffix (ident *suffix, ident *id);
131
132 /****f* ident/print_id
133  *
134  * NAME
135  *
136  * SYNOPSIS
137  *  int print_id (ident *id);
138  * FUNCTION
139  *  Prints the ident to stdout.
140  * INPUTS
141  *  The ident to print.
142  * SEE ALSO
143  *  id_from_str, id_to_str, id_is_prefix, fprint_id
144  ***
145  */
146 /*  */
147 int print_id (ident *id);
148
149 /****f* ident/fprint_id
150  *
151  * NAME
152  *
153  * SYNOPSIS
154  *  int fprint_id (FILE *f, ident *id);
155  * FUNCTION
156  *  Prints the ident to the file passed.
157  * INPUTS
158  *  The ident to print and the file.
159  * SEE ALSO
160  *  id_from_str, id_to_str, id_is_prefix, print_id
161  ***
162  */
163 /*  */
164 int fprint_id (FILE *F, ident *id);
165
166
167 # endif /* _IDENT_H_ */