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
8 This file is part of CACAO.
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.
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.
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
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Reinhard Grafl
29 Changes: Christian Thalinger
31 $Id: tables.h 2665 2005-06-13 14:22:44Z twisti $
42 /* forward typedefs ***********************************************************/
44 typedef struct hashtable hashtable;
51 /* data structures for hashtables ********************************************
53 All utf-symbols, javastrings and classes are stored in global
54 hashtables, so every symbol exists only once. Equal symbols have
55 identical pointers. The functions for adding hashtable elements
56 search the table for the element with the specified name/text and
57 return it on success. Otherwise a new hashtable element is created.
59 The hashtables use external linking for handling collisions. The
60 hashtable structure contains a pointer <ptr> to the array of
61 hashtable slots. The number of hashtable slots and therefore the
62 size of this array is specified by the element <size> of hashtable
63 structure. <entries> contains the number of all hashtable elements
64 stored in the table, including those in the external chains. The
65 hashtable element structures (utf, literalstring, classinfo)
66 contain both a pointer to the next hashtable element as a link for
67 the external hash chain and the key of the element. The key is
68 computed from the text of the string or the classname by using up
71 If the number of entries in the hashtable exceeds twice the size of
72 the hashtableslot-array it is supposed that the average length of
73 the external chains has reached a value beyond 2. Therefore the
74 functions for adding hashtable elements (utf_new, class_new,
75 literalstring_new) double the hashtableslot-array. In this
76 restructuring process all elements have to be inserted into the new
77 hashtable and new external chains must be built.
79 Example for the layout of a hashtable:
81 hashtable.ptr-->+-------------------+
85 +-------------------+ +-------------------+ +-------------------+
86 | hashtable element |-->| hashtable element |-->| hashtable element |-->NULL
87 +-------------------+ +-------------------+ +-------------------+
89 +-------------------+ +-------------------+
90 | hashtable element |-->| hashtable element |-->NULL
91 +-------------------+ +-------------------+
92 | hashtable element |-->NULL
102 /* hashtable ******************************************************************/
106 u4 entries; /* number of entries in the table */
107 void **ptr; /* pointer to hashtable */
111 #define CLASS(name) (unicode_getclasslink(unicode_new_char(name)))
113 extern hashtable utf_hash; /* hashtable for utf8-symbols */
114 extern hashtable string_hash; /* hashtable for javastrings */
117 /* function prototypes ********************************************************/
119 /* creates hashtables for symboltables */
120 void tables_init(void);
122 /* free memory for hashtables */
123 void tables_close(void);
125 /* get javatype according to a typedescriptor */
126 u2 desc_to_type(utf *descriptor);
128 /* get length of a datatype */
129 u2 desc_typesize(utf *descriptor);
131 /* create hashtable */
132 void init_hashtable(hashtable *hash, u4 size);
134 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
135 void tables_lock(void);
136 void tables_unlock(void);
139 #endif /* _TABLES_H */
143 * These are local overrides for various environment variables in Emacs.
144 * Please do not remove this and leave it at the end of the file, where
145 * Emacs will automagically detect them.
146 * ---------------------------------------------------------------------
149 * indent-tabs-mode: t