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