* Dummy commit to fix conversion problems with some files.
[cacao.git] / src / vmcore / loader.h
1 /* src/vmcore/loader.h - class loader header
2
3    Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, 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., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    $Id: loader.h 8324 2007-08-16 16:48:12Z michi $
26 */
27
28
29 #ifndef _LOADER_H
30 #define _LOADER_H
31
32 /* forward typedefs ***********************************************************/
33
34 typedef struct classbuffer classbuffer;
35
36
37 #include "config.h"
38
39 #include <stdio.h>
40
41 #include "vm/types.h"
42
43 #include "vm/global.h"
44
45 #include "vmcore/descriptor.h"
46 #include "vmcore/class.h"
47 #include "vmcore/method.h"
48 #include "vmcore/references.h"
49 #include "vmcore/utf8.h"
50
51
52 /* constant pool entries *******************************************************
53
54         All constant pool entries need a data structure which contain the entrys
55         value. In some cases this structure exist already, in the remaining cases
56         this structure must be generated:
57
58                 kind                      structure                     generated?
59         ----------------------------------------------------------------------
60     CONSTANT_Class               constant_classref                  yes
61     CONSTANT_Fieldref            constant_FMIref                    yes
62     CONSTANT_Methodref           constant_FMIref                    yes
63     CONSTANT_InterfaceMethodref  constant_FMIref                    yes
64     CONSTANT_String              unicode                             no
65     CONSTANT_Integer             constant_integer                   yes
66     CONSTANT_Float               constant_float                     yes
67     CONSTANT_Long                constant_long                      yes
68     CONSTANT_Double              constant_double                    yes
69     CONSTANT_NameAndType         constant_nameandtype               yes
70     CONSTANT_Utf8                unicode                             no
71     CONSTANT_UNUSED              -
72
73 *******************************************************************************/
74
75 typedef struct {            /* Integer                                        */
76         s4 value;
77 } constant_integer;
78
79         
80 typedef struct {            /* Float                                          */
81         float value;
82 } constant_float;
83
84
85 typedef struct {            /* Long                                           */
86         s8 value;
87 } constant_long;
88         
89
90 typedef struct {            /* Double                                         */
91         double value;
92 } constant_double;
93
94
95 typedef struct {            /* NameAndType (Field or Method)                  */
96         utf *name;              /* field/method name                              */
97         utf *descriptor;        /* field/method type descriptor string            */
98 } constant_nameandtype;
99
100
101 /* classbuffer ****************************************************************/
102
103 struct classbuffer {
104         classinfo *class;                   /* pointer to classinfo structure     */
105         u1        *data;                    /* pointer to byte code               */
106         s4         size;                    /* size of the byte code              */
107         u1        *pos;                     /* current read position              */
108         char      *path;                    /* path to file (for debugging)       */
109 };
110
111
112 /* hashtable_classloader_entry *************************************************
113
114    ATTENTION: The pointer to the classloader object needs to be the
115    first field of the entry, so that it can be used as an indirection
116    cell. This is checked by gc_init() during startup.
117
118 *******************************************************************************/
119
120 typedef struct hashtable_classloader_entry hashtable_classloader_entry;
121
122 struct hashtable_classloader_entry {
123         java_object_t               *object;
124         hashtable_classloader_entry *hashlink;
125 };
126
127
128 /* classloader ****************************************************************/
129
130 typedef hashtable_classloader_entry classloader;
131
132
133 /* function prototypes ********************************************************/
134
135 /* initialize loader, load important systemclasses */
136 bool loader_init(void);
137
138 /* classloader management functions */
139 classloader *loader_hashtable_classloader_add(java_handle_t *cl);
140 classloader *loader_hashtable_classloader_find(java_handle_t *cl);
141
142 void loader_load_all_classes(void);
143
144 bool loader_skip_attribute_body(classbuffer *cb);
145
146 #if defined(ENABLE_JAVASE)
147 bool loader_load_attribute_signature(classbuffer *cb, utf **signature);
148 #endif
149
150 /* free resources */
151 void loader_close(void);
152
153 /* class loading functions */
154 classinfo *load_class_from_sysloader(utf *name);
155 classinfo *load_class_from_classloader(utf *name, classloader *cl);
156 classinfo *load_class_bootstrap(utf *name);
157
158 /* (don't use the following directly) */
159 classinfo *load_class_from_classbuffer(classbuffer *cb);
160 classinfo *load_newly_created_array(classinfo *c, classloader *loader);
161
162 #endif /* _LOADER_H */
163
164 /*
165  * These are local overrides for various environment variables in Emacs.
166  * Please do not remove this and leave it at the end of the file, where
167  * Emacs will automagically detect them.
168  * ---------------------------------------------------------------------
169  * Local variables:
170  * mode: c
171  * indent-tabs-mode: t
172  * c-basic-offset: 4
173  * tab-width: 4
174  * End:
175  * vim:noexpandtab:sw=4:ts=4:
176  */