* Updated header: Added 2006. Changed address of FSF. Changed email
[cacao.git] / src / vm / loader.h
1 /* src/vm/loader.h - class loader header
2
3    Copyright (C) 1996-2005, 2006 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    Contact: cacao@cacaojvm.org
26
27    Authors: Reinhard Grafl
28
29    Changes: Christian Thalinger
30
31    $Id: loader.h 4357 2006-01-22 23:33:38Z twisti $
32 */
33
34
35 #ifndef _LOADER_H
36 #define _LOADER_H
37
38 #include "config.h"
39
40 #include <stdio.h>
41
42 #include "vm/types.h"
43
44
45 /* forward typedefs ***********************************************************/
46
47 typedef struct classbuffer classbuffer;
48
49
50 #include "vm/class.h"
51 #include "vm/descriptor.h"
52 #include "vm/global.h"
53 #include "vm/references.h"
54 #include "vm/method.h"
55 #include "vm/utf8.h"
56
57
58 /* constant pool entries *******************************************************
59
60         All constant pool entries need a data structure which contain the entrys
61         value. In some cases this structure exist already, in the remaining cases
62         this structure must be generated:
63
64                 kind                      structure                     generated?
65         ----------------------------------------------------------------------
66     CONSTANT_Class               classinfo                           no   XXX this will change
67     CONSTANT_Fieldref            constant_FMIref                    yes
68     CONSTANT_Methodref           constant_FMIref                    yes
69     CONSTANT_InterfaceMethodref  constant_FMIref                    yes
70     CONSTANT_String              unicode                             no
71     CONSTANT_Integer             constant_integer                   yes
72     CONSTANT_Float               constant_float                     yes
73     CONSTANT_Long                constant_long                      yes
74     CONSTANT_Double              constant_double                    yes
75     CONSTANT_NameAndType         constant_nameandtype               yes
76     CONSTANT_Utf8                unicode                             no
77     CONSTANT_UNUSED              -
78
79 *******************************************************************************/
80
81 typedef struct {            /* Integer                                        */
82         s4 value;
83 } constant_integer;
84
85         
86 typedef struct {            /* Float                                          */
87         float value;
88 } constant_float;
89
90
91 typedef struct {            /* Long                                           */
92         s8 value;
93 } constant_long;
94         
95
96 typedef struct {            /* Double                                         */
97         double value;
98 } constant_double;
99
100
101 typedef struct {            /* NameAndType (Field or Method)                  */
102         utf *name;              /* field/method name                              */
103         utf *descriptor;        /* field/method type descriptor string            */
104 } constant_nameandtype;
105
106
107 /* classbuffer ****************************************************************/
108
109 struct classbuffer {
110         classinfo *class;                   /* pointer to classinfo structure     */
111         u1        *data;                    /* pointer to byte code               */
112         s4         size;                    /* size of the byte code              */
113         u1        *pos;                     /* current read position              */
114         char      *path;                    /* path to file (for debugging)       */
115 };
116
117
118 /* export variables ***********************************************************/
119
120 #if defined(USE_THREADS)
121 extern int blockInts;
122 #endif
123
124
125 /* function prototypes ********************************************************/
126
127 /* initialize loader, load important systemclasses */
128 bool loader_init(u1 *stackbottom);
129
130 void loader_load_all_classes(void);
131
132 /* free resources */
133 void loader_close(void);
134
135 /* class loading functions */
136 classinfo *load_class_from_sysloader(utf *name);
137 classinfo *load_class_from_classloader(utf *name, java_objectheader *cl);
138 classinfo *load_class_bootstrap(utf *name);
139
140 /* (don't use the following directly) */
141 classinfo *load_class_from_classbuffer(classbuffer *cb);
142 classinfo *load_newly_created_array(classinfo *c,java_objectheader *loader);
143
144 #endif /* _LOADER_H */
145
146 /*
147  * These are local overrides for various environment variables in Emacs.
148  * Please do not remove this and leave it at the end of the file, where
149  * Emacs will automagically detect them.
150  * ---------------------------------------------------------------------
151  * Local variables:
152  * mode: c
153  * indent-tabs-mode: t
154  * c-basic-offset: 4
155  * tab-width: 4
156  * End:
157  */