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