author | Claus Gittinger <cg@exept.de> |
Thu, 24 Nov 2011 11:46:44 +0100 | |
changeset 2182 | 9e6c5374b09d |
parent 2160 | 15a9de58bf7d |
child 2204 | 07553171f189 |
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 |
|
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: |
|
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. |
|
2086 | 41 |
" |
678 | 42 |
"{ Package: 'stx:libjava' }" |
43 |
||
427 | 44 |
CompiledCode variableSubclass:#JavaMethod |
2160 | 45 |
instanceVariableNames:'accessFlags selector javaClass descriptor signature lookupObject |
46 |
lineNumberTable localVariableTable sourceLineNumber annotations' |
|
47 |
classVariableNames:'AbstractMethodInvokationSignal SignatureTypeCodes |
|
48 |
ForceByteCodeDisplay UnresolvedClassSignal A_PUBLIC A_PRIVATE |
|
49 |
A_PROTECTED A_STATIC A_FINAL A_SYNCHRONIZED A_ABSTRACT A_NATIVE |
|
50 |
A_BREAKPOINT R_VOID R_LONG R_DOUBLE A_HASHANDLER A_BRIDGE |
|
51 |
A_VARARGS A_STRICT A_SYNTHETIC' |
|
52 |
poolDictionaries:'' |
|
53 |
category:'Languages-Java-Classes' |
|
2 | 54 |
! |
55 |
||
454 | 56 |
!JavaMethod class methodsFor:'documentation'! |
57 |
||
58 |
copyright |
|
59 |
" |
|
2151 | 60 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
61 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
|
62 |
SWING Research Group, Czech Technical University in Prague |
|
63 |
||
64 |
Parts of the code written by Claus Gittinger are under following |
|
65 |
license: |
|
454 | 66 |
|
67 |
This software is furnished under a license and may be used |
|
68 |
only in accordance with the terms of that license and with the |
|
69 |
inclusion of the above copyright notice. This software may not |
|
70 |
be provided or otherwise made available to, or used by, any |
|
71 |
other person. No title to or ownership of the software is |
|
72 |
hereby transferred. |
|
2151 | 73 |
|
74 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed: |
|
75 |
||
76 |
Permission is hereby granted, free of charge, to any person |
|
77 |
obtaining a copy of this software and associated documentation |
|
78 |
files (the 'Software'), to deal in the Software without |
|
79 |
restriction, including without limitation the rights to use, |
|
80 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
81 |
copies of the Software, and to permit persons to whom the |
|
82 |
Software is furnished to do so, subject to the following |
|
83 |
conditions: |
|
84 |
||
85 |
The above copyright notice and this permission notice shall be |
|
86 |
included in all copies or substantial portions of the Software. |
|
87 |
||
88 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
89 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
90 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
91 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
92 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
93 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
94 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
95 |
OTHER DEALINGS IN THE SOFTWARE. |
|
96 |
||
97 |
[1] Code written at SWING Research Group contain a signature |
|
98 |
of one of the above copright owners. |
|
99 |
||
2086 | 100 |
" |
454 | 101 |
! ! |
2 | 102 |
|
129 | 103 |
!JavaMethod class methodsFor:'initialization'! |
8 | 104 |
|
105 |
initialize |
|
277 | 106 |
AbstractMethodInvokationSignal isNil ifTrue:[ |
2114
cbdc4c02a8e2
ExecutionErrorSignal -> ExecutionError
Claus Gittinger <cg@exept.de>
parents:
2110
diff
changeset
|
107 |
AbstractMethodInvokationSignal := ExecutionError newSignalMayProceed:true. |
594 | 108 |
AbstractMethodInvokationSignal nameClass:self message:#abstractMethodInvokationSignal. |
109 |
AbstractMethodInvokationSignal notifierString:'attempt to execute abstract method'. |
|
110 |
||
2114
cbdc4c02a8e2
ExecutionErrorSignal -> ExecutionError
Claus Gittinger <cg@exept.de>
parents:
2110
diff
changeset
|
111 |
UnresolvedClassSignal := ExecutionError newSignalMayProceed:true. |
594 | 112 |
UnresolvedClassSignal nameClass:self message:#unresolvedClassSignal. |
113 |
UnresolvedClassSignal notifierString:'unresolved class'. |
|
277 | 114 |
]. |
115 |
||
252 | 116 |
A_PUBLIC := 16r0001. |
117 |
A_PRIVATE := 16r0002. |
|
118 |
A_PROTECTED := 16r0004. |
|
119 |
A_STATIC := 16r0008. |
|
120 |
A_FINAL := 16r0010. |
|
121 |
A_SYNCHRONIZED := 16r0020. |
|
2145 | 122 |
A_BRIDGE := 16r0040. |
123 |
A_VARARGS := 16r0080. |
|
252 | 124 |
A_NATIVE := 16r0100. |
125 |
A_ABSTRACT := 16r0400. |
|
2145 | 126 |
A_STRICT := 16r0800. |
127 |
A_SYNTHETIC := 16r1000. |
|
252 | 128 |
|
129 |
R_VOID := 16r100000. |
|
130 |
R_LONG := 16r200000. |
|
131 |
R_DOUBLE := 16r300000. |
|
132 |
||
255 | 133 |
A_BREAKPOINT := 16r0800000. |
378 | 134 |
A_HASHANDLER := 16r1000000. |
255 | 135 |
|
173 | 136 |
self flags:(self flags bitOr:Behavior flagJavaMethod). |
137 |
||
8 | 138 |
SignatureTypeCodes := IdentityDictionary new. |
139 |
SignatureTypeCodes at:$B put:#byte. |
|
140 |
SignatureTypeCodes at:$C put:#char. |
|
141 |
SignatureTypeCodes at:$D put:#double. |
|
142 |
SignatureTypeCodes at:$F put:#float. |
|
143 |
SignatureTypeCodes at:$I put:#int. |
|
144 |
SignatureTypeCodes at:$J put:#long. |
|
145 |
SignatureTypeCodes at:$S put:#'unsigned short'. |
|
146 |
SignatureTypeCodes at:$Z put:#boolean. |
|
147 |
SignatureTypeCodes at:$L put:#object. |
|
148 |
SignatureTypeCodes at:$[ put:#array. |
|
2151 | 149 |
SignatureTypeCodes at:$T put:#typevar. |
8 | 150 |
|
207 | 151 |
ForceByteCodeDisplay := false. |
152 |
||
8 | 153 |
" |
378 | 154 |
JavaMethod initialize. |
155 |
JavaMethodWithHandler initialize. |
|
209 | 156 |
ForceByteCodeDisplay := true. |
255 | 157 |
ForceByteCodeDisplay := false. |
8 | 158 |
" |
173 | 159 |
|
2151 | 160 |
"Modified: / 16-10-1998 / 01:29:48 / cg" |
161 |
"Modified: / 13-08-2011 / 01:02:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
162 |
! |
|
163 |
||
164 |
reinitialize |
|
165 |
||
166 |
self flags:(self flags bitOr:Behavior flagJavaMethod). |
|
167 |
||
168 |
"Created: / 14-12-2010 / 20:58:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
378 | 169 |
! ! |
170 |
||
171 |
!JavaMethod class methodsFor:'instance creation'! |
|
172 |
||
173 |
fromMethod:aJavaMethod |
|
174 |
"create a new javaMethod, copying values from another javaMethod" |
|
175 |
||
176 |
^ self new fromMethod:aJavaMethod |
|
177 |
||
178 |
"Created: / 16.10.1998 / 01:25:12 / cg" |
|
179 |
! |
|
180 |
||
181 |
new |
|
182 |
"create a new javaMethod. |
|
183 |
Redefined, since constants are NOT stored in a literalArray, |
|
184 |
but my classes constantTable instead." |
|
185 |
||
186 |
^ self basicNew:0. |
|
187 |
||
188 |
"Created: / 16.10.1998 / 01:13:02 / cg" |
|
277 | 189 |
! ! |
190 |
||
191 |
!JavaMethod class methodsFor:'Signal constants'! |
|
192 |
||
193 |
abstractMethodInvokationSignal |
|
194 |
"return the signal raised when an abstract method is invoked" |
|
195 |
||
196 |
^ AbstractMethodInvokationSignal |
|
197 |
||
198 |
"Created: / 27.1.1998 / 21:50:05 / cg" |
|
594 | 199 |
! |
200 |
||
201 |
unresolvedClassSignal |
|
202 |
"return the signal raised when an unresolved class is referenced" |
|
203 |
||
204 |
^ UnresolvedClassSignal |
|
205 |
||
206 |
"Created: / 27.1.1998 / 21:50:05 / cg" |
|
8 | 207 |
! ! |
208 |
||
357 | 209 |
!JavaMethod class methodsFor:'constants'! |
210 |
||
467 | 211 |
A_HASHANDLER |
212 |
^ A_HASHANDLER |
|
213 |
||
214 |
"Created: / 26.11.1998 / 22:23:12 / cg" |
|
215 |
! |
|
216 |
||
357 | 217 |
A_NATIVE |
2091 | 218 |
^ A_NATIVE |
357 | 219 |
|
220 |
"Created: / 16.5.1998 / 01:18:24 / cg" |
|
221 |
! |
|
222 |
||
223 |
A_PUBLIC |
|
2091 | 224 |
^ A_PUBLIC |
357 | 225 |
|
226 |
"Created: / 16.5.1998 / 00:01:10 / cg" |
|
227 |
! |
|
228 |
||
229 |
A_STATIC |
|
2091 | 230 |
^ A_STATIC |
357 | 231 |
|
232 |
"Created: / 16.5.1998 / 00:01:17 / cg" |
|
233 |
! ! |
|
234 |
||
169 | 235 |
!JavaMethod class methodsFor:'misc'! |
236 |
||
237 |
forceByteCodeDisplay |
|
238 |
^ ForceByteCodeDisplay |
|
239 |
||
240 |
"Created: 7.4.1997 / 20:11:39 / cg" |
|
309 | 241 |
! |
242 |
||
243 |
forceByteCodeDisplay:aBoolean |
|
244 |
ForceByteCodeDisplay := aBoolean |
|
245 |
||
246 |
" |
|
247 |
self forceByteCodeDisplay:true |
|
248 |
self forceByteCodeDisplay:false |
|
249 |
" |
|
250 |
||
251 |
"Created: / 4.2.1998 / 00:22:54 / cg" |
|
2151 | 252 |
! |
253 |
||
254 |
makeJavaMethod |
|
255 |
||
256 |
self flags:((self flags |
|
257 |
bitOr:Behavior flagJavaMethod) |
|
258 |
bitClear:Behavior flagMetaMethod) |
|
259 |
||
260 |
" |
|
261 |
JavaMethod makeJavaMethod |
|
262 |
JavaMethod makeMetaMethod |
|
263 |
" |
|
264 |
||
265 |
"Created: / 23-02-2011 / 12:56:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
266 |
! |
|
267 |
||
268 |
makeMetaMethod |
|
269 |
||
270 |
self flags:((self flags |
|
271 |
bitOr:Behavior flagMetaMethod) |
|
272 |
bitClear:Behavior flagJavaMethod) |
|
273 |
" |
|
274 |
JavaMethod makeJavaMethod |
|
275 |
JavaMethod makeMetaMethod |
|
276 |
" |
|
277 |
||
278 |
"Created: / 23-02-2011 / 12:56:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
169 | 279 |
! ! |
280 |
||
129 | 281 |
!JavaMethod class methodsFor:'signature parsing'! |
5 | 282 |
|
29 | 283 |
argSigArrayFromSignature:aSignature |
284 |
"given a signature, return a specArray for the arguments" |
|
285 |
||
238 | 286 |
|s| |
29 | 287 |
|
288 |
s := aSignature readStream. |
|
237 | 289 |
s next ~~ $( ifTrue:[self halt]. |
29 | 290 |
|
291 |
^ self argSigArrayFromStream:s. |
|
292 |
||
293 |
" |
|
294 |
JavaMethod argSigArrayFromSignature:'(LObject;)V' |
|
295 |
JavaMethod argSigArrayFromSignature:'(BB)S' |
|
296 |
JavaMethod argSigArrayFromSignature:'(LObject;LObject;II)V' |
|
297 |
" |
|
298 |
! |
|
299 |
||
300 |
argSigArrayFromStream:s |
|
301 |
"parse an argSpec, return an array of specs - see java doc" |
|
302 |
||
303 |
|argSpec spec| |
|
304 |
||
305 |
spec := #(). |
|
306 |
[s atEnd or:[s peek == $)]] whileFalse:[ |
|
307 |
"/ s peek == Character space ifTrue:[ |
|
308 |
"/ s next |
|
309 |
"/ ] ifFalse:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
310 |
argSpec := self fieldTypeFromStream:s in:nil. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
311 |
spec := spec copyWith:argSpec. |
29 | 312 |
"/ ] |
313 |
]. |
|
314 |
^ spec |
|
315 |
||
255 | 316 |
"Modified: / 8.1.1998 / 19:10:20 / cg" |
29 | 317 |
! |
318 |
||
2151 | 319 |
argSignatureFromArgTypeArray:arr |
320 |
| sig | |
|
321 | 321 |
|
322 |
sig := ''. |
|
2151 | 323 |
arr do: |
324 |
[:el | |
|
325 |
| jCLass | |
|
326 |
||
327 |
jCLass := el. |
|
328 |
jCLass isJavaClass |
|
329 |
ifFalse:[ jCLass := JavaVM reflection classForJavaClassObject:el ]. |
|
330 |
jCLass isJavaClass |
|
331 |
ifTrue: |
|
332 |
[ sig := sig , jCLass typeName. |
|
333 |
] |
|
334 |
ifFalse:[ self halt. ] ]. |
|
322 | 335 |
^ sig |
321 | 336 |
|
337 |
" |
|
338 |
self argSignatureFromArgTypeArray: |
|
2151 | 339 |
(Array |
340 |
with:(JavaVM javaClassObjectForClass:(Java at:'com.sun.java.swing.JComponent')))" |
|
341 |
||
342 |
"Modified: / 13-02-1998 / 14:57:58 / cg" |
|
343 |
"Modified: / 02-03-2011 / 22:49:24 / Marcel Hlopko <hlopik@gmail.com>" |
|
321 | 344 |
! |
345 |
||
113 | 346 |
argSpecFromSignature:aSignature withName:name |
347 |
"given a signature, return a spec" |
|
348 |
||
238 | 349 |
|s argSpec| |
113 | 350 |
|
351 |
s := aSignature readStream. |
|
352 |
s next ~~ $( ifTrue:[self halt. ^ name]. |
|
353 |
||
255 | 354 |
argSpec := self argSpecFromStream:s in:nil. |
113 | 355 |
|
356 |
s next ~~ $) ifTrue:[self halt. ^ name]. |
|
357 |
||
358 |
^ name , ' (' , argSpec , ')' |
|
359 |
||
360 |
" |
|
361 |
JavaMethod argSpecFromSignature:'(LObject;)V' withName:'foo' |
|
362 |
JavaMethod argSpecFromSignature:'(BB)S' withName:'foo' |
|
363 |
" |
|
364 |
||
255 | 365 |
"Modified: / 8.1.1998 / 19:05:36 / cg" |
5 | 366 |
! |
367 |
||
142 | 368 |
argSpecFromStream:s in:aPackage |
369 |
"parse an argSpec - see java doc" |
|
370 |
||
371 |
|argSpec spec| |
|
372 |
||
373 |
spec := ''. |
|
374 |
[s atEnd or:[s peek == $)]] whileFalse:[ |
|
375 |
"/ s peek == Character space ifTrue:[ |
|
376 |
"/ s next |
|
377 |
"/ ] ifFalse:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
378 |
argSpec := self fieldTypeFromStream:s in:aPackage. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
379 |
spec size ~~ 0 ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
380 |
spec := spec , ' ' |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
381 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
382 |
spec := spec , argSpec. |
142 | 383 |
"/ ] |
384 |
]. |
|
385 |
^ spec |
|
386 |
||
387 |
"Created: 18.3.1997 / 11:06:44 / cg" |
|
388 |
! |
|
389 |
||
154 | 390 |
argSpecWithArgsFromStream:s in:aPackage |
391 |
"parse an argSpec - see java doc" |
|
392 |
||
255 | 393 |
^ self argSpecWithArgsFromStream:s in:aPackage argNames:nil |
394 |
||
395 |
"Modified: / 8.1.1998 / 19:21:00 / cg" |
|
396 |
! |
|
397 |
||
398 |
argSpecWithArgsFromStream:s in:aPackage argNames:argNames |
|
399 |
"parse an argSpec - see java doc" |
|
400 |
||
401 |
|argSpec spec argNr nm| |
|
154 | 402 |
|
403 |
argNr := 1. |
|
404 |
spec := ''. |
|
405 |
[s atEnd or:[s peek == $)]] whileFalse:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
406 |
argSpec := self fieldTypeFromStream:s in:aPackage. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
407 |
|
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
408 |
(argNames notNil |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
409 |
and:[argNames size >= argNr |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
410 |
and:[(nm := argNames at:argNr) notNil]]) ifFalse:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
411 |
nm := 'arg' , argNr printString. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
412 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
413 |
argSpec := argSpec , ' ' , nm. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
414 |
|
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
415 |
spec size ~~ 0 ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
416 |
spec := spec , ', ' |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
417 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
418 |
spec := spec , argSpec. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
419 |
|
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
420 |
argNr := argNr + 1. |
154 | 421 |
]. |
422 |
^ spec |
|
423 |
||
255 | 424 |
"Created: / 8.1.1998 / 19:20:36 / cg" |
425 |
"Modified: / 8.1.1998 / 21:14:33 / cg" |
|
8 | 426 |
! |
427 |
||
142 | 428 |
fieldTypeFromStream:s in:aPackage |
429 |
"parse a fieldTypeSpec - see java doc" |
|
430 |
||
2151 | 431 |
|typeChar typeSym elType size className nm out nangles | |
142 | 432 |
|
433 |
typeChar := s next. |
|
434 |
||
435 |
typeSym := SignatureTypeCodes at:typeChar ifAbsent:#unknown. |
|
436 |
||
437 |
typeSym == #unknown ifTrue:[ |
|
2151 | 438 |
^ typeSym |
142 | 439 |
]. |
2151 | 440 |
(typeSym == #object or: [typeSym == #typevar]) ifTrue:[ |
441 |
"Take care about type variables" |
|
442 |
out := String new writeStream. |
|
443 |
[ s peek ~~ $; and:[ s peek ~~ $< ] ] whileTrue:[ |
|
444 |
out nextPut: s next. |
|
445 |
]. |
|
446 |
className := out contents. |
|
447 |
"Eat possible type variables" |
|
448 |
(s peek == $<) ifTrue:[ |
|
449 |
nangles := 1. s next. |
|
450 |
[ nangles ~~ 0 ] whileTrue:[ |
|
451 |
s peek == $< ifTrue:[nangles := nangles + 1]. |
|
452 |
s peek == $> ifTrue:[nangles := nangles - 1]. |
|
453 |
s next. |
|
454 |
] |
|
455 |
]. |
|
456 |
s peek ~~ $; ifTrue:[self error: 'Signature corrupted?']. |
|
457 |
s next. "/eat ; |
|
458 |
||
459 |
||
460 |
typeSym == #typevar ifTrue:[^className]. |
|
461 |
"/ strip off default |
|
462 |
nm := className. |
|
463 |
aPackage notNil ifTrue:[ |
|
464 |
(nm startsWith:aPackage) ifTrue:[ |
|
465 |
nm := nm copyFrom:(aPackage size + 2). |
|
466 |
]. |
|
467 |
]. |
|
142 | 468 |
|
2151 | 469 |
nm := nm copyReplaceAll:$/ with:$.. |
470 |
^ nm |
|
142 | 471 |
]. |
189 | 472 |
|
142 | 473 |
typeSym == #array ifTrue:[ |
2151 | 474 |
s peek isDigit ifTrue:[ |
475 |
size := Integer readFrom:s. |
|
476 |
elType := self fieldTypeFromStream:s in:aPackage. |
|
477 |
^ elType , '[' , size printString , ']' |
|
478 |
]. |
|
479 |
elType := self fieldTypeFromStream:s in:aPackage. |
|
480 |
^ elType , '[]' |
|
142 | 481 |
]. |
189 | 482 |
|
142 | 483 |
^ typeSym |
484 |
||
2151 | 485 |
"Created: / 18-03-1997 / 11:07:56 / cg" |
486 |
"Modified: / 18-07-1998 / 22:57:06 / cg" |
|
487 |
"Modified: / 13-08-2011 / 01:05:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
142 | 488 |
! |
489 |
||
27 | 490 |
numArgsFromSignature:aSignature |
491 |
"given a signature, return the number of args" |
|
492 |
||
238 | 493 |
|s| |
27 | 494 |
|
495 |
s := aSignature readStream. |
|
2151 | 496 |
(aSignature includes: $() ifFalse:[self error:'Invalid signature']. |
497 |
[s next ~~ $(] whileTrue. |
|
27 | 498 |
|
499 |
^ self numArgsFromStream:s. |
|
500 |
||
501 |
" |
|
502 |
JavaMethod numArgsFromSignature:'(LObject;)V' |
|
503 |
JavaMethod numArgsFromSignature:'(BB)S' |
|
504 |
JavaMethod numArgsFromSignature:'()V' |
|
2151 | 505 |
JavaMethod numArgsFromSignature:'(Ljava/util/ArrayList<*>;)V' |
27 | 506 |
" |
2151 | 507 |
|
508 |
"Modified (comment): / 13-08-2011 / 00:59:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
27 | 509 |
! |
510 |
||
511 |
numArgsFromStream:s |
|
512 |
"parse an argSpec - see java doc" |
|
513 |
||
238 | 514 |
|n t| |
27 | 515 |
|
516 |
n := 0. |
|
517 |
[s atEnd or:[s peek == $)]] whileFalse:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
518 |
t := self fieldTypeFromStream:s in:nil. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
519 |
"/ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
520 |
"/ some args count as 2 |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
521 |
"/ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
522 |
t == #long ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
523 |
n := n + 2. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
524 |
] ifFalse:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
525 |
t == #double ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
526 |
n := n + 2 |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
527 |
] ifFalse:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
528 |
n := n + 1. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
529 |
] |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
530 |
] |
27 | 531 |
]. |
532 |
^ n |
|
533 |
||
255 | 534 |
"Modified: / 8.1.1998 / 19:10:25 / cg" |
29 | 535 |
! |
536 |
||
142 | 537 |
retValSpecFromSignature:aSignature in:aPackage |
538 |
"given a signature, return a spec" |
|
539 |
||
540 |
|s argSpec retvalSpec| |
|
541 |
||
542 |
s := aSignature readStream. |
|
237 | 543 |
s next ~~ $( ifTrue:[self halt]. |
142 | 544 |
|
545 |
argSpec := self argSpecFromStream:s in:aPackage. |
|
546 |
||
237 | 547 |
s next ~~ $) ifTrue:[self halt]. |
142 | 548 |
|
549 |
retvalSpec := self retvalSpecFromStream:s in:aPackage. |
|
550 |
||
551 |
^ retvalSpec |
|
552 |
||
553 |
" |
|
554 |
JavaMethod retValSpecFromSignature:'(LObject;)V' |
|
555 |
JavaMethod retValSpecFromSignature:'(BB)S' |
|
556 |
" |
|
557 |
||
558 |
"Created: 18.3.1997 / 11:11:50 / cg" |
|
559 |
! |
|
560 |
||
189 | 561 |
returnTypeFromSignature:aSignature in:aPackage |
562 |
"given a signature, return its type as a string" |
|
563 |
||
238 | 564 |
|s c| |
189 | 565 |
|
566 |
s := aSignature readStream. |
|
567 |
(c := s peek) ~~ $( ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
568 |
c == $' ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
569 |
[s peek ~= $'] whileTrue:[s next]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
570 |
s next. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
571 |
^ (self retvalSpecFromStream:s in:aPackage) |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
572 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
573 |
^ (self retvalSpecFromStream:s in:aPackage) |
189 | 574 |
]. |
575 |
||
576 |
s next. |
|
255 | 577 |
self argSpecFromStream:s in:aPackage. |
189 | 578 |
s next ~~ $) ifTrue:[self halt. ^ nil]. |
579 |
||
580 |
^ (self retvalSpecFromStream:s in:aPackage) |
|
581 |
||
582 |
" |
|
583 |
JavaMethod returnTypeFromSignature:'(LObject;)V' |
|
584 |
JavaMethod returnTypeFromSignature:'(BB)S' |
|
585 |
JavaMethod returnTypeFromSignature:'()J' |
|
586 |
JavaMethod returnTypeFromSignature:'''first''J' |
|
587 |
" |
|
588 |
||
255 | 589 |
"Created: / 1.8.1997 / 10:54:31 / cg" |
590 |
"Modified: / 8.1.1998 / 19:09:06 / cg" |
|
72 | 591 |
! |
592 |
||
593 |
returnsVoidFromSignature:aSignature |
|
594 |
"given a signature, return true if it returns void, false if not" |
|
595 |
||
255 | 596 |
^ (self typeFromSignature:aSignature in:nil) = 'void' |
27 | 597 |
|
598 |
" |
|
599 |
JavaMethod returnsVoidFromSignature:'(LObject;)V' |
|
600 |
JavaMethod returnsVoidFromSignature:'(BB)S' |
|
601 |
" |
|
602 |
||
255 | 603 |
"Modified: / 8.1.1998 / 19:13:53 / cg" |
10 | 604 |
! |
605 |
||
142 | 606 |
retvalSpecFromStream:s in:aPackage |
607 |
"parse a retvalSpec - see java doc" |
|
608 |
||
332 | 609 |
|spec| |
610 |
||
142 | 611 |
s atEnd ifTrue:[self halt. ^ #void]. |
612 |
s peek == $V ifTrue:[^ #void]. |
|
332 | 613 |
spec := self fieldTypeFromStream:s in:aPackage. |
614 |
spec knownAsSymbol ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
615 |
^ spec asSymbol |
332 | 616 |
]. |
617 |
^ spec |
|
142 | 618 |
|
332 | 619 |
"Created: / 18.3.1997 / 11:12:19 / cg" |
620 |
"Modified: / 7.4.1998 / 22:28:27 / cg" |
|
142 | 621 |
! |
622 |
||
189 | 623 |
specComponentsWithArgsFromSignature:aSignature withName:name in:aPackage |
624 |
"given a signature, return a spec" |
|
625 |
||
626 |
|s argSpec retvalSpec| |
|
627 |
||
628 |
s := aSignature readStream. |
|
629 |
s next ~~ $( ifTrue:[self halt. ^ name]. |
|
630 |
||
631 |
argSpec := self argSpecWithArgsFromStream:s in:aPackage. |
|
632 |
||
633 |
s next ~~ $) ifTrue:[self halt. ^ name]. |
|
634 |
||
635 |
retvalSpec := self retvalSpecFromStream:s in:aPackage. |
|
636 |
||
637 |
^ Array with:retvalSpec with:name with:argSpec |
|
638 |
||
639 |
" |
|
640 |
JavaMethod specWithArgsFromSignature:'(LObject;)V' withName:'foo' in:nil |
|
641 |
JavaMethod specComponentsWithArgsFromSignature:'(LObject;)V' withName:'foo' in:nil |
|
642 |
" |
|
643 |
||
644 |
"Created: 18.3.1997 / 11:06:22 / cg" |
|
645 |
"Modified: 1.8.1997 / 11:03:50 / cg" |
|
646 |
! |
|
647 |
||
255 | 648 |
specFromSignature:aSignature withName:name argNames:argNames in:aPackage |
10 | 649 |
"given a signature, return a spec" |
650 |
||
651 |
|s argSpec retvalSpec| |
|
652 |
||
653 |
s := aSignature readStream. |
|
654 |
s next ~~ $( ifTrue:[self halt. ^ name]. |
|
655 |
||
255 | 656 |
argSpec := self argSpecWithArgsFromStream:s in:aPackage argNames:argNames. |
10 | 657 |
|
658 |
s next ~~ $) ifTrue:[self halt. ^ name]. |
|
659 |
||
255 | 660 |
retvalSpec := self retvalSpecFromStream:s in:aPackage. |
10 | 661 |
|
662 |
^ retvalSpec , ' ' , name , ' (' , argSpec , ')' |
|
663 |
||
664 |
" |
|
255 | 665 |
JavaMethod specFromSignature:'(LObject;)V' withName:'foo' argNames:#('a') in:nil |
666 |
JavaMethod specFromSignature:'(BB)S' withName:'foo' argNames:#('a' 'b') in:nil |
|
10 | 667 |
" |
255 | 668 |
|
669 |
"Created: / 18.3.1997 / 11:06:22 / cg" |
|
670 |
"Modified: / 8.1.1998 / 21:14:43 / cg" |
|
83 | 671 |
! |
672 |
||
142 | 673 |
specFromSignature:aSignature withName:name in:aPackage |
674 |
"given a signature, return a spec" |
|
675 |
||
676 |
|s argSpec retvalSpec| |
|
677 |
||
678 |
s := aSignature readStream. |
|
679 |
s next ~~ $( ifTrue:[self halt. ^ name]. |
|
680 |
||
681 |
argSpec := self argSpecFromStream:s in:aPackage. |
|
682 |
||
683 |
s next ~~ $) ifTrue:[self halt. ^ name]. |
|
684 |
||
685 |
retvalSpec := self retvalSpecFromStream:s in:aPackage. |
|
686 |
||
687 |
^ retvalSpec , ' ' , name , ' (' , argSpec , ')' |
|
688 |
||
689 |
" |
|
255 | 690 |
JavaMethod specFromSignature:'(LObject;)V' withName:'foo' in:nil |
691 |
JavaMethod specFromSignature:'(BB)S' withName:'foo' in:nil |
|
142 | 692 |
" |
693 |
||
255 | 694 |
"Created: / 18.3.1997 / 11:06:22 / cg" |
695 |
"Modified: / 8.1.1998 / 21:06:32 / cg" |
|
142 | 696 |
! |
697 |
||
678 | 698 |
specTextFromSignature:aSignature in:aPackage withName:name |
699 |
"given a signature, return a spec as boldified text" |
|
700 |
||
701 |
|s argSpec retvalSpec| |
|
702 |
||
703 |
s := aSignature readStream. |
|
704 |
s next ~~ $( ifTrue:[self halt. ^ name]. |
|
705 |
||
706 |
argSpec := self argSpecFromStream:s in:aPackage. |
|
707 |
||
708 |
s next ~~ $) ifTrue:[self halt. ^ name]. |
|
709 |
||
710 |
retvalSpec := self retvalSpecFromStream:s in:aPackage. |
|
711 |
||
2110
6188ec8713ea
no need for asText when sending allBold
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
712 |
"/ ^ retvalSpec , ' ' , (name allBold) , ' (' , argSpec , ')' |
6188ec8713ea
no need for asText when sending allBold
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
713 |
^ (name allBold) , ' (' , argSpec , ')' |
678 | 714 |
|
715 |
" |
|
716 |
JavaMethod specTextFromSignature:'(LObject;)V' withName:'foo' |
|
717 |
JavaMethod specTextFromSignature:'(BB)S' withName:'foo' |
|
718 |
" |
|
719 |
||
720 |
"Modified: / 8.1.1998 / 19:11:20 / cg" |
|
721 |
! |
|
722 |
||
175 | 723 |
specTextFromSignature:aSignature withName:name |
724 |
"given a signature, return a spec as boldified text" |
|
725 |
||
726 |
|s argSpec retvalSpec| |
|
727 |
||
728 |
s := aSignature readStream. |
|
729 |
s next ~~ $( ifTrue:[self halt. ^ name]. |
|
730 |
||
255 | 731 |
argSpec := self argSpecFromStream:s in:nil. |
175 | 732 |
|
733 |
s next ~~ $) ifTrue:[self halt. ^ name]. |
|
734 |
||
255 | 735 |
retvalSpec := self retvalSpecFromStream:s in:nil. |
175 | 736 |
|
2110
6188ec8713ea
no need for asText when sending allBold
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
737 |
^ retvalSpec , ' ' , (name allBold) , ' (' , argSpec , ')' |
175 | 738 |
|
739 |
" |
|
740 |
JavaMethod specTextFromSignature:'(LObject;)V' withName:'foo' |
|
741 |
JavaMethod specTextFromSignature:'(BB)S' withName:'foo' |
|
742 |
" |
|
743 |
||
255 | 744 |
"Modified: / 8.1.1998 / 19:11:20 / cg" |
175 | 745 |
! |
746 |
||
189 | 747 |
specTextWithArgsFromSignature:aSignature withName:name in:aPackage |
748 |
"given a signature, return a spec" |
|
749 |
||
750 |
|s argSpec retvalSpec| |
|
751 |
||
752 |
s := aSignature readStream. |
|
753 |
s next ~~ $( ifTrue:[self halt. ^ name]. |
|
754 |
||
755 |
argSpec := self argSpecWithArgsFromStream:s in:aPackage. |
|
756 |
||
757 |
s next ~~ $) ifTrue:[self halt. ^ name]. |
|
758 |
||
759 |
retvalSpec := self retvalSpecFromStream:s in:aPackage. |
|
760 |
||
2110
6188ec8713ea
no need for asText when sending allBold
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
761 |
^ retvalSpec , ' ' , (name allBold) , ' (' , argSpec , ')' |
189 | 762 |
|
763 |
" |
|
764 |
JavaMethod specWithArgsFromSignature:'(LObject;)V' withName:'foo' in:nil |
|
765 |
JavaMethod specWithArgsFromSignature:'(BB)S' withName:'foo' in:nil |
|
766 |
" |
|
767 |
||
768 |
"Modified: 20.3.1997 / 12:50:10 / cg" |
|
769 |
"Created: 1.8.1997 / 10:43:57 / cg" |
|
770 |
! |
|
771 |
||
154 | 772 |
specWithArgsFromSignature:aSignature withName:name in:aPackage |
773 |
"given a signature, return a spec" |
|
774 |
||
775 |
|s argSpec retvalSpec| |
|
776 |
||
777 |
s := aSignature readStream. |
|
778 |
s next ~~ $( ifTrue:[self halt. ^ name]. |
|
779 |
||
780 |
argSpec := self argSpecWithArgsFromStream:s in:aPackage. |
|
781 |
||
782 |
s next ~~ $) ifTrue:[self halt. ^ name]. |
|
783 |
||
784 |
retvalSpec := self retvalSpecFromStream:s in:aPackage. |
|
785 |
||
786 |
^ retvalSpec , ' ' , name , ' (' , argSpec , ')' |
|
787 |
||
788 |
" |
|
789 |
JavaMethod specWithArgsFromSignature:'(LObject;)V' withName:'foo' in:nil |
|
790 |
JavaMethod specWithArgsFromSignature:'(BB)S' withName:'foo' in:nil |
|
791 |
" |
|
792 |
||
793 |
"Created: 18.3.1997 / 11:06:22 / cg" |
|
794 |
"Modified: 20.3.1997 / 12:50:10 / cg" |
|
795 |
! |
|
796 |
||
189 | 797 |
typeFromSignature:aSignature in:package |
798 |
"given a signature, return its type as a string" |
|
799 |
||
238 | 800 |
|s c| |
189 | 801 |
|
802 |
s := aSignature readStream. |
|
803 |
(c := s peek) ~~ $( ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
804 |
c == $' ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
805 |
s next. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
806 |
[s peek ~= $'] whileTrue:[s next]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
807 |
s next. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
808 |
^ (self retvalSpecFromStream:s in:package) |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
809 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
810 |
^ (self retvalSpecFromStream:s in:package) |
189 | 811 |
]. |
812 |
||
813 |
s next. |
|
255 | 814 |
self argSpecFromStream:s in:nil. |
189 | 815 |
s next ~~ $) ifTrue:[self halt. ^ nil]. |
816 |
||
817 |
^ (self retvalSpecFromStream:s in:package) |
|
818 |
||
819 |
" |
|
820 |
JavaMethod typeFromSignature:'(LObject;)Ljava/lang/Object' |
|
821 |
JavaMethod typeFromSignature:'(LObject;)Ljava/lang/Object' in:'java.lang' |
|
822 |
" |
|
823 |
||
255 | 824 |
"Created: / 1.8.1997 / 10:50:38 / cg" |
825 |
"Modified: / 8.1.1998 / 19:09:31 / cg" |
|
10 | 826 |
! ! |
827 |
||
2151 | 828 |
!JavaMethod methodsFor:'* As yet uncategorized *'! |
829 |
||
830 |
sends:symbol1 or:symbol2 |
|
831 |
||
832 |
^false |
|
833 |
! ! |
|
834 |
||
10 | 835 |
!JavaMethod methodsFor:'accessing'! |
836 |
||
334 | 837 |
accessFlags |
838 |
"java calls this the modifiers" |
|
839 |
||
840 |
^ accessFlags |
|
841 |
||
842 |
"Created: / 9.4.1998 / 17:49:44 / cg" |
|
843 |
! |
|
844 |
||
2151 | 845 |
annotations |
846 |
^ annotations ifNil:[JavaMethodAnnotationContainer empty]. |
|
847 |
||
848 |
"Modified: / 03-03-2011 / 23:51:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
849 |
! |
|
850 |
||
851 |
annotations:something |
|
852 |
annotations := something. |
|
853 |
! |
|
854 |
||
29 | 855 |
argSignature |
2151 | 856 |
^ self class argSigArrayFromSignature:descriptor |
857 |
! |
|
858 |
||
859 |
asByteCodeMethod |
|
860 |
||
861 |
"JavaMethods are always bytecode methods" |
|
862 |
||
863 |
^self |
|
864 |
||
865 |
"Created: / 18-07-2011 / 20:48:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
29 | 866 |
! |
867 |
||
678 | 868 |
comment |
869 |
"should access the source here, and parse any method comment" |
|
870 |
||
871 |
^ nil |
|
872 |
! |
|
873 |
||
10 | 874 |
constantPool |
875 |
^ javaClass constantPool |
|
876 |
||
877 |
"Modified: 16.4.1996 / 12:36:27 / cg" |
|
878 |
"Created: 16.4.1996 / 15:28:50 / cg" |
|
879 |
! |
|
880 |
||
129 | 881 |
containingClass |
882 |
^ javaClass |
|
883 |
||
884 |
! |
|
885 |
||
169 | 886 |
decompiledBytecode |
887 |
|s| |
|
888 |
||
889 |
s := '' writeStream. |
|
890 |
JavaDecompiler decompile:self to:s. |
|
891 |
^ s contents |
|
892 |
||
893 |
"Created: 7.4.1997 / 20:10:37 / cg" |
|
894 |
! |
|
895 |
||
75 | 896 |
decompiledSource |
897 |
|s| |
|
898 |
||
899 |
s := '' writeStream. |
|
175 | 900 |
self decompileSourceTo:s. |
75 | 901 |
^ s contents |
175 | 902 |
|
903 |
"Modified: 30.7.1997 / 16:27:55 / cg" |
|
75 | 904 |
! |
905 |
||
2151 | 906 |
descriptor |
907 |
||
908 |
^ JavaDescriptor fromString: descriptor |
|
909 |
||
910 |
"Created: / 16-04-1996 / 11:34:29 / cg" |
|
911 |
"Modified: / 14-08-2011 / 19:32:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
912 |
! |
|
913 |
||
914 |
ensureHasAnnotations |
|
915 |
annotations |
|
916 |
ifNil:[ annotations := JavaMethodAnnotationContainer for:self ]. |
|
917 |
^ annotations |
|
918 |
||
919 |
"Created: / 25-02-2011 / 16:02:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
920 |
"Modified: / 28-02-2011 / 16:33:00 / Marcel Hlopko <hlopik@gmail.com>" |
|
921 |
! |
|
922 |
||
135 | 923 |
exceptionHandlerTable |
378 | 924 |
^ nil |
135 | 925 |
|
378 | 926 |
"Created: / 16.10.1998 / 01:50:51 / cg" |
135 | 927 |
! |
928 |
||
83 | 929 |
exceptionTable |
378 | 930 |
^ nil |
83 | 931 |
|
378 | 932 |
"Created: / 16.10.1998 / 01:51:04 / cg" |
83 | 933 |
! |
934 |
||
2151 | 935 |
firstInstructionLineNumber |
936 |
ForceByteCodeDisplay == true ifTrue:[ ^ 1]. |
|
937 |
lineNumberTable notNil ifTrue:[ ^ lineNumberTable at:2]. |
|
938 |
^ 0. |
|
939 |
||
940 |
"Created: / 17-12-2010 / 17:02:46 / Jan Kurs <kurs.jan@post.cz>" |
|
941 |
"Modified: / 08-01-2011 / 16:30:16 / Jan Kurs <kurs.jan@post.cz>" |
|
942 |
! |
|
943 |
||
944 |
getExceptionTable |
|
945 |
||
946 |
^ nil |
|
947 |
||
948 |
"Created: / 04-02-2011 / 23:07:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
949 |
! |
|
950 |
||
2090 | 951 |
getSourcePosition |
952 |
^ 1 |
|
953 |
! |
|
954 |
||
90 | 955 |
hasLineNumberInformation |
956 |
^ lineNumberTable notNil |
|
957 |
||
958 |
"Created: 16.4.1996 / 12:34:04 / cg" |
|
959 |
"Modified: 16.4.1996 / 12:49:06 / cg" |
|
960 |
! |
|
961 |
||
10 | 962 |
javaByteCode |
184 | 963 |
"/ ^ javaByteCode |
964 |
^ byteCode |
|
10 | 965 |
|
966 |
"Created: 16.4.1996 / 14:55:44 / cg" |
|
184 | 967 |
"Modified: 1.8.1997 / 00:08:45 / cg" |
8 | 968 |
! |
969 |
||
27 | 970 |
javaClass |
971 |
^ javaClass |
|
972 |
||
973 |
"Modified: 16.4.1996 / 12:36:27 / cg" |
|
974 |
"Created: 16.4.1996 / 14:55:44 / cg" |
|
975 |
! |
|
976 |
||
2151 | 977 |
javaExceptionTable |
978 |
^ nil |
|
979 |
||
980 |
"Created: / 04-06-2011 / 18:16:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
981 |
! |
|
982 |
||
983 |
javaNumArgs |
|
984 |
^ self argSignature size. |
|
985 |
||
986 |
"Created: / 14-03-2011 / 15:50:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
987 |
! |
|
988 |
||
90 | 989 |
lineNumber |
252 | 990 |
lineNumberTable isNil ifTrue:[^ nil]. |
90 | 991 |
^ lineNumberTable at:2 |
992 |
||
993 |
"Created: 16.4.1996 / 12:34:04 / cg" |
|
994 |
"Modified: 16.4.1996 / 12:49:06 / cg" |
|
995 |
! |
|
996 |
||
50 | 997 |
lineNumberTable |
2151 | 998 |
"/ lineNumberTable ifNil:[ lineNumberTable := Dictionary new.]. |
50 | 999 |
^ lineNumberTable |
1000 |
||
2151 | 1001 |
"Created: / 16-04-1996 / 12:34:04 / cg" |
1002 |
"Modified: / 13-12-2010 / 11:06:40 / Jan Kurs <kurs.jan@post.cz>" |
|
50 | 1003 |
! |
1004 |
||
618 | 1005 |
literalsDetect:aBlock ifNone:exceptionBlock |
1006 |
"execute a one arg block for each of our literals. |
|
1007 |
return the first literal for which aBlock returns true" |
|
1008 |
||
1009 |
"/ sigh - must first extract all accessed literals ... |
|
1010 |
"/ must deparse the byteCode in order to do this. |
|
1011 |
||
1012 |
|walker| |
|
1013 |
||
1014 |
walker := JavaByteCodeEnumerator new. |
|
651 | 1015 |
walker literalAction:[:pc :slotIndex :const | |
1016 |
const isJavaMethodRef ifTrue:[ |
|
654 | 1017 |
(aBlock value:(const name)) ifTrue:[^ const name]. |
651 | 1018 |
] ifFalse:[ |
1019 |
const isJavaClassRef ifTrue:[ |
|
654 | 1020 |
(aBlock value:(const name)) ifTrue:[^ const name]. |
651 | 1021 |
] |
1022 |
] |
|
1023 |
]. |
|
618 | 1024 |
walker decompile:self to:nil. |
654 | 1025 |
^ nil |
618 | 1026 |
|
1027 |
"Created: / 9.11.1999 / 15:21:40 / cg" |
|
654 | 1028 |
"Modified: / 24.12.1999 / 02:55:55 / cg" |
618 | 1029 |
! |
1030 |
||
85 | 1031 |
localVariableTable |
1032 |
^ localVariableTable |
|
1033 |
||
1034 |
" |
|
1035 |
JavaMethod allInstancesDo:[:m| m localVariableTable notNil ifTrue:[self halt]] |
|
1036 |
" |
|
1037 |
! |
|
1038 |
||
2151 | 1039 |
mclass |
1040 |
^ self javaClass |
|
1041 |
! |
|
1042 |
||
1043 |
mclass: anObject |
|
1044 |
||
1045 |
javaClass := anObject |
|
1046 |
||
1047 |
"Created: / 18-10-2010 / 19:01:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1048 |
! |
|
1049 |
||
2086 | 1050 |
methodArgAndVarNames |
2151 | 1051 |
^ "((1 to:self numArgs) collect:[:i | 'arg' , i printString])" |
1052 |
self methodArgNames |
|
2086 | 1053 |
, |
2151 | 1054 |
"((1 to:self numVars) collect:[:i | 'local' , i printString])" |
1055 |
self methodVarNames |
|
1056 |
||
1057 |
"Modified: / 23-11-2010 / 19:32:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
31 | 1058 |
! |
1059 |
||
1060 |
methodArgNames |
|
252 | 1061 |
|nA| |
1062 |
||
1063 |
nA := self numArgs. |
|
102 | 1064 |
localVariableTable notNil ifTrue:[ |
2151 | 1065 |
^ (1 to:nA) collect: |
1066 |
[:argIndex | |
|
1067 |
|slot name| |
|
1068 |
"/ search for an entry with that index (slot), |
|
1069 |
"/ which has is valid at PC 0 |
|
1070 |
||
1071 |
self isStatic ifTrue:[ |
|
1072 |
slot := argIndex - 1 |
|
1073 |
] ifFalse:[ |
|
1074 |
slot := argIndex "/+ 1 |
|
1075 |
]. |
|
1076 |
name := localVariableTable nameForSlot:slot atPC:0. |
|
1077 |
name isNil ifTrue:[ |
|
1078 |
'arg' , argIndex printString |
|
1079 |
] ifFalse:[ |
|
1080 |
name |
|
1081 |
]. |
|
1082 |
] |
|
102 | 1083 |
]. |
252 | 1084 |
^ (1 to:nA) collect:[:i | 'arg' , i printString] |
2151 | 1085 |
|
1086 |
"Modified: / 23-11-2010 / 19:47:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1087 |
! |
|
1088 |
||
1089 |
methodVarNames |
|
1090 |
|nV| |
|
1091 |
||
1092 |
nV := self numVars. |
|
1093 |
localVariableTable notNil ifTrue:[ |
|
1094 |
^ (self numArgs + 1 to: self numArgs + nV) collect: |
|
1095 |
[:argIndex | |
|
1096 |
|slot name| |
|
1097 |
"/ search for an entry with that index (slot), |
|
1098 |
"/ which has is valid at PC 0 |
|
1099 |
||
1100 |
self isStatic ifTrue:[ |
|
1101 |
slot := argIndex - 1 |
|
1102 |
] ifFalse:[ |
|
1103 |
slot := argIndex"/ + 1 |
|
1104 |
]. |
|
1105 |
name := localVariableTable nameForSlot:slot atPC:0. |
|
1106 |
name isNil ifTrue:[ |
|
1107 |
'local' , argIndex printString |
|
1108 |
] ifFalse:[ |
|
1109 |
name |
|
1110 |
]. |
|
1111 |
] |
|
1112 |
]. |
|
1113 |
^ (1 to:nV) collect:[:i | 'local' , i printString] |
|
1114 |
||
1115 |
"Created: / 23-11-2010 / 19:28:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
31 | 1116 |
! |
1117 |
||
29 | 1118 |
name |
2151 | 1119 |
^ (selector copyWithoutLast:descriptor size) asSymbol |
29 | 1120 |
|
1121 |
"Created: 16.4.1996 / 11:34:22 / cg" |
|
1122 |
! |
|
1123 |
||
2151 | 1124 |
nameSpaceName |
1125 |
||
1126 |
^'' |
|
1127 |
||
1128 |
"Created: / 18-10-2010 / 19:10:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1129 |
! |
|
1130 |
||
252 | 1131 |
numLocals |
1132 |
^super numVars. |
|
1133 |
"/ numLocals isNil ifTrue:[^ 0]. |
|
1134 |
"/ ^ numLocals |
|
27 | 1135 |
|
252 | 1136 |
"Modified: / 3.1.1998 / 21:15:38 / cg" |
118 | 1137 |
! |
1138 |
||
261 | 1139 |
numVars |
1140 |
|n| |
|
118 | 1141 |
|
261 | 1142 |
"/ a Java-stackframe includes the args in the locals |
1143 |
n := self numLocals - self numArgs. |
|
1144 |
^ n |
|
1145 |
||
1146 |
"Modified: / 13.1.1998 / 17:34:37 / cg" |
|
27 | 1147 |
! |
1148 |
||
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1149 |
originalMethodIfWrapped |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1150 |
"return the method the receiver is wrapping - none here" |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1151 |
|
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1152 |
^ self |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1153 |
|
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1154 |
"Created: / 22-10-2010 / 11:46:07 / cg" |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1155 |
! |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1156 |
|
175 | 1157 |
previousVersion |
1158 |
^ nil |
|
1159 |
||
1160 |
"Created: 30.7.1997 / 15:56:18 / cg" |
|
1161 |
! |
|
1162 |
||
2151 | 1163 |
previousVersionCode |
1164 |
||
1165 |
^nil |
|
1166 |
||
1167 |
"Created: / 18-10-2010 / 20:15:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1168 |
! |
|
1169 |
||
29 | 1170 |
retValSignature |
2151 | 1171 |
^ self class retValSpecFromSignature:descriptor in:nil |
29 | 1172 |
|
255 | 1173 |
"Modified: / 8.1.1998 / 19:06:40 / cg" |
29 | 1174 |
! |
1175 |
||
123 | 1176 |
returnType |
378 | 1177 |
"/ ^ returnType |
2151 | 1178 |
^ self class typeFromSignature:descriptor in:nil. |
378 | 1179 |
|
1180 |
"Modified: / 16.10.1998 / 00:17:43 / cg" |
|
123 | 1181 |
! |
1182 |
||
322 | 1183 |
returnTypeClass |
378 | 1184 |
|cls returnType| |
322 | 1185 |
|
378 | 1186 |
(returnType := self returnType) isNil ifTrue:[ |
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1187 |
self halt. |
322 | 1188 |
]. |
1189 |
cls := Java at:returnType. |
|
1190 |
cls notNil ifTrue:[^ cls]. |
|
1191 |
||
1192 |
returnType == #void ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1193 |
^ nil |
322 | 1194 |
]. |
1195 |
returnType == #double ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1196 |
'warning: no returnTypeClass for double' printCR. |
334 | 1197 |
"/ self halt:'no returnTypeClass for double'. |
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1198 |
^ nil |
322 | 1199 |
]. |
1200 |
returnType == #float ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1201 |
'warning: no returnTypeClass for float' printCR. |
334 | 1202 |
"/ self halt:'no returnTypeClass for float'. |
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1203 |
^ nil |
322 | 1204 |
]. |
1205 |
returnType == #long ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1206 |
'warning: no returnTypeClass for long' printCR. |
334 | 1207 |
"/ self halt:'no returnTypeClass for long'. |
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1208 |
^ nil |
334 | 1209 |
]. |
1210 |
returnType == #int ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1211 |
'warning: no returnTypeClass for int' printCR. |
334 | 1212 |
"/ self halt:'no returnTypeClass for int'. |
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1213 |
^ nil |
334 | 1214 |
]. |
1215 |
returnType == #boolean ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1216 |
'warning: no returnTypeClass for boolean' printCR. |
334 | 1217 |
"/ self halt:'no returnTypeClass for boolean'. |
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1218 |
^ nil |
322 | 1219 |
]. |
1220 |
self halt. |
|
1221 |
^ nil |
|
1222 |
||
1223 |
"Created: / 13.2.1998 / 15:08:26 / cg" |
|
378 | 1224 |
"Modified: / 16.10.1998 / 00:16:07 / cg" |
322 | 1225 |
! |
1226 |
||
116 | 1227 |
returnsDouble |
378 | 1228 |
^ self returnType == #double |
1229 |
||
1230 |
"Modified: / 16.10.1998 / 00:18:24 / cg" |
|
116 | 1231 |
! |
1232 |
||
72 | 1233 |
returnsLong |
378 | 1234 |
^ self returnType == #long |
1235 |
||
1236 |
"Modified: / 16.10.1998 / 00:18:41 / cg" |
|
72 | 1237 |
! |
1238 |
||
27 | 1239 |
returnsVoid |
378 | 1240 |
^ self returnType == #void |
1241 |
||
2151 | 1242 |
"Modified: / 16-10-1998 / 00:18:53 / cg" |
1243 |
"Modified: / 22-03-2011 / 12:27:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
27 | 1244 |
! |
1245 |
||
255 | 1246 |
selector |
378 | 1247 |
"/ could theoretically be extracted from my classes |
1248 |
"/ methodDictionary via: |
|
1249 |
"/ ^ javaClass methodDictionary keyAtValue:self ifAbsent:nil. |
|
1250 |
||
255 | 1251 |
^ selector |
1252 |
||
1253 |
"Created: / 7.1.1998 / 14:05:11 / cg" |
|
378 | 1254 |
"Modified: / 16.10.1998 / 13:41:06 / cg" |
255 | 1255 |
! |
1256 |
||
27 | 1257 |
signature |
2151 | 1258 |
^ signature ? descriptor |
31 | 1259 |
! |
1260 |
||
1261 |
source |
|
2151 | 1262 |
| classSource | |
1263 |
"/ self isNative ifTrue:[ |
|
1264 |
"/ ^ 'native method' |
|
1265 |
"/ ]. |
|
169 | 1266 |
ForceByteCodeDisplay == true ifTrue:[ |
2151 | 1267 |
^ self decompiledBytecode |
169 | 1268 |
]. |
75 | 1269 |
lineNumberTable notNil ifTrue:[ |
2151 | 1270 |
classSource := javaClass source. |
1271 |
classSource notNil ifTrue:[ ^ classSource]. |
|
75 | 1272 |
]. |
1273 |
^ self decompiledSource |
|
169 | 1274 |
|
2151 | 1275 |
"Modified: / 04-01-1998 / 13:48:35 / cg" |
1276 |
"Modified: / 13-12-2010 / 11:06:51 / Jan Kurs <kurs.jan@post.cz>" |
|
31 | 1277 |
! |
1278 |
||
1279 |
sourceFilename |
|
1280 |
^ javaClass sourceFile |
|
175 | 1281 |
! |
1282 |
||
1283 |
sourceLineNumber |
|
2151 | 1284 |
" |
1285 |
sourceLineNumber ifNil: [ |
|
1286 |
sourceLineNumber := (JavaSourceCodeCache new) |
|
1287 |
findLineForMethod: self |
|
1288 |
inClass:javaClass. |
|
1289 |
]. |
|
1290 |
" |
|
1291 |
sourceLineNumber := 0. |
|
1292 |
||
1293 |
sourceLineNumber == 0 ifTrue: |
|
1294 |
[ |
|
1295 |
"There is something wrong with parsing" |
|
1296 |
"/ self halt. |
|
1297 |
self breakPoint: #libjava. |
|
1298 |
sourceLineNumber := self firstInstructionLineNumber -2. |
|
175 | 1299 |
]. |
1300 |
||
2151 | 1301 |
^ sourceLineNumber. |
1302 |
||
1303 |
"Created: / 30-07-1997 / 15:40:45 / cg" |
|
1304 |
"Modified: / 13-12-2010 / 23:46:30 / Marcel Hlopko <hlopik@gmail.com>" |
|
1305 |
"Modified: / 08-01-2011 / 16:20:40 / Jan Kurs <kurs.jan@post.cz>" |
|
1306 |
"Modified: / 05-02-2011 / 22:29:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1307 |
! |
|
1308 |
||
1309 |
wrapper |
|
1310 |
||
1311 |
^nil |
|
1312 |
||
1313 |
"Created: / 18-10-2010 / 19:11:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1314 |
! ! |
|
1315 |
||
1316 |
!JavaMethod methodsFor:'compiler interface'! |
|
1317 |
||
1318 |
programmingLanguage |
|
1319 |
||
1320 |
^JavaLanguage instance |
|
1321 |
"Created: / 26-10-2010 / 23:42:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
8 | 1322 |
! ! |
1323 |
||
255 | 1324 |
!JavaMethod methodsFor:'debugging'! |
1325 |
||
1326 |
breakPoint |
|
1327 |
Debugger enter:thisContext sender withMessage:'breakpoint' |
|
1328 |
||
1329 |
"Modified: / 9.1.1998 / 23:01:17 / cg" |
|
1330 |
! |
|
1331 |
||
1332 |
clearBreakPoint |
|
449 | 1333 |
self hasCode ifTrue:[ |
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1334 |
MessageTracer unwrapMethod:self |
449 | 1335 |
]. |
1336 |
accessFlags := (accessFlags bitClear:A_BREAKPOINT). |
|
1337 |
||
1338 |
"Modified: / 13.11.1998 / 23:31:00 / cg" |
|
255 | 1339 |
! |
1340 |
||
257 | 1341 |
isCounting |
1342 |
^ false. |
|
1343 |
||
1344 |
"Created: / 12.1.1998 / 20:02:23 / cg" |
|
1345 |
! |
|
1346 |
||
1347 |
isCountingMemoryUsage |
|
1348 |
^ false. |
|
1349 |
||
1350 |
"Created: / 12.1.1998 / 20:03:22 / cg" |
|
1351 |
! |
|
1352 |
||
255 | 1353 |
setBreakPoint |
449 | 1354 |
self hasCode ifTrue:[ |
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1355 |
MessageTracer trapMethod:self |
449 | 1356 |
]. |
1357 |
accessFlags := (accessFlags bitOr:A_BREAKPOINT). |
|
1358 |
||
1359 |
"Modified: / 13.11.1998 / 23:30:45 / cg" |
|
257 | 1360 |
! |
1361 |
||
1362 |
setTraceFullPoint |
|
1363 |
"not yet implemented" |
|
1364 |
||
1365 |
"Modified: / 9.1.1998 / 23:01:17 / cg" |
|
1366 |
"Created: / 12.1.1998 / 20:04:45 / cg" |
|
1367 |
! |
|
1368 |
||
1369 |
setTracePoint |
|
1370 |
"not yet implemented" |
|
1371 |
||
1372 |
"Modified: / 9.1.1998 / 23:01:17 / cg" |
|
1373 |
"Created: / 12.1.1998 / 20:04:02 / cg" |
|
1374 |
! |
|
1375 |
||
1376 |
setTraceSenderPoint |
|
1377 |
"not yet implemented" |
|
1378 |
||
1379 |
"Modified: / 9.1.1998 / 23:01:17 / cg" |
|
1380 |
"Created: / 12.1.1998 / 20:04:35 / cg" |
|
1381 |
! |
|
1382 |
||
1383 |
startCounting |
|
1384 |
"not yet implemented" |
|
1385 |
||
1386 |
"Modified: / 9.1.1998 / 23:01:17 / cg" |
|
1387 |
"Created: / 12.1.1998 / 20:05:01 / cg" |
|
1388 |
! |
|
1389 |
||
1390 |
startCountingMemoryUsage |
|
1391 |
"not yet implemented" |
|
1392 |
||
1393 |
"Modified: / 9.1.1998 / 23:01:17 / cg" |
|
1394 |
"Created: / 12.1.1998 / 20:05:04 / cg" |
|
1395 |
! |
|
1396 |
||
1397 |
startTiming |
|
1398 |
"not yet implemented" |
|
1399 |
||
1400 |
"Modified: / 9.1.1998 / 23:01:17 / cg" |
|
1401 |
"Created: / 12.1.1998 / 20:04:57 / cg" |
|
255 | 1402 |
! ! |
1403 |
||
18 | 1404 |
!JavaMethod methodsFor:'decompiling'! |
1405 |
||
175 | 1406 |
decompileSourceTo:aStream |
637 | 1407 |
|argNames| |
1408 |
||
1409 |
byteCode isNil ifTrue:[ |
|
1410 |
self isPublic ifTrue:[ |
|
1411 |
aStream nextPutAll:'public '. |
|
1412 |
]. |
|
1413 |
self isProtected ifTrue:[ |
|
1414 |
aStream nextPutAll:'protected '. |
|
1415 |
]. |
|
1416 |
self isPrivate ifTrue:[ |
|
1417 |
aStream nextPutAll:'private '. |
|
1418 |
]. |
|
1419 |
self isStatic ifTrue:[ |
|
1420 |
aStream nextPutAll:'static '. |
|
1421 |
]. |
|
1422 |
||
1423 |
self isNative ifTrue:[ |
|
1424 |
aStream nextPutAll:'native '. |
|
1425 |
]. |
|
1426 |
self isAbstract ifTrue:[ |
|
1427 |
aStream nextPutAll:'abstract '. |
|
1428 |
]. |
|
1429 |
argNames := #('arg1' 'arg2' 'arg3' 'arg4' 'arg5' 'arg6' 'arg7' 'arg8' 'arg9'). |
|
1430 |
aStream nextPutAll:(self signatureNameWithArgNames:argNames). |
|
1431 |
aStream nextPutAll:';'; cr. |
|
1432 |
^ self |
|
1433 |
]. |
|
1434 |
||
2151 | 1435 |
" |
637 | 1436 |
JavaDeparser isNil ifTrue:[ |
1437 |
aStream nextPutAll:'// Sorry - no decompiler'. |
|
1438 |
^ self |
|
1439 |
]. |
|
2151 | 1440 |
" |
637 | 1441 |
|
1442 |
||
252 | 1443 |
"/ self isNative ifFalse:[ |
1444 |
"/ self isAbstract ifFalse:[ |
|
2151 | 1445 |
aStream nextPutAll:'// source not available...'; cr. |
637 | 1446 |
SignalSet anySignal handle:[:ex | |
1447 |
ex signal == Object haltSignal ifTrue:[ex reject]. |
|
1448 |
ex signal == MessageTracer breakpointSignal ifTrue:[ex reject]. |
|
1449 |
ex signal == Signal noHandlerSignal ifTrue:[ex reject]. |
|
506 | 1450 |
|
637 | 1451 |
aStream nextPutAll:'error while decompiling:'. |
1452 |
aStream cr; cr; spaces:4. |
|
1453 |
aStream nextPutAll:ex errorString. |
|
1454 |
aStream cr. |
|
1455 |
aStream nextPutAll:ex suspendedContext printString. |
|
1456 |
aStream cr. |
|
1457 |
aStream nextPutAll:ex suspendedContext sender printString. |
|
1458 |
aStream cr. |
|
1459 |
aStream nextPutAll:ex suspendedContext sender sender printString. |
|
1460 |
aStream cr. |
|
1461 |
aStream nextPutAll:ex suspendedContext sender sender sender printString. |
|
1462 |
aStream cr. |
|
1463 |
aStream nextPutAll:ex suspendedContext sender sender sender sender printString. |
|
1464 |
aStream cr. |
|
1465 |
aStream nextPutAll:ex suspendedContext sender sender sender sender sender printString. |
|
1466 |
aStream cr. |
|
2095 | 1467 |
aStream nextPutAll:ex suspendedContext sender sender sender sender sender sender printString. |
1468 |
aStream cr. |
|
1469 |
aStream nextPutAll:ex suspendedContext sender sender sender sender sender sender sender printString. |
|
1470 |
aStream cr. |
|
1471 |
aStream nextPutAll:ex suspendedContext sender sender sender sender sender sender sender sender printString. |
|
1472 |
aStream cr. |
|
506 | 1473 |
|
2151 | 1474 |
" |
1475 |
JavaByteCodeDisassembler isNil ifTrue:[ |
|
637 | 1476 |
aStream nextPutAll:'// Sorry - no decompiler' |
1477 |
] ifFalse:[ |
|
2151 | 1478 |
JavaByteCodeDisassembler diassemble:self to:aStream. |
637 | 1479 |
]. |
2151 | 1480 |
" |
637 | 1481 |
ex return |
1482 |
] do:[ |
|
2151 | 1483 |
"aStream nextPutAll:(JavaDeparser decompile:self)." |
1484 |
JavaByteCodeDisassembler diassemble:self to:aStream. |
|
637 | 1485 |
]. |
252 | 1486 |
"/ ]. |
1487 |
"/ ]. |
|
18 | 1488 |
|
2151 | 1489 |
"Created: / 30-07-1997 / 16:28:09 / cg" |
1490 |
"Modified: / 21-12-1999 / 14:31:54 / cg" |
|
1491 |
"Modified: / 22-03-2011 / 21:34:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
175 | 1492 |
! |
1493 |
||
1494 |
decompiler |
|
1495 |
^ JavaDecompiler |
|
1496 |
||
1497 |
"Created: 30.7.1997 / 16:36:48 / cg" |
|
261 | 1498 |
! |
1499 |
||
449 | 1500 |
isMethod |
1501 |
"return true, if the receiver is some kind of method; |
|
1502 |
true returned here - the method is redefined from Object." |
|
1503 |
||
1504 |
^ true |
|
1505 |
||
1506 |
"Created: / 13.11.1998 / 23:57:40 / cg" |
|
1507 |
! |
|
1508 |
||
261 | 1509 |
originalMethod |
1510 |
^ self |
|
1511 |
||
1512 |
"Created: / 13.1.1998 / 15:03:05 / cg" |
|
18 | 1513 |
! ! |
1514 |
||
277 | 1515 |
!JavaMethod methodsFor:'error handling'! |
1516 |
||
2151 | 1517 |
errorInvalidClassRefAt: index |
1518 |
||
1519 |
"Sent by the VM when an invalid entry in contant pool |
|
1520 |
is encountered - for instance when the VM expects |
|
1521 |
a classref but the entry is not a classref" |
|
1522 |
||
1523 |
" |
|
1524 |
javaClass constantPool at: index. |
|
1525 |
" |
|
1526 |
||
1527 |
JavaInvalidRefError new |
|
1528 |
javaClass: javaClass; |
|
1529 |
index: index; |
|
1530 |
raiseRequest |
|
1531 |
||
1532 |
"Created: / 18-07-2011 / 23:33:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1533 |
! |
|
1534 |
||
1535 |
errorInvalidFieldRefAt: index |
|
1536 |
||
1537 |
"Sent by the VM when an invalid entry in contant pool |
|
1538 |
is encountered - for instance when the VM expects |
|
1539 |
a classref but the entry is not a classref" |
|
1540 |
||
1541 |
" |
|
1542 |
javaClass constantPool at: index. |
|
1543 |
" |
|
1544 |
||
1545 |
JavaInvalidRefError new |
|
1546 |
javaClass: javaClass; |
|
1547 |
index: index; |
|
1548 |
raiseRequest |
|
1549 |
||
1550 |
"Created: / 18-07-2011 / 23:33:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1551 |
! |
|
1552 |
||
1553 |
errorInvalidMethodRefAt: index |
|
1554 |
||
1555 |
"Sent by the VM when an invalid entry in contant pool |
|
1556 |
is encountered - for instance when the VM expects |
|
1557 |
a classref but the entry is not a classref" |
|
1558 |
||
1559 |
" |
|
1560 |
javaClass constantPool at: index. |
|
1561 |
" |
|
1562 |
||
1563 |
JavaInvalidRefError new |
|
1564 |
javaClass: javaClass; |
|
1565 |
index: index; |
|
1566 |
raiseRequest |
|
1567 |
||
1568 |
"Created: / 18-07-2011 / 19:59:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1569 |
! |
|
1570 |
||
277 | 1571 |
invalidByteCode |
1572 |
self isAbstract ifTrue:[ |
|
2151 | 1573 |
^ AbstractMethodInvokationSignal raise. |
277 | 1574 |
]. |
2151 | 1575 |
((self class numArgsFromSignature:descriptor) > self class maxNumberOfArguments) ifTrue:[ |
1576 |
^ self error:'method cannot be executed - too many args' |
|
309 | 1577 |
]. |
277 | 1578 |
^ super invalidByteCode |
1579 |
||
2151 | 1580 |
"Created: / 27-01-1998 / 21:48:01 / cg" |
1581 |
"Modified: / 14-08-2011 / 19:29:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
378 | 1582 |
! |
1583 |
||
1584 |
invalidMethodRef |
|
1585 |
self halt. |
|
1586 |
^ nil. |
|
1587 |
||
1588 |
"Modified: / 27.1.1998 / 21:50:19 / cg" |
|
1589 |
"Created: / 16.10.1998 / 11:27:21 / cg" |
|
594 | 1590 |
! |
1591 |
||
1592 |
nullClassPointer |
|
1593 |
JavaVM throwClassNotFoundException |
|
277 | 1594 |
! ! |
1595 |
||
2151 | 1596 |
!JavaMethod methodsFor:'initialization'! |
1597 |
||
1598 |
setAccessFlags:flags |
|
1599 |
accessFlags := flags. |
|
1600 |
||
1601 |
"Created: 16.4.1996 / 11:34:14 / cg" |
|
1602 |
! |
|
1603 |
||
1604 |
setCode:codeBytes maxStack:max_stack maxLocals:max_locals u1:unknown1 u2:unknown2 |
|
1605 |
"/ javaByteCode := codeBytes. |
|
1606 |
byteCode := codeBytes. |
|
1607 |
"/ numStack := max_stack. |
|
1608 |
"/ numLocals := max_locals. |
|
1609 |
super numberOfVars:max_locals. |
|
1610 |
super stackSize:max_stack. |
|
1611 |
||
1612 |
"/ self displayString printNL. |
|
1613 |
"/ ' nStack: ' print. numStack print. |
|
1614 |
"/ ' nLocal: ' print. numLocals print. |
|
1615 |
"/ ' u1: ' print. unknown1 print. |
|
1616 |
"/ ' u2: ' print. unknown2 printNL. |
|
1617 |
||
1618 |
"Modified: 1.8.1997 / 00:08:32 / cg" |
|
1619 |
! |
|
1620 |
||
1621 |
setDescriptor:aString |
|
1622 |
||
1623 |
descriptor := aString asSymbol. |
|
1624 |
||
1625 |
"Created: / 16-04-1996 / 11:34:29 / cg" |
|
1626 |
"Modified: / 16-10-1998 / 00:17:12 / cg" |
|
1627 |
"Modified: / 13-08-2011 / 01:21:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1628 |
"Created: / 14-08-2011 / 19:41:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1629 |
! |
|
1630 |
||
1631 |
setJavaClass:aJavaClass |
|
1632 |
javaClass := aJavaClass |
|
1633 |
||
1634 |
"Modified: 16.4.1996 / 12:36:27 / cg" |
|
1635 |
"Created: 16.4.1996 / 15:28:15 / cg" |
|
1636 |
! |
|
1637 |
||
1638 |
setLineNumberTable:anArrayOfPCtoLineAssociations |
|
1639 |
"since this uses up lots of memory, compress it" |
|
1640 |
||
1641 |
|allBytes allWords idx| |
|
1642 |
||
1643 |
allBytes := allWords := true. |
|
1644 |
||
1645 |
anArrayOfPCtoLineAssociations do:[:assoc | |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1646 |
assoc key > 255 ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1647 |
allBytes := false. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1648 |
assoc key > 16rFFFF ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1649 |
allWords := false. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1650 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1651 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1652 |
assoc value > 255 ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1653 |
allBytes := false. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1654 |
assoc value > 16rFFFF ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1655 |
allWords := false |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1656 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1657 |
]. |
2151 | 1658 |
]. |
1659 |
allBytes ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1660 |
lineNumberTable := ByteArray new:(anArrayOfPCtoLineAssociations size * 2). |
2151 | 1661 |
] ifFalse:[ |
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1662 |
allWords ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1663 |
lineNumberTable := WordArray new:(anArrayOfPCtoLineAssociations size * 2). |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1664 |
] ifFalse:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1665 |
lineNumberTable := Array new:(anArrayOfPCtoLineAssociations size * 2). |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1666 |
] |
2151 | 1667 |
]. |
1668 |
||
1669 |
idx := 1. |
|
1670 |
anArrayOfPCtoLineAssociations do:[:assoc | |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1671 |
lineNumberTable at:idx put:assoc key. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1672 |
lineNumberTable at:idx+1 put:assoc value. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1673 |
idx := idx + 2. |
2151 | 1674 |
]. |
1675 |
||
1676 |
"Created: 16.4.1996 / 12:34:04 / cg" |
|
1677 |
"Modified: 16.4.1996 / 12:49:06 / cg" |
|
1678 |
! |
|
1679 |
||
1680 |
setLocalVariableTable:anArray |
|
1681 |
localVariableTable := anArray. |
|
1682 |
! |
|
1683 |
||
1684 |
setName:nameString descriptor:aString |
|
1685 |
||
1686 |
||
1687 |
|numArgs tooManyArgs returnType| |
|
1688 |
||
1689 |
selector := (nameString , aString) asSymbol. |
|
1690 |
self setDescriptor:aString. |
|
1691 |
||
1692 |
numArgs := self class numArgsFromSignature:aString. |
|
1693 |
(tooManyArgs := (numArgs > self class maxNumberOfArguments)) ifTrue:[ |
|
1694 |
numArgs := 0. |
|
1695 |
]. |
|
1696 |
self numberOfArgs:numArgs. |
|
1697 |
returnType := self class typeFromSignature:aString in:nil. |
|
1698 |
||
1699 |
"/ for the convenience of the VM, also mirror the return type in |
|
1700 |
"/ the flags ... |
|
1701 |
||
1702 |
returnType == #void ifTrue:[ |
|
1703 |
accessFlags := accessFlags bitOr:R_VOID |
|
1704 |
] ifFalse:[ |
|
1705 |
returnType == #long ifTrue:[ |
|
1706 |
accessFlags := accessFlags bitOr:R_LONG |
|
1707 |
] ifFalse:[ |
|
1708 |
returnType == #double ifTrue:[ |
|
1709 |
accessFlags := accessFlags bitOr:R_DOUBLE |
|
1710 |
] |
|
1711 |
] |
|
1712 |
]. |
|
1713 |
tooManyArgs ifTrue:[ |
|
1714 |
^ ArgumentError |
|
1715 |
raiseRequestWith:self |
|
1716 |
errorString:'too many args in method' |
|
1717 |
]. |
|
1718 |
||
1719 |
"Created: / 14-08-2011 / 19:41:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1720 |
! |
|
1721 |
||
1722 |
setSignature:aString |
|
1723 |
||
1724 |
signature := aString asSymbol. |
|
1725 |
||
1726 |
"Created: / 16-04-1996 / 11:34:29 / cg" |
|
1727 |
"Modified: / 16-10-1998 / 00:17:12 / cg" |
|
1728 |
"Modified (format): / 14-08-2011 / 19:41:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1729 |
! ! |
|
1730 |
||
1731 |
!JavaMethod methodsFor:'inspecting'! |
|
1732 |
||
1733 |
inspectorExtraAttributes |
|
1734 |
"extra (pseudo instvar) entries to be shown in an inspector." |
|
1735 |
||
1736 |
^ Dictionary new |
|
1737 |
declareAllNewFrom:(super inspectorExtraAttributes ? #()); |
|
1738 |
"/add:'-code' -> [ String streamContents:[:s | JavaDecompiler decompile: self to: s] ]; |
|
1739 |
add:'-code' -> [ String streamContents:[:s | JavaByteCodeDisassembler diassemble: self to: s] ]; |
|
1740 |
"/add:'-source' -> [ self source ]; |
|
1741 |
yourself |
|
1742 |
||
1743 |
"Modified: / 22-03-2011 / 21:13:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1744 |
! ! |
|
1745 |
||
1746 |
!JavaMethod methodsFor:'interpretation'! |
|
1747 |
||
1748 |
interpretWithReceiver: receiver |
|
1749 |
||
1750 |
^self |
|
1751 |
interpretWithReceiver: receiver |
|
1752 |
arguments: #() |
|
1753 |
||
1754 |
"Created: / 24-02-2011 / 22:05:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1755 |
! |
|
1756 |
||
1757 |
interpretWithReceiver: receiver arg: a1 |
|
1758 |
||
1759 |
^self |
|
1760 |
interpretWithReceiver: receiver |
|
1761 |
arguments: (Array with: a1) |
|
1762 |
||
1763 |
"Created: / 24-02-2011 / 22:05:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1764 |
! |
|
1765 |
||
1766 |
interpretWithReceiver: receiver arg: a1 arg: a2 |
|
1767 |
||
1768 |
^self |
|
1769 |
interpretWithReceiver: receiver |
|
1770 |
arguments: (Array with: a1 with: a2) |
|
1771 |
||
1772 |
"Created: / 24-02-2011 / 22:05:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1773 |
! |
|
1774 |
||
1775 |
interpretWithReceiver: receiver arg: a1 arg: a2 arg: a3 |
|
1776 |
||
1777 |
^self |
|
1778 |
interpretWithReceiver: receiver |
|
1779 |
arguments: (Array with: a1 with: a2 with: a3) |
|
1780 |
||
1781 |
"Created: / 24-02-2011 / 22:06:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1782 |
! |
|
1783 |
||
1784 |
interpretWithReceiver: receiver arguments:args |
|
1785 |
||
1786 |
^ JavaByteCodeInterpreter |
|
1787 |
interpret:self |
|
1788 |
receiver:receiver |
|
1789 |
arguments:args |
|
1790 |
||
1791 |
"Modified: / 24-02-2011 / 23:00:42 / Marcel Hlopko <hlopik@gmail.com>" |
|
1792 |
"Created: / 24-02-2011 / 22:04:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1793 |
! ! |
|
1794 |
||
118 | 1795 |
!JavaMethod methodsFor:'methodref interchangability'! |
1796 |
||
673 | 1797 |
homeMethod |
1798 |
^ self |
|
1799 |
! |
|
1800 |
||
118 | 1801 |
method |
1802 |
^ self |
|
692 | 1803 |
! |
1804 |
||
1805 |
setPackage:newPackage |
|
1806 |
newPackage ~= javaClass package ifTrue:[ |
|
1807 |
self halt:'java method cannot be in a package different from its class'. |
|
1808 |
] |
|
118 | 1809 |
! ! |
1810 |
||
148 | 1811 |
!JavaMethod methodsFor:'misc'! |
1812 |
||
378 | 1813 |
fromMethod:aJavaMethod |
1814 |
"copy values from another javaMethod" |
|
149 | 1815 |
|
378 | 1816 |
flags := aJavaMethod flags. |
1817 |
byteCode := aJavaMethod byteCode. |
|
1818 |
accessFlags := aJavaMethod accessFlags. |
|
1819 |
selector := aJavaMethod selector. |
|
1820 |
javaClass := aJavaMethod javaClass. |
|
2151 | 1821 |
descriptor := aJavaMethod instVarNamed:#descriptor. |
1822 |
signature := aJavaMethod instVarNamed:#signature. |
|
378 | 1823 |
lineNumberTable := aJavaMethod lineNumberTable. |
1824 |
localVariableTable := aJavaMethod localVariableTable. |
|
2151 | 1825 |
annotations := aJavaMethod annotations. |
1826 |
||
1827 |
"Modified: / 16-10-1998 / 01:27:19 / cg" |
|
1828 |
"Modified: / 14-08-2011 / 19:30:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
255 | 1829 |
! |
252 | 1830 |
|
255 | 1831 |
updateClassRefsFrom:oldClass to:newClass |
1832 |
javaClass == oldClass ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1833 |
"/ invalidate |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1834 |
byteCode := nil. |
255 | 1835 |
] |
252 | 1836 |
|
255 | 1837 |
"Created: / 6.1.1998 / 18:19:48 / cg" |
252 | 1838 |
! ! |
1839 |
||
8 | 1840 |
!JavaMethod methodsFor:'printing & storing'! |
1841 |
||
29 | 1842 |
displayString |
168 | 1843 |
javaClass isNil ifTrue:[ |
611 | 1844 |
^ self class name , '(???)' |
168 | 1845 |
]. |
611 | 1846 |
^ self class name , '(' , javaClass displayString , '::' , self signatureName , ')' |
423 | 1847 |
|
611 | 1848 |
"Modified: / 25.9.1999 / 23:04:01 / cg" |
29 | 1849 |
! |
1850 |
||
670 | 1851 |
printStringForBrowserWithSelector:dummySelector inClass:dummyClass |
43 | 1852 |
"/ self isStatic ifTrue:[ |
1853 |
"/ ^ 'static ' , self signatureName |
|
1854 |
"/ ]. |
|
168 | 1855 |
"/ self isBreakpointed ifTrue:[ |
1856 |
"/ ^ (LabelAndIcon '!! ' , self signatureName |
|
1857 |
"/ ]. |
|
175 | 1858 |
|
252 | 1859 |
self name = #'<init>' ifTrue:[ |
2151 | 1860 |
^ self class specTextFromSignature:descriptor in:javaClass package withName:(javaClass lastName). |
166 | 1861 |
]. |
2151 | 1862 |
^ self class specTextFromSignature:descriptor in:javaClass package withName:(self name) |
10 | 1863 |
! |
1864 |
||
118 | 1865 |
shortDisplayString |
1866 |
^ javaClass name , '::' , self signatureNameWithoutReturnType |
|
1867 |
! |
|
1868 |
||
10 | 1869 |
signatureName |
1870 |
"return a string to be used when browsing" |
|
1871 |
||
2151 | 1872 |
^ self class specFromSignature:descriptor withName:(self name) in:nil |
255 | 1873 |
|
1874 |
"Modified: / 8.1.1998 / 19:15:33 / cg" |
|
113 | 1875 |
! |
1876 |
||
164 | 1877 |
signatureNameFor:name withArgsIn:aPackage |
1878 |
"return a string to be used when decompiling" |
|
1879 |
||
2151 | 1880 |
^ self class specWithArgsFromSignature:descriptor withName:name in:aPackage |
164 | 1881 |
|
1882 |
"Created: 25.3.1997 / 18:49:45 / cg" |
|
1883 |
! |
|
1884 |
||
142 | 1885 |
signatureNameIn:aPackage |
1886 |
"return a string to be used when browsing" |
|
1887 |
||
2151 | 1888 |
^ self class specFromSignature:descriptor withName:(self name) in:aPackage |
142 | 1889 |
|
1890 |
"Created: 18.3.1997 / 11:11:01 / cg" |
|
1891 |
! |
|
1892 |
||
175 | 1893 |
signatureNameText |
1894 |
"return a text to be used when browsing" |
|
1895 |
||
2151 | 1896 |
^ self class specTextFromSignature:descriptor withName:(self name) |
175 | 1897 |
|
1898 |
"Created: 30.7.1997 / 14:40:29 / cg" |
|
1899 |
! |
|
1900 |
||
189 | 1901 |
signatureNameTextFor:name withArgsIn:aPackage |
1902 |
"return a text to be used when decompiling" |
|
1903 |
||
2151 | 1904 |
^ self class specTextWithArgsFromSignature:descriptor withName:name in:aPackage |
189 | 1905 |
|
1906 |
"Created: 25.3.1997 / 18:49:45 / cg" |
|
1907 |
"Modified: 1.8.1997 / 10:44:28 / cg" |
|
1908 |
! |
|
1909 |
||
255 | 1910 |
signatureNameWithArgNames:argNames |
1911 |
"return a string to be used when browsing" |
|
1912 |
||
1913 |
|myName| |
|
1914 |
||
1915 |
myName := self name. |
|
1916 |
myName = '<init>' ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1917 |
myName := javaClass name |
255 | 1918 |
]. |
2151 | 1919 |
^ self class specFromSignature:descriptor withName:myName argNames:argNames in:nil |
255 | 1920 |
|
1921 |
"Created: / 8.1.1998 / 21:04:03 / cg" |
|
1922 |
"Modified: / 8.1.1998 / 21:22:38 / cg" |
|
1923 |
! |
|
1924 |
||
1925 |
signatureNameWithArgNames:argNames in:package |
|
1926 |
"return a string to be used when browsing" |
|
1927 |
||
1928 |
|myName| |
|
1929 |
||
1930 |
myName := self name. |
|
1931 |
myName = '<init>' ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1932 |
myName := javaClass name |
255 | 1933 |
]. |
2151 | 1934 |
^ self class specFromSignature:descriptor withName:myName argNames:argNames in:package |
255 | 1935 |
|
1936 |
"Modified: / 8.1.1998 / 21:05:52 / cg" |
|
1937 |
"Created: / 8.1.1998 / 21:23:03 / cg" |
|
1938 |
! |
|
1939 |
||
154 | 1940 |
signatureNameWithArgsIn:aPackage |
1941 |
"return a string to be used when browsing" |
|
1942 |
||
2151 | 1943 |
^ self class specWithArgsFromSignature:descriptor withName:(self name) in:aPackage |
1944 |
||
1945 |
"Created: / 20-03-1997 / 12:44:17 / cg" |
|
1946 |
"Modified: / 14-08-2011 / 19:29:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1947 |
! |
|
1948 |
||
1949 |
signatureNameWithModifiers |
|
1950 |
"return a string to be used when deassembling" |
|
1951 |
||
1952 |
| result | |
|
1953 |
||
1954 |
result := self signatureName. |
|
1955 |
self isFinal ifTrue: [ result := 'final ' , result ]. |
|
1956 |
self isStatic ifTrue: [ result := 'static ' , result ]. |
|
1957 |
self isSynchronized ifTrue: [ result := 'synchronized ' , result ]. |
|
1958 |
self isPrivate |
|
1959 |
ifTrue: [ result := 'private ' , result ] |
|
1960 |
ifFalse: |
|
1961 |
[ self isProtected |
|
1962 |
ifTrue: [ result := 'protected ' , result ] |
|
1963 |
ifFalse: [ self isPublic ifTrue: [ result := 'public ' , result ] ] ]. |
|
1964 |
self isAbstract ifTrue: [ result := 'abstract ' , result ]. |
|
1965 |
^ result. |
|
1966 |
||
1967 |
"Modified: / 08-01-1998 / 19:15:33 / cg" |
|
1968 |
"Created: / 22-03-2011 / 16:25:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
154 | 1969 |
! |
1970 |
||
113 | 1971 |
signatureNameWithoutReturnType |
1972 |
"return a string to be used when browsing" |
|
1973 |
||
2151 | 1974 |
^ self class argSpecFromSignature:descriptor withName:(self name) |
113 | 1975 |
|
8 | 1976 |
! ! |
1977 |
||
1978 |
!JavaMethod methodsFor:'queries'! |
|
1979 |
||
111 | 1980 |
handlerFor:anException at:pc |
611 | 1981 |
"return an exceptionHandlers pc, for an exception of the given type, |
1982 |
occurring at pc. Returns nil, if there is none." |
|
1983 |
||
1984 |
|handlerTable| |
|
1985 |
||
1986 |
(handlerTable := self exceptionHandlerTable) isNil ifTrue:[^ nil]. |
|
1987 |
||
1988 |
handlerTable do:[:entry | |
|
1989 |
|hpc| |
|
1990 |
||
1991 |
hpc := entry handlerPCFor:anException at:pc in:self. |
|
1992 |
hpc notNil ifTrue:[^ hpc]. |
|
1993 |
]. |
|
1994 |
||
378 | 1995 |
^ nil |
48 | 1996 |
|
611 | 1997 |
"Created: / 16.10.1998 / 01:18:40 / cg" |
1998 |
"Modified: / 25.9.1999 / 23:07:01 / cg" |
|
31 | 1999 |
! |
2000 |
||
2151 | 2001 |
hasPrimitiveCode |
2002 |
||
2003 |
^false |
|
2004 |
||
2005 |
"Created: / 18-07-2011 / 20:45:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2006 |
! |
|
2007 |
||
127 | 2008 |
hasResource |
2009 |
^ false |
|
2010 |
! |
|
2011 |
||
19 | 2012 |
isAbstract |
252 | 2013 |
^ (accessFlags bitAnd:A_ABSTRACT) ~~ 0 |
19 | 2014 |
! |
2015 |
||
80 | 2016 |
isBreakpointed |
256 | 2017 |
^ (accessFlags bitAnd:A_BREAKPOINT) ~~ 0 |
2018 |
||
2019 |
"Modified: / 11.1.1998 / 13:28:43 / cg" |
|
80 | 2020 |
! |
2021 |
||
19 | 2022 |
isFinal |
252 | 2023 |
^ (accessFlags bitAnd:A_FINAL) ~~ 0 |
19 | 2024 |
! |
2025 |
||
175 | 2026 |
isIgnored |
2027 |
"not really a java attribute; |
|
2028 |
added to allow browsing" |
|
2029 |
||
2030 |
^ false. |
|
2031 |
||
2032 |
"Created: 30.7.1997 / 15:34:33 / cg" |
|
2033 |
! |
|
2034 |
||
625 | 2035 |
isJavaClassRef |
2036 |
^ false |
|
2037 |
||
2038 |
"Created: / 9.11.1999 / 17:16:20 / cg" |
|
2039 |
! |
|
2040 |
||
431 | 2041 |
isJavaMethod |
2042 |
^ true |
|
2043 |
||
2044 |
"Created: / 10.11.1998 / 18:24:51 / cg" |
|
2045 |
! |
|
2046 |
||
19 | 2047 |
isNative |
252 | 2048 |
^ (accessFlags bitAnd:A_NATIVE) ~~ 0 |
19 | 2049 |
! |
2050 |
||
2051 |
isPrivate |
|
252 | 2052 |
^ (accessFlags bitAnd:A_PRIVATE) ~~ 0 |
19 | 2053 |
! |
2054 |
||
2055 |
isProtected |
|
252 | 2056 |
^ (accessFlags bitAnd:A_PROTECTED) ~~ 0 |
19 | 2057 |
! |
2058 |
||
2059 |
isPublic |
|
252 | 2060 |
^ (accessFlags bitAnd:A_PUBLIC) ~~ 0 |
19 | 2061 |
! |
2062 |
||
2063 |
isStatic |
|
252 | 2064 |
^ (accessFlags bitAnd:A_STATIC) ~~ 0 |
19 | 2065 |
! |
2066 |
||
2067 |
isSynchronized |
|
252 | 2068 |
^ (accessFlags bitAnd:A_SYNCHRONIZED) ~~ 0 |
18 | 2069 |
! |
2070 |
||
256 | 2071 |
isTraced |
2072 |
^ false |
|
2073 |
||
2074 |
"Modified: / 11.1.1998 / 13:28:43 / cg" |
|
2075 |
"Created: / 11.1.1998 / 13:38:11 / cg" |
|
2076 |
! |
|
2077 |
||
8 | 2078 |
isUnloaded |
2079 |
^ false |
|
18 | 2080 |
! |
2081 |
||
2151 | 2082 |
isUnresolved |
2083 |
"return true, if the receiver is unresolved;" |
|
2084 |
||
2085 |
||
2086 |
^ false |
|
2087 |
||
2088 |
"Created: / 06-03-2011 / 22:57:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
2089 |
! |
|
2090 |
||
256 | 2091 |
isWrapped |
2092 |
^ self isBreakpointed |
|
2093 |
||
2094 |
"Modified: / 11.1.1998 / 13:28:43 / cg" |
|
2095 |
"Created: / 11.1.1998 / 13:38:04 / cg" |
|
2096 |
! |
|
2097 |
||
31 | 2098 |
lineNumberForPC:pc |
75 | 2099 |
|last num text classSource| |
31 | 2100 |
|
2101 |
num := nil. |
|
2102 |
||
207 | 2103 |
ForceByteCodeDisplay == true ifFalse:[ |
169 | 2104 |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2105 |
lineNumberTable notNil ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2106 |
classSource := javaClass source. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2107 |
classSource notNil ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2108 |
lineNumberTable pairWiseDo:[:lPc :lNr | |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2109 |
lPc >= pc ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2110 |
lPc == pc ifTrue:[^ lNr]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2111 |
last isNil ifTrue:[^ lNr]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2112 |
^ last. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2113 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2114 |
last := lNr. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2115 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2116 |
last notNil ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2117 |
^ last |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2118 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2119 |
^ lineNumberTable at:2 |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2120 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2121 |
]. |
46 | 2122 |
]. |
31 | 2123 |
|
46 | 2124 |
"/ decompile and look which line the pc falls into |
209 | 2125 |
|
2126 |
ForceByteCodeDisplay == true ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2127 |
text := self decompiledBytecode asCollectionOfLines. |
209 | 2128 |
] ifFalse:[ |
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2129 |
text := self decompiledSource asCollectionOfLines. |
209 | 2130 |
]. |
31 | 2131 |
|
46 | 2132 |
text keysAndValuesDo:[:lineNr :line | |
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2133 |
|nr| |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2134 |
|
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2135 |
(line startsWith:' ') ifFalse:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2136 |
nr := Integer readFrom:line onError:0. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2137 |
nr >= pc ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2138 |
^ lineNr |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2139 |
] |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2140 |
] |
31 | 2141 |
]. |
2142 |
^ num |
|
141 | 2143 |
|
261 | 2144 |
"Modified: / 14.1.1998 / 13:30:54 / cg" |
31 | 2145 |
! |
2146 |
||
2087 | 2147 |
messagesSent |
2148 |
"return a collection of messages sent by this method" |
|
2149 |
||
2091 | 2150 |
|walker selectors| |
2087 | 2151 |
|
2152 |
"/ sigh - must extract all accessed literals ... |
|
2153 |
"/ must deparse the byteCode in order to do this. |
|
2154 |
||
2155 |
selectors := IdentitySet new. |
|
2156 |
walker := JavaByteCodeEnumerator new. |
|
2157 |
walker |
|
2158 |
literalAction: |
|
2159 |
[:pc :slotIndex :const | |
|
2160 |
|mSel| |
|
2161 |
||
2162 |
(const isNumber |
|
2163 |
or:[const isString |
|
2164 |
or:[const isNil]]) ifFalse:[ |
|
2165 |
const isJavaMethod ifTrue:[ |
|
2166 |
mSel := const selector. |
|
2167 |
] ifFalse:[ |
|
2168 |
const isJavaMethodRef ifTrue:[ |
|
2169 |
mSel := const selector "/ signature. |
|
2170 |
] |
|
2171 |
]. |
|
2172 |
]. |
|
2173 |
mSel notNil ifTrue:[ |
|
2174 |
"/ Transcript showCR:mSel. |
|
2175 |
selectors add:mSel |
|
2176 |
]. |
|
2177 |
]. |
|
2178 |
walker decompile:self to:nil. |
|
2179 |
^ selectors |
|
2180 |
! |
|
2181 |
||
156 | 2182 |
package |
685 | 2183 |
"in java, class extensions are not possible; |
2184 |
all methods MUST be in their classes package" |
|
156 | 2185 |
|
685 | 2186 |
^ javaClass package |
156 | 2187 |
! |
2188 |
||
428 | 2189 |
quickLineNumberForPC:pc |
2190 |
|last| |
|
2191 |
||
2192 |
lineNumberTable notNil ifTrue:[ |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2193 |
lineNumberTable pairWiseDo:[:lPc :lNr | |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2194 |
lPc >= pc ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2195 |
lPc == pc ifTrue:[^ lNr]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2196 |
last isNil ifTrue:[^ lNr]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2197 |
^ last. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2198 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2199 |
last := lNr. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2200 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2201 |
last notNil ifTrue:[ |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2202 |
^ last |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2203 |
]. |
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2204 |
^ lineNumberTable at:2 |
428 | 2205 |
]. |
2206 |
^ nil |
|
2207 |
||
2208 |
"Modified: / 14.1.1998 / 13:30:54 / cg" |
|
2209 |
"Created: / 10.11.1998 / 14:18:22 / cg" |
|
2210 |
! |
|
2211 |
||
625 | 2212 |
referencesGlobal:aGlobalName |
2213 |
"return true, if this method refers to a global named aGlobalName" |
|
2214 |
||
2215 |
|walker any| |
|
2216 |
||
2217 |
"/ quick check, if constantPool includes a methodRef for this |
|
2218 |
"/ selector. |
|
2219 |
||
2220 |
any := false. |
|
2221 |
self javaClass constantPool do:[:const | |
|
2222 |
(const isNumber |
|
2223 |
or:[const isString |
|
2224 |
or:[const isNil]]) ifFalse:[ |
|
2225 |
const isJavaClass ifTrue:[ |
|
2226 |
any := any or:[const fullName = aGlobalName]. |
|
2227 |
] ifFalse:[ |
|
2228 |
const isJavaClassRef ifTrue:[ |
|
2229 |
any := any or:[const fullName = aGlobalName]. |
|
2230 |
] |
|
2231 |
]. |
|
2232 |
]. |
|
2233 |
]. |
|
2234 |
any ifFalse:[^ false]. |
|
2235 |
||
2236 |
"/ sigh - must extract all accessed literals ... |
|
2237 |
"/ must deparse the byteCode in order to do this. |
|
2238 |
||
2239 |
walker := JavaByteCodeEnumerator new. |
|
2240 |
walker |
|
2241 |
literalAction: |
|
2242 |
[:pc :slotIndex :const | |
|
2243 |
|mSel| |
|
2244 |
||
2245 |
(const isNumber |
|
2246 |
or:[const isString |
|
2247 |
or:[const isNil]]) ifFalse:[ |
|
2248 |
const isJavaClass ifTrue:[ |
|
2249 |
mSel := const fullName. |
|
2250 |
] ifFalse:[ |
|
2251 |
const isJavaClassRef ifTrue:[ |
|
2252 |
mSel := const fullName. |
|
2253 |
] |
|
2254 |
]. |
|
2255 |
]. |
|
2256 |
mSel notNil ifTrue:[ |
|
2257 |
"/ Transcript showCR:mSel. |
|
2258 |
mSel = aGlobalName ifTrue:[ |
|
2259 |
^ true |
|
2260 |
] |
|
2261 |
]. |
|
2262 |
]. |
|
2263 |
walker decompile:self to:nil. |
|
2264 |
||
2265 |
"Created: / 9.11.1999 / 17:15:46 / cg" |
|
2266 |
"Modified: / 9.11.1999 / 17:18:02 / cg" |
|
2267 |
! |
|
2268 |
||
618 | 2269 |
sends:aSelectorSymbol |
2270 |
"return true, if this method contains a message-send |
|
2271 |
with aSelectorSymbol as selector." |
|
2272 |
||
2273 |
|walker any| |
|
2274 |
||
2275 |
"/ quick check, if constantPool includes a methodRef for this |
|
2276 |
"/ selector. |
|
2277 |
||
2278 |
any := false. |
|
2279 |
self javaClass constantPool do:[:const | |
|
2280 |
(const isNumber |
|
2281 |
or:[const isString |
|
2282 |
or:[const isNil]]) ifFalse:[ |
|
2283 |
const isJavaMethod ifTrue:[ |
|
2284 |
any := any or:[const selector = aSelectorSymbol]. |
|
2285 |
] ifFalse:[ |
|
2286 |
const isJavaMethodRef ifTrue:[ |
|
2287 |
any := any or:[const signature = aSelectorSymbol]. |
|
2288 |
] |
|
2289 |
]. |
|
2290 |
]. |
|
2291 |
]. |
|
2292 |
any ifFalse:[^ false]. |
|
2293 |
||
625 | 2294 |
"/ sigh - must extract all accessed literals ... |
2295 |
"/ must deparse the byteCode in order to do this. |
|
2296 |
||
618 | 2297 |
walker := JavaByteCodeEnumerator new. |
2298 |
walker |
|
2299 |
literalAction: |
|
2300 |
[:pc :slotIndex :const | |
|
2301 |
|mSel| |
|
2302 |
||
2303 |
(const isNumber |
|
2304 |
or:[const isString |
|
2305 |
or:[const isNil]]) ifFalse:[ |
|
2306 |
const isJavaMethod ifTrue:[ |
|
2307 |
mSel := const selector. |
|
2308 |
] ifFalse:[ |
|
2309 |
const isJavaMethodRef ifTrue:[ |
|
2310 |
mSel := const signature. |
|
2311 |
] |
|
2312 |
]. |
|
2313 |
]. |
|
2314 |
mSel notNil ifTrue:[ |
|
2315 |
"/ Transcript showCR:mSel. |
|
2316 |
mSel = aSelectorSymbol ifTrue:[ |
|
2317 |
^ true |
|
2318 |
] |
|
2319 |
]. |
|
2320 |
]. |
|
2321 |
walker decompile:self to:nil. |
|
2322 |
||
2323 |
"Created: / 9.11.1999 / 15:38:14 / cg" |
|
625 | 2324 |
"Modified: / 9.11.1999 / 17:06:03 / cg" |
618 | 2325 |
! |
2326 |
||
2151 | 2327 |
shouldBeSkippedInDebuggersWalkBack |
2328 |
||
2329 |
^false |
|
2330 |
||
2331 |
"Created: / 30-11-2010 / 15:35:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2332 |
! |
|
2333 |
||
18 | 2334 |
who |
2335 |
"return the class and selector of where I am defined in." |
|
2336 |
||
64 | 2337 |
|sel| |
18 | 2338 |
|
252 | 2339 |
javaClass isNil ifTrue:[^ nil]. |
378 | 2340 |
sel := selector. |
2341 |
"/ sel := javaClass methodDictionary keyAtValue:self ifAbsent:nil. |
|
64 | 2342 |
sel isNil ifTrue:[^ nil]. |
129 | 2343 |
^ Method::MethodWhoInfo class:javaClass selector:sel. |
378 | 2344 |
|
2345 |
"Modified: / 16.10.1998 / 13:42:10 / cg" |
|
5 | 2346 |
! ! |
2347 |
||
154 | 2348 |
!JavaMethod methodsFor:'signature parsing'! |
2349 |
||
255 | 2350 |
XXXspecWithArgsFromSignature:aSignature withName:name in:aPackage |
154 | 2351 |
"given a signature, return a spec with args" |
2352 |
||
2353 |
|s argSpec retvalSpec| |
|
2354 |
||
2355 |
s := aSignature readStream. |
|
2356 |
s next ~~ $( ifTrue:[self halt. ^ name]. |
|
2357 |
||
2358 |
argSpec := self argSpecWithArgsFromStream:s in:aPackage. |
|
2359 |
||
2360 |
s next ~~ $) ifTrue:[self halt. ^ name]. |
|
2361 |
||
2362 |
retvalSpec := self retvalSpecFromStream:s in:aPackage. |
|
2363 |
||
2364 |
^ retvalSpec , ' ' , name , ' (' , argSpec , ')' |
|
2365 |
||
2366 |
" |
|
2367 |
JavaMethod specFromSignature:'(LObject;)V' withName:'foo' |
|
2368 |
JavaMethod specFromSignature:'(BB)S' withName:'foo' |
|
2369 |
" |
|
2370 |
||
255 | 2371 |
"Created: / 8.1.1998 / 19:17:58 / cg" |
154 | 2372 |
! ! |
2373 |
||
2151 | 2374 |
!JavaMethod methodsFor:'testing'! |
2375 |
||
2376 |
isSynthetic |
|
2160 | 2377 |
"a syntheric method does not really exist - it is only shown in a browser's list" |
2378 |
||
2379 |
^ false |
|
2151 | 2380 |
|
2381 |
"Created: / 18-10-2010 / 19:09:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2160 | 2382 |
"Modified (comment): / 07-09-2011 / 09:00:47 / cg" |
2151 | 2383 |
! ! |
2384 |
||
129 | 2385 |
!JavaMethod class methodsFor:'documentation'! |
2 | 2386 |
|
2387 |
version |
|
2160 | 2388 |
^ '$Header: /cvs/stx/stx/libjava/JavaMethod.st,v 1.109 2011-09-07 07:05:55 cg Exp $' |
2145 | 2389 |
! |
2390 |
||
2391 |
version_CVS |
|
2160 | 2392 |
^ '$Header: /cvs/stx/stx/libjava/JavaMethod.st,v 1.109 2011-09-07 07:05:55 cg Exp $' |
2151 | 2393 |
! |
2394 |
||
2395 |
version_SVN |
|
2158
cf16fc148fb8
added: #originalMethodIfWrapped
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
2396 |
^ '§Id: JavaMethod.st,v 1.107 2011/08/18 18:42:48 vrany Exp §' |
2 | 2397 |
! ! |
2107 | 2398 |
|
2086 | 2399 |
JavaMethod initialize! |