* src/vmcore/loader.h (classbuffer): Use stdint data types.
[cacao.git] / src / vmcore / loader.h
1 /* src/vmcore/loader.h - class loader header
2
3    Copyright (C) 1996-2005, 2006, 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23 */
24
25
26 #ifndef _LOADER_H
27 #define _LOADER_H
28
29 /* forward typedefs ***********************************************************/
30
31 typedef struct classbuffer classbuffer;
32
33
34 #include "config.h"
35
36 #include <stdio.h>
37
38 #include "vm/types.h"
39
40 #include "vm/global.h"
41
42 #include "vmcore/descriptor.h"
43 #include "vmcore/class.h"
44 #include "vmcore/method.h"
45 #include "vmcore/references.h"
46 #include "vmcore/utf8.h"
47
48
49 /* constant pool entries *******************************************************
50
51         All constant pool entries need a data structure which contain the entrys
52         value. In some cases this structure exist already, in the remaining cases
53         this structure must be generated:
54
55                 kind                      structure                     generated?
56         ----------------------------------------------------------------------
57     CONSTANT_Class               constant_classref                  yes
58     CONSTANT_Fieldref            constant_FMIref                    yes
59     CONSTANT_Methodref           constant_FMIref                    yes
60     CONSTANT_InterfaceMethodref  constant_FMIref                    yes
61     CONSTANT_String              unicode                             no
62     CONSTANT_Integer             constant_integer                   yes
63     CONSTANT_Float               constant_float                     yes
64     CONSTANT_Long                constant_long                      yes
65     CONSTANT_Double              constant_double                    yes
66     CONSTANT_NameAndType         constant_nameandtype               yes
67     CONSTANT_Utf8                unicode                             no
68     CONSTANT_UNUSED              -
69
70 *******************************************************************************/
71
72 typedef struct {            /* Integer                                        */
73         s4 value;
74 } constant_integer;
75
76         
77 typedef struct {            /* Float                                          */
78         float value;
79 } constant_float;
80
81
82 typedef struct {            /* Long                                           */
83         s8 value;
84 } constant_long;
85         
86
87 typedef struct {            /* Double                                         */
88         double value;
89 } constant_double;
90
91
92 typedef struct {            /* NameAndType (Field or Method)                  */
93         utf *name;              /* field/method name                              */
94         utf *descriptor;        /* field/method type descriptor string            */
95 } constant_nameandtype;
96
97
98 /* classbuffer ****************************************************************/
99
100 struct classbuffer {
101         classinfo *class;                   /* pointer to classinfo structure     */
102         uint8_t   *data;                    /* pointer to byte code               */
103         int32_t    size;                    /* size of the byte code              */
104         uint8_t   *pos;                     /* current read position              */
105         char      *path;                    /* path to file (for debugging)       */
106 };
107
108
109 /* hashtable_classloader_entry *************************************************
110
111    ATTENTION: The pointer to the classloader object needs to be the
112    first field of the entry, so that it can be used as an indirection
113    cell. This is checked by gc_init() during startup.
114
115 *******************************************************************************/
116
117 typedef struct hashtable_classloader_entry hashtable_classloader_entry;
118
119 struct hashtable_classloader_entry {
120         java_object_t               *object;
121         hashtable_classloader_entry *hashlink;
122 };
123
124
125 /* classloader *****************************************************************
126
127    [!ENABLE_HANDLES]: The classloader is a Java Object which cannot move.
128    [ENABLE_HANDLES] : The classloader entry itself is a static handle for a
129                       given classloader (use loader_hashtable_classloader_foo).
130
131 *******************************************************************************/
132
133 #if defined(ENABLE_HANDLES)
134 typedef hashtable_classloader_entry classloader;
135 #else
136 typedef java_object_t classloader;
137 #endif
138
139
140 /* function prototypes ********************************************************/
141
142 void loader_preinit(void);
143 void loader_init(void);
144
145 /* classloader management functions */
146 classloader *loader_hashtable_classloader_add(java_handle_t *cl);
147 classloader *loader_hashtable_classloader_find(java_handle_t *cl);
148
149 void loader_load_all_classes(void);
150
151 bool loader_skip_attribute_body(classbuffer *cb);
152
153 #if defined(ENABLE_JAVASE)
154 bool loader_load_attribute_signature(classbuffer *cb, utf **signature);
155 #endif
156
157 /* free resources */
158 void loader_close(void);
159
160 /* class loading functions */
161 classinfo *load_class_from_sysloader(utf *name);
162 classinfo *load_class_from_classloader(utf *name, classloader *cl);
163 classinfo *load_class_bootstrap(utf *name);
164
165 /* (don't use the following directly) */
166 classinfo *load_class_from_classbuffer(classbuffer *cb);
167 classinfo *load_newly_created_array(classinfo *c, classloader *loader);
168
169 #endif /* _LOADER_H */
170
171 /*
172  * These are local overrides for various environment variables in Emacs.
173  * Please do not remove this and leave it at the end of the file, where
174  * Emacs will automagically detect them.
175  * ---------------------------------------------------------------------
176  * Local variables:
177  * mode: c
178  * indent-tabs-mode: t
179  * c-basic-offset: 4
180  * tab-width: 4
181  * End:
182  * vim:noexpandtab:sw=4:ts=4:
183  */