author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 16 Sep 2013 01:04:57 +0100 | |
branch | development |
changeset 2733 | 3d97124aebf5 |
parent 2731 | 13f5be2bf83b |
child 2737 | 83f8416e153c |
permissions | -rw-r--r-- |
454 | 1 |
" |
2151 | 2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
3 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
4 |
New code and modifications done at SWING Research Group [1]: |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
5 |
|
2151 | 6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
7 |
SWING Research Group, Czech Technical University in Prague |
454 | 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. |
|
2151 | 15 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
16 |
[1] Code written at SWING Research Group contains a signature |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
17 |
of one of the above copright owners. For exact set of such code, |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
18 |
see the differences between this version and version stx:libjava |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
19 |
as of 1.9.2010 |
2151 | 20 |
" |
713 | 21 |
"{ Package: 'stx:libjava' }" |
22 |
||
2678
c865275e48a7
Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
23 |
Array variableSubclass:#JavaConstantPool |
89 | 24 |
instanceVariableNames:'owner' |
2151 | 25 |
classVariableNames:'ConstantPools' |
89 | 26 |
poolDictionaries:'' |
713 | 27 |
category:'Languages-Java-Reader-Support' |
89 | 28 |
! |
29 |
||
454 | 30 |
!JavaConstantPool class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
2151 | 34 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
35 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
36 |
New code and modifications done at SWING Research Group [1]: |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
37 |
|
2151 | 38 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
39 |
SWING Research Group, Czech Technical University in Prague |
454 | 40 |
|
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
2151 | 47 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
48 |
[1] Code written at SWING Research Group contains a signature |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
49 |
of one of the above copright owners. For exact set of such code, |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
50 |
see the differences between this version and version stx:libjava |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
51 |
as of 1.9.2010 |
2151 | 52 |
|
454 | 53 |
" |
2151 | 54 |
! ! |
55 |
||
56 |
!JavaConstantPool class methodsFor:'accessing'! |
|
57 |
||
58 |
allConstantPools |
|
59 |
"linked list of all constant pools in system" |
|
60 |
^ ConstantPools. |
|
61 |
||
62 |
"Created: / 08-04-2011 / 16:53:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
63 |
"Modified: / 09-04-2011 / 09:24:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
64 |
! |
|
65 |
||
66 |
allConstantPools: anOorderedCollection |
|
67 |
"linked list of all constant pools in system" |
|
68 |
||
69 |
ConstantPools := anOorderedCollection. |
|
70 |
||
71 |
"Created: / 08-04-2011 / 17:07:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
72 |
"Modified: / 09-04-2011 / 09:24:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
73 |
"Modified: / 11-04-2011 / 18:47:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
454 | 74 |
! ! |
89 | 75 |
|
243 | 76 |
!JavaConstantPool class methodsFor:'special'! |
77 |
||
2151 | 78 |
invalidateForClass: internalJavaClassName |
79 |
"Only alias, everybody calls invalidateForClass so why not me :)" |
|
80 |
||
81 |
^self invalidateReferencesToClass: internalJavaClassName. |
|
243 | 82 |
|
2151 | 83 |
"Created: / 08-04-2011 / 16:52:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
84 |
! |
|
243 | 85 |
|
2151 | 86 |
invalidateReferencesToClass: internalJavaClassName |
87 |
"Go over all constant pools and call invalidateForClass on all |
|
88 |
references. (usable when given class was unloaded etc)" |
|
89 |
ConstantPools do: [:each | each invalidateForClass: internalJavaClassName]. |
|
243 | 90 |
|
2151 | 91 |
"Created: / 08-04-2011 / 16:09:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
243 | 92 |
! ! |
93 |
||
89 | 94 |
!JavaConstantPool methodsFor:'accessing'! |
95 |
||
96 |
owner |
|
97 |
"return owner" |
|
98 |
||
99 |
^ owner |
|
100 |
||
101 |
"Created: 28.6.1996 / 21:12:22 / cg" |
|
102 |
! |
|
103 |
||
104 |
owner:something |
|
105 |
"set owner" |
|
106 |
||
107 |
owner := something. |
|
108 |
||
109 |
"Created: 28.6.1996 / 21:12:22 / cg" |
|
110 |
! ! |
|
111 |
||
2151 | 112 |
!JavaConstantPool methodsFor:'adding'! |
113 |
||
114 |
at: classRefIndex putClassRefWithNameAt: classNameIndex |
|
115 |
self at: classRefIndex |
|
116 |
put: (JavaClassRef2 in: self withNameAt: classNameIndex). |
|
117 |
||
118 |
"Created: / 13-05-2011 / 09:48:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
119 |
! |
|
120 |
||
121 |
at: fieldRefIndex putFieldRefWithClassAt: classRefIndex andNameAndTypeAt: nameAndTypeIndex |
|
122 |
self at: fieldRefIndex |
|
123 |
put: (JavaFieldRef2 |
|
124 |
in: self |
|
125 |
withNameAndTypeAt: nameAndTypeIndex |
|
126 |
andClassAt: classRefIndex). |
|
127 |
||
128 |
"Created: / 13-05-2011 / 09:08:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
129 |
! |
|
130 |
||
131 |
at: interfaceMethodRefIndex putInterfaceMethodRefWithClassAt: classRefIndex andNameAndTypeAt: nameAndTypeIndex |
|
132 |
self at: interfaceMethodRefIndex |
|
133 |
put: (JavaInterfaceMethodRef2 |
|
134 |
in: self |
|
135 |
withNameAndTypeAt: nameAndTypeIndex |
|
136 |
andClassAt: classRefIndex). |
|
137 |
||
138 |
"Created: / 13-05-2011 / 09:08:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
139 |
! |
|
140 |
||
141 |
at: methodRefIndex putMethodRefWithClassAt: classRefIndex andNameAndTypeAt: nameAndTypeIndex |
|
142 |
self at: methodRefIndex |
|
143 |
put: (JavaMethodRef2 in: self withNameAndTypeAt: nameAndTypeIndex andClassAt:classRefIndex). |
|
144 |
||
145 |
"Created: / 13-05-2011 / 09:07:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
146 |
! |
|
147 |
||
148 |
at: nameAndTypeIndex putNameAndTypeWithNameAt: nameIndex andDescriptorAt: descriptorIndex |
|
149 |
self at: nameAndTypeIndex |
|
150 |
put: (JavaNameAndType2 in: self withNameAt: nameIndex andDescriptorAt: descriptorIndex). |
|
151 |
||
152 |
"Created: / 13-05-2011 / 09:05:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
153 |
! ! |
|
154 |
||
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
155 |
!JavaConstantPool methodsFor:'invalidation'! |
2151 | 156 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
157 |
invalidateForClass: slashedJavaClassName |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
158 |
"Invalidate all resolved references to given class. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
159 |
Returns true if at least one ref has been invalidated, |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
160 |
false otherwise" |
2151 | 161 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
162 |
| anyInvalidated | |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
163 |
anyInvalidated := false. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
164 |
self do:[:ref| |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
165 |
(ref notNil and:[ref isString not and:[ref isNumber not]]) ifTrue:[ |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
166 |
anyInvalidated := anyInvalidated | (ref invalidateForClass: slashedJavaClassName)]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
167 |
]. |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
168 |
^anyInvalidated |
2151 | 169 |
|
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
170 |
"Created: / 08-04-2011 / 16:11:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
171 |
"Modified: / 22-02-2012 / 20:53:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2151 | 172 |
! ! |
173 |
||
89 | 174 |
!JavaConstantPool methodsFor:'printing & storing'! |
175 |
||
176 |
displayString |
|
177 |
owner isNil ifTrue:[ |
|
178 |
^ '*** unowned ConstantPool' |
|
179 |
]. |
|
180 |
^ 'ConstantPool of ' , owner fullName |
|
181 |
||
182 |
"Created: 28.6.1996 / 21:13:41 / cg" |
|
183 |
"Modified: 28.6.1996 / 21:20:26 / cg" |
|
184 |
! ! |
|
185 |
||
171 | 186 |
!JavaConstantPool methodsFor:'queries'! |
187 |
||
188 |
refersToMethod:aJavaMethod |
|
2151 | 189 |
|
190 |
self error: 'JV@2011-07-26: Update to new resolving scheme!!'. |
|
191 |
||
171 | 192 |
self do:[:constItem | |
193 |
(constItem == aJavaMethod) ifTrue:[^ true]. |
|
2151 | 194 |
|
195 |
]. |
|
196 |
^ false |
|
197 |
||
198 |
"Created: / 29-07-1997 / 17:39:19 / cg" |
|
199 |
"Modified: / 26-07-2011 / 18:00:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
200 |
! |
|
201 |
||
202 |
refersToMethodNamed:aJavaMethodName |
|
203 |
||
204 |
self error: 'JV@2011-07-26: Update to new resolving scheme!!'. |
|
205 |
||
206 |
self do:[:constItem | |
|
207 |
(constItem isKindOf:JavaMethod) ifTrue:[ |
|
208 |
constItem name = aJavaMethodName ifTrue:[^ true]. |
|
209 |
] ifFalse:[ |
|
210 |
||
2108 | 211 |
] |
749 | 212 |
]. |
213 |
^ false |
|
214 |
||
2151 | 215 |
"Created: / 29-07-1997 / 17:39:24 / cg" |
216 |
"Modified: / 16-10-1998 / 01:22:02 / cg" |
|
217 |
"Modified: / 26-07-2011 / 17:54:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
171 | 218 |
! ! |
219 |
||
203 | 220 |
!JavaConstantPool methodsFor:'special'! |
221 |
||
252 | 222 |
classReferencesDo:aBlock |
223 |
self do:[:constItem | |
|
224 |
constItem isJavaClass ifTrue:[ |
|
225 |
aBlock value:constItem |
|
226 |
] |
|
227 |
] |
|
228 |
||
229 |
"Modified: / 7.8.1997 / 19:17:38 / cg" |
|
230 |
"Created: / 4.1.1998 / 00:40:11 / cg" |
|
231 |
! |
|
232 |
||
2151 | 233 |
invalidateAll |
234 |
"go over all entries and call invalidate on all references" |
|
235 |
||
236 |
self do: |
|
237 |
[:entry | |
|
238 |
entry isJavaRef |
|
239 |
ifTrue: [ entry invalidate] ]. |
|
240 |
||
241 |
"Created: / 13-05-2011 / 09:37:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
242 |
! |
|
243 |
||
203 | 244 |
updateClassRefsFrom:oldClass to:newClass |
206 | 245 |
owner == oldClass ifTrue:[ |
246 |
self halt. |
|
247 |
^ self |
|
248 |
]. |
|
249 |
||
203 | 250 |
self keysAndValuesDo:[:index :constItem | |
313 | 251 |
|nameIndex| |
252 |
||
203 | 253 |
constItem == oldClass ifTrue:[ |
254 |
self at:index put:newClass |
|
255 |
] ifFalse:[ |
|
206 | 256 |
(constItem isNil |
257 |
or:[constItem isNumber]) ifFalse:[ |
|
203 | 258 |
constItem isString ifTrue:[ |
259 |
"/ nothing done ... |
|
260 |
] ifFalse:[ |
|
261 |
(constItem isMemberOf:(Java java_lang_String)) ifTrue:[ |
|
262 |
"/ nothing done ... |
|
263 |
] ifFalse:[ |
|
206 | 264 |
constItem isBehavior ifFalse:[ |
203 | 265 |
constItem updateClassRefsFrom:oldClass to:newClass |
206 | 266 |
] ifTrue:[ |
267 |
constItem isJavaClass ifTrue:[ |
|
268 |
constItem fullName = oldClass fullName ifTrue:[ |
|
269 |
'JAVA: class update by name [in pool].' infoPrintCR. |
|
313 | 270 |
newClass isNil ifTrue:[ |
271 |
"/ mhm - must find a slot for the classes name |
|
272 |
nameIndex := -1. |
|
273 |
self |
|
274 |
at:index |
|
275 |
put:(JavaUnresolvedClassConstant |
|
276 |
pool:self |
|
277 |
poolIndex:index |
|
278 |
nameIndex:nameIndex) |
|
279 |
] ifFalse:[ |
|
280 |
self at:index put:newClass |
|
281 |
] |
|
206 | 282 |
] |
283 |
] |
|
203 | 284 |
] |
285 |
] |
|
286 |
] |
|
287 |
] |
|
288 |
] |
|
289 |
] |
|
290 |
||
313 | 291 |
"Modified: / 4.2.1998 / 22:12:03 / cg" |
203 | 292 |
! ! |
293 |
||
135 | 294 |
!JavaConstantPool class methodsFor:'documentation'! |
89 | 295 |
|
296 |
version |
|
2678
c865275e48a7
Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
297 |
^ '$Header: /cvs/stx/stx/libjava/JavaConstantPool.st,v 1.20 2013-09-06 00:41:22 vrany Exp $' |
2213 | 298 |
! |
299 |
||
300 |
version_CVS |
|
2678
c865275e48a7
Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2396
diff
changeset
|
301 |
^ '$Header: /cvs/stx/stx/libjava/JavaConstantPool.st,v 1.20 2013-09-06 00:41:22 vrany Exp $' |
2353
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
302 |
! |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
303 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
304 |
version_HG |
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
305 |
|
fa7400d022a0
Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2269
diff
changeset
|
306 |
^ '$Changeset: <not expanded> $' |
2151 | 307 |
! |
308 |
||
309 |
version_SVN |
|
2731
13f5be2bf83b
Merged d87e89dd5276 and fe83a843a7bf (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
310 |
^ 'Id' |
89 | 311 |
! ! |
2151 | 312 |