454
|
1 |
"
|
2108
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
3 |
All Rights Reserved
|
454
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
2108
|
11 |
"
|
454
|
12 |
|
|
13 |
|
|
14 |
|
713
|
15 |
"{ Package: 'stx:libjava' }"
|
|
16 |
|
427
|
17 |
Array variableSubclass:#JavaConstantPool
|
89
|
18 |
instanceVariableNames:'owner'
|
2108
|
19 |
classVariableNames:''
|
89
|
20 |
poolDictionaries:''
|
713
|
21 |
category:'Languages-Java-Reader-Support'
|
89
|
22 |
!
|
|
23 |
|
454
|
24 |
!JavaConstantPool class methodsFor:'documentation'!
|
|
25 |
|
|
26 |
copyright
|
|
27 |
"
|
2108
|
28 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
29 |
All Rights Reserved
|
454
|
30 |
|
|
31 |
This software is furnished under a license and may be used
|
|
32 |
only in accordance with the terms of that license and with the
|
|
33 |
inclusion of the above copyright notice. This software may not
|
|
34 |
be provided or otherwise made available to, or used by, any
|
|
35 |
other person. No title to or ownership of the software is
|
|
36 |
hereby transferred.
|
|
37 |
"
|
|
38 |
|
|
39 |
|
|
40 |
! !
|
89
|
41 |
|
243
|
42 |
!JavaConstantPool class methodsFor:'special'!
|
|
43 |
|
2108
|
44 |
compressPools
|
|
45 |
"unify all constants"
|
|
46 |
|
|
47 |
|strings nameandTypes jStrings|
|
|
48 |
|
|
49 |
strings := Set new.
|
|
50 |
nameandTypes := Set new.
|
|
51 |
|
|
52 |
self allInstancesDo:[:aPool |
|
|
53 |
aPool keysAndValuesDo:[:idx :aConst |
|
|
54 |
|existing nt|
|
243
|
55 |
|
2108
|
56 |
aConst isString ifTrue:[
|
|
57 |
existing := strings elementAt:aConst ifAbsent:nil.
|
|
58 |
existing isNil ifTrue:[
|
|
59 |
strings add:aConst
|
|
60 |
] ifFalse:[
|
|
61 |
aPool at:idx put:existing
|
|
62 |
]
|
|
63 |
] ifFalse:[
|
|
64 |
(aConst isMemberOf:JavaFieldref) ifTrue:[
|
|
65 |
nt := aConst nameandType.
|
|
66 |
existing := nameandTypes elementAt:nt ifAbsent:nil.
|
|
67 |
existing isNil ifTrue:[
|
|
68 |
nameandTypes add:nt
|
|
69 |
] ifFalse:[
|
|
70 |
aConst nameandType:existing
|
|
71 |
]
|
|
72 |
] ifFalse:[
|
|
73 |
(aConst isMemberOf:JavaNameandType) ifTrue:[
|
|
74 |
existing := nameandTypes elementAt:aConst ifAbsent:nil.
|
|
75 |
existing isNil ifTrue:[
|
|
76 |
nameandTypes add:aConst
|
|
77 |
] ifFalse:[
|
|
78 |
aPool at:idx put:existing
|
|
79 |
]
|
|
80 |
]
|
|
81 |
]
|
|
82 |
]
|
|
83 |
].
|
|
84 |
]
|
243
|
85 |
|
2108
|
86 |
"
|
|
87 |
self compressPools
|
|
88 |
"
|
243
|
89 |
|
2108
|
90 |
"Modified: 19.8.1997 / 14:04:25 / cg"
|
243
|
91 |
! !
|
|
92 |
|
89
|
93 |
!JavaConstantPool methodsFor:'accessing'!
|
|
94 |
|
|
95 |
owner
|
|
96 |
"return owner"
|
|
97 |
|
|
98 |
^ owner
|
|
99 |
|
|
100 |
"Created: 28.6.1996 / 21:12:22 / cg"
|
|
101 |
!
|
|
102 |
|
|
103 |
owner:something
|
|
104 |
"set owner"
|
|
105 |
|
|
106 |
owner := something.
|
|
107 |
|
|
108 |
"Created: 28.6.1996 / 21:12:22 / cg"
|
|
109 |
! !
|
|
110 |
|
|
111 |
!JavaConstantPool methodsFor:'printing & storing'!
|
|
112 |
|
|
113 |
displayString
|
|
114 |
owner isNil ifTrue:[
|
|
115 |
^ '*** unowned ConstantPool'
|
|
116 |
].
|
|
117 |
^ 'ConstantPool of ' , owner fullName
|
|
118 |
|
|
119 |
"Created: 28.6.1996 / 21:13:41 / cg"
|
|
120 |
"Modified: 28.6.1996 / 21:20:26 / cg"
|
|
121 |
! !
|
|
122 |
|
171
|
123 |
!JavaConstantPool methodsFor:'queries'!
|
|
124 |
|
|
125 |
refersToMethod:aJavaMethod
|
|
126 |
self do:[:constItem |
|
|
127 |
(constItem == aJavaMethod) ifTrue:[^ true].
|
2108
|
128 |
(constItem isMemberOf:JavaMethodref) ifTrue:[
|
|
129 |
self halt.
|
|
130 |
].
|
|
131 |
(constItem isMemberOf:JavaUnresolvedMethodrefConstant) ifTrue:[
|
|
132 |
self halt.
|
|
133 |
]
|
749
|
134 |
].
|
|
135 |
^ false
|
|
136 |
|
2108
|
137 |
"Modified: 29.7.1997 / 17:36:49 / cg"
|
|
138 |
"Created: 29.7.1997 / 17:39:19 / cg"
|
749
|
139 |
!
|
|
140 |
|
|
141 |
refersToMethodNamed:aJavaMethodName
|
|
142 |
self do:[:constItem |
|
|
143 |
(constItem isKindOf:JavaMethod) ifTrue:[
|
|
144 |
constItem name = aJavaMethodName ifTrue:[^ true].
|
|
145 |
] ifFalse:[
|
2108
|
146 |
(constItem isMemberOf:JavaMethodref) ifTrue:[
|
|
147 |
constItem name = aJavaMethodName ifTrue:[^ true].
|
|
148 |
].
|
|
149 |
(constItem isMemberOf:JavaUnresolvedMethodrefConstant) ifTrue:[
|
|
150 |
self halt.
|
|
151 |
]
|
171
|
152 |
]
|
|
153 |
].
|
|
154 |
^ false
|
|
155 |
|
2108
|
156 |
"Created: / 29.7.1997 / 17:39:24 / cg"
|
|
157 |
"Modified: / 16.10.1998 / 01:22:02 / cg"
|
171
|
158 |
! !
|
|
159 |
|
203
|
160 |
!JavaConstantPool methodsFor:'special'!
|
|
161 |
|
252
|
162 |
classReferencesDo:aBlock
|
|
163 |
self do:[:constItem |
|
|
164 |
constItem isJavaClass ifTrue:[
|
|
165 |
aBlock value:constItem
|
|
166 |
]
|
|
167 |
]
|
|
168 |
|
|
169 |
"Modified: / 7.8.1997 / 19:17:38 / cg"
|
|
170 |
"Created: / 4.1.1998 / 00:40:11 / cg"
|
|
171 |
!
|
|
172 |
|
203
|
173 |
updateClassRefsFrom:oldClass to:newClass
|
206
|
174 |
owner == oldClass ifTrue:[
|
|
175 |
self halt.
|
|
176 |
^ self
|
|
177 |
].
|
|
178 |
|
203
|
179 |
self keysAndValuesDo:[:index :constItem |
|
313
|
180 |
|nameIndex|
|
|
181 |
|
203
|
182 |
constItem == oldClass ifTrue:[
|
|
183 |
self at:index put:newClass
|
|
184 |
] ifFalse:[
|
206
|
185 |
(constItem isNil
|
|
186 |
or:[constItem isNumber]) ifFalse:[
|
203
|
187 |
constItem isString ifTrue:[
|
|
188 |
"/ nothing done ...
|
|
189 |
] ifFalse:[
|
|
190 |
(constItem isMemberOf:(Java java_lang_String)) ifTrue:[
|
|
191 |
"/ nothing done ...
|
|
192 |
] ifFalse:[
|
206
|
193 |
constItem isBehavior ifFalse:[
|
203
|
194 |
constItem updateClassRefsFrom:oldClass to:newClass
|
206
|
195 |
] ifTrue:[
|
|
196 |
constItem isJavaClass ifTrue:[
|
|
197 |
constItem fullName = oldClass fullName ifTrue:[
|
|
198 |
'JAVA: class update by name [in pool].' infoPrintCR.
|
313
|
199 |
newClass isNil ifTrue:[
|
|
200 |
"/ mhm - must find a slot for the classes name
|
|
201 |
nameIndex := -1.
|
|
202 |
self
|
|
203 |
at:index
|
|
204 |
put:(JavaUnresolvedClassConstant
|
|
205 |
pool:self
|
|
206 |
poolIndex:index
|
|
207 |
nameIndex:nameIndex)
|
|
208 |
] ifFalse:[
|
|
209 |
self at:index put:newClass
|
|
210 |
]
|
206
|
211 |
]
|
|
212 |
]
|
203
|
213 |
]
|
|
214 |
]
|
|
215 |
]
|
|
216 |
]
|
|
217 |
]
|
|
218 |
]
|
|
219 |
|
313
|
220 |
"Modified: / 4.2.1998 / 22:12:03 / cg"
|
203
|
221 |
! !
|
|
222 |
|
135
|
223 |
!JavaConstantPool class methodsFor:'documentation'!
|
89
|
224 |
|
|
225 |
version
|
2108
|
226 |
^ '$Header: /cvs/stx/stx/libjava/JavaConstantPool.st,v 1.14 2002-11-22 20:11:58 cg Exp $'
|
89
|
227 |
! !
|