1 /* vm/resolve.h - resolving classes/interfaces/fields/methods
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: Edwin Steiner
31 $Id: resolve.h 2182 2005-04-01 20:56:33Z edwin $
39 /* forward declarations *******************************************************/
41 typedef struct unresolved_field unresolved_field;
42 typedef struct unresolved_method unresolved_method;
43 typedef struct unresolved_subtype_set unresolved_subtype_set;
46 #include "vm/global.h"
47 #include "vm/references.h"
48 #include "vm/jit/jit.h"
51 /* constants ******************************************************************/
53 #define RESOLVE_STATIC 0x0001
54 #define RESOLVE_PUTFIELD 0x0002
57 /* enums **********************************************************************/
67 resolveIllegalAccessError
71 /* structs ********************************************************************/
73 struct unresolved_subtype_set {
74 classref_or_classinfo *subtyperefs; /* NULL terminated list */
78 /* XXX unify heads of unresolved_field and unresolved_method? */
80 struct unresolved_field {
81 constant_FMIref *fieldref;
82 methodinfo *referermethod;
85 unresolved_subtype_set instancetypes;
86 unresolved_subtype_set valueconstraints;
89 struct unresolved_method {
90 constant_FMIref *methodref;
91 methodinfo *referermethod;
94 unresolved_subtype_set instancetypes;
95 unresolved_subtype_set *paramconstraints;
98 #define SUBTYPESET_IS_EMPTY(stset) \
99 ((stset).subtyperefs == NULL)
101 #define UNRESOLVED_SUBTYPE_SET_EMTPY(stset) \
102 do { (stset).subtyperefs = NULL; } while(0)
104 /* function prototypes ********************************************************/
106 /* resolve_class ***************************************************************
108 Resolve a symbolic class reference
111 referer..........the class containing the reference
112 refmethod........the method from which resolution was triggered
113 (may be NULL if not applicable)
114 classname........class name to resolve
115 mode.............mode of resolution:
116 resolveLazy...only resolve if it does not
117 require loading classes
118 resolveEager..load classes if necessary
121 *result..........set to result of resolution, or to NULL if
122 the reference has not been resolved
123 In the case of an exception, *result is
124 guaranteed to be set to NULL.
127 true.............everything ok
128 (*result may still be NULL for resolveLazy)
129 false............an exception has been thrown
132 The returned class is *not* guaranteed to be linked!
133 (It is guaranteed to be loaded, though.)
135 *******************************************************************************/
138 resolve_class(classinfo *referer,methodinfo *refmethod,
143 /* resolve_classref_or_classinfo ***********************************************
145 Resolve a symbolic class reference if necessary
148 refmethod........the method from which resolution was triggered
149 (may be NULL if not applicable)
150 cls..............class reference or classinfo
151 mode.............mode of resolution:
152 resolveLazy...only resolve if it does not
153 require loading classes
154 resolveEager..load classes if necessary
155 link.............if true, guarantee that the returned class, if any,
159 *result..........set to result of resolution, or to NULL if
160 the reference has not been resolved
161 In the case of an exception, *result is
162 guaranteed to be set to NULL.
165 true.............everything ok
166 (*result may still be NULL for resolveLazy)
167 false............an exception has been thrown
169 *******************************************************************************/
172 resolve_classref_or_classinfo(methodinfo *refmethod,
173 classref_or_classinfo cls,
178 /* resolve_class_from_typedesc *************************************************
180 Return a classinfo * for the given type descriptor
183 d................type descriptor
184 link.............if true, guarantee that the returned class, if any,
187 *result..........set to result of resolution, or to NULL if
188 the reference has not been resolved
189 In the case of an exception, *result is
190 guaranteed to be set to NULL.
193 true.............everything ok
194 false............an exception has been thrown
197 This function always resolved eagerly.
199 *******************************************************************************/
201 bool resolve_class_from_typedesc(typedesc *d,bool link,classinfo **result);
203 /* resolve_field ***************************************************************
205 Resolve an unresolved field reference
208 ref..............struct containing the reference
209 mode.............mode of resolution:
210 resolveLazy...only resolve if it does not
211 require loading classes
212 resolveEager..load classes if necessary
215 *result..........set to the result of resolution, or to NULL if
216 the reference has not been resolved
217 In the case of an exception, *result is
218 guaranteed to be set to NULL.
221 true.............everything ok
222 (*result may still be NULL for resolveLazy) XXX implement
223 false............an exception has been thrown
225 *******************************************************************************/
228 resolve_field(unresolved_field *ref,
232 /* resolve_method **************************************************************
234 Resolve an unresolved method reference
237 ref..............struct containing the reference
238 mode.............mode of resolution:
239 resolveLazy...only resolve if it does not
240 require loading classes
241 resolveEager..load classes if necessary
244 *result..........set to the result of resolution, or to NULL if
245 the reference has not been resolved
246 In the case of an exception, *result is
247 guaranteed to be set to NULL.
250 true.............everything ok
251 (*result may still be NULL for resolveLazy) XXX implement
252 false............an exception has been thrown
254 *******************************************************************************/
257 resolve_method(unresolved_method *ref,
259 methodinfo **result);
261 /* resolve_and_check_subtype_set ***********************************************
263 Resolve the references in the given set and test subtype relationships
266 referer..........the class containing the references
267 refmethod........the method triggering the resolution
268 ref..............a set of class/interface references
270 type.............the type to test against the set
271 reversed.........if true, test if type is a subtype of
272 the set members, instead of the other
274 mode.............mode of resolution:
275 resolveLazy...only resolve if it does not
276 require loading classes
277 resolveEager..load classes if necessary
278 error............which type of exception to throw if
279 the test fails. May be:
280 resolveLinkageError, or
281 resolveIllegalAccessError
284 *checked.........set to true if all checks were performed,
285 otherwise set to false
286 (This is guaranteed to be true if mode was
287 resolveEager and no exception occured.)
288 If checked == NULL, this parameter is not used.
291 true.............the check succeeded
292 false............the check failed. An exception has been
296 The references in the set are resolved first, so any
297 exception which may occurr during resolution may
298 be thrown by this function.
300 *******************************************************************************/
303 resolve_and_check_subtype_set(classinfo *referer,methodinfo *refmethod,
304 unresolved_subtype_set *ref,
305 classref_or_classinfo type,
311 /* create_unresolved_field *****************************************************
313 Create an unresolved_field struct for the given field access instruction
316 referer..........the class containing the reference
317 refmethod........the method triggering the resolution (if any)
318 iptr.............the {GET,PUT}{FIELD,STATIC}{,CONST} instruction
319 stack............the input stack of the instruction
322 a pointer to a new unresolved_field struct
324 *******************************************************************************/
327 create_unresolved_field(classinfo *referer,methodinfo *refmethod,
329 stackelement *stack);
331 /* create_unresolved_method ****************************************************
333 Create an unresolved_method struct for the given method invocation
336 referer..........the class containing the reference
337 refmethod........the method triggering the resolution (if any)
338 iptr.............the INVOKE* instruction
339 stack............the input stack of the instruction
342 a pointer to a new unresolved_method struct
344 *******************************************************************************/
347 create_unresolved_method(classinfo *referer,methodinfo *refmethod,
349 stackelement *stack);
351 /* unresolved_field_free *******************************************************
353 Free the memory used by an unresolved_field
356 ref..............the unresolved_field
358 *******************************************************************************/
360 void unresolved_field_free(unresolved_field *ref);
362 /* unresolved_method_free ******************************************************
364 Free the memory used by an unresolved_method
367 ref..............the unresolved_method
369 *******************************************************************************/
371 void unresolved_method_free(unresolved_method *ref);
373 /* unresolved_field_debug_dump *************************************************
375 Print debug info for unresolved_field to stream
378 ref..............the unresolved_field
379 file.............the stream
381 *******************************************************************************/
383 void unresolved_field_debug_dump(unresolved_field *ref,FILE *file);
385 /* unresolved_method_debug_dump ************************************************
387 Print debug info for unresolved_method to stream
390 ref..............the unresolved_method
391 file.............the stream
393 *******************************************************************************/
395 void unresolved_method_debug_dump(unresolved_method *ref,FILE *file);
397 /* unresolved_subtype_set_debug_dump *******************************************
399 Print debug info for unresolved_subtype_set to stream
402 stset............the unresolved_subtype_set
403 file.............the stream
405 *******************************************************************************/
407 void unresolved_subtype_set_debug_dump(unresolved_subtype_set *stset,FILE *file);
409 #endif /* _RESOLVE_H */
412 * These are local overrides for various environment variables in Emacs.
413 * Please do not remove this and leave it at the end of the file, where
414 * Emacs will automagically detect them.
415 * ---------------------------------------------------------------------
418 * indent-tabs-mode: t
422 * vim:noexpandtab:sw=4:ts=4: