author | vranyj1 |
Wed, 23 Nov 2011 15:26:06 +0000 | |
branch | jk_new_structure |
changeset 1152 | 040cba55a7d2 |
parent 1049 | d873d4e99ef6 |
child 1155 | d6f6d5fc0343 |
permissions | -rw-r--r-- |
752 | 1 |
" |
877 | 2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
1152 | 3 |
|
4 |
New code and modification done at SWING Research Group [1]: |
|
5 |
||
877 | 6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
7 |
SWING Research Group, Czech Technical University in Prague |
|
8 |
||
9 |
Parts of the code written by Claus Gittinger are under following |
|
10 |
license: |
|
752 | 11 |
|
12 |
This software is furnished under a license and may be used |
|
13 |
only in accordance with the terms of that license and with the |
|
14 |
inclusion of the above copyright notice. This software may not |
|
15 |
be provided or otherwise made available to, or used by, any |
|
16 |
other person. No title to or ownership of the software is |
|
17 |
hereby transferred. |
|
877 | 18 |
|
19 |
[1] Code written at SWING Research Group contain a signature |
|
1152 | 20 |
of one of the above copright owners. For exact set of such code |
21 |
see the differences between this version and version stx:lib |
|
22 |
as of 1.9.2010 |
|
752 | 23 |
" |
24 |
"{ Package: 'stx:libjava' }" |
|
25 |
||
879 | 26 |
Object subclass:#JavaField |
913 | 27 |
instanceVariableNames:'accessFlags class name descriptor signature index constantValue |
28 |
annotations constantPool' |
|
752 | 29 |
classVariableNames:'A_FINAL A_PRIVATE A_PROTECTED A_PUBLIC A_STATIC A_TRANSIENT |
30 |
A_VOLATILE A_SMALLTALK A_SYBTHETIC A_ENUM FieldTypeClasses' |
|
31 |
poolDictionaries:'' |
|
32 |
category:'Languages-Java-Reader-Support' |
|
33 |
! |
|
34 |
||
35 |
!JavaField class methodsFor:'documentation'! |
|
36 |
||
37 |
copyright |
|
38 |
" |
|
877 | 39 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
1152 | 40 |
|
41 |
New code and modification done at SWING Research Group [1]: |
|
42 |
||
877 | 43 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
44 |
SWING Research Group, Czech Technical University in Prague |
|
45 |
||
46 |
Parts of the code written by Claus Gittinger are under following |
|
47 |
license: |
|
752 | 48 |
|
49 |
This software is furnished under a license and may be used |
|
50 |
only in accordance with the terms of that license and with the |
|
51 |
inclusion of the above copyright notice. This software may not |
|
52 |
be provided or otherwise made available to, or used by, any |
|
53 |
other person. No title to or ownership of the software is |
|
54 |
hereby transferred. |
|
877 | 55 |
|
56 |
[1] Code written at SWING Research Group contain a signature |
|
1152 | 57 |
of one of the above copright owners. For exact set of such code |
58 |
see the differences between this version and version stx:lib |
|
59 |
as of 1.9.2010 |
|
877 | 60 |
|
61 |
" |
|
752 | 62 |
! ! |
63 |
||
64 |
!JavaField class methodsFor:'class initialization'! |
|
65 |
||
66 |
initialize |
|
67 |
A_PUBLIC := 16r0001. "/ JavaClass A_PUBLIC |
|
68 |
A_PRIVATE := 16r0002. |
|
69 |
A_PROTECTED := 16r0004. |
|
70 |
A_STATIC := 16r0008. |
|
71 |
A_FINAL := 16r0010. "/ JavaClass A_FINAL |
|
72 |
A_VOLATILE := 16r0040. |
|
73 |
A_TRANSIENT := 16r0080. |
|
74 |
A_SYBTHETIC := 16r1000. |
|
75 |
A_ENUM := 16r4000. |
|
76 |
||
77 |
FieldTypeClasses := IdentityDictionary new |
|
78 |
"Base types" |
|
873
933263bd2d27
Fixes for primitive array types (uses Signed* variant of an array)
vranyj1
parents:
811
diff
changeset
|
79 |
"/WARNING: If you change something here, you MUST also |
933263bd2d27
Fixes for primitive array types (uses Signed* variant of an array)
vranyj1
parents:
811
diff
changeset
|
80 |
"/ change JavaDescriptor class>>#initialize !!!!!! |
933263bd2d27
Fixes for primitive array types (uses Signed* variant of an array)
vranyj1
parents:
811
diff
changeset
|
81 |
|
933263bd2d27
Fixes for primitive array types (uses Signed* variant of an array)
vranyj1
parents:
811
diff
changeset
|
82 |
at: #B put: Byte; |
752 | 83 |
at: #C put: Character; |
84 |
at: #D put: Float; |
|
85 |
at: #F put: ShortFloat; |
|
86 |
at: #I put: Integer; "Kludge: instances of java int are in fact SmallIntegers" |
|
87 |
at: #J put: LargeInteger; |
|
873
933263bd2d27
Fixes for primitive array types (uses Signed* variant of an array)
vranyj1
parents:
811
diff
changeset
|
88 |
at: #S put: Short; |
752 | 89 |
at: #Z put: Boolean; |
90 |
||
91 |
"Array types" |
|
873
933263bd2d27
Fixes for primitive array types (uses Signed* variant of an array)
vranyj1
parents:
811
diff
changeset
|
92 |
"/WARNING: If you change something here, you MUST also |
933263bd2d27
Fixes for primitive array types (uses Signed* variant of an array)
vranyj1
parents:
811
diff
changeset
|
93 |
"/ change JavaDescriptor class>>#initialize !!!!!! |
752 | 94 |
at: #'[B' put: ByteArray; |
900 | 95 |
at: #'[C' put: Unicode16String; |
752 | 96 |
at: #'[D' put: DoubleArray; |
97 |
at: #'[F' put: FloatArray; |
|
873
933263bd2d27
Fixes for primitive array types (uses Signed* variant of an array)
vranyj1
parents:
811
diff
changeset
|
98 |
at: #'[I' put: SignedIntegerArray; "Kludge: instances of java int are in fact SmallIntegers" |
933263bd2d27
Fixes for primitive array types (uses Signed* variant of an array)
vranyj1
parents:
811
diff
changeset
|
99 |
at: #'[J' put: SignedLongIntegerArray; |
933263bd2d27
Fixes for primitive array types (uses Signed* variant of an array)
vranyj1
parents:
811
diff
changeset
|
100 |
at: #'[S' put: WordArray; |
752 | 101 |
at: #'[Z' put: BooleanArray; |
102 |
||
103 |
yourself |
|
104 |
||
105 |
||
106 |
||
107 |
||
108 |
" |
|
109 |
self initialize |
|
110 |
" |
|
111 |
||
112 |
"Modified: / 13-05-1998 / 14:44:43 / cg" |
|
900 | 113 |
"Modified: / 10-08-2011 / 00:48:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 114 |
! ! |
115 |
||
116 |
!JavaField class methodsFor:'constants'! |
|
117 |
||
118 |
A_FINAL |
|
119 |
^ A_FINAL |
|
120 |
||
121 |
||
122 |
! |
|
123 |
||
124 |
A_PRIVATE |
|
125 |
^ A_PRIVATE |
|
126 |
||
127 |
||
128 |
! |
|
129 |
||
130 |
A_PROTECTED |
|
131 |
^ A_PROTECTED |
|
132 |
||
133 |
"Created: / 13.5.1998 / 13:03:51 / cg" |
|
134 |
! |
|
135 |
||
136 |
A_PUBLIC |
|
137 |
^ A_PUBLIC |
|
138 |
||
139 |
||
140 |
! |
|
141 |
||
142 |
A_STATIC |
|
143 |
^ A_STATIC |
|
144 |
||
145 |
"Created: / 13.5.1998 / 13:03:55 / cg" |
|
146 |
! |
|
147 |
||
148 |
A_TRANSIENT |
|
149 |
^ A_TRANSIENT |
|
150 |
||
151 |
||
152 |
! |
|
153 |
||
154 |
A_VOLATILE |
|
155 |
^ A_VOLATILE |
|
156 |
||
157 |
||
158 |
! ! |
|
159 |
||
160 |
!JavaField methodsFor:'accessing'! |
|
161 |
||
162 |
accessFlags |
|
163 |
^ accessFlags |
|
164 |
! |
|
165 |
||
166 |
annotations |
|
167 |
^ annotations |
|
168 |
! |
|
169 |
||
170 |
annotations:something |
|
171 |
annotations := something. |
|
172 |
! |
|
173 |
||
174 |
constantPool |
|
879 | 175 |
|
176 |
^ constantPool |
|
752 | 177 |
|
178 |
"Created: / 17-12-2010 / 18:40:23 / Marcel Hlopko <hlopik@gmail.com>" |
|
879 | 179 |
"Modified: / 27-07-2011 / 09:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 180 |
! |
181 |
||
182 |
constantValue |
|
183 |
^ constantValue |
|
184 |
! |
|
185 |
||
186 |
constantValue:aValue |
|
187 |
constantValue := aValue |
|
188 |
! |
|
189 |
||
190 |
ensureHasAnnotations |
|
191 |
annotations ifNil: [ annotations := JavaAnnotationContainer for:self ]. |
|
192 |
^ annotations |
|
193 |
||
194 |
"Created: / 25-02-2011 / 16:04:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
195 |
"Modified: / 16-03-2011 / 17:13:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
196 |
! |
|
197 |
||
198 |
index |
|
918 | 199 |
|
200 |
index ifNil:[ |
|
201 |
self isStatic ifTrue:[ |
|
202 |
index := class class instVarOffsetOf: name |
|
203 |
] ifFalse:[ |
|
204 |
index := class instVarOffsetOf: name |
|
205 |
]. |
|
206 |
]. |
|
752 | 207 |
^ index |
918 | 208 |
|
209 |
"Modified: / 17-08-2011 / 09:26:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 210 |
! |
211 |
||
879 | 212 |
javaClass |
213 |
||
214 |
^ class |
|
215 |
||
216 |
"Created: / 27-07-2011 / 09:17:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
217 |
! |
|
218 |
||
752 | 219 |
name |
220 |
^ name |
|
221 |
! |
|
222 |
||
223 |
signature |
|
224 |
^ signature |
|
225 |
||
226 |
"Created: / 15.10.1998 / 10:37:06 / cg" |
|
227 |
! ! |
|
228 |
||
913 | 229 |
!JavaField methodsFor:'initialization'! |
752 | 230 |
|
231 |
setAccessFlags:flags |
|
232 |
accessFlags := flags. |
|
233 |
||
234 |
"Created: 16.4.1996 / 13:04:25 / cg" |
|
235 |
! |
|
236 |
||
879 | 237 |
setClass: aClass |
238 |
||
239 |
class := aClass |
|
240 |
||
241 |
"Created: / 27-07-2011 / 09:27:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
242 |
! |
|
752 | 243 |
|
879 | 244 |
setConstantPool:aJavaContantPool |
245 |
||
246 |
constantPool := aJavaContantPool. |
|
247 |
||
248 |
"Created: / 17-12-2010 / 18:41:59 / Marcel Hlopko <hlopik@gmail.com>" |
|
249 |
"Created: / 27-07-2011 / 09:30:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 250 |
! |
251 |
||
252 |
setConstantValue:something |
|
253 |
constantValue := something. |
|
254 |
||
255 |
"Created: 16.4.1996 / 13:04:58 / cg" |
|
256 |
! |
|
257 |
||
913 | 258 |
setDescriptor:aString |
259 |
||
260 |
descriptor := aString. |
|
261 |
||
262 |
"Created: / 16-04-1996 / 13:04:43 / cg" |
|
263 |
"Created: / 14-08-2011 / 19:40:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
264 |
! |
|
265 |
||
752 | 266 |
setIndex:anInteger |
267 |
index := anInteger. |
|
268 |
||
269 |
"Created: / 22-11-2010 / 17:13:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
270 |
! |
|
271 |
||
272 |
setName:aString |
|
273 |
name := aString. |
|
274 |
||
275 |
"Created: 16.4.1996 / 13:04:35 / cg" |
|
276 |
! |
|
277 |
||
278 |
setSignature:aString |
|
279 |
signature := aString. |
|
280 |
||
281 |
"Created: 16.4.1996 / 13:04:43 / cg" |
|
282 |
! ! |
|
283 |
||
913 | 284 |
!JavaField methodsFor:'printing & storing'! |
285 |
||
286 |
printOn: aStream |
|
287 |
||
288 |
super printOn: aStream. |
|
289 |
aStream |
|
290 |
nextPutAll:'(name: '; |
|
291 |
nextPutAll: name; |
|
292 |
nextPut:$,; space; |
|
293 |
nextPutAll:'descriptor: '; |
|
294 |
nextPutAll: signature; |
|
295 |
nextPut:$) |
|
296 |
||
297 |
"Created: / 22-05-2011 / 16:07:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
298 |
! ! |
|
299 |
||
752 | 300 |
!JavaField methodsFor:'queries'! |
301 |
||
302 |
initialValue |
|
914 | 303 |
^ JavaClass initialValueFromSignature: descriptor |
752 | 304 |
|
914 | 305 |
"Modified: / 14-08-2011 / 19:59:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 306 |
! |
307 |
||
308 |
isFinal |
|
309 |
^ (accessFlags bitAnd:A_FINAL) ~~ 0 |
|
310 |
||
311 |
"Modified: / 13.5.1998 / 12:59:26 / cg" |
|
312 |
! |
|
313 |
||
314 |
isPrivate |
|
315 |
^ (accessFlags bitAnd:A_PRIVATE) ~~ 0 |
|
316 |
||
317 |
"Modified: / 13.5.1998 / 12:59:30 / cg" |
|
318 |
! |
|
319 |
||
320 |
isProtected |
|
321 |
^ (accessFlags bitAnd:A_PROTECTED) ~~ 0 |
|
322 |
||
323 |
"Modified: / 13.5.1998 / 12:59:35 / cg" |
|
324 |
! |
|
325 |
||
326 |
isPublic |
|
327 |
^ (accessFlags bitAnd:A_PUBLIC) ~~ 0 |
|
328 |
||
329 |
"Modified: / 13.5.1998 / 12:59:40 / cg" |
|
330 |
! |
|
331 |
||
332 |
isStatic |
|
333 |
^ (accessFlags bitAnd:A_STATIC) ~~ 0 |
|
334 |
||
335 |
"Modified: / 13.5.1998 / 12:59:43 / cg" |
|
336 |
! |
|
337 |
||
338 |
isTransient |
|
339 |
^ (accessFlags bitAnd:A_TRANSIENT) ~~ 0 |
|
340 |
||
341 |
"Modified: / 13.5.1998 / 12:59:51 / cg" |
|
342 |
! |
|
343 |
||
344 |
isVolatile |
|
345 |
^ (accessFlags bitAnd:A_VOLATILE) ~~ 0 |
|
346 |
||
347 |
"Modified: / 13.5.1998 / 12:59:56 / cg" |
|
348 |
! |
|
349 |
||
350 |
type |
|
913 | 351 |
^ JavaMethod typeFromSignature:descriptor in:nil |
752 | 352 |
|
913 | 353 |
"Modified: / 08-01-1998 / 19:13:22 / cg" |
354 |
"Modified: / 14-08-2011 / 19:43:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 355 |
! |
356 |
||
357 |
typeClass |
|
358 |
||
914 | 359 |
^(JavaDescriptor fromString: descriptor) javaClass. |
752 | 360 |
|
361 |
"Created: / 23-11-2010 / 17:02:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
914 | 362 |
"Modified: / 14-08-2011 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 363 |
! ! |
364 |
||
365 |
!JavaField class methodsFor:'documentation'! |
|
366 |
||
367 |
version |
|
1049 | 368 |
^ '$Id$' |
752 | 369 |
! |
370 |
||
371 |
version_CVS |
|
372 |
^ '§Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaField.st,v 1.17 2009/10/09 14:04:34 cg Exp §' |
|
373 |
! |
|
374 |
||
375 |
version_SVN |
|
1022 | 376 |
^ '$Id$' |
752 | 377 |
! ! |
378 |
||
957 | 379 |
JavaField initialize! |