454
|
1 |
"
|
2151
|
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:
|
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 |
|
|
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:
|
454
|
26 |
|
2151
|
27 |
The above copyright notice and this permission notice shall be
|
|
28 |
included in all copies or substantial portions of the Software.
|
454
|
29 |
|
2151
|
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.
|
454
|
38 |
|
2151
|
39 |
[1] Code written at SWING Research Group contain a signature
|
|
40 |
of one of the above copright owners.
|
|
41 |
"
|
713
|
42 |
"{ Package: 'stx:libjava' }"
|
|
43 |
|
427
|
44 |
Array variableSubclass:#JavaConstantPool
|
89
|
45 |
instanceVariableNames:'owner'
|
2151
|
46 |
classVariableNames:'ConstantPools'
|
89
|
47 |
poolDictionaries:''
|
713
|
48 |
category:'Languages-Java-Reader-Support'
|
89
|
49 |
!
|
|
50 |
|
454
|
51 |
!JavaConstantPool class methodsFor:'documentation'!
|
|
52 |
|
|
53 |
copyright
|
|
54 |
"
|
2151
|
55 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
56 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
57 |
SWING Research Group, Czech Technical University in Prague
|
|
58 |
|
|
59 |
Parts of the code written by Claus Gittinger are under following
|
|
60 |
license:
|
454
|
61 |
|
|
62 |
This software is furnished under a license and may be used
|
|
63 |
only in accordance with the terms of that license and with the
|
|
64 |
inclusion of the above copyright notice. This software may not
|
|
65 |
be provided or otherwise made available to, or used by, any
|
|
66 |
other person. No title to or ownership of the software is
|
|
67 |
hereby transferred.
|
2151
|
68 |
|
|
69 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
|
|
70 |
|
|
71 |
Permission is hereby granted, free of charge, to any person
|
|
72 |
obtaining a copy of this software and associated documentation
|
|
73 |
files (the 'Software'), to deal in the Software without
|
|
74 |
restriction, including without limitation the rights to use,
|
|
75 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
76 |
copies of the Software, and to permit persons to whom the
|
|
77 |
Software is furnished to do so, subject to the following
|
|
78 |
conditions:
|
|
79 |
|
|
80 |
The above copyright notice and this permission notice shall be
|
|
81 |
included in all copies or substantial portions of the Software.
|
|
82 |
|
|
83 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
84 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
85 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
86 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
87 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
88 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
89 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
90 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
91 |
|
|
92 |
[1] Code written at SWING Research Group contain a signature
|
|
93 |
of one of the above copright owners.
|
|
94 |
|
454
|
95 |
"
|
2151
|
96 |
! !
|
|
97 |
|
|
98 |
!JavaConstantPool class methodsFor:'initialization'!
|
|
99 |
|
|
100 |
initialize
|
|
101 |
ConstantPools := OrderedCollection new: 1000.
|
454
|
102 |
|
2151
|
103 |
"Modified: / 08-04-2011 / 17:28:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
104 |
"Modified: / 09-04-2011 / 09:25:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
105 |
! !
|
454
|
106 |
|
2151
|
107 |
!JavaConstantPool class methodsFor:'instance creation'!
|
|
108 |
|
|
109 |
new: size
|
|
110 |
"return an initialized instance"
|
|
111 |
|
|
112 |
^ ConstantPools add: ((super new: size)
|
|
113 |
initialize;
|
|
114 |
yourself).
|
|
115 |
|
|
116 |
"Created: / 08-04-2011 / 16:56:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
117 |
"Modified: / 09-04-2011 / 09:24:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
118 |
"Modified: / 11-04-2011 / 18:46:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
119 |
! !
|
|
120 |
|
|
121 |
!JavaConstantPool class methodsFor:'accessing'!
|
|
122 |
|
|
123 |
allConstantPools
|
|
124 |
"linked list of all constant pools in system"
|
|
125 |
^ ConstantPools.
|
|
126 |
|
|
127 |
"Created: / 08-04-2011 / 16:53:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
128 |
"Modified: / 09-04-2011 / 09:24:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
129 |
!
|
|
130 |
|
|
131 |
allConstantPools: anOorderedCollection
|
|
132 |
"linked list of all constant pools in system"
|
|
133 |
|
|
134 |
ConstantPools := anOorderedCollection.
|
|
135 |
|
|
136 |
"Created: / 08-04-2011 / 17:07:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
137 |
"Modified: / 09-04-2011 / 09:24:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
138 |
"Modified: / 11-04-2011 / 18:47:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
454
|
139 |
! !
|
89
|
140 |
|
243
|
141 |
!JavaConstantPool class methodsFor:'special'!
|
|
142 |
|
2151
|
143 |
invalidateForClass: internalJavaClassName
|
|
144 |
"Only alias, everybody calls invalidateForClass so why not me :)"
|
|
145 |
|
|
146 |
^self invalidateReferencesToClass: internalJavaClassName.
|
243
|
147 |
|
2151
|
148 |
"Created: / 08-04-2011 / 16:52:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
149 |
!
|
243
|
150 |
|
2151
|
151 |
invalidateReferencesToClass: internalJavaClassName
|
|
152 |
"Go over all constant pools and call invalidateForClass on all
|
|
153 |
references. (usable when given class was unloaded etc)"
|
|
154 |
ConstantPools do: [:each | each invalidateForClass: internalJavaClassName].
|
243
|
155 |
|
2151
|
156 |
"Created: / 08-04-2011 / 16:09:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
243
|
157 |
! !
|
|
158 |
|
89
|
159 |
!JavaConstantPool methodsFor:'accessing'!
|
|
160 |
|
|
161 |
owner
|
|
162 |
"return owner"
|
|
163 |
|
|
164 |
^ owner
|
|
165 |
|
|
166 |
"Created: 28.6.1996 / 21:12:22 / cg"
|
|
167 |
!
|
|
168 |
|
|
169 |
owner:something
|
|
170 |
"set owner"
|
|
171 |
|
|
172 |
owner := something.
|
|
173 |
|
|
174 |
"Created: 28.6.1996 / 21:12:22 / cg"
|
|
175 |
! !
|
|
176 |
|
2151
|
177 |
!JavaConstantPool methodsFor:'adding'!
|
|
178 |
|
|
179 |
at: classRefIndex putClassRefWithNameAt: classNameIndex
|
|
180 |
self at: classRefIndex
|
|
181 |
put: (JavaClassRef2 in: self withNameAt: classNameIndex).
|
|
182 |
|
|
183 |
"Created: / 13-05-2011 / 09:48:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
184 |
!
|
|
185 |
|
|
186 |
at: fieldRefIndex putFieldRefWithClassAt: classRefIndex andNameAndTypeAt: nameAndTypeIndex
|
|
187 |
self at: fieldRefIndex
|
|
188 |
put: (JavaFieldRef2
|
|
189 |
in: self
|
|
190 |
withNameAndTypeAt: nameAndTypeIndex
|
|
191 |
andClassAt: classRefIndex).
|
|
192 |
|
|
193 |
"Created: / 13-05-2011 / 09:08:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
194 |
!
|
|
195 |
|
|
196 |
at: interfaceMethodRefIndex putInterfaceMethodRefWithClassAt: classRefIndex andNameAndTypeAt: nameAndTypeIndex
|
|
197 |
self at: interfaceMethodRefIndex
|
|
198 |
put: (JavaInterfaceMethodRef2
|
|
199 |
in: self
|
|
200 |
withNameAndTypeAt: nameAndTypeIndex
|
|
201 |
andClassAt: classRefIndex).
|
|
202 |
|
|
203 |
"Created: / 13-05-2011 / 09:08:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
204 |
!
|
|
205 |
|
|
206 |
at: methodRefIndex putMethodRefWithClassAt: classRefIndex andNameAndTypeAt: nameAndTypeIndex
|
|
207 |
self at: methodRefIndex
|
|
208 |
put: (JavaMethodRef2 in: self withNameAndTypeAt: nameAndTypeIndex andClassAt:classRefIndex).
|
|
209 |
|
|
210 |
"Created: / 13-05-2011 / 09:07:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
211 |
!
|
|
212 |
|
|
213 |
at: nameAndTypeIndex putNameAndTypeWithNameAt: nameIndex andDescriptorAt: descriptorIndex
|
|
214 |
self at: nameAndTypeIndex
|
|
215 |
put: (JavaNameAndType2 in: self withNameAt: nameIndex andDescriptorAt: descriptorIndex).
|
|
216 |
|
|
217 |
"Created: / 13-05-2011 / 09:05:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
218 |
! !
|
|
219 |
|
|
220 |
!JavaConstantPool methodsFor:'initialization'!
|
|
221 |
|
|
222 |
initialize
|
|
223 |
"Invoked when a new instance is created."
|
|
224 |
|
|
225 |
"/ please change as required (and remove this comment)
|
|
226 |
"/ owner := nil.
|
|
227 |
|
|
228 |
"/ super initialize. -- commented since inherited method does nothing
|
|
229 |
! !
|
|
230 |
|
89
|
231 |
!JavaConstantPool methodsFor:'printing & storing'!
|
|
232 |
|
|
233 |
displayString
|
|
234 |
owner isNil ifTrue:[
|
|
235 |
^ '*** unowned ConstantPool'
|
|
236 |
].
|
|
237 |
^ 'ConstantPool of ' , owner fullName
|
|
238 |
|
|
239 |
"Created: 28.6.1996 / 21:13:41 / cg"
|
|
240 |
"Modified: 28.6.1996 / 21:20:26 / cg"
|
|
241 |
! !
|
|
242 |
|
171
|
243 |
!JavaConstantPool methodsFor:'queries'!
|
|
244 |
|
|
245 |
refersToMethod:aJavaMethod
|
2151
|
246 |
|
|
247 |
self error: 'JV@2011-07-26: Update to new resolving scheme!!'.
|
|
248 |
|
171
|
249 |
self do:[:constItem |
|
|
250 |
(constItem == aJavaMethod) ifTrue:[^ true].
|
2151
|
251 |
|
|
252 |
].
|
|
253 |
^ false
|
|
254 |
|
|
255 |
"Created: / 29-07-1997 / 17:39:19 / cg"
|
|
256 |
"Modified: / 26-07-2011 / 18:00:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
257 |
!
|
|
258 |
|
|
259 |
refersToMethodNamed:aJavaMethodName
|
|
260 |
|
|
261 |
self error: 'JV@2011-07-26: Update to new resolving scheme!!'.
|
|
262 |
|
|
263 |
self do:[:constItem |
|
|
264 |
(constItem isKindOf:JavaMethod) ifTrue:[
|
|
265 |
constItem name = aJavaMethodName ifTrue:[^ true].
|
|
266 |
] ifFalse:[
|
|
267 |
|
2108
|
268 |
]
|
749
|
269 |
].
|
|
270 |
^ false
|
|
271 |
|
2151
|
272 |
"Created: / 29-07-1997 / 17:39:24 / cg"
|
|
273 |
"Modified: / 16-10-1998 / 01:22:02 / cg"
|
|
274 |
"Modified: / 26-07-2011 / 17:54:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
171
|
275 |
! !
|
|
276 |
|
203
|
277 |
!JavaConstantPool methodsFor:'special'!
|
|
278 |
|
252
|
279 |
classReferencesDo:aBlock
|
|
280 |
self do:[:constItem |
|
|
281 |
constItem isJavaClass ifTrue:[
|
|
282 |
aBlock value:constItem
|
|
283 |
]
|
|
284 |
]
|
|
285 |
|
|
286 |
"Modified: / 7.8.1997 / 19:17:38 / cg"
|
|
287 |
"Created: / 4.1.1998 / 00:40:11 / cg"
|
|
288 |
!
|
|
289 |
|
2151
|
290 |
invalidateAll
|
|
291 |
"go over all entries and call invalidate on all references"
|
|
292 |
|
|
293 |
self do:
|
|
294 |
[:entry |
|
|
295 |
entry isJavaRef
|
|
296 |
ifTrue: [ entry invalidate] ].
|
|
297 |
|
|
298 |
"Created: / 13-05-2011 / 09:37:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
299 |
!
|
|
300 |
|
|
301 |
invalidateForClass: internalJavaClassName
|
|
302 |
"go over all entries and call invalidateForClass on all references"
|
|
303 |
|
|
304 |
self do: [:entry | entry isJavaRef ifTrue:[entry invalidateForClass: internalJavaClassName]].
|
|
305 |
|
|
306 |
"Created: / 08-04-2011 / 16:11:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
307 |
!
|
|
308 |
|
203
|
309 |
updateClassRefsFrom:oldClass to:newClass
|
206
|
310 |
owner == oldClass ifTrue:[
|
|
311 |
self halt.
|
|
312 |
^ self
|
|
313 |
].
|
|
314 |
|
203
|
315 |
self keysAndValuesDo:[:index :constItem |
|
313
|
316 |
|nameIndex|
|
|
317 |
|
203
|
318 |
constItem == oldClass ifTrue:[
|
|
319 |
self at:index put:newClass
|
|
320 |
] ifFalse:[
|
206
|
321 |
(constItem isNil
|
|
322 |
or:[constItem isNumber]) ifFalse:[
|
203
|
323 |
constItem isString ifTrue:[
|
|
324 |
"/ nothing done ...
|
|
325 |
] ifFalse:[
|
|
326 |
(constItem isMemberOf:(Java java_lang_String)) ifTrue:[
|
|
327 |
"/ nothing done ...
|
|
328 |
] ifFalse:[
|
206
|
329 |
constItem isBehavior ifFalse:[
|
203
|
330 |
constItem updateClassRefsFrom:oldClass to:newClass
|
206
|
331 |
] ifTrue:[
|
|
332 |
constItem isJavaClass ifTrue:[
|
|
333 |
constItem fullName = oldClass fullName ifTrue:[
|
|
334 |
'JAVA: class update by name [in pool].' infoPrintCR.
|
313
|
335 |
newClass isNil ifTrue:[
|
|
336 |
"/ mhm - must find a slot for the classes name
|
|
337 |
nameIndex := -1.
|
|
338 |
self
|
|
339 |
at:index
|
|
340 |
put:(JavaUnresolvedClassConstant
|
|
341 |
pool:self
|
|
342 |
poolIndex:index
|
|
343 |
nameIndex:nameIndex)
|
|
344 |
] ifFalse:[
|
|
345 |
self at:index put:newClass
|
|
346 |
]
|
206
|
347 |
]
|
|
348 |
]
|
203
|
349 |
]
|
|
350 |
]
|
|
351 |
]
|
|
352 |
]
|
|
353 |
]
|
|
354 |
]
|
|
355 |
|
313
|
356 |
"Modified: / 4.2.1998 / 22:12:03 / cg"
|
203
|
357 |
! !
|
|
358 |
|
135
|
359 |
!JavaConstantPool class methodsFor:'documentation'!
|
89
|
360 |
|
|
361 |
version
|
2151
|
362 |
^ '$Id: JavaConstantPool.st,v 1.15 2011-08-18 18:42:48 vrany Exp $'
|
|
363 |
!
|
|
364 |
|
|
365 |
version_SVN
|
|
366 |
^ '$Id: JavaConstantPool.st,v 1.15 2011-08-18 18:42:48 vrany Exp $'
|
89
|
367 |
! !
|
2151
|
368 |
|
|
369 |
JavaConstantPool initialize!
|