2
|
1 |
CompiledCode subclass:#JavaMethod
|
184
|
2 |
instanceVariableNames:'numArgs numLocals returnType accessFlags name signature
|
|
3 |
exceptionHandlerTable exceptionTable lineNumberTable
|
148
|
4 |
localVariableTable javaClass numStack isNOOPMethod'
|
169
|
5 |
classVariableNames:'SignatureTypeCodes ForceByteCodeDisplay'
|
2
|
6 |
poolDictionaries:''
|
|
7 |
category:'Java-Classes'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
129
|
11 |
!JavaMethod class methodsFor:'initialization'!
|
8
|
12 |
|
|
13 |
initialize
|
173
|
14 |
self flags:(self flags bitOr:Behavior flagJavaMethod).
|
|
15 |
|
8
|
16 |
SignatureTypeCodes := IdentityDictionary new.
|
|
17 |
SignatureTypeCodes at:$B put:#byte.
|
|
18 |
SignatureTypeCodes at:$C put:#char.
|
|
19 |
SignatureTypeCodes at:$D put:#double.
|
|
20 |
SignatureTypeCodes at:$F put:#float.
|
|
21 |
SignatureTypeCodes at:$I put:#int.
|
|
22 |
SignatureTypeCodes at:$J put:#long.
|
|
23 |
SignatureTypeCodes at:$S put:#'unsigned short'.
|
|
24 |
SignatureTypeCodes at:$Z put:#boolean.
|
|
25 |
SignatureTypeCodes at:$L put:#object.
|
|
26 |
SignatureTypeCodes at:$[ put:#array.
|
|
27 |
|
|
28 |
"
|
|
29 |
JavaMethod initialize
|
|
30 |
"
|
173
|
31 |
|
|
32 |
"Modified: 30.7.1997 / 11:42:25 / cg"
|
8
|
33 |
! !
|
|
34 |
|
169
|
35 |
!JavaMethod class methodsFor:'misc'!
|
|
36 |
|
|
37 |
forceByteCodeDisplay
|
|
38 |
^ ForceByteCodeDisplay
|
|
39 |
|
|
40 |
"Created: 7.4.1997 / 20:11:39 / cg"
|
|
41 |
! !
|
|
42 |
|
129
|
43 |
!JavaMethod class methodsFor:'signature parsing'!
|
5
|
44 |
|
29
|
45 |
argSigArrayFromSignature:aSignature
|
|
46 |
"given a signature, return a specArray for the arguments"
|
|
47 |
|
|
48 |
|s argSpec retvalSpec|
|
|
49 |
|
|
50 |
s := aSignature readStream.
|
|
51 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
52 |
|
|
53 |
^ self argSigArrayFromStream:s.
|
|
54 |
|
|
55 |
"
|
|
56 |
JavaMethod argSigArrayFromSignature:'(LObject;)V'
|
|
57 |
JavaMethod argSigArrayFromSignature:'(BB)S'
|
|
58 |
JavaMethod argSigArrayFromSignature:'(LObject;LObject;II)V'
|
|
59 |
"
|
|
60 |
!
|
|
61 |
|
|
62 |
argSigArrayFromStream:s
|
|
63 |
"parse an argSpec, return an array of specs - see java doc"
|
|
64 |
|
|
65 |
|argSpec spec|
|
|
66 |
|
|
67 |
spec := #().
|
|
68 |
[s atEnd or:[s peek == $)]] whileFalse:[
|
|
69 |
"/ s peek == Character space ifTrue:[
|
|
70 |
"/ s next
|
|
71 |
"/ ] ifFalse:[
|
|
72 |
argSpec := self fieldTypeFromStream:s.
|
|
73 |
spec := spec copyWith:argSpec.
|
|
74 |
"/ ]
|
|
75 |
].
|
|
76 |
^ spec
|
|
77 |
|
|
78 |
|
|
79 |
!
|
|
80 |
|
113
|
81 |
argSpecFromSignature:aSignature withName:name
|
|
82 |
"given a signature, return a spec"
|
|
83 |
|
|
84 |
|s argSpec retvalSpec|
|
|
85 |
|
|
86 |
s := aSignature readStream.
|
|
87 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
88 |
|
|
89 |
argSpec := self argSpecFromStream:s.
|
|
90 |
|
|
91 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
92 |
|
|
93 |
^ name , ' (' , argSpec , ')'
|
|
94 |
|
|
95 |
"
|
|
96 |
JavaMethod argSpecFromSignature:'(LObject;)V' withName:'foo'
|
|
97 |
JavaMethod argSpecFromSignature:'(BB)S' withName:'foo'
|
|
98 |
"
|
|
99 |
!
|
|
100 |
|
8
|
101 |
argSpecFromStream:s
|
|
102 |
"parse an argSpec - see java doc"
|
|
103 |
|
|
104 |
|argSpec spec|
|
|
105 |
|
|
106 |
spec := ''.
|
|
107 |
[s atEnd or:[s peek == $)]] whileFalse:[
|
27
|
108 |
"/ s peek == Character space ifTrue:[
|
|
109 |
"/ s next
|
|
110 |
"/ ] ifFalse:[
|
|
111 |
argSpec := self fieldTypeFromStream:s.
|
|
112 |
spec size ~~ 0 ifTrue:[
|
|
113 |
spec := spec , ' '
|
|
114 |
].
|
|
115 |
spec := spec , argSpec.
|
|
116 |
"/ ]
|
8
|
117 |
].
|
|
118 |
^ spec
|
|
119 |
|
5
|
120 |
|
|
121 |
!
|
|
122 |
|
142
|
123 |
argSpecFromStream:s in:aPackage
|
|
124 |
"parse an argSpec - see java doc"
|
|
125 |
|
|
126 |
|argSpec spec|
|
|
127 |
|
|
128 |
spec := ''.
|
|
129 |
[s atEnd or:[s peek == $)]] whileFalse:[
|
|
130 |
"/ s peek == Character space ifTrue:[
|
|
131 |
"/ s next
|
|
132 |
"/ ] ifFalse:[
|
|
133 |
argSpec := self fieldTypeFromStream:s in:aPackage.
|
|
134 |
spec size ~~ 0 ifTrue:[
|
|
135 |
spec := spec , ' '
|
|
136 |
].
|
|
137 |
spec := spec , argSpec.
|
|
138 |
"/ ]
|
|
139 |
].
|
|
140 |
^ spec
|
|
141 |
|
|
142 |
"Created: 18.3.1997 / 11:06:44 / cg"
|
|
143 |
!
|
|
144 |
|
154
|
145 |
argSpecWithArgsFromStream:s in:aPackage
|
|
146 |
"parse an argSpec - see java doc"
|
|
147 |
|
|
148 |
|argSpec spec argNr|
|
|
149 |
|
|
150 |
argNr := 1.
|
|
151 |
spec := ''.
|
|
152 |
[s atEnd or:[s peek == $)]] whileFalse:[
|
|
153 |
argSpec := self fieldTypeFromStream:s in:aPackage.
|
|
154 |
spec size ~~ 0 ifTrue:[
|
|
155 |
spec := spec , ', '
|
|
156 |
].
|
|
157 |
spec := spec , argSpec.
|
|
158 |
spec := spec , ' arg' , argNr printString.
|
|
159 |
argNr := argNr + 1.
|
|
160 |
].
|
|
161 |
^ spec
|
|
162 |
|
|
163 |
"Created: 20.3.1997 / 12:45:40 / cg"
|
|
164 |
"Modified: 20.3.1997 / 12:49:52 / cg"
|
|
165 |
!
|
|
166 |
|
8
|
167 |
fieldTypeFromStream:s
|
|
168 |
"parse a fieldTypeSpec - see java doc"
|
|
169 |
|
10
|
170 |
|typeChar typeSym spec elType size className|
|
8
|
171 |
|
|
172 |
typeChar := s next.
|
|
173 |
|
|
174 |
typeSym := SignatureTypeCodes at:typeChar ifAbsent:#unknown.
|
|
175 |
|
|
176 |
typeSym == #unknown ifTrue:[
|
|
177 |
^ typeSym
|
|
178 |
].
|
|
179 |
typeSym == #object ifTrue:[
|
10
|
180 |
className := s upTo:$;.
|
|
181 |
"/ strip off default
|
113
|
182 |
"/ (className startsWith:'java/lang/') ifTrue:[
|
|
183 |
"/ ^ className copyFrom:11
|
|
184 |
"/ ].
|
|
185 |
^ className copy replaceAll:$/ by:$.
|
8
|
186 |
].
|
|
187 |
typeSym == #array ifTrue:[
|
|
188 |
s peek isDigit ifTrue:[
|
|
189 |
size := Integer readFrom:s.
|
|
190 |
elType := self fieldTypeFromStream:s.
|
|
191 |
^ elType , '[' , size printString , ']'
|
|
192 |
].
|
|
193 |
elType := self fieldTypeFromStream:s.
|
|
194 |
^ elType , '[]'
|
|
195 |
].
|
|
196 |
^ typeSym
|
|
197 |
!
|
|
198 |
|
142
|
199 |
fieldTypeFromStream:s in:aPackage
|
|
200 |
"parse a fieldTypeSpec - see java doc"
|
|
201 |
|
|
202 |
|typeChar typeSym spec elType size className nm|
|
|
203 |
|
|
204 |
typeChar := s next.
|
|
205 |
|
|
206 |
typeSym := SignatureTypeCodes at:typeChar ifAbsent:#unknown.
|
|
207 |
|
|
208 |
typeSym == #unknown ifTrue:[
|
|
209 |
^ typeSym
|
|
210 |
].
|
|
211 |
typeSym == #object ifTrue:[
|
|
212 |
className := s upTo:$;.
|
|
213 |
"/ strip off default
|
|
214 |
|
|
215 |
"/ (className startsWith:'java/lang/') ifTrue:[
|
|
216 |
"/ ^ className copyFrom:11
|
|
217 |
"/ ].
|
|
218 |
|
|
219 |
nm := className.
|
|
220 |
aPackage notNil ifTrue:[
|
|
221 |
(nm startsWith:aPackage) ifTrue:[
|
|
222 |
nm := nm copyFrom:(aPackage size + 2).
|
|
223 |
].
|
|
224 |
].
|
|
225 |
|
|
226 |
nm := nm copy replaceAll:$/ by:$..
|
|
227 |
^ nm
|
|
228 |
].
|
|
229 |
typeSym == #array ifTrue:[
|
|
230 |
s peek isDigit ifTrue:[
|
|
231 |
size := Integer readFrom:s.
|
|
232 |
elType := self fieldTypeFromStream:s.
|
|
233 |
^ elType , '[' , size printString , ']'
|
|
234 |
].
|
|
235 |
elType := self fieldTypeFromStream:s.
|
|
236 |
^ elType , '[]'
|
|
237 |
].
|
|
238 |
^ typeSym
|
|
239 |
|
|
240 |
"Created: 18.3.1997 / 11:07:56 / cg"
|
|
241 |
"Modified: 18.3.1997 / 11:18:09 / cg"
|
|
242 |
!
|
|
243 |
|
27
|
244 |
numArgsFromSignature:aSignature
|
|
245 |
"given a signature, return the number of args"
|
|
246 |
|
|
247 |
|s argSpec|
|
|
248 |
|
|
249 |
s := aSignature readStream.
|
|
250 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
251 |
|
|
252 |
^ self numArgsFromStream:s.
|
|
253 |
|
|
254 |
"
|
|
255 |
JavaMethod numArgsFromSignature:'(LObject;)V'
|
|
256 |
JavaMethod numArgsFromSignature:'(BB)S'
|
|
257 |
JavaMethod numArgsFromSignature:'()V'
|
|
258 |
"
|
|
259 |
!
|
|
260 |
|
|
261 |
numArgsFromStream:s
|
|
262 |
"parse an argSpec - see java doc"
|
|
263 |
|
55
|
264 |
|argSpec n t|
|
27
|
265 |
|
|
266 |
n := 0.
|
|
267 |
[s atEnd or:[s peek == $)]] whileFalse:[
|
55
|
268 |
t := self fieldTypeFromStream:s.
|
|
269 |
"/
|
|
270 |
"/ some args count as 2
|
|
271 |
"/
|
|
272 |
t == #long ifTrue:[
|
|
273 |
n := n + 2.
|
|
274 |
] ifFalse:[
|
|
275 |
t == #double ifTrue:[
|
|
276 |
n := n + 2
|
|
277 |
] ifFalse:[
|
|
278 |
n := n + 1.
|
|
279 |
]
|
|
280 |
]
|
27
|
281 |
].
|
|
282 |
^ n
|
|
283 |
!
|
|
284 |
|
29
|
285 |
retValSpecFromSignature:aSignature
|
|
286 |
"given a signature, return a spec"
|
|
287 |
|
|
288 |
|s argSpec retvalSpec|
|
|
289 |
|
|
290 |
s := aSignature readStream.
|
|
291 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
292 |
|
|
293 |
argSpec := self argSpecFromStream:s.
|
|
294 |
|
|
295 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
296 |
|
|
297 |
retvalSpec := self retvalSpecFromStream:s.
|
|
298 |
|
|
299 |
^ retvalSpec
|
|
300 |
|
|
301 |
"
|
|
302 |
JavaMethod retValSpecFromSignature:'(LObject;)V'
|
|
303 |
JavaMethod retValSpecFromSignature:'(BB)S'
|
|
304 |
"
|
|
305 |
!
|
|
306 |
|
142
|
307 |
retValSpecFromSignature:aSignature in:aPackage
|
|
308 |
"given a signature, return a spec"
|
|
309 |
|
|
310 |
|s argSpec retvalSpec|
|
|
311 |
|
|
312 |
s := aSignature readStream.
|
|
313 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
314 |
|
|
315 |
argSpec := self argSpecFromStream:s in:aPackage.
|
|
316 |
|
|
317 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
318 |
|
|
319 |
retvalSpec := self retvalSpecFromStream:s in:aPackage.
|
|
320 |
|
|
321 |
^ retvalSpec
|
|
322 |
|
|
323 |
"
|
|
324 |
JavaMethod retValSpecFromSignature:'(LObject;)V'
|
|
325 |
JavaMethod retValSpecFromSignature:'(BB)S'
|
|
326 |
"
|
|
327 |
|
|
328 |
"Created: 18.3.1997 / 11:11:50 / cg"
|
|
329 |
!
|
|
330 |
|
72
|
331 |
returnTypeFromSignature:aSignature
|
|
332 |
"given a signature, return its type as a string"
|
27
|
333 |
|
80
|
334 |
|s c argSpec retvalSpec|
|
27
|
335 |
|
|
336 |
s := aSignature readStream.
|
80
|
337 |
(c := s peek) ~~ $( ifTrue:[
|
|
338 |
c == $' ifTrue:[
|
|
339 |
[s peek ~= $'] whileTrue:[s next].
|
|
340 |
s next.
|
|
341 |
^ (self retvalSpecFromStream:s)
|
|
342 |
].
|
|
343 |
^ (self retvalSpecFromStream:s)
|
|
344 |
].
|
27
|
345 |
|
80
|
346 |
s next.
|
27
|
347 |
self argSpecFromStream:s.
|
80
|
348 |
s next ~~ $) ifTrue:[self halt. ^ nil].
|
27
|
349 |
|
72
|
350 |
^ (self retvalSpecFromStream:s)
|
|
351 |
|
|
352 |
"
|
|
353 |
JavaMethod returnTypeFromSignature:'(LObject;)V'
|
|
354 |
JavaMethod returnTypeFromSignature:'(BB)S'
|
|
355 |
JavaMethod returnTypeFromSignature:'()J'
|
80
|
356 |
JavaMethod returnTypeFromSignature:'''first''J'
|
72
|
357 |
"
|
|
358 |
!
|
|
359 |
|
|
360 |
returnsVoidFromSignature:aSignature
|
|
361 |
"given a signature, return true if it returns void, false if not"
|
|
362 |
|
83
|
363 |
^ (self typeFromSignature:aSignature) = 'void'
|
27
|
364 |
|
|
365 |
"
|
|
366 |
JavaMethod returnsVoidFromSignature:'(LObject;)V'
|
|
367 |
JavaMethod returnsVoidFromSignature:'(BB)S'
|
|
368 |
"
|
|
369 |
!
|
|
370 |
|
8
|
371 |
retvalSpecFromStream:s
|
|
372 |
"parse a retvalSpec - see java doc"
|
|
373 |
|
|
374 |
|argSpec spec|
|
|
375 |
|
72
|
376 |
s atEnd ifTrue:[self halt. ^ #void].
|
|
377 |
s peek == $V ifTrue:[^ #void].
|
8
|
378 |
^ self fieldTypeFromStream:s
|
10
|
379 |
|
|
380 |
!
|
|
381 |
|
142
|
382 |
retvalSpecFromStream:s in:aPackage
|
|
383 |
"parse a retvalSpec - see java doc"
|
|
384 |
|
|
385 |
|argSpec spec|
|
|
386 |
|
|
387 |
s atEnd ifTrue:[self halt. ^ #void].
|
|
388 |
s peek == $V ifTrue:[^ #void].
|
|
389 |
^ self fieldTypeFromStream:s in:aPackage
|
|
390 |
|
|
391 |
"Created: 18.3.1997 / 11:12:19 / cg"
|
|
392 |
!
|
|
393 |
|
10
|
394 |
specFromSignature:aSignature withName:name
|
|
395 |
"given a signature, return a spec"
|
|
396 |
|
|
397 |
|s argSpec retvalSpec|
|
|
398 |
|
|
399 |
s := aSignature readStream.
|
|
400 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
401 |
|
|
402 |
argSpec := self argSpecFromStream:s.
|
|
403 |
|
|
404 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
405 |
|
|
406 |
retvalSpec := self retvalSpecFromStream:s.
|
|
407 |
|
|
408 |
^ retvalSpec , ' ' , name , ' (' , argSpec , ')'
|
|
409 |
|
|
410 |
"
|
|
411 |
JavaMethod specFromSignature:'(LObject;)V' withName:'foo'
|
27
|
412 |
JavaMethod specFromSignature:'(BB)S' withName:'foo'
|
10
|
413 |
"
|
83
|
414 |
!
|
|
415 |
|
142
|
416 |
specFromSignature:aSignature withName:name in:aPackage
|
|
417 |
"given a signature, return a spec"
|
|
418 |
|
|
419 |
|s argSpec retvalSpec|
|
|
420 |
|
|
421 |
s := aSignature readStream.
|
|
422 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
423 |
|
|
424 |
argSpec := self argSpecFromStream:s in:aPackage.
|
|
425 |
|
|
426 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
427 |
|
|
428 |
retvalSpec := self retvalSpecFromStream:s in:aPackage.
|
|
429 |
|
|
430 |
^ retvalSpec , ' ' , name , ' (' , argSpec , ')'
|
|
431 |
|
|
432 |
"
|
|
433 |
JavaMethod specFromSignature:'(LObject;)V' withName:'foo'
|
|
434 |
JavaMethod specFromSignature:'(BB)S' withName:'foo'
|
|
435 |
"
|
|
436 |
|
|
437 |
"Created: 18.3.1997 / 11:06:22 / cg"
|
|
438 |
!
|
|
439 |
|
175
|
440 |
specTextFromSignature:aSignature withName:name
|
|
441 |
"given a signature, return a spec as boldified text"
|
|
442 |
|
|
443 |
|s argSpec retvalSpec|
|
|
444 |
|
|
445 |
s := aSignature readStream.
|
|
446 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
447 |
|
|
448 |
argSpec := self argSpecFromStream:s.
|
|
449 |
|
|
450 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
451 |
|
|
452 |
retvalSpec := self retvalSpecFromStream:s.
|
|
453 |
|
|
454 |
^ retvalSpec , ' ' , (name asText allBold) , ' (' , argSpec , ')'
|
|
455 |
|
|
456 |
"
|
|
457 |
JavaMethod specTextFromSignature:'(LObject;)V' withName:'foo'
|
|
458 |
JavaMethod specTextFromSignature:'(BB)S' withName:'foo'
|
|
459 |
"
|
|
460 |
|
|
461 |
"Modified: 30.7.1997 / 14:40:12 / cg"
|
|
462 |
!
|
|
463 |
|
154
|
464 |
specWithArgsFromSignature:aSignature withName:name in:aPackage
|
|
465 |
"given a signature, return a spec"
|
|
466 |
|
|
467 |
|s argSpec retvalSpec|
|
|
468 |
|
|
469 |
s := aSignature readStream.
|
|
470 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
471 |
|
|
472 |
argSpec := self argSpecWithArgsFromStream:s in:aPackage.
|
|
473 |
|
|
474 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
475 |
|
|
476 |
retvalSpec := self retvalSpecFromStream:s in:aPackage.
|
|
477 |
|
|
478 |
^ retvalSpec , ' ' , name , ' (' , argSpec , ')'
|
|
479 |
|
|
480 |
"
|
|
481 |
JavaMethod specWithArgsFromSignature:'(LObject;)V' withName:'foo' in:nil
|
|
482 |
JavaMethod specWithArgsFromSignature:'(BB)S' withName:'foo' in:nil
|
|
483 |
"
|
|
484 |
|
|
485 |
"Created: 18.3.1997 / 11:06:22 / cg"
|
|
486 |
"Modified: 20.3.1997 / 12:50:10 / cg"
|
|
487 |
!
|
|
488 |
|
83
|
489 |
typeFromSignature:aSignature
|
|
490 |
"given a signature, return its type as a string"
|
|
491 |
|
|
492 |
|s c argSpec retvalSpec|
|
|
493 |
|
|
494 |
s := aSignature readStream.
|
|
495 |
(c := s peek) ~~ $( ifTrue:[
|
|
496 |
c == $' ifTrue:[
|
|
497 |
s next.
|
|
498 |
[s peek ~= $'] whileTrue:[s next].
|
|
499 |
s next.
|
|
500 |
^ (self retvalSpecFromStream:s)
|
|
501 |
].
|
|
502 |
^ (self retvalSpecFromStream:s)
|
|
503 |
].
|
|
504 |
|
|
505 |
s next.
|
|
506 |
self argSpecFromStream:s.
|
|
507 |
s next ~~ $) ifTrue:[self halt. ^ nil].
|
|
508 |
|
|
509 |
^ (self retvalSpecFromStream:s)
|
|
510 |
|
|
511 |
"
|
|
512 |
JavaMethod typeFromSignature:'(LObject;)V'
|
|
513 |
JavaMethod typeFromSignature:'(BB)S'
|
|
514 |
JavaMethod typeFromSignature:'()J'
|
|
515 |
JavaMethod typeFromSignature:'J'
|
|
516 |
JavaMethod typeFromSignature:'''first''J'
|
|
517 |
"
|
10
|
518 |
! !
|
|
519 |
|
|
520 |
!JavaMethod methodsFor:'accessing'!
|
|
521 |
|
29
|
522 |
argSignature
|
|
523 |
^ self class argSigArrayFromSignature:signature
|
|
524 |
!
|
|
525 |
|
10
|
526 |
constantPool
|
|
527 |
^ javaClass constantPool
|
|
528 |
|
|
529 |
"Modified: 16.4.1996 / 12:36:27 / cg"
|
|
530 |
"Created: 16.4.1996 / 15:28:50 / cg"
|
|
531 |
!
|
|
532 |
|
129
|
533 |
containingClass
|
|
534 |
^ javaClass
|
|
535 |
|
|
536 |
!
|
|
537 |
|
169
|
538 |
decompiledBytecode
|
|
539 |
|s|
|
|
540 |
|
|
541 |
s := '' writeStream.
|
|
542 |
JavaDecompiler decompile:self to:s.
|
|
543 |
^ s contents
|
|
544 |
|
|
545 |
"Created: 7.4.1997 / 20:10:37 / cg"
|
|
546 |
!
|
|
547 |
|
75
|
548 |
decompiledSource
|
|
549 |
|s|
|
|
550 |
|
|
551 |
s := '' writeStream.
|
175
|
552 |
self decompileSourceTo:s.
|
75
|
553 |
^ s contents
|
175
|
554 |
|
|
555 |
"Modified: 30.7.1997 / 16:27:55 / cg"
|
75
|
556 |
!
|
|
557 |
|
135
|
558 |
exceptionHandlerTable
|
|
559 |
^ exceptionHandlerTable
|
|
560 |
|
|
561 |
"Modified: 16.4.1996 / 12:49:06 / cg"
|
|
562 |
"Created: 7.2.1997 / 20:04:20 / cg"
|
|
563 |
!
|
|
564 |
|
83
|
565 |
exceptionTable
|
|
566 |
^ exceptionTable
|
|
567 |
|
|
568 |
"Created: 16.4.1996 / 12:34:04 / cg"
|
|
569 |
"Modified: 16.4.1996 / 12:49:06 / cg"
|
|
570 |
!
|
|
571 |
|
90
|
572 |
hasLineNumberInformation
|
|
573 |
^ lineNumberTable notNil
|
|
574 |
|
|
575 |
"Created: 16.4.1996 / 12:34:04 / cg"
|
|
576 |
"Modified: 16.4.1996 / 12:49:06 / cg"
|
|
577 |
!
|
|
578 |
|
148
|
579 |
isNOOPMethod:aBoolean
|
|
580 |
isNOOPMethod := aBoolean
|
|
581 |
|
|
582 |
"Created: 18.3.1997 / 13:31:16 / cg"
|
|
583 |
!
|
|
584 |
|
10
|
585 |
javaByteCode
|
184
|
586 |
"/ ^ javaByteCode
|
|
587 |
^ byteCode
|
10
|
588 |
|
|
589 |
"Created: 16.4.1996 / 14:55:44 / cg"
|
184
|
590 |
"Modified: 1.8.1997 / 00:08:45 / cg"
|
8
|
591 |
!
|
|
592 |
|
27
|
593 |
javaClass
|
|
594 |
^ javaClass
|
|
595 |
|
|
596 |
"Modified: 16.4.1996 / 12:36:27 / cg"
|
|
597 |
"Created: 16.4.1996 / 14:55:44 / cg"
|
|
598 |
!
|
|
599 |
|
90
|
600 |
lineNumber
|
|
601 |
^ lineNumberTable at:2
|
|
602 |
|
|
603 |
"Created: 16.4.1996 / 12:34:04 / cg"
|
|
604 |
"Modified: 16.4.1996 / 12:49:06 / cg"
|
|
605 |
!
|
|
606 |
|
50
|
607 |
lineNumberTable
|
|
608 |
^ lineNumberTable
|
|
609 |
|
|
610 |
"Created: 16.4.1996 / 12:34:04 / cg"
|
|
611 |
"Modified: 16.4.1996 / 12:49:06 / cg"
|
|
612 |
!
|
|
613 |
|
85
|
614 |
localVariableTable
|
|
615 |
^ localVariableTable
|
|
616 |
|
|
617 |
"
|
|
618 |
JavaMethod allInstancesDo:[:m| m localVariableTable notNil ifTrue:[self halt]]
|
|
619 |
"
|
|
620 |
!
|
|
621 |
|
31
|
622 |
methodArgAndVarNames
|
|
623 |
^ ((1 to:self numArgs) collect:[:i | 'arg' , i printString])
|
|
624 |
,
|
|
625 |
((1 to:self numVars) collect:[:i | 'local' , i printString])
|
|
626 |
|
|
627 |
!
|
|
628 |
|
|
629 |
methodArgNames
|
102
|
630 |
localVariableTable notNil ifTrue:[
|
|
631 |
^ (1 to:self numArgs) collect:
|
|
632 |
[:argIndex | |slot name|
|
|
633 |
"/ search for an entry with that index (slot),
|
|
634 |
"/ which has is valid at PC 0
|
|
635 |
|
|
636 |
self isStatic ifTrue:[
|
|
637 |
slot := argIndex
|
|
638 |
] ifFalse:[
|
|
639 |
slot := argIndex + 1
|
|
640 |
].
|
|
641 |
name := localVariableTable nameForSlot:slot atPC:0.
|
|
642 |
name isNil ifTrue:[
|
|
643 |
'arg' , argIndex printString
|
|
644 |
] ifFalse:[
|
|
645 |
name
|
|
646 |
].
|
|
647 |
]
|
|
648 |
].
|
31
|
649 |
^ (1 to:self numArgs) collect:[:i | 'arg' , i printString]
|
|
650 |
!
|
|
651 |
|
29
|
652 |
name
|
|
653 |
^ name
|
|
654 |
|
|
655 |
"Created: 16.4.1996 / 11:34:22 / cg"
|
|
656 |
!
|
|
657 |
|
27
|
658 |
numArgs
|
29
|
659 |
numArgs isNil ifTrue:[^ 0].
|
27
|
660 |
^ numArgs
|
|
661 |
!
|
|
662 |
|
118
|
663 |
numLocals
|
|
664 |
numLocals isNil ifTrue:[^ 0].
|
|
665 |
^ numLocals
|
|
666 |
!
|
|
667 |
|
|
668 |
numStack
|
|
669 |
numStack isNil ifTrue:[^ 0].
|
|
670 |
^ numStack
|
|
671 |
!
|
|
672 |
|
29
|
673 |
numVars
|
|
674 |
numLocals isNil ifTrue:[^ 0].
|
118
|
675 |
numArgs isNil ifTrue:[^ numLocals].
|
|
676 |
^ numLocals - numArgs
|
29
|
677 |
!
|
|
678 |
|
184
|
679 |
numberOfArgs:n
|
174
|
680 |
super numberOfArgs:n.
|
27
|
681 |
numArgs := n
|
174
|
682 |
|
|
683 |
"Modified: 30.7.1997 / 12:43:00 / cg"
|
184
|
684 |
"Created: 1.8.1997 / 00:26:24 / cg"
|
27
|
685 |
!
|
|
686 |
|
175
|
687 |
previousVersion
|
|
688 |
^ nil
|
|
689 |
|
|
690 |
"Created: 30.7.1997 / 15:56:18 / cg"
|
|
691 |
!
|
|
692 |
|
29
|
693 |
retValSignature
|
|
694 |
^ self class retValSpecFromSignature:signature
|
|
695 |
|
|
696 |
!
|
|
697 |
|
123
|
698 |
returnType
|
|
699 |
^ returnType
|
|
700 |
!
|
|
701 |
|
116
|
702 |
returnsDouble
|
|
703 |
^ returnType == #double
|
|
704 |
!
|
|
705 |
|
72
|
706 |
returnsLong
|
|
707 |
^ returnType == #long
|
|
708 |
!
|
|
709 |
|
27
|
710 |
returnsVoid
|
72
|
711 |
^ returnType == #void
|
27
|
712 |
!
|
|
713 |
|
5
|
714 |
setAccessFlags:flags
|
|
715 |
accessFlags := flags.
|
|
716 |
|
|
717 |
"Created: 16.4.1996 / 11:34:14 / cg"
|
|
718 |
!
|
|
719 |
|
29
|
720 |
setCode:codeBytes maxStack:max_stack maxLocals:max_locals u1:unknown1 u2:unknown2
|
184
|
721 |
"/ javaByteCode := codeBytes.
|
|
722 |
byteCode := codeBytes.
|
29
|
723 |
numStack := max_stack.
|
|
724 |
numLocals := max_locals.
|
5
|
725 |
|
43
|
726 |
"/ self displayString printNL.
|
|
727 |
"/ ' nStack: ' print. numStack print.
|
|
728 |
"/ ' nLocal: ' print. numLocals print.
|
|
729 |
"/ ' u1: ' print. unknown1 print.
|
|
730 |
"/ ' u2: ' print. unknown2 printNL.
|
29
|
731 |
|
184
|
732 |
"Modified: 1.8.1997 / 00:08:32 / cg"
|
5
|
733 |
!
|
|
734 |
|
83
|
735 |
setExceptionHandlerTable:anArray
|
|
736 |
exceptionHandlerTable := anArray.
|
|
737 |
|
|
738 |
"Created: 16.4.1996 / 12:34:04 / cg"
|
|
739 |
!
|
|
740 |
|
5
|
741 |
setExceptionTable:anArray
|
|
742 |
exceptionTable := anArray.
|
|
743 |
|
|
744 |
"Created: 16.4.1996 / 12:34:04 / cg"
|
|
745 |
!
|
|
746 |
|
|
747 |
setJavaClass:aJavaClass
|
|
748 |
javaClass := aJavaClass
|
|
749 |
|
|
750 |
"Modified: 16.4.1996 / 12:36:27 / cg"
|
|
751 |
"Created: 16.4.1996 / 15:28:15 / cg"
|
|
752 |
!
|
|
753 |
|
90
|
754 |
setLineNumberTable:anArrayOfPCtoLineAssociations
|
|
755 |
"since this uses up lots of memory, compress it"
|
|
756 |
|
|
757 |
|allBytes allWords idx|
|
|
758 |
|
|
759 |
allBytes := allWords := true.
|
|
760 |
|
|
761 |
anArrayOfPCtoLineAssociations do:[:assoc |
|
|
762 |
assoc key > 255 ifTrue:[
|
|
763 |
allBytes := false.
|
|
764 |
assoc key > 16rFFFF ifTrue:[
|
|
765 |
allWords := false.
|
|
766 |
].
|
|
767 |
].
|
|
768 |
assoc value > 255 ifTrue:[
|
|
769 |
allBytes := false.
|
|
770 |
assoc value > 16rFFFF ifTrue:[
|
|
771 |
allWords := false
|
|
772 |
].
|
|
773 |
].
|
|
774 |
].
|
|
775 |
allBytes ifTrue:[
|
|
776 |
lineNumberTable := ByteArray new:(anArrayOfPCtoLineAssociations size * 2).
|
|
777 |
] ifFalse:[
|
|
778 |
allWords ifTrue:[
|
|
779 |
lineNumberTable := WordArray new:(anArrayOfPCtoLineAssociations size * 2).
|
|
780 |
] ifFalse:[
|
|
781 |
lineNumberTable := Array new:(anArrayOfPCtoLineAssociations size * 2).
|
|
782 |
]
|
|
783 |
].
|
|
784 |
|
|
785 |
idx := 1.
|
|
786 |
anArrayOfPCtoLineAssociations do:[:assoc |
|
|
787 |
lineNumberTable at:idx put:assoc key.
|
|
788 |
lineNumberTable at:idx+1 put:assoc value.
|
|
789 |
idx := idx + 2.
|
|
790 |
].
|
5
|
791 |
|
|
792 |
"Created: 16.4.1996 / 12:34:04 / cg"
|
|
793 |
"Modified: 16.4.1996 / 12:49:06 / cg"
|
|
794 |
!
|
|
795 |
|
50
|
796 |
setLocalVariableTable:anArray
|
83
|
797 |
localVariableTable := anArray.
|
50
|
798 |
!
|
|
799 |
|
5
|
800 |
setName:aString
|
29
|
801 |
name := aString asSymbol.
|
5
|
802 |
|
|
803 |
"Created: 16.4.1996 / 11:34:22 / cg"
|
|
804 |
!
|
|
805 |
|
|
806 |
setSignature:aString
|
29
|
807 |
signature := aString asSymbol.
|
|
808 |
|
184
|
809 |
self numberOfArgs:(self class numArgsFromSignature:aString).
|
83
|
810 |
returnType := self class typeFromSignature:aString.
|
27
|
811 |
|
|
812 |
"Created: 16.4.1996 / 11:34:29 / cg"
|
184
|
813 |
"Modified: 1.8.1997 / 00:26:16 / cg"
|
27
|
814 |
!
|
|
815 |
|
|
816 |
signature
|
|
817 |
^ signature
|
5
|
818 |
|
|
819 |
"Created: 16.4.1996 / 11:34:29 / cg"
|
31
|
820 |
!
|
|
821 |
|
|
822 |
source
|
75
|
823 |
|classSource|
|
31
|
824 |
|
169
|
825 |
ForceByteCodeDisplay == true ifTrue:[
|
|
826 |
^ self decompiledBytecode
|
|
827 |
].
|
|
828 |
|
75
|
829 |
lineNumberTable notNil ifTrue:[
|
|
830 |
classSource := javaClass source.
|
|
831 |
classSource notNil ifTrue:[^ classSource].
|
|
832 |
].
|
|
833 |
|
|
834 |
^ self decompiledSource
|
169
|
835 |
|
|
836 |
"Modified: 7.4.1997 / 20:10:57 / cg"
|
31
|
837 |
!
|
|
838 |
|
|
839 |
sourceFilename
|
|
840 |
^ javaClass sourceFile
|
175
|
841 |
!
|
|
842 |
|
|
843 |
sourceLineNumber
|
|
844 |
ForceByteCodeDisplay == true ifTrue:[
|
|
845 |
^ 1
|
|
846 |
].
|
|
847 |
|
|
848 |
lineNumberTable notNil ifTrue:[
|
|
849 |
^ lineNumberTable at:2
|
|
850 |
].
|
|
851 |
|
|
852 |
^ 1
|
|
853 |
|
|
854 |
"Created: 30.7.1997 / 15:40:45 / cg"
|
|
855 |
"Modified: 30.7.1997 / 15:46:12 / cg"
|
8
|
856 |
! !
|
|
857 |
|
18
|
858 |
!JavaMethod methodsFor:'decompiling'!
|
|
859 |
|
175
|
860 |
decompileSourceTo:aStream
|
155
|
861 |
self isNative ifFalse:[
|
|
862 |
self isAbstract ifFalse:[
|
|
863 |
aStream cr; cr.
|
|
864 |
aStream nextPutAll:'decompiled source:'; cr; cr.
|
|
865 |
SignalSet anySignal handle:[:ex |
|
|
866 |
aStream nextPutAll:'error while decompiling:'.
|
|
867 |
aStream cr; cr; spaces:4.
|
|
868 |
aStream nextPutAll:ex errorString.
|
175
|
869 |
|
|
870 |
JavaDecompiler decompile:self to:aStream.
|
155
|
871 |
ex return
|
|
872 |
] do:[
|
|
873 |
aStream nextPutAll:(JavaDeparser decompile:self).
|
|
874 |
].
|
|
875 |
].
|
|
876 |
].
|
18
|
877 |
^ true
|
|
878 |
|
175
|
879 |
"Modified: 30.7.1997 / 16:19:28 / cg"
|
|
880 |
"Created: 30.7.1997 / 16:28:09 / cg"
|
|
881 |
!
|
|
882 |
|
|
883 |
decompiler
|
|
884 |
^ JavaDecompiler
|
|
885 |
|
|
886 |
"Created: 30.7.1997 / 16:36:48 / cg"
|
18
|
887 |
! !
|
|
888 |
|
118
|
889 |
!JavaMethod methodsFor:'methodref interchangability'!
|
|
890 |
|
|
891 |
method
|
|
892 |
^ self
|
|
893 |
! !
|
|
894 |
|
148
|
895 |
!JavaMethod methodsFor:'misc'!
|
|
896 |
|
|
897 |
checkForNOOPMethod
|
184
|
898 |
|code insn1 insn2 insn3 idx ref mthd|
|
149
|
899 |
|
|
900 |
isNOOPMethod notNil ifTrue:[^ self].
|
|
901 |
|
184
|
902 |
code := self javaByteCode.
|
|
903 |
code notNil ifTrue:[
|
|
904 |
insn1 := code at:1.
|
149
|
905 |
insn1 == 177 "RETURN" ifTrue:[
|
|
906 |
'JAVA [info]: dummy static method: ' print. self displayString printCR.
|
148
|
907 |
isNOOPMethod := true.
|
|
908 |
^ self
|
|
909 |
].
|
149
|
910 |
|
|
911 |
insn1 == 42 "ALOAD_0" ifTrue:[
|
184
|
912 |
insn2 := code at:2.
|
149
|
913 |
insn2 == 183 "INVOKENONVIRTUAL" ifTrue:[
|
184
|
914 |
insn3 := code at:5.
|
149
|
915 |
insn3 == 177 "RETURN" ifTrue:[
|
184
|
916 |
idx := code wordAt:3 MSB:true.
|
149
|
917 |
ref := javaClass constantPool at:idx.
|
|
918 |
mthd := ref method.
|
|
919 |
mthd isNOOPMethod ifTrue:[
|
|
920 |
'JAVA [info]: dummy method (calls dummy): ' print. self displayString printCR.
|
|
921 |
isNOOPMethod := true.
|
|
922 |
] ifFalse:[
|
|
923 |
isNOOPMethod := false.
|
|
924 |
].
|
|
925 |
^ self
|
|
926 |
]
|
|
927 |
].
|
|
928 |
].
|
148
|
929 |
].
|
149
|
930 |
isNOOPMethod := false.
|
148
|
931 |
^ self
|
|
932 |
|
|
933 |
"Created: 18.3.1997 / 13:31:50 / cg"
|
184
|
934 |
"Modified: 1.8.1997 / 00:09:42 / cg"
|
148
|
935 |
! !
|
|
936 |
|
8
|
937 |
!JavaMethod methodsFor:'printing & storing'!
|
|
938 |
|
29
|
939 |
displayString
|
168
|
940 |
javaClass isNil ifTrue:[
|
|
941 |
^ 'JavaMethod(???)'
|
|
942 |
].
|
29
|
943 |
^ 'JavaMethod(' , javaClass name , '::' , self signatureName , ')'
|
168
|
944 |
|
|
945 |
"Modified: 7.4.1997 / 15:54:10 / cg"
|
29
|
946 |
!
|
|
947 |
|
8
|
948 |
printStringForBrowserWithSelector:selector
|
43
|
949 |
"/ self isStatic ifTrue:[
|
|
950 |
"/ ^ 'static ' , self signatureName
|
|
951 |
"/ ].
|
168
|
952 |
"/ self isBreakpointed ifTrue:[
|
|
953 |
"/ ^ (LabelAndIcon '!! ' , self signatureName
|
|
954 |
"/ ].
|
175
|
955 |
|
166
|
956 |
name = #'<init>' ifTrue:[
|
175
|
957 |
^ self class specTextFromSignature:signature withName:(javaClass name).
|
166
|
958 |
].
|
175
|
959 |
^ self signatureNameText
|
166
|
960 |
|
175
|
961 |
"Modified: 30.7.1997 / 14:40:42 / cg"
|
10
|
962 |
!
|
|
963 |
|
118
|
964 |
shortDisplayString
|
|
965 |
^ javaClass name , '::' , self signatureNameWithoutReturnType
|
|
966 |
!
|
|
967 |
|
10
|
968 |
signatureName
|
|
969 |
"return a string to be used when browsing"
|
|
970 |
|
|
971 |
^ self class specFromSignature:signature withName:name
|
113
|
972 |
!
|
|
973 |
|
164
|
974 |
signatureNameFor:name withArgsIn:aPackage
|
|
975 |
"return a string to be used when decompiling"
|
|
976 |
|
|
977 |
^ self class specWithArgsFromSignature:signature withName:name in:aPackage
|
|
978 |
|
|
979 |
"Created: 25.3.1997 / 18:49:45 / cg"
|
|
980 |
!
|
|
981 |
|
142
|
982 |
signatureNameIn:aPackage
|
|
983 |
"return a string to be used when browsing"
|
|
984 |
|
|
985 |
^ self class specFromSignature:signature withName:name in:aPackage
|
|
986 |
|
|
987 |
"Created: 18.3.1997 / 11:11:01 / cg"
|
|
988 |
!
|
|
989 |
|
175
|
990 |
signatureNameText
|
|
991 |
"return a text to be used when browsing"
|
|
992 |
|
|
993 |
^ self class specTextFromSignature:signature withName:name
|
|
994 |
|
|
995 |
"Created: 30.7.1997 / 14:40:29 / cg"
|
|
996 |
!
|
|
997 |
|
154
|
998 |
signatureNameWithArgsIn:aPackage
|
|
999 |
"return a string to be used when browsing"
|
|
1000 |
|
|
1001 |
^ self class specWithArgsFromSignature:signature withName:name in:aPackage
|
|
1002 |
|
|
1003 |
"Created: 20.3.1997 / 12:44:17 / cg"
|
|
1004 |
!
|
|
1005 |
|
113
|
1006 |
signatureNameWithoutReturnType
|
|
1007 |
"return a string to be used when browsing"
|
|
1008 |
|
|
1009 |
^ self class argSpecFromSignature:signature withName:name
|
|
1010 |
|
8
|
1011 |
! !
|
|
1012 |
|
|
1013 |
!JavaMethod methodsFor:'queries'!
|
|
1014 |
|
111
|
1015 |
handlerFor:anException at:pc
|
|
1016 |
exceptionHandlerTable isNil ifTrue:[^ nil].
|
83
|
1017 |
exceptionHandlerTable do:[:entry |
|
48
|
1018 |
|hpc|
|
|
1019 |
|
|
1020 |
hpc := entry handlerPCFor:anException at:pc in:self.
|
111
|
1021 |
hpc notNil ifTrue:[^ hpc].
|
48
|
1022 |
].
|
|
1023 |
|
111
|
1024 |
^ nil
|
31
|
1025 |
!
|
|
1026 |
|
127
|
1027 |
hasResource
|
|
1028 |
^ false
|
|
1029 |
!
|
|
1030 |
|
19
|
1031 |
isAbstract
|
|
1032 |
^ (accessFlags bitAnd:16r0400) ~~ 0
|
|
1033 |
!
|
|
1034 |
|
80
|
1035 |
isBreakpointed
|
|
1036 |
^ false
|
|
1037 |
!
|
|
1038 |
|
19
|
1039 |
isFinal
|
|
1040 |
^ (accessFlags bitAnd:16r0010) ~~ 0
|
|
1041 |
!
|
|
1042 |
|
175
|
1043 |
isIgnored
|
|
1044 |
"not really a java attribute;
|
|
1045 |
added to allow browsing"
|
|
1046 |
|
|
1047 |
^ false.
|
|
1048 |
|
|
1049 |
"Created: 30.7.1997 / 15:34:33 / cg"
|
|
1050 |
!
|
|
1051 |
|
148
|
1052 |
isNOOPMethod
|
149
|
1053 |
isNOOPMethod isNil ifTrue:[
|
|
1054 |
self checkForNOOPMethod
|
|
1055 |
].
|
|
1056 |
^ isNOOPMethod
|
148
|
1057 |
|
149
|
1058 |
"Modified: 18.3.1997 / 18:04:02 / cg"
|
148
|
1059 |
!
|
|
1060 |
|
19
|
1061 |
isNative
|
|
1062 |
^ (accessFlags bitAnd:16r0100) ~~ 0
|
|
1063 |
!
|
|
1064 |
|
|
1065 |
isPrivate
|
|
1066 |
^ (accessFlags bitAnd:16r0002) ~~ 0
|
|
1067 |
|
|
1068 |
!
|
|
1069 |
|
|
1070 |
isProtected
|
|
1071 |
^ (accessFlags bitAnd:16r0004) ~~ 0
|
|
1072 |
!
|
|
1073 |
|
|
1074 |
isPublic
|
|
1075 |
^ (accessFlags bitAnd:16r0001) ~~ 0
|
|
1076 |
|
|
1077 |
!
|
|
1078 |
|
|
1079 |
isStatic
|
|
1080 |
^ (accessFlags bitAnd:16r0008) ~~ 0
|
|
1081 |
!
|
|
1082 |
|
|
1083 |
isSynchronized
|
|
1084 |
^ (accessFlags bitAnd:16r0020) ~~ 0
|
18
|
1085 |
!
|
|
1086 |
|
8
|
1087 |
isUnloaded
|
|
1088 |
^ false
|
18
|
1089 |
!
|
|
1090 |
|
31
|
1091 |
lineNumberForPC:pc
|
75
|
1092 |
|last num text classSource|
|
31
|
1093 |
|
|
1094 |
num := nil.
|
|
1095 |
|
169
|
1096 |
ForceByteCodeDisplay ifFalse:[
|
|
1097 |
|
|
1098 |
lineNumberTable notNil ifTrue:[
|
|
1099 |
classSource := javaClass source.
|
|
1100 |
classSource notNil ifTrue:[
|
|
1101 |
lineNumberTable pairWiseDo:[:lPc :lNr |
|
|
1102 |
lPc >= pc ifTrue:[
|
|
1103 |
"/ lPc == pc ifTrue:[^ lNr].
|
|
1104 |
last isNil ifTrue:[^ lNr].
|
|
1105 |
^ last.
|
|
1106 |
].
|
|
1107 |
last := lNr.
|
75
|
1108 |
].
|
169
|
1109 |
last notNil ifTrue:[
|
|
1110 |
^ last
|
|
1111 |
].
|
|
1112 |
^ lineNumberTable at:2
|
75
|
1113 |
].
|
|
1114 |
].
|
46
|
1115 |
].
|
31
|
1116 |
|
46
|
1117 |
"/ decompile and look which line the pc falls into
|
75
|
1118 |
text := self decompiledSource asCollectionOfLines.
|
31
|
1119 |
|
46
|
1120 |
text keysAndValuesDo:[:lineNr :line |
|
|
1121 |
|nr|
|
|
1122 |
|
83
|
1123 |
(line startsWith:' ') ifFalse:[
|
|
1124 |
nr := Integer readFrom:line onError:0.
|
|
1125 |
nr >= pc ifTrue:[
|
|
1126 |
^ lineNr
|
|
1127 |
]
|
46
|
1128 |
]
|
31
|
1129 |
].
|
|
1130 |
^ num
|
141
|
1131 |
|
169
|
1132 |
"Modified: 7.4.1997 / 20:13:21 / cg"
|
31
|
1133 |
!
|
|
1134 |
|
156
|
1135 |
package
|
|
1136 |
^ 'none'
|
|
1137 |
|
|
1138 |
"Created: 5.2.1997 / 11:31:26 / cg"
|
|
1139 |
!
|
|
1140 |
|
18
|
1141 |
who
|
|
1142 |
"return the class and selector of where I am defined in."
|
|
1143 |
|
64
|
1144 |
|sel|
|
18
|
1145 |
|
64
|
1146 |
sel := javaClass methodDictionary keyAtValue:self ifAbsent:nil.
|
|
1147 |
sel isNil ifTrue:[^ nil].
|
129
|
1148 |
^ Method::MethodWhoInfo class:javaClass selector:sel.
|
5
|
1149 |
! !
|
|
1150 |
|
154
|
1151 |
!JavaMethod methodsFor:'signature parsing'!
|
|
1152 |
|
|
1153 |
specWithArgsFromSignature:aSignature withName:name in:aPackage
|
|
1154 |
"given a signature, return a spec with args"
|
|
1155 |
|
|
1156 |
|s argSpec retvalSpec|
|
|
1157 |
|
|
1158 |
s := aSignature readStream.
|
|
1159 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
1160 |
|
|
1161 |
argSpec := self argSpecWithArgsFromStream:s in:aPackage.
|
|
1162 |
|
|
1163 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
1164 |
|
|
1165 |
retvalSpec := self retvalSpecFromStream:s in:aPackage.
|
|
1166 |
|
|
1167 |
^ retvalSpec , ' ' , name , ' (' , argSpec , ')'
|
|
1168 |
|
|
1169 |
"
|
|
1170 |
JavaMethod specFromSignature:'(LObject;)V' withName:'foo'
|
|
1171 |
JavaMethod specFromSignature:'(BB)S' withName:'foo'
|
|
1172 |
"
|
|
1173 |
|
|
1174 |
"Created: 20.3.1997 / 12:44:36 / cg"
|
|
1175 |
! !
|
|
1176 |
|
129
|
1177 |
!JavaMethod class methodsFor:'documentation'!
|
2
|
1178 |
|
|
1179 |
version
|
184
|
1180 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethod.st,v 1.46 1997/07/31 22:33:54 cg Exp $'
|
2
|
1181 |
! !
|
8
|
1182 |
JavaMethod initialize!
|