added functions for dynamically creating classrefs
[cacao.git] / src / vm / class.h
1 /* src/vm/class.h - class related functions header
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: Christian Thalinger
28
29    Changes:
30
31    $Id: class.h 2093 2005-03-27 15:16:57Z edwin $
32
33 */
34
35
36 #ifndef _CLASS_H
37 #define _CLASS_H
38
39 #include "vm/tables.h"
40 #include "vm/utf8.h"
41
42
43 /* global variables ***********************************************************/
44
45 extern hashtable class_hash;            /* hashtable for classes              */
46
47 extern list unlinkedclasses;   /* this is only used for eager class loading   */
48
49
50 /* frequently used classes ****************************************************/
51
52 /* important system classes */
53
54 extern classinfo *class_java_lang_Object;
55 extern classinfo *class_java_lang_Class;
56 extern classinfo *class_java_lang_ClassLoader;
57 extern classinfo *class_java_lang_Cloneable;
58 extern classinfo *class_java_lang_SecurityManager;
59 extern classinfo *class_java_lang_String;
60 extern classinfo *class_java_lang_System;
61 extern classinfo *class_java_io_Serializable;
62
63
64 /* system exception classes required in cacao */
65
66 extern classinfo *class_java_lang_Throwable;
67 extern classinfo *class_java_lang_VMThrowable;
68 extern classinfo *class_java_lang_Exception;
69 extern classinfo *class_java_lang_Error;
70 extern classinfo *class_java_lang_OutOfMemoryError;
71
72
73 extern classinfo *class_java_lang_Void;
74 extern classinfo *class_java_lang_Boolean;
75 extern classinfo *class_java_lang_Byte;
76 extern classinfo *class_java_lang_Character;
77 extern classinfo *class_java_lang_Short;
78 extern classinfo *class_java_lang_Integer;
79 extern classinfo *class_java_lang_Long;
80 extern classinfo *class_java_lang_Float;
81 extern classinfo *class_java_lang_Double;
82
83
84 /* some classes which may be used more often */
85
86 extern classinfo *class_java_util_Vector;
87
88
89 /* macros *********************************************************************/
90
91 /* initialize a constant_classref with referer `ref` and name `classname` */
92 #define CLASSREF_INIT(c,ref,classname)                          \
93                         do { (c).pseudo_vftbl = CLASSREF_PSEUDO_VFTBL;      \
94                                  (c).referer = (ref);                           \
95                                  (c).name = (classname); } while (0)
96
97 /* function prototypes ********************************************************/
98
99 void class_init_foo(void);
100
101 /* search for class and create it if not found */
102 classinfo *class_new(utf *u);
103
104 /* without locking (caller already holding lock*/
105 classinfo *class_new_intern(utf *u);
106
107 /* search for class in classtable */
108 classinfo *class_get(utf *u);
109
110 /* remove class from classtable */
111 bool class_remove(classinfo *c);
112
113 /* return an array class with the given component class */
114 classinfo *class_array_of(classinfo *component);
115
116 /* return an array class with the given dimension and element class */
117 classinfo *class_multiarray_of(s4 dim, classinfo *element);
118
119 /* return a classref for the given class name */
120 /* (does a linear search!)                    */
121 constant_classref *class_lookup_classref(classinfo *cls,utf *name);
122
123 /* return a classref for the given class name */
124 /* (does a linear search!)                    */
125 constant_classref *class_get_classref(classinfo *cls,utf *name);
126
127 /* return a classref for an array with the given dimension of with the */
128 /* given component type */
129 constant_classref *class_get_classref_multiarray_of(s4 dim,constant_classref *ref);
130
131 /* return a classref for the component type of the given array type */
132 constant_classref *class_get_classref_component_of(constant_classref *ref);
133
134 #endif /* _CLASS_H */
135
136
137 /*
138  * These are local overrides for various environment variables in Emacs.
139  * Please do not remove this and leave it at the end of the file, where
140  * Emacs will automagically detect them.
141  * ---------------------------------------------------------------------
142  * Local variables:
143  * mode: c
144  * indent-tabs-mode: t
145  * c-basic-offset: 4
146  * tab-width: 4
147  * End:
148  */