1 /* src/vmcore/references.h - references to classes/fields/methods
3 Copyright (C) 1996-2005, 2006, 2007 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
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., 51 Franklin Street, Fifth Floor, Boston, MA
25 $Id: references.h 7246 2007-01-29 18:49:05Z twisti $
29 #ifndef _REFERENCES_H_
30 #define _REFERENCES_H_
32 /* forward typedefs ***********************************************************/
34 typedef struct constant_classref constant_classref;
35 typedef struct constant_FMIref constant_FMIref;
38 /* constant_classref **********************************************************/
40 struct constant_classref {
41 void *pseudo_vftbl; /* for distinguishing it from classinfo */
42 struct classinfo *referer; /* class containing the reference */
43 struct utf *name; /* name of the class refered to */
47 /* classref_or_classinfo ******************************************************/
49 typedef union classref_or_classinfo {
50 constant_classref *ref; /* a symbolic class reference */
51 struct classinfo *cls; /* an already loaded class */
52 void *any; /* used for general access (x != NULL,...) */
53 } classref_or_classinfo;
56 /* parseddesc *****************************************************************/
58 typedef union parseddesc {
59 struct typedesc *fd; /* parsed field descriptor */
60 struct methoddesc *md; /* parsed method descriptor */
61 void *any; /* used for simple test against NULL */
68 #include "vm/global.h"
70 #include "vmcore/class.h"
71 #include "vmcore/descriptor.h"
72 #include "vmcore/field.h"
73 #include "vmcore/method.h"
74 #include "vmcore/utf8.h"
77 /*----------------------------------------------------------------------------*/
80 /* This header files defines the following types used for references to */
81 /* classes/methods/fields and descriptors: */
83 /* classinfo * a loaded class */
84 /* constant_classref a symbolic reference */
85 /* classref_or_classinfo a loaded class or a symbolic reference */
87 /* constant_FMIref a symb. ref. to a field/method/intf.method */
89 /* typedesc * describes a field type */
90 /* methoddesc * descrives a method type */
91 /* parseddesc describes a field type or a method type */
92 /*----------------------------------------------------------------------------*/
94 /* structs ********************************************************************/
96 /* constant_FMIref ************************************************************/
98 struct constant_FMIref{ /* Fieldref, Methodref and InterfaceMethodref */
100 s4 index; /* used only within the loader */
101 constant_classref *classref; /* class having this field/meth./intfm. */
102 fieldinfo *field; /* resolved field */
103 methodinfo *method; /* resolved method */
105 utf *name; /* field/method/interfacemethod name */
106 utf *descriptor; /* field/method/intfmeth. type descriptor string */
107 parseddesc parseddesc; /* parsed descriptor */
111 /* macros *********************************************************************/
113 /* a value that never occurrs in classinfo.header.vftbl */
114 #define CLASSREF_PSEUDO_VFTBL ((void *) 1)
116 /* macro for testing if a classref_or_classinfo is a classref */
117 /* `reforinfo` is only evaluated once */
118 #define IS_CLASSREF(reforinfo) \
119 ((reforinfo).ref->pseudo_vftbl == CLASSREF_PSEUDO_VFTBL)
121 /* macro for testing if a constant_FMIref has been resolved */
122 /* `fmiref` is only evaluated once */
123 #define IS_FMIREF_RESOLVED(fmiref) \
124 ((fmiref)->p.classref->pseudo_vftbl != CLASSREF_PSEUDO_VFTBL)
126 /* the same as IS_CLASSREF, but also check against NULL */
127 #define IS_XCLASSREF(reforinfo) \
128 ((reforinfo).any && IS_CLASSREF(reforinfo))
130 /* macro for casting a classref/classinfo * to a classref_or_classinfo */
131 #define CLASSREF_OR_CLASSINFO(value) \
132 (*((classref_or_classinfo *)(&(value))))
134 /* macro for accessing the name of a classref/classinfo */
135 #define CLASSREF_OR_CLASSINFO_NAME(value) \
136 (IS_CLASSREF(value) ? (value).ref->name : (value).cls->name)
138 /* macro for accessing the class name of a method reference */
139 #define METHODREF_CLASSNAME(fmiref) \
140 (IS_FMIREF_RESOLVED(fmiref) ? (fmiref)->p.method->class->name \
141 : (fmiref)->p.classref->name)
143 /* macro for accessing the class name of a method reference */
144 #define FIELDREF_CLASSNAME(fmiref) \
145 (IS_FMIREF_RESOLVED(fmiref) ? (fmiref)->p.field->class->name \
146 : (fmiref)->p.classref->name)
148 /* initialize a constant_classref with referer `ref` and name `classname` */
150 #define CLASSREF_INIT(c,ref,classname) \
152 (c).pseudo_vftbl = CLASSREF_PSEUDO_VFTBL; \
153 (c).referer = (ref); \
154 (c).name = (classname); \
157 #endif /* _REFERENCES_H_ */
160 * These are local overrides for various environment variables in Emacs.
161 * Please do not remove this and leave it at the end of the file, where
162 * Emacs will automagically detect them.
163 * ---------------------------------------------------------------------
166 * indent-tabs-mode: t
170 * vim:noexpandtab:sw=4:ts=4: