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