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