* src/vm/jit/jit.h (instruction): Removed.
[cacao.git] / src / vm / resolve.h
1 /* vm/resolve.h - resolving classes/interfaces/fields/methods
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: Edwin Steiner
28
29    Changes:
30
31    $Id: resolve.h 5332 2006-09-05 19:38:28Z twisti $
32
33 */
34
35
36 #ifndef _RESOLVE_H
37 #define _RESOLVE_H
38
39 /* forward declarations *******************************************************/
40
41 typedef struct unresolved_class unresolved_class;
42 typedef struct unresolved_field unresolved_field;
43 typedef struct unresolved_method unresolved_method;
44 typedef struct unresolved_subtype_set unresolved_subtype_set;
45
46
47 #include "config.h"
48 #include "vm/types.h"
49 #include "vm/global.h"
50 #include "vm/references.h"
51 #include "vm/jit/jit.h"
52 #include "vm/jit/verify/typeinfo.h"
53
54
55 /* constants ******************************************************************/
56
57 #define RESOLVE_STATIC    0x0001  /* ref to static fields/methods             */
58 #define RESOLVE_PUTFIELD  0x0002  /* field ref inside a PUT{FIELD,STATIC}...  */
59 #define RESOLVE_SPECIAL   0x0004  /* method ref inside INVOKESPECIAL          */
60
61
62 /* enums **********************************************************************/
63
64 typedef enum {
65         resolveLazy,
66         resolveEager
67 } resolve_mode_t;
68
69 typedef enum {
70         resolveLinkageError,
71         resolveIllegalAccessError
72 } resolve_err_t;
73
74 typedef enum {
75         resolveFailed = false,  /* this must be a false value */
76         resolveDeferred = true, /* this must be a true value  */
77         resolveSucceeded
78 } resolve_result_t;
79
80 /* structs ********************************************************************/
81
82 struct unresolved_subtype_set {
83         classref_or_classinfo *subtyperefs;     /* NULL terminated list */
84 };
85
86 struct unresolved_class {
87         constant_classref      *classref;
88         methodinfo                     *referermethod;
89         unresolved_subtype_set  subtypeconstraints;
90 };
91
92 /* XXX unify heads of unresolved_field and unresolved_method? */
93
94 struct unresolved_field {
95         constant_FMIref *fieldref;
96         methodinfo      *referermethod;
97         s4               flags;
98         
99         unresolved_subtype_set  instancetypes;
100         unresolved_subtype_set  valueconstraints;
101 };
102
103 struct unresolved_method {
104         constant_FMIref *methodref;
105         methodinfo      *referermethod;
106         s4               flags;
107         
108         unresolved_subtype_set  instancetypes;
109         unresolved_subtype_set *paramconstraints;
110 };
111
112 #define SUBTYPESET_IS_EMPTY(stset) \
113         ((stset).subtyperefs == NULL)
114
115 #define UNRESOLVED_SUBTYPE_SET_EMTPY(stset) \
116         do { (stset).subtyperefs = NULL; } while(0)
117
118 /* function prototypes ********************************************************/
119
120 bool resolve_class_from_name(classinfo* referer,methodinfo *refmethod,
121                                                 utf *classname,
122                                                 resolve_mode_t mode,
123                                                 bool checkaccess,
124                                                 bool link,
125                                                 classinfo **result);
126
127 bool resolve_classref(methodinfo *refmethod,
128                                  constant_classref *ref,
129                                  resolve_mode_t mode,
130                                  bool checkaccess,
131                              bool link,
132                                  classinfo **result);
133
134 bool resolve_classref_or_classinfo(methodinfo *refmethod,
135                                                           classref_or_classinfo cls,
136                                                           resolve_mode_t mode,
137                                                           bool checkaccess,
138                                                           bool link,
139                                                           classinfo **result);
140
141 bool resolve_class_from_typedesc(typedesc *d,bool checkaccess,bool link,classinfo **result);
142
143 #ifdef ENABLE_VERIFIER
144 bool resolve_class(unresolved_class *ref,
145                           resolve_mode_t mode,
146                           bool checkaccess,
147                           classinfo **result);
148
149 classinfo * resolve_class_eager(unresolved_class *ref);
150 #endif /* ENABLE_VERIFIER */
151
152 bool resolve_field(unresolved_field *ref,
153                           resolve_mode_t mode,
154                           fieldinfo **result);
155
156 bool resolve_method(unresolved_method *ref,
157                           resolve_mode_t mode,
158                            methodinfo **result);
159
160 classinfo * resolve_classref_eager(constant_classref *ref);
161 classinfo * resolve_classref_eager_nonabstract(constant_classref *ref);
162 fieldinfo * resolve_field_eager(unresolved_field *ref);
163 methodinfo * resolve_method_eager(unresolved_method *ref);
164
165 #ifdef ENABLE_VERIFIER
166 unresolved_class * create_unresolved_class(methodinfo *refmethod,
167                                                 constant_classref *classref,
168                                                 typeinfo *valuetype);
169 #endif
170
171 unresolved_field *new_create_unresolved_field(classinfo *referer,
172                                                                                           methodinfo *refmethod,
173                                                                                           instruction *iptr);
174
175 unresolved_method *new_create_unresolved_method(classinfo *referer,
176                                                                                                 methodinfo *refmethod,
177                                                                                                 instruction *iptr);
178
179 void unresolved_class_free(unresolved_class *ref);
180 void unresolved_field_free(unresolved_field *ref);
181 void unresolved_method_free(unresolved_method *ref);
182
183 resolve_result_t new_resolve_method_lazy(instruction *iptr,
184                                                                                  methodinfo *refmethod);
185
186 resolve_result_t new_resolve_field_lazy(instruction *iptr,
187                                                                                 methodinfo *refmethod);
188
189 #ifdef ENABLE_VERIFIER
190 bool new_constrain_unresolved_field(unresolved_field *ref, classinfo *referer,
191                                                                         methodinfo *refmethod, instruction *iptr);
192
193 bool new_constrain_unresolved_method(unresolved_method *ref, classinfo *referer,
194                                                                          methodinfo *refmethod, instruction *iptr);
195
196 #endif
197
198 #ifndef NDEBUG
199 void unresolved_class_debug_dump(unresolved_class *ref,FILE *file);
200 void unresolved_field_debug_dump(unresolved_field *ref,FILE *file);
201 void unresolved_method_debug_dump(unresolved_method *ref,FILE *file);
202 void unresolved_subtype_set_debug_dump(unresolved_subtype_set *stset,FILE *file);
203 #endif
204         
205 #endif /* _RESOLVE_H */
206
207 /*
208  * These are local overrides for various environment variables in Emacs.
209  * Please do not remove this and leave it at the end of the file, where
210  * Emacs will automagically detect them.
211  * ---------------------------------------------------------------------
212  * Local variables:
213  * mode: c
214  * indent-tabs-mode: t
215  * c-basic-offset: 4
216  * tab-width: 4
217  * End:
218  * vim:noexpandtab:sw=4:ts=4:
219  */
220