GNU header update.
[cacao.git] / src / vm / tables.h
1 /* tables.h - 
2
3    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Reinhard Grafl
28
29    $Id: tables.h 1735 2004-12-07 14:33:27Z twisti $
30
31 */
32
33
34 #ifndef _TABLES_H
35 #define _TABLES_H
36
37 #include <stdio.h>
38 #include "global.h" /* for unicode. -- phil */
39
40 #define CLASS(name)     (unicode_getclasslink(unicode_new_char(name)))
41
42 /* to determine the end of utf strings */
43 #define utf_end(utf) ((char *) utf->text+utf->blength)
44
45 extern hashtable utf_hash;     /* hashtable for utf8-symbols */
46 extern hashtable string_hash;  /* hashtable for javastrings  */
47 extern hashtable class_hash;   /* hashtable for classes      */
48
49 extern list unlinkedclasses;   /* this is only used for eager class loading   */
50
51
52 /* creates hashtables for symboltables */
53 void tables_init();
54
55 /* free memory for hashtables */ 
56 void tables_close();
57
58 /* check if a UTF-8 string is valid */
59 bool is_valid_utf(char *utf_ptr, char *end_pos);
60
61 /* check if a UTF-8 string may be used as a class/field/method name */
62 bool is_valid_name(char *utf_ptr, char *end_pos);
63 bool is_valid_name_utf(utf *u);
64
65 /* write utf symbol to file/buffer */
66 void utf_sprint(char *buffer, utf *u);
67 void utf_sprint_classname(char *buffer, utf *u);
68 void utf_fprint(FILE *file, utf *u);
69 void utf_fprint_classname(FILE *file, utf *u);
70 void utf_display(utf *u);
71 void utf_display_classname(utf *u);
72
73 /* write utf symbol to logfile/stdout */
74 void log_utf(utf *u);
75 void log_plain_utf(utf *u);
76
77 /* create new utf-symbol */
78 utf *utf_new(char *text, u2 length);
79
80 /* without locking (caller already holding lock*/
81 utf *utf_new_intern(char *text, u2 length);
82
83 utf *utf_new_char(char *text);
84 utf *utf_new_char_classname(char *text);
85
86 /* show utf-table */
87 void utf_show();
88
89 /* get next unicode character of a utf-string */
90 u2 utf_nextu2(char **utf);
91
92 /* get number of unicode characters of a utf string */
93 u4 utf_strlen(utf *u);
94
95 /* search for class and create it if not found */
96 classinfo *class_new(utf *u);
97
98 /* without locking (caller already holding lock*/
99 classinfo *class_new_intern(utf *u);
100
101 /* return an array class with the given component class */
102 classinfo *class_array_of(classinfo *component);
103
104 /* return an array class with the given dimension and element class */
105 classinfo *class_multiarray_of(int dim, classinfo *element);
106
107 /* get javatype according to a typedescriptor */
108 u2 desc_to_type(utf *descriptor);
109
110 /* get length of a datatype */
111 u2 desc_typesize(utf *descriptor);
112
113 /* determine hashkey of a unicode-symbol */
114 u4 unicode_hashkey(u2 *text, u2 length);
115
116 /* create hashtable */
117 void init_hashtable(hashtable *hash, u4 size);
118
119 /* search for class in classtable */
120 classinfo *class_get(utf *u);
121
122 /* remove class from classtable */
123 bool class_remove(classinfo *c);
124
125 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
126 void tables_lock();
127 void tables_unlock();
128 #endif
129
130 #endif /* _TABLES_H */
131
132
133 /*
134  * These are local overrides for various environment variables in Emacs.
135  * Please do not remove this and leave it at the end of the file, where
136  * Emacs will automagically detect them.
137  * ---------------------------------------------------------------------
138  * Local variables:
139  * mode: c
140  * indent-tabs-mode: t
141  * c-basic-offset: 4
142  * tab-width: 4
143  * End:
144  */