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