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