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