Changes:
- $Id: references.h 4357 2006-01-22 23:33:38Z twisti $
+ $Id: references.h 4758 2006-04-12 17:51:10Z edwin $
*/
/* forward declarations *******************************************************/
typedef struct classinfo classinfo;
+typedef struct methodinfo methodinfo;
+typedef struct fieldinfo fieldinfo;
typedef struct typedesc typedesc;
typedef struct methoddesc methoddesc;
/* constant_FMIref ************************************************************/
typedef struct { /* Fieldref, Methodref and InterfaceMethodref */
- constant_classref *classref; /* class containing this field/meth./intfm. */
+ union {
+ s4 index; /* used only within the loader */
+ constant_classref *classref; /* class having this field/meth./intfm. */
+ fieldinfo *field; /* resolved field */
+ methodinfo *method; /* resolved method */
+ } p;
utf *name; /* field/method/interfacemethod name */
utf *descriptor; /* field/method/intfmeth. type descriptor string */
parseddesc parseddesc; /* parsed descriptor */
#define IS_CLASSREF(reforinfo) \
((reforinfo).ref->pseudo_vftbl == CLASSREF_PSEUDO_VFTBL)
+/* macro for testing if a constant_FMIref has been resolved */
+/* `fmiref` is only evaluated once */
+#define IS_FMIREF_RESOLVED(fmiref) \
+ ((fmiref)->p.classref->pseudo_vftbl != CLASSREF_PSEUDO_VFTBL)
+
+/* the same as IS_CLASSREF, but also check against NULL */
+#define IS_XCLASSREF(reforinfo) \
+ ((reforinfo).any && IS_CLASSREF(reforinfo))
+
/* macro for casting a classref/classinfo * to a classref_or_classinfo */
#define CLASSREF_OR_CLASSINFO(value) \
(*((classref_or_classinfo *)(&(value))))
+/* macro for accessing the name of a classref/classinfo */
+#define CLASSREF_OR_CLASSINFO_NAME(value) \
+ (IS_CLASSREF(value) ? (value).ref->name : (value).cls->name)
+
+/* macro for accessing the class name of a method reference */
+#define METHODREF_CLASSNAME(fmiref) \
+ (IS_FMIREF_RESOLVED(fmiref) ? (fmiref)->p.method->class->name \
+ : (fmiref)->p.classref->name)
+
+/* macro for accessing the class name of a method reference */
+#define FIELDREF_CLASSNAME(fmiref) \
+ (IS_FMIREF_RESOLVED(fmiref) ? (fmiref)->p.field->class->name \
+ : (fmiref)->p.classref->name)
+
/* initialize a constant_classref with referer `ref` and name `classname` */
#define CLASSREF_INIT(c,ref,classname) \