749
|
1 |
"
|
|
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:
|
|
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.
|
|
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.
|
|
41 |
"
|
|
42 |
"{ Package: 'stx:libjava' }"
|
|
43 |
|
|
44 |
Object subclass:#JavaNameAndType2
|
|
45 |
instanceVariableNames:'constantPool nameIndex descriptorIndex nameCache descriptorCache'
|
|
46 |
classVariableNames:''
|
|
47 |
poolDictionaries:''
|
|
48 |
category:'Languages-Java-Reader-Support-new'
|
|
49 |
!
|
|
50 |
|
|
51 |
!JavaNameAndType2 class methodsFor:'documentation'!
|
|
52 |
|
|
53 |
copyright
|
|
54 |
"
|
|
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:
|
|
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.
|
|
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 |
|
|
95 |
"
|
|
96 |
!
|
|
97 |
|
|
98 |
documentation
|
|
99 |
"
|
|
100 |
I represent NameAndTypeInfo structure found in java constant pool.
|
|
101 |
|
|
102 |
[author:]
|
|
103 |
Marcel Hlopko <hlopkmar@fel.cvut.cz>
|
|
104 |
|
|
105 |
[instance variables:]
|
|
106 |
name - string found in constant pool at nameIndex. Represents field or method name.
|
|
107 |
descriptor - string found in constant pool at descIndex. Represents field or method type.
|
|
108 |
|
|
109 |
[class variables:]
|
|
110 |
|
|
111 |
[see also:]
|
|
112 |
|
|
113 |
"
|
|
114 |
! !
|
|
115 |
|
|
116 |
!JavaNameAndType2 class methodsFor:'instance creation'!
|
|
117 |
|
|
118 |
in: aJavaConstantPool withNameAt: arg1 andDescriptorAt: arg2
|
|
119 |
"Create & return a new instance for arg."
|
|
120 |
|
|
121 |
^ self basicNew
|
|
122 |
initializeIn: aJavaConstantPool
|
|
123 |
withNameAt: arg1
|
|
124 |
andDescriptorAt: arg2
|
|
125 |
|
|
126 |
"Created: / 10-05-2011 / 15:45:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
127 |
! !
|
|
128 |
|
|
129 |
!JavaNameAndType2 methodsFor:'accessing'!
|
|
130 |
|
|
131 |
constantPool
|
|
132 |
^constantPool.
|
|
133 |
|
|
134 |
"Created: / 10-05-2011 / 17:16:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
135 |
!
|
|
136 |
|
|
137 |
constantPool: aJavaConstantPool
|
|
138 |
constantPool := aJavaConstantPool.
|
|
139 |
|
|
140 |
"Created: / 10-05-2011 / 17:16:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
141 |
!
|
|
142 |
|
|
143 |
descriptor
|
|
144 |
^constantPool at: descriptorIndex.
|
|
145 |
|
|
146 |
"Created: / 08-04-2011 / 11:55:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
147 |
"Modified: / 12-05-2011 / 18:51:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
148 |
!
|
|
149 |
|
|
150 |
name
|
|
151 |
^ constantPool at: nameIndex.
|
|
152 |
|
|
153 |
"Created: / 08-04-2011 / 11:55:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
154 |
"Modified: / 12-05-2011 / 18:42:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
155 |
!
|
|
156 |
|
|
157 |
owner
|
|
158 |
^ constantPool owner.
|
|
159 |
|
|
160 |
"Created: / 12-05-2011 / 18:43:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
161 |
!
|
|
162 |
|
|
163 |
owner: javaClass
|
|
164 |
constantPool owner: javaClass.
|
|
165 |
|
|
166 |
"Created: / 12-05-2011 / 18:43:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
167 |
!
|
|
168 |
|
|
169 |
selector
|
|
170 |
^ (self name , self descriptor) asSymbol.
|
|
171 |
|
|
172 |
"Created: / 11-04-2011 / 21:31:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
173 |
"Modified: / 12-05-2011 / 18:51:55 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
174 |
! !
|
|
175 |
|
|
176 |
!JavaNameAndType2 methodsFor:'backward compatibility'!
|
|
177 |
|
|
178 |
isUnresolved
|
|
179 |
^false.
|
|
180 |
|
|
181 |
"Created: / 13-05-2011 / 18:43:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
182 |
!
|
|
183 |
|
|
184 |
signature
|
|
185 |
^self descriptor.
|
|
186 |
|
|
187 |
"Created: / 13-05-2011 / 18:45:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
188 |
! !
|
|
189 |
|
|
190 |
!JavaNameAndType2 methodsFor:'comparing'!
|
|
191 |
|
|
192 |
= aNameAndType
|
|
193 |
self name ~= aNameAndType name ifTrue: [ ^ false ].
|
|
194 |
^ self descriptor = aNameAndType descriptor.
|
|
195 |
|
|
196 |
"Created: / 08-04-2011 / 11:56:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
197 |
"Modified: / 12-05-2011 / 18:44:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
198 |
!
|
|
199 |
|
|
200 |
hash
|
|
201 |
^ self name hash bitXor: self descriptor hash.
|
|
202 |
|
|
203 |
"Created: / 08-04-2011 / 11:57:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
204 |
"Modified: / 12-05-2011 / 18:44:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
205 |
! !
|
|
206 |
|
|
207 |
!JavaNameAndType2 methodsFor:'initialization'!
|
|
208 |
|
|
209 |
initializeIn: aJavaConstantPool withNameAt: nameCPIndex andDescriptorAt: descriptorCPIndex
|
|
210 |
nameIndex := nameCPIndex.
|
|
211 |
descriptorIndex := descriptorCPIndex.
|
|
212 |
constantPool := aJavaConstantPool.
|
|
213 |
super initialize.
|
|
214 |
|
|
215 |
"Created: / 10-05-2011 / 15:45:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
216 |
! !
|
|
217 |
|
|
218 |
!JavaNameAndType2 methodsFor:'logging'!
|
|
219 |
|
|
220 |
info: arg
|
|
221 |
Transcript show: arg printString.
|
|
222 |
|
|
223 |
"Created: / 10-05-2011 / 16:50:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
224 |
!
|
|
225 |
|
|
226 |
warning: arg
|
|
227 |
Transcript show: arg printString.
|
|
228 |
|
|
229 |
"Created: / 10-05-2011 / 15:01:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
230 |
! !
|
|
231 |
|
|
232 |
!JavaNameAndType2 methodsFor:'printing'!
|
|
233 |
|
|
234 |
printString
|
|
235 |
^ 'JavaNameAndType name=' , self name printString , ' descriptor= '
|
|
236 |
, self descriptor printString.
|
|
237 |
|
|
238 |
"Created: / 10-05-2011 / 14:17:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
239 |
"Modified: / 12-05-2011 / 18:44:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
240 |
! !
|
|
241 |
|
|
242 |
!JavaNameAndType2 methodsFor:'queries'!
|
|
243 |
|
|
244 |
isJavaNameAndType
|
|
245 |
"return true, if given object represents name and type struct in java constant pool"
|
|
246 |
|
|
247 |
^ true.
|
|
248 |
|
|
249 |
"Created: / 10-05-2011 / 12:23:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
250 |
!
|
|
251 |
|
|
252 |
isNewJavaNameAndType
|
|
253 |
"only temporary, to know if name and type is old (claus' version) or new (m version)"
|
|
254 |
|
|
255 |
^ true.
|
|
256 |
|
|
257 |
"Created: / 10-05-2011 / 12:24:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
258 |
! !
|
|
259 |
|
|
260 |
!JavaNameAndType2 methodsFor:'resolving'!
|
|
261 |
|
|
262 |
resolve
|
|
263 |
nameCache := constantPool at: nameIndex.
|
|
264 |
descriptorCache := constantPool at: descriptorIndex.
|
|
265 |
(nameCache isNil or: [ descriptorCache isNil ])
|
|
266 |
ifTrue: [ self breakPoint: #mh ].
|
|
267 |
^self.
|
|
268 |
|
|
269 |
"Created: / 18-05-2011 / 13:19:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
270 |
!
|
|
271 |
|
|
272 |
updateClassRefsFrom: oldOwner to: newOwner
|
|
273 |
self owner = oldOwner ifTrue: [
|
|
274 |
self owner: newOwner.
|
|
275 |
].
|
|
276 |
|
|
277 |
"Created: / 10-05-2011 / 16:50:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
278 |
"Modified: / 04-06-2011 / 18:40:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
279 |
! !
|
|
280 |
|
|
281 |
!JavaNameAndType2 class methodsFor:'documentation'!
|
|
282 |
|
|
283 |
version_SVN
|
2152
|
284 |
^ '$Id: JavaNameAndType2.st,v 1.1 2011-08-18 19:06:53 vrany Exp $'
|
|
285 |
! !
|