1 /* src/vm/loader.h - class loader header
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 $Id: loader.h 3501 2005-10-26 20:27:15Z twisti $
39 /* forward typedefs ***********************************************************/
41 typedef struct classbuffer classbuffer;
42 typedef struct classpath_info classpath_info;
45 #include "vm/global.h"
47 #include "vm/references.h"
48 #include "vm/descriptor.h"
49 #include "vm/method.h"
52 # include "vm/unzip.h"
56 /* signed suck defines ********************************************************/
58 #define suck_s8(a) (s8) suck_u8((a))
59 #define suck_s2(a) (s2) suck_u2((a))
60 #define suck_s4(a) (s4) suck_u4((a))
61 #define suck_s1(a) (s1) suck_u1((a))
64 /* constant pool entries *******************************************************
66 All constant pool entries need a data structure which contain the entrys
67 value. In some cases this structure exist already, in the remaining cases
68 this structure must be generated:
70 kind structure generated?
71 ----------------------------------------------------------------------
72 CONSTANT_Class classinfo no XXX this will change
73 CONSTANT_Fieldref constant_FMIref yes
74 CONSTANT_Methodref constant_FMIref yes
75 CONSTANT_InterfaceMethodref constant_FMIref yes
76 CONSTANT_String unicode no
77 CONSTANT_Integer constant_integer yes
78 CONSTANT_Float constant_float yes
79 CONSTANT_Long constant_long yes
80 CONSTANT_Double constant_double yes
81 CONSTANT_NameAndType constant_nameandtype yes
82 CONSTANT_Utf8 unicode no
85 *******************************************************************************/
87 typedef struct { /* Integer */
92 typedef struct { /* Float */
97 typedef struct { /* Long */
102 typedef struct { /* Double */
107 typedef struct { /* NameAndType (Field or Method) */
108 utf *name; /* field/method name */
109 utf *descriptor; /* field/method type descriptor string */
110 } constant_nameandtype;
113 /* classbuffer ****************************************************************/
116 classinfo *class; /* pointer to classinfo structure */
117 u1 *data; /* pointer to byte code */
118 s4 size; /* size of the byte code */
119 u1 *pos; /* current read position */
120 char *path; /* path to file (for debugging) */
124 /* classpath_info *************************************************************/
126 #define CLASSPATH_PATH 0
127 #define CLASSPATH_ARCHIVE 1
129 struct classpath_info {
130 #if defined(USE_THREADS)
131 /* Required for monitor locking on zip/jar files. */
132 java_objectheader header;
137 #if defined(USE_ZLIB)
140 classpath_info *next;
144 /* export variables ***********************************************************/
146 #if defined(USE_THREADS)
147 extern int blockInts;
150 extern classpath_info *classpath_entries;
153 /* function prototypes ********************************************************/
155 /* initialize loader, load important systemclasses */
156 bool loader_init(u1 *stackbottom);
158 void suck_init(char *cpath);
159 void loader_load_all_classes(void);
160 void suck_stop(classbuffer *cb);
162 inline bool check_classbuffer_size(classbuffer *cb, s4 len);
164 inline u1 suck_u1(classbuffer *cb);
165 inline u2 suck_u2(classbuffer *cb);
166 inline u4 suck_u4(classbuffer *cb);
169 void loader_close(void);
171 /* class loading functions */
172 classinfo *load_class_from_sysloader(utf *name);
173 classinfo *load_class_from_classloader(utf *name, java_objectheader *cl);
174 classinfo *load_class_bootstrap(utf *name);
176 /* (don't use the following directly) */
177 classinfo *load_class_from_classbuffer(classbuffer *cb);
178 classinfo *load_newly_created_array(classinfo *c,java_objectheader *loader);
180 /* return the primitive class inidicated by the given signature character */
181 classinfo *class_primitive_from_sig(char sig);
184 void fprintflags(FILE *fp, u2 f);
185 void printflags(u2 f);
187 #endif /* _LOADER_H */
190 * These are local overrides for various environment variables in Emacs.
191 * Please do not remove this and leave it at the end of the file, where
192 * Emacs will automagically detect them.
193 * ---------------------------------------------------------------------
196 * indent-tabs-mode: t