RT update for loader changes
[cacao.git] / src / vm / loader.h
1 /* loader.h - class loader header
2
3    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4    R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
5    M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
6    P. Tomsich, J. Wenninger
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: Reinhard Grafl
28
29    $Id: loader.h 911 2004-02-04 11:42:41Z carolyn $
30 */
31
32
33 #ifndef _LOADER_H
34 #define _LOADER_H
35
36 #include <stdio.h>
37
38 #ifdef USE_ZLIB
39 #include "unzip.h"
40 #endif
41
42 /* export variables */
43
44 extern list unloadedclasses;     /* list of all referenced but not loaded classes */
45 extern list unlinkedclasses;     /* List containing all unlinked classes */
46 extern list linkedclasses;       /* List containing all linked classes */
47
48 #ifdef USE_THREADS
49 extern int blockInts;
50 #endif
51
52
53 /************************ prototypes ******************************************/
54
55 /* initialize laoder, load important systemclasses */
56 void loader_init();
57
58 void suck_init(char *cpath);
59
60 /* free resources */
61 void loader_close();
62
63 /* load a class and all referenced classes */
64 classinfo *loader_load(utf *topname);
65
66 /* initializes all loaded classes */
67 void loader_initclasses();
68
69 void loader_compute_subclasses();
70
71 /* retrieve constantpool element */
72 voidptr class_getconstant(classinfo *class, u4 pos, u4 ctype);
73
74 /* determine type of a constantpool element */
75 u4 class_constanttype(classinfo *class, u4 pos);
76
77 s4 class_findmethodIndex(classinfo *c, utf *name, utf *desc);
78
79 /* search class for a field */
80 fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc);
81
82 /* search for a method with a specified name and descriptor */
83 methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc);
84 methodinfo *class_fetchmethod(classinfo *c, utf *name, utf *desc);
85 methodinfo *class_findmethod_w(classinfo *c, utf *name, utf *desc, char*);
86 methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *dest);
87
88 /* search for a method with specified name and arguments (returntype ignored) */
89 methodinfo *class_findmethod_approx(classinfo *c, utf *name, utf *desc);
90 methodinfo *class_resolvemethod_approx(classinfo *c, utf *name, utf *dest);
91
92 bool class_issubclass(classinfo *sub, classinfo *super);
93
94 /* call initializer of class */
95 void class_init(classinfo *c);
96
97 void class_showconstanti(classinfo *c, int ii);
98
99 /* debug purposes */
100 void class_showmethods(classinfo *c);
101 void class_showconstantpool(classinfo *c);
102 void print_arraydescriptor(FILE *file, arraydescriptor *desc);
103
104 classinfo *loader_load(utf *topname);
105 classinfo *loader_load_sysclass(classinfo **top,utf *topname);
106
107 /* set buffer for reading classdata */
108 void classload_buffer(u1 *buf, int len);
109
110 /* return the primitive class inidicated by the given signature character */
111 classinfo *class_primitive_from_sig(char sig);
112
113
114 /* return the class indicated by the given descriptor */
115 /* (see loader.c for documentation) */
116 #define CLASSLOAD_NEW           0      /* default */
117 #define CLASSLOAD_LOAD          0x0001
118 #define CLASSLOAD_SKIP          0x0002
119 #define CLASSLOAD_PANIC         0      /* default */
120 #define CLASSLOAD_NOPANIC       0x0010
121 #define CLASSLOAD_PRIMITIVE     0      /* default */
122 #define CLASSLOAD_NULLPRIMITIVE 0x0020
123 #define CLASSLOAD_VOID          0      /* default */
124 #define CLASSLOAD_NOVOID        0x0040
125 #define CLASSLOAD_NOCHECKEND    0      /* default */
126 #define CLASSLOAD_CHECKEND      0x1000
127
128 classinfo *class_from_descriptor(char *utf_ptr,char *end_ptr,char **next,int mode);
129 int type_from_descriptor(classinfo **cls,char *utf_ptr,char *end_ptr,char **next,int mode);
130
131 /* (used by class_new, don't use directly) */
132 void class_new_array(classinfo *c);
133
134 void class_link(classinfo *c);
135
136 void field_display(fieldinfo *f);
137
138 void method_display(methodinfo *m);
139
140 utf* clinit_desc();
141 utf* clinit_name();
142
143
144 /******************************** CLASSPATH handling *******************/
145 #define CLASSPATH_MAXFILENAME 1000                /* maximum length of a filename           */
146 #define CLASSPATH_PATH 0
147 #define CLASSPATH_ARCHIVE 1
148
149 typedef union classpath_info {
150         struct {
151                 int type;
152                 union classpath_info *next;
153                 char *filename;
154                 int pathlen; } filepath;
155 #ifdef USE_ZLIB
156         struct {
157                 int type;
158                 union classpath_info *next;
159                 unzFile uf;
160         } archive;
161 #endif  
162 } classpath_info;
163
164 #endif /* _LOADER_H */
165
166
167 /*
168  * These are local overrides for various environment variables in Emacs.
169  * Please do not remove this and leave it at the end of the file, where
170  * Emacs will automagically detect them.
171  * ---------------------------------------------------------------------
172  * Local variables:
173  * mode: c
174  * indent-tabs-mode: t
175  * c-basic-offset: 4
176  * tab-width: 4
177  * End:
178  */