OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [gcj/] [field.h] - Blame information for rev 769

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 755 jeremybenn
// field.h - Header file for fieldID instances.  -*- c++ -*-
2
 
3
/* Copyright (C) 1998, 1999, 2000, 2004, 2006  Free Software Foundation
4
 
5
   This file is part of libgcj.
6
 
7
This software is copyrighted work licensed under the terms of the
8
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9
details.  */
10
 
11
#ifndef __GCJ_FIELD_H__
12
#define __GCJ_FIELD_H__
13
 
14
#include <java/lang/Class.h>
15
#include <java/lang/reflect/Field.h>
16
#include <java/lang/reflect/Modifier.h>
17
#include <gnu/gcj/RawData.h>
18
 
19
#define _Jv_FIELD_UNRESOLVED_FLAG       0x8000
20
 
21
struct _Jv_Field
22
{
23
  struct _Jv_Utf8Const* name;
24
 
25
  /* The type of the field, if isResolved().
26
     If !isResolved():  The fields's signature as a (Utf8Const*). */
27
  jclass                type;
28
 
29
  _Jv_ushort            flags;
30
 
31
  _Jv_ushort            bsize;  /* not really needed ... */
32
 
33
  union {
34
    jint                boffset;  /* offset in bytes for instance field */
35
    char*               addr;  /* address of static field */
36
 
37
    jobject* object_addr;  /* address of static object field... etc */
38
    jbyte* byte_addr;
39
    jshort* short_addr;
40
    jchar* char_addr;
41
    jint* int_addr;
42
    jlong* long_addr;
43
    jfloat* float_addr;
44
    jdouble* double_addr;
45
  } u;
46
 
47
#ifdef __cplusplus
48
  jboolean isResolved ()
49
  { return ! (flags & _Jv_FIELD_UNRESOLVED_FLAG); }
50
 
51
  public:
52
 
53
  int getOffset () { return u.boffset; }
54
 
55
  jobject getObjectField (jobject obj)
56
  { return *(jobject *)((char *)obj + getOffset ()); }
57
 
58
  jfieldID getNextField () { return this + 1; }
59
 
60
  jboolean isRef ()
61
    {
62
      if (!isResolved ())
63
        {
64
          char first = ((_Jv_Utf8Const*)type)->first();
65
          return first == '[' || first == 'L';
66
        }
67
      else
68
        {
69
          return ! type->isPrimitive ();
70
        }
71
    }
72
 
73
  jclass getClass ()
74
  {
75
    // We can't use JvAssert here because it is not in a public
76
    // header.
77
    // JvAssert (isResolved ());
78
    return type;
79
  }
80
 
81
  // Need to mask off all unknown/internal flags before returning.
82
  int getModifiers()
83
  {
84
    return flags & java::lang::reflect::Modifier::ALL_FLAGS;
85
  }
86
 
87
  _Jv_Utf8Const * getNameUtf8Const (jclass) { return name; }
88
#endif
89
};
90
 
91
#ifdef __cplusplus
92
 
93
inline jbyte
94
_Jv_GetStaticByteField (jclass, _Jv_Field* field)
95
{
96
  return * (jbyte *) field->u.addr;
97
}
98
 
99
inline jshort
100
_Jv_GetStaticShortField (jclass, _Jv_Field* field)
101
{
102
  return * (jshort *) field->u.addr;
103
}
104
 
105
inline jint
106
_Jv_GetStaticIntField (jclass, _Jv_Field* field)
107
{
108
  return * (jint *) field->u.addr;
109
}
110
 
111
inline jlong
112
_Jv_GetStaticLongField (jclass, _Jv_Field* field)
113
{
114
  return * (jlong *) field->u.addr;
115
}
116
 
117
inline jobject
118
_Jv_GetObjectField (jobject obj, _Jv_Field* field)
119
{
120
  return field->getObjectField (obj);
121
}
122
 
123
inline jbyte
124
_Jv_GetByteField (jobject obj, _Jv_Field* field)
125
{
126
  return * (jbyte *) ((char*) obj + field->getOffset ());
127
}
128
 
129
inline jshort
130
_Jv_GetShortField (jobject obj, _Jv_Field* field)
131
{
132
  return * (jshort *) ((char*) obj + field->getOffset ());
133
}
134
inline jint
135
_Jv_GetIntField (jobject obj, _Jv_Field* field)
136
{
137
  return * (jint *) ((char*) obj + field->getOffset ());
138
}
139
inline jlong
140
_Jv_GetLongField (jobject obj, _Jv_Field* field)
141
{
142
  return * (jlong *) ((char*) obj + field->getOffset ());
143
}
144
 
145
extern inline jfieldID
146
_Jv_FromReflectedField (java::lang::reflect::Field *field)
147
{
148
  return (jfieldID) ((char *) field->declaringClass->fields + field->offset);
149
}
150
 
151
 
152
#ifdef __GCJ_CNI_H__
153
extern inline jfieldID
154
JvGetFirstInstanceField (jclass klass)
155
{
156
  return &(klass->fields[klass->static_field_count]);
157
}
158
 
159
extern inline jint
160
JvNumInstanceFields (jclass klass)
161
{
162
  return klass->field_count - klass->static_field_count;
163
}
164
 
165
extern inline jfieldID
166
JvGetFirstStaticField (jclass klass)
167
{
168
  return &(klass->fields[0]);
169
}
170
 
171
extern inline jint
172
JvNumStaticFields (jclass klass)
173
{
174
  return klass->static_field_count;
175
}
176
 
177
extern inline jboolean
178
JvFieldIsRef (jfieldID field)
179
{
180
  return field->isRef () && field->type != &gnu::gcj::RawData::class$;
181
}
182
 
183
extern inline jobject
184
JvGetObjectField (jobject obj, _Jv_Field* field)
185
{
186
  return _Jv_GetObjectField (obj, field);
187
}
188
#endif /* defined (__GCJ_CNI_H__) */
189
 
190
#endif /* __cplusplus */
191
 
192
#endif /* __GCJ_FIELD_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.