454
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG
|
506
|
3 |
All Rights Reserved
|
454
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
|
427
|
14 |
CompiledCode variableSubclass:#JavaMethod
|
378
|
15 |
instanceVariableNames:'accessFlags selector javaClass signature lineNumberTable
|
|
16 |
localVariableTable'
|
277
|
17 |
classVariableNames:'AbstractMethodInvokationSignal SignatureTypeCodes
|
594
|
18 |
ForceByteCodeDisplay UnresolvedClassSignal A_PUBLIC A_PRIVATE
|
|
19 |
A_PROTECTED A_STATIC A_FINAL A_SYNCHRONIZED A_ABSTRACT A_NATIVE
|
611
|
20 |
A_BREAKPOINT R_VOID R_LONG R_DOUBLE A_HASHANDLER'
|
2
|
21 |
poolDictionaries:''
|
|
22 |
category:'Java-Classes'
|
|
23 |
!
|
|
24 |
|
454
|
25 |
!JavaMethod class methodsFor:'documentation'!
|
|
26 |
|
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 1997 by eXept Software AG
|
506
|
30 |
All Rights Reserved
|
454
|
31 |
|
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
|
|
40 |
! !
|
2
|
41 |
|
129
|
42 |
!JavaMethod class methodsFor:'initialization'!
|
8
|
43 |
|
|
44 |
initialize
|
277
|
45 |
AbstractMethodInvokationSignal isNil ifTrue:[
|
594
|
46 |
AbstractMethodInvokationSignal := ExecutionErrorSignal newSignalMayProceed:true.
|
|
47 |
AbstractMethodInvokationSignal nameClass:self message:#abstractMethodInvokationSignal.
|
|
48 |
AbstractMethodInvokationSignal notifierString:'attempt to execute abstract method'.
|
|
49 |
|
|
50 |
UnresolvedClassSignal := ExecutionErrorSignal newSignalMayProceed:true.
|
|
51 |
UnresolvedClassSignal nameClass:self message:#unresolvedClassSignal.
|
|
52 |
UnresolvedClassSignal notifierString:'unresolved class'.
|
277
|
53 |
].
|
|
54 |
|
252
|
55 |
A_PUBLIC := 16r0001.
|
|
56 |
A_PRIVATE := 16r0002.
|
|
57 |
A_PROTECTED := 16r0004.
|
|
58 |
A_STATIC := 16r0008.
|
|
59 |
A_FINAL := 16r0010.
|
|
60 |
A_SYNCHRONIZED := 16r0020.
|
|
61 |
A_NATIVE := 16r0100.
|
|
62 |
A_ABSTRACT := 16r0400.
|
|
63 |
|
|
64 |
R_VOID := 16r100000.
|
|
65 |
R_LONG := 16r200000.
|
|
66 |
R_DOUBLE := 16r300000.
|
|
67 |
|
255
|
68 |
A_BREAKPOINT := 16r0800000.
|
378
|
69 |
A_HASHANDLER := 16r1000000.
|
255
|
70 |
|
173
|
71 |
self flags:(self flags bitOr:Behavior flagJavaMethod).
|
|
72 |
|
8
|
73 |
SignatureTypeCodes := IdentityDictionary new.
|
|
74 |
SignatureTypeCodes at:$B put:#byte.
|
|
75 |
SignatureTypeCodes at:$C put:#char.
|
|
76 |
SignatureTypeCodes at:$D put:#double.
|
|
77 |
SignatureTypeCodes at:$F put:#float.
|
|
78 |
SignatureTypeCodes at:$I put:#int.
|
|
79 |
SignatureTypeCodes at:$J put:#long.
|
|
80 |
SignatureTypeCodes at:$S put:#'unsigned short'.
|
|
81 |
SignatureTypeCodes at:$Z put:#boolean.
|
|
82 |
SignatureTypeCodes at:$L put:#object.
|
|
83 |
SignatureTypeCodes at:$[ put:#array.
|
|
84 |
|
207
|
85 |
ForceByteCodeDisplay := false.
|
|
86 |
|
8
|
87 |
"
|
378
|
88 |
JavaMethod initialize.
|
|
89 |
JavaMethodWithHandler initialize.
|
209
|
90 |
ForceByteCodeDisplay := true.
|
255
|
91 |
ForceByteCodeDisplay := false.
|
8
|
92 |
"
|
173
|
93 |
|
378
|
94 |
"Modified: / 16.10.1998 / 01:29:48 / cg"
|
|
95 |
! !
|
|
96 |
|
|
97 |
!JavaMethod class methodsFor:'instance creation'!
|
|
98 |
|
|
99 |
fromMethod:aJavaMethod
|
|
100 |
"create a new javaMethod, copying values from another javaMethod"
|
|
101 |
|
|
102 |
^ self new fromMethod:aJavaMethod
|
|
103 |
|
|
104 |
"Created: / 16.10.1998 / 01:25:12 / cg"
|
|
105 |
!
|
|
106 |
|
|
107 |
new
|
|
108 |
"create a new javaMethod.
|
|
109 |
Redefined, since constants are NOT stored in a literalArray,
|
|
110 |
but my classes constantTable instead."
|
|
111 |
|
|
112 |
^ self basicNew:0.
|
|
113 |
|
|
114 |
"Created: / 16.10.1998 / 01:13:02 / cg"
|
277
|
115 |
! !
|
|
116 |
|
|
117 |
!JavaMethod class methodsFor:'Signal constants'!
|
|
118 |
|
|
119 |
abstractMethodInvokationSignal
|
|
120 |
"return the signal raised when an abstract method is invoked"
|
|
121 |
|
|
122 |
^ AbstractMethodInvokationSignal
|
|
123 |
|
|
124 |
"Created: / 27.1.1998 / 21:50:05 / cg"
|
594
|
125 |
!
|
|
126 |
|
|
127 |
unresolvedClassSignal
|
|
128 |
"return the signal raised when an unresolved class is referenced"
|
|
129 |
|
|
130 |
^ UnresolvedClassSignal
|
|
131 |
|
|
132 |
"Created: / 27.1.1998 / 21:50:05 / cg"
|
8
|
133 |
! !
|
|
134 |
|
357
|
135 |
!JavaMethod class methodsFor:'constants'!
|
|
136 |
|
467
|
137 |
A_HASHANDLER
|
|
138 |
^ A_HASHANDLER
|
|
139 |
|
|
140 |
"Created: / 26.11.1998 / 22:23:12 / cg"
|
|
141 |
!
|
|
142 |
|
357
|
143 |
A_NATIVE
|
|
144 |
^ JavaClass A_NATIVE
|
|
145 |
|
|
146 |
"Created: / 16.5.1998 / 01:18:24 / cg"
|
|
147 |
!
|
|
148 |
|
|
149 |
A_PUBLIC
|
|
150 |
^ JavaClass A_PUBLIC
|
|
151 |
|
|
152 |
"Created: / 16.5.1998 / 00:01:10 / cg"
|
|
153 |
!
|
|
154 |
|
|
155 |
A_STATIC
|
|
156 |
^ JavaClass A_STATIC
|
|
157 |
|
|
158 |
"Created: / 16.5.1998 / 00:01:17 / cg"
|
|
159 |
! !
|
|
160 |
|
169
|
161 |
!JavaMethod class methodsFor:'misc'!
|
|
162 |
|
|
163 |
forceByteCodeDisplay
|
|
164 |
^ ForceByteCodeDisplay
|
|
165 |
|
|
166 |
"Created: 7.4.1997 / 20:11:39 / cg"
|
309
|
167 |
!
|
|
168 |
|
|
169 |
forceByteCodeDisplay:aBoolean
|
|
170 |
ForceByteCodeDisplay := aBoolean
|
|
171 |
|
|
172 |
"
|
|
173 |
self forceByteCodeDisplay:true
|
|
174 |
self forceByteCodeDisplay:false
|
|
175 |
"
|
|
176 |
|
|
177 |
"Created: / 4.2.1998 / 00:22:54 / cg"
|
169
|
178 |
! !
|
|
179 |
|
129
|
180 |
!JavaMethod class methodsFor:'signature parsing'!
|
5
|
181 |
|
29
|
182 |
argSigArrayFromSignature:aSignature
|
|
183 |
"given a signature, return a specArray for the arguments"
|
|
184 |
|
238
|
185 |
|s|
|
29
|
186 |
|
|
187 |
s := aSignature readStream.
|
237
|
188 |
s next ~~ $( ifTrue:[self halt].
|
29
|
189 |
|
|
190 |
^ self argSigArrayFromStream:s.
|
|
191 |
|
|
192 |
"
|
|
193 |
JavaMethod argSigArrayFromSignature:'(LObject;)V'
|
|
194 |
JavaMethod argSigArrayFromSignature:'(BB)S'
|
|
195 |
JavaMethod argSigArrayFromSignature:'(LObject;LObject;II)V'
|
|
196 |
"
|
|
197 |
!
|
|
198 |
|
|
199 |
argSigArrayFromStream:s
|
|
200 |
"parse an argSpec, return an array of specs - see java doc"
|
|
201 |
|
|
202 |
|argSpec spec|
|
|
203 |
|
|
204 |
spec := #().
|
|
205 |
[s atEnd or:[s peek == $)]] whileFalse:[
|
|
206 |
"/ s peek == Character space ifTrue:[
|
|
207 |
"/ s next
|
|
208 |
"/ ] ifFalse:[
|
506
|
209 |
argSpec := self fieldTypeFromStream:s in:nil.
|
|
210 |
spec := spec copyWith:argSpec.
|
29
|
211 |
"/ ]
|
|
212 |
].
|
|
213 |
^ spec
|
|
214 |
|
255
|
215 |
"Modified: / 8.1.1998 / 19:10:20 / cg"
|
29
|
216 |
!
|
|
217 |
|
321
|
218 |
argSignatureFromArgTypeArray:arr
|
322
|
219 |
|sig|
|
321
|
220 |
|
|
221 |
sig := ''.
|
|
222 |
arr do:[:el |
|
506
|
223 |
|jCLass|
|
|
224 |
|
|
225 |
jCLass := el.
|
|
226 |
jCLass isJavaClass ifFalse:[
|
|
227 |
jCLass := JavaVM classForJavaClassObject:el
|
|
228 |
].
|
|
229 |
jCLass isJavaClass ifTrue:[
|
|
230 |
sig := sig , jCLass typeName.
|
|
231 |
sig := sig, ';'
|
|
232 |
] ifFalse:[
|
|
233 |
self halt.
|
|
234 |
]
|
321
|
235 |
].
|
322
|
236 |
^ sig
|
321
|
237 |
|
|
238 |
"
|
|
239 |
self argSignatureFromArgTypeArray:
|
506
|
240 |
(Array
|
|
241 |
with:(JavaVM javaClassObjectForClass:(Java at:'com.sun.java.swing.JComponent')))
|
321
|
242 |
"
|
|
243 |
|
322
|
244 |
"Modified: / 13.2.1998 / 14:57:58 / cg"
|
321
|
245 |
!
|
|
246 |
|
113
|
247 |
argSpecFromSignature:aSignature withName:name
|
|
248 |
"given a signature, return a spec"
|
|
249 |
|
238
|
250 |
|s argSpec|
|
113
|
251 |
|
|
252 |
s := aSignature readStream.
|
|
253 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
254 |
|
255
|
255 |
argSpec := self argSpecFromStream:s in:nil.
|
113
|
256 |
|
|
257 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
258 |
|
|
259 |
^ name , ' (' , argSpec , ')'
|
|
260 |
|
|
261 |
"
|
|
262 |
JavaMethod argSpecFromSignature:'(LObject;)V' withName:'foo'
|
|
263 |
JavaMethod argSpecFromSignature:'(BB)S' withName:'foo'
|
|
264 |
"
|
|
265 |
|
255
|
266 |
"Modified: / 8.1.1998 / 19:05:36 / cg"
|
5
|
267 |
!
|
|
268 |
|
142
|
269 |
argSpecFromStream:s in:aPackage
|
|
270 |
"parse an argSpec - see java doc"
|
|
271 |
|
|
272 |
|argSpec spec|
|
|
273 |
|
|
274 |
spec := ''.
|
|
275 |
[s atEnd or:[s peek == $)]] whileFalse:[
|
|
276 |
"/ s peek == Character space ifTrue:[
|
|
277 |
"/ s next
|
|
278 |
"/ ] ifFalse:[
|
252
|
279 |
argSpec := self fieldTypeFromStream:s in:aPackage.
|
|
280 |
spec size ~~ 0 ifTrue:[
|
|
281 |
spec := spec , ' '
|
|
282 |
].
|
|
283 |
spec := spec , argSpec.
|
142
|
284 |
"/ ]
|
|
285 |
].
|
|
286 |
^ spec
|
|
287 |
|
|
288 |
"Created: 18.3.1997 / 11:06:44 / cg"
|
|
289 |
!
|
|
290 |
|
154
|
291 |
argSpecWithArgsFromStream:s in:aPackage
|
|
292 |
"parse an argSpec - see java doc"
|
|
293 |
|
255
|
294 |
^ self argSpecWithArgsFromStream:s in:aPackage argNames:nil
|
|
295 |
|
|
296 |
"Modified: / 8.1.1998 / 19:21:00 / cg"
|
|
297 |
!
|
|
298 |
|
|
299 |
argSpecWithArgsFromStream:s in:aPackage argNames:argNames
|
|
300 |
"parse an argSpec - see java doc"
|
|
301 |
|
|
302 |
|argSpec spec argNr nm|
|
154
|
303 |
|
|
304 |
argNr := 1.
|
|
305 |
spec := ''.
|
|
306 |
[s atEnd or:[s peek == $)]] whileFalse:[
|
506
|
307 |
argSpec := self fieldTypeFromStream:s in:aPackage.
|
|
308 |
|
|
309 |
(argNames notNil
|
|
310 |
and:[argNames size >= argNr
|
|
311 |
and:[(nm := argNames at:argNr) notNil]]) ifFalse:[
|
|
312 |
nm := 'arg' , argNr printString.
|
|
313 |
].
|
|
314 |
argSpec := argSpec , ' ' , nm.
|
|
315 |
|
|
316 |
spec size ~~ 0 ifTrue:[
|
|
317 |
spec := spec , ', '
|
|
318 |
].
|
|
319 |
spec := spec , argSpec.
|
|
320 |
|
|
321 |
argNr := argNr + 1.
|
154
|
322 |
].
|
|
323 |
^ spec
|
|
324 |
|
255
|
325 |
"Created: / 8.1.1998 / 19:20:36 / cg"
|
|
326 |
"Modified: / 8.1.1998 / 21:14:33 / cg"
|
8
|
327 |
!
|
|
328 |
|
142
|
329 |
fieldTypeFromStream:s in:aPackage
|
|
330 |
"parse a fieldTypeSpec - see java doc"
|
|
331 |
|
238
|
332 |
|typeChar typeSym elType size className nm|
|
142
|
333 |
|
|
334 |
typeChar := s next.
|
|
335 |
|
|
336 |
typeSym := SignatureTypeCodes at:typeChar ifAbsent:#unknown.
|
|
337 |
|
|
338 |
typeSym == #unknown ifTrue:[
|
506
|
339 |
^ typeSym
|
142
|
340 |
].
|
|
341 |
typeSym == #object ifTrue:[
|
506
|
342 |
className := s upTo:$;.
|
|
343 |
"/ strip off default
|
|
344 |
|
|
345 |
nm := className.
|
|
346 |
aPackage notNil ifTrue:[
|
|
347 |
(nm startsWith:aPackage) ifTrue:[
|
|
348 |
nm := nm copyFrom:(aPackage size + 2).
|
|
349 |
].
|
|
350 |
].
|
142
|
351 |
|
506
|
352 |
nm := nm copyReplaceAll:$/ with:$..
|
|
353 |
^ nm
|
142
|
354 |
].
|
189
|
355 |
|
142
|
356 |
typeSym == #array ifTrue:[
|
506
|
357 |
s peek isDigit ifTrue:[
|
|
358 |
size := Integer readFrom:s.
|
|
359 |
elType := self fieldTypeFromStream:s in:aPackage.
|
|
360 |
^ elType , '[' , size printString , ']'
|
|
361 |
].
|
|
362 |
elType := self fieldTypeFromStream:s in:aPackage.
|
|
363 |
^ elType , '[]'
|
142
|
364 |
].
|
189
|
365 |
|
142
|
366 |
^ typeSym
|
|
367 |
|
360
|
368 |
"Created: / 18.3.1997 / 11:07:56 / cg"
|
|
369 |
"Modified: / 18.7.1998 / 22:57:06 / cg"
|
142
|
370 |
!
|
|
371 |
|
27
|
372 |
numArgsFromSignature:aSignature
|
|
373 |
"given a signature, return the number of args"
|
|
374 |
|
238
|
375 |
|s|
|
27
|
376 |
|
|
377 |
s := aSignature readStream.
|
237
|
378 |
s next ~~ $( ifTrue:[self halt].
|
27
|
379 |
|
|
380 |
^ self numArgsFromStream:s.
|
|
381 |
|
|
382 |
"
|
|
383 |
JavaMethod numArgsFromSignature:'(LObject;)V'
|
|
384 |
JavaMethod numArgsFromSignature:'(BB)S'
|
|
385 |
JavaMethod numArgsFromSignature:'()V'
|
|
386 |
"
|
|
387 |
!
|
|
388 |
|
|
389 |
numArgsFromStream:s
|
|
390 |
"parse an argSpec - see java doc"
|
|
391 |
|
238
|
392 |
|n t|
|
27
|
393 |
|
|
394 |
n := 0.
|
|
395 |
[s atEnd or:[s peek == $)]] whileFalse:[
|
506
|
396 |
t := self fieldTypeFromStream:s in:nil.
|
|
397 |
"/
|
|
398 |
"/ some args count as 2
|
|
399 |
"/
|
|
400 |
t == #long ifTrue:[
|
|
401 |
n := n + 2.
|
|
402 |
] ifFalse:[
|
|
403 |
t == #double ifTrue:[
|
|
404 |
n := n + 2
|
|
405 |
] ifFalse:[
|
|
406 |
n := n + 1.
|
|
407 |
]
|
|
408 |
]
|
27
|
409 |
].
|
|
410 |
^ n
|
|
411 |
|
255
|
412 |
"Modified: / 8.1.1998 / 19:10:25 / cg"
|
29
|
413 |
!
|
|
414 |
|
142
|
415 |
retValSpecFromSignature:aSignature in:aPackage
|
|
416 |
"given a signature, return a spec"
|
|
417 |
|
|
418 |
|s argSpec retvalSpec|
|
|
419 |
|
|
420 |
s := aSignature readStream.
|
237
|
421 |
s next ~~ $( ifTrue:[self halt].
|
142
|
422 |
|
|
423 |
argSpec := self argSpecFromStream:s in:aPackage.
|
|
424 |
|
237
|
425 |
s next ~~ $) ifTrue:[self halt].
|
142
|
426 |
|
|
427 |
retvalSpec := self retvalSpecFromStream:s in:aPackage.
|
|
428 |
|
|
429 |
^ retvalSpec
|
|
430 |
|
|
431 |
"
|
|
432 |
JavaMethod retValSpecFromSignature:'(LObject;)V'
|
|
433 |
JavaMethod retValSpecFromSignature:'(BB)S'
|
|
434 |
"
|
|
435 |
|
|
436 |
"Created: 18.3.1997 / 11:11:50 / cg"
|
|
437 |
!
|
|
438 |
|
189
|
439 |
returnTypeFromSignature:aSignature in:aPackage
|
|
440 |
"given a signature, return its type as a string"
|
|
441 |
|
238
|
442 |
|s c|
|
189
|
443 |
|
|
444 |
s := aSignature readStream.
|
|
445 |
(c := s peek) ~~ $( ifTrue:[
|
506
|
446 |
c == $' ifTrue:[
|
|
447 |
[s peek ~= $'] whileTrue:[s next].
|
|
448 |
s next.
|
|
449 |
^ (self retvalSpecFromStream:s in:aPackage)
|
|
450 |
].
|
|
451 |
^ (self retvalSpecFromStream:s in:aPackage)
|
189
|
452 |
].
|
|
453 |
|
|
454 |
s next.
|
255
|
455 |
self argSpecFromStream:s in:aPackage.
|
189
|
456 |
s next ~~ $) ifTrue:[self halt. ^ nil].
|
|
457 |
|
|
458 |
^ (self retvalSpecFromStream:s in:aPackage)
|
|
459 |
|
|
460 |
"
|
|
461 |
JavaMethod returnTypeFromSignature:'(LObject;)V'
|
|
462 |
JavaMethod returnTypeFromSignature:'(BB)S'
|
|
463 |
JavaMethod returnTypeFromSignature:'()J'
|
|
464 |
JavaMethod returnTypeFromSignature:'''first''J'
|
|
465 |
"
|
|
466 |
|
255
|
467 |
"Created: / 1.8.1997 / 10:54:31 / cg"
|
|
468 |
"Modified: / 8.1.1998 / 19:09:06 / cg"
|
72
|
469 |
!
|
|
470 |
|
|
471 |
returnsVoidFromSignature:aSignature
|
|
472 |
"given a signature, return true if it returns void, false if not"
|
|
473 |
|
255
|
474 |
^ (self typeFromSignature:aSignature in:nil) = 'void'
|
27
|
475 |
|
|
476 |
"
|
|
477 |
JavaMethod returnsVoidFromSignature:'(LObject;)V'
|
|
478 |
JavaMethod returnsVoidFromSignature:'(BB)S'
|
|
479 |
"
|
|
480 |
|
255
|
481 |
"Modified: / 8.1.1998 / 19:13:53 / cg"
|
10
|
482 |
!
|
|
483 |
|
142
|
484 |
retvalSpecFromStream:s in:aPackage
|
|
485 |
"parse a retvalSpec - see java doc"
|
|
486 |
|
332
|
487 |
|spec|
|
|
488 |
|
142
|
489 |
s atEnd ifTrue:[self halt. ^ #void].
|
|
490 |
s peek == $V ifTrue:[^ #void].
|
332
|
491 |
spec := self fieldTypeFromStream:s in:aPackage.
|
|
492 |
spec knownAsSymbol ifTrue:[
|
506
|
493 |
^ spec asSymbol
|
332
|
494 |
].
|
|
495 |
^ spec
|
142
|
496 |
|
332
|
497 |
"Created: / 18.3.1997 / 11:12:19 / cg"
|
|
498 |
"Modified: / 7.4.1998 / 22:28:27 / cg"
|
142
|
499 |
!
|
|
500 |
|
189
|
501 |
specComponentsWithArgsFromSignature:aSignature withName:name in:aPackage
|
|
502 |
"given a signature, return a spec"
|
|
503 |
|
|
504 |
|s argSpec retvalSpec|
|
|
505 |
|
|
506 |
s := aSignature readStream.
|
|
507 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
508 |
|
|
509 |
argSpec := self argSpecWithArgsFromStream:s in:aPackage.
|
|
510 |
|
|
511 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
512 |
|
|
513 |
retvalSpec := self retvalSpecFromStream:s in:aPackage.
|
|
514 |
|
|
515 |
^ Array with:retvalSpec with:name with:argSpec
|
|
516 |
|
|
517 |
"
|
|
518 |
JavaMethod specWithArgsFromSignature:'(LObject;)V' withName:'foo' in:nil
|
|
519 |
JavaMethod specComponentsWithArgsFromSignature:'(LObject;)V' withName:'foo' in:nil
|
|
520 |
"
|
|
521 |
|
|
522 |
"Created: 18.3.1997 / 11:06:22 / cg"
|
|
523 |
"Modified: 1.8.1997 / 11:03:50 / cg"
|
|
524 |
!
|
|
525 |
|
255
|
526 |
specFromSignature:aSignature withName:name argNames:argNames in:aPackage
|
10
|
527 |
"given a signature, return a spec"
|
|
528 |
|
|
529 |
|s argSpec retvalSpec|
|
|
530 |
|
|
531 |
s := aSignature readStream.
|
|
532 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
533 |
|
255
|
534 |
argSpec := self argSpecWithArgsFromStream:s in:aPackage argNames:argNames.
|
10
|
535 |
|
|
536 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
537 |
|
255
|
538 |
retvalSpec := self retvalSpecFromStream:s in:aPackage.
|
10
|
539 |
|
|
540 |
^ retvalSpec , ' ' , name , ' (' , argSpec , ')'
|
|
541 |
|
|
542 |
"
|
255
|
543 |
JavaMethod specFromSignature:'(LObject;)V' withName:'foo' argNames:#('a') in:nil
|
|
544 |
JavaMethod specFromSignature:'(BB)S' withName:'foo' argNames:#('a' 'b') in:nil
|
10
|
545 |
"
|
255
|
546 |
|
|
547 |
"Created: / 18.3.1997 / 11:06:22 / cg"
|
|
548 |
"Modified: / 8.1.1998 / 21:14:43 / cg"
|
83
|
549 |
!
|
|
550 |
|
142
|
551 |
specFromSignature:aSignature withName:name in:aPackage
|
|
552 |
"given a signature, return a spec"
|
|
553 |
|
|
554 |
|s argSpec retvalSpec|
|
|
555 |
|
|
556 |
s := aSignature readStream.
|
|
557 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
558 |
|
|
559 |
argSpec := self argSpecFromStream:s in:aPackage.
|
|
560 |
|
|
561 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
562 |
|
|
563 |
retvalSpec := self retvalSpecFromStream:s in:aPackage.
|
|
564 |
|
|
565 |
^ retvalSpec , ' ' , name , ' (' , argSpec , ')'
|
|
566 |
|
|
567 |
"
|
255
|
568 |
JavaMethod specFromSignature:'(LObject;)V' withName:'foo' in:nil
|
|
569 |
JavaMethod specFromSignature:'(BB)S' withName:'foo' in:nil
|
142
|
570 |
"
|
|
571 |
|
255
|
572 |
"Created: / 18.3.1997 / 11:06:22 / cg"
|
|
573 |
"Modified: / 8.1.1998 / 21:06:32 / cg"
|
142
|
574 |
!
|
|
575 |
|
175
|
576 |
specTextFromSignature:aSignature withName:name
|
|
577 |
"given a signature, return a spec as boldified text"
|
|
578 |
|
|
579 |
|s argSpec retvalSpec|
|
|
580 |
|
|
581 |
s := aSignature readStream.
|
|
582 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
583 |
|
255
|
584 |
argSpec := self argSpecFromStream:s in:nil.
|
175
|
585 |
|
|
586 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
587 |
|
255
|
588 |
retvalSpec := self retvalSpecFromStream:s in:nil.
|
175
|
589 |
|
|
590 |
^ retvalSpec , ' ' , (name asText allBold) , ' (' , argSpec , ')'
|
|
591 |
|
|
592 |
"
|
|
593 |
JavaMethod specTextFromSignature:'(LObject;)V' withName:'foo'
|
|
594 |
JavaMethod specTextFromSignature:'(BB)S' withName:'foo'
|
|
595 |
"
|
|
596 |
|
255
|
597 |
"Modified: / 8.1.1998 / 19:11:20 / cg"
|
175
|
598 |
!
|
|
599 |
|
189
|
600 |
specTextWithArgsFromSignature:aSignature withName:name in:aPackage
|
|
601 |
"given a signature, return a spec"
|
|
602 |
|
|
603 |
|s argSpec retvalSpec|
|
|
604 |
|
|
605 |
s := aSignature readStream.
|
|
606 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
607 |
|
|
608 |
argSpec := self argSpecWithArgsFromStream:s in:aPackage.
|
|
609 |
|
|
610 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
611 |
|
|
612 |
retvalSpec := self retvalSpecFromStream:s in:aPackage.
|
|
613 |
|
|
614 |
^ retvalSpec , ' ' , (name asText allBold) , ' (' , argSpec , ')'
|
|
615 |
|
|
616 |
"
|
|
617 |
JavaMethod specWithArgsFromSignature:'(LObject;)V' withName:'foo' in:nil
|
|
618 |
JavaMethod specWithArgsFromSignature:'(BB)S' withName:'foo' in:nil
|
|
619 |
"
|
|
620 |
|
|
621 |
"Modified: 20.3.1997 / 12:50:10 / cg"
|
|
622 |
"Created: 1.8.1997 / 10:43:57 / cg"
|
|
623 |
!
|
|
624 |
|
154
|
625 |
specWithArgsFromSignature:aSignature withName:name in:aPackage
|
|
626 |
"given a signature, return a spec"
|
|
627 |
|
|
628 |
|s argSpec retvalSpec|
|
|
629 |
|
|
630 |
s := aSignature readStream.
|
|
631 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
632 |
|
|
633 |
argSpec := self argSpecWithArgsFromStream:s in:aPackage.
|
|
634 |
|
|
635 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
636 |
|
|
637 |
retvalSpec := self retvalSpecFromStream:s in:aPackage.
|
|
638 |
|
|
639 |
^ retvalSpec , ' ' , name , ' (' , argSpec , ')'
|
|
640 |
|
|
641 |
"
|
|
642 |
JavaMethod specWithArgsFromSignature:'(LObject;)V' withName:'foo' in:nil
|
|
643 |
JavaMethod specWithArgsFromSignature:'(BB)S' withName:'foo' in:nil
|
|
644 |
"
|
|
645 |
|
|
646 |
"Created: 18.3.1997 / 11:06:22 / cg"
|
|
647 |
"Modified: 20.3.1997 / 12:50:10 / cg"
|
|
648 |
!
|
|
649 |
|
189
|
650 |
typeFromSignature:aSignature in:package
|
|
651 |
"given a signature, return its type as a string"
|
|
652 |
|
238
|
653 |
|s c|
|
189
|
654 |
|
|
655 |
s := aSignature readStream.
|
|
656 |
(c := s peek) ~~ $( ifTrue:[
|
506
|
657 |
c == $' ifTrue:[
|
|
658 |
s next.
|
|
659 |
[s peek ~= $'] whileTrue:[s next].
|
|
660 |
s next.
|
|
661 |
^ (self retvalSpecFromStream:s in:package)
|
|
662 |
].
|
|
663 |
^ (self retvalSpecFromStream:s in:package)
|
189
|
664 |
].
|
|
665 |
|
|
666 |
s next.
|
255
|
667 |
self argSpecFromStream:s in:nil.
|
189
|
668 |
s next ~~ $) ifTrue:[self halt. ^ nil].
|
|
669 |
|
|
670 |
^ (self retvalSpecFromStream:s in:package)
|
|
671 |
|
|
672 |
"
|
|
673 |
JavaMethod typeFromSignature:'(LObject;)Ljava/lang/Object'
|
|
674 |
JavaMethod typeFromSignature:'(LObject;)Ljava/lang/Object' in:'java.lang'
|
|
675 |
"
|
|
676 |
|
255
|
677 |
"Created: / 1.8.1997 / 10:50:38 / cg"
|
|
678 |
"Modified: / 8.1.1998 / 19:09:31 / cg"
|
10
|
679 |
! !
|
|
680 |
|
|
681 |
!JavaMethod methodsFor:'accessing'!
|
|
682 |
|
334
|
683 |
accessFlags
|
|
684 |
"java calls this the modifiers"
|
|
685 |
|
|
686 |
^ accessFlags
|
|
687 |
|
|
688 |
"Created: / 9.4.1998 / 17:49:44 / cg"
|
|
689 |
!
|
|
690 |
|
29
|
691 |
argSignature
|
|
692 |
^ self class argSigArrayFromSignature:signature
|
|
693 |
!
|
|
694 |
|
10
|
695 |
constantPool
|
|
696 |
^ javaClass constantPool
|
|
697 |
|
|
698 |
"Modified: 16.4.1996 / 12:36:27 / cg"
|
|
699 |
"Created: 16.4.1996 / 15:28:50 / cg"
|
|
700 |
!
|
|
701 |
|
129
|
702 |
containingClass
|
|
703 |
^ javaClass
|
|
704 |
|
|
705 |
!
|
|
706 |
|
169
|
707 |
decompiledBytecode
|
|
708 |
|s|
|
|
709 |
|
|
710 |
s := '' writeStream.
|
|
711 |
JavaDecompiler decompile:self to:s.
|
|
712 |
^ s contents
|
|
713 |
|
|
714 |
"Created: 7.4.1997 / 20:10:37 / cg"
|
|
715 |
!
|
|
716 |
|
75
|
717 |
decompiledSource
|
|
718 |
|s|
|
|
719 |
|
|
720 |
s := '' writeStream.
|
175
|
721 |
self decompileSourceTo:s.
|
75
|
722 |
^ s contents
|
175
|
723 |
|
|
724 |
"Modified: 30.7.1997 / 16:27:55 / cg"
|
75
|
725 |
!
|
|
726 |
|
135
|
727 |
exceptionHandlerTable
|
378
|
728 |
^ nil
|
135
|
729 |
|
378
|
730 |
"Created: / 16.10.1998 / 01:50:51 / cg"
|
135
|
731 |
!
|
|
732 |
|
83
|
733 |
exceptionTable
|
378
|
734 |
^ nil
|
83
|
735 |
|
378
|
736 |
"Created: / 16.10.1998 / 01:51:04 / cg"
|
83
|
737 |
!
|
|
738 |
|
90
|
739 |
hasLineNumberInformation
|
|
740 |
^ lineNumberTable notNil
|
|
741 |
|
|
742 |
"Created: 16.4.1996 / 12:34:04 / cg"
|
|
743 |
"Modified: 16.4.1996 / 12:49:06 / cg"
|
|
744 |
!
|
|
745 |
|
10
|
746 |
javaByteCode
|
184
|
747 |
"/ ^ javaByteCode
|
|
748 |
^ byteCode
|
10
|
749 |
|
|
750 |
"Created: 16.4.1996 / 14:55:44 / cg"
|
184
|
751 |
"Modified: 1.8.1997 / 00:08:45 / cg"
|
8
|
752 |
!
|
|
753 |
|
27
|
754 |
javaClass
|
|
755 |
^ javaClass
|
|
756 |
|
|
757 |
"Modified: 16.4.1996 / 12:36:27 / cg"
|
|
758 |
"Created: 16.4.1996 / 14:55:44 / cg"
|
|
759 |
!
|
|
760 |
|
90
|
761 |
lineNumber
|
252
|
762 |
lineNumberTable isNil ifTrue:[^ nil].
|
90
|
763 |
^ lineNumberTable at:2
|
|
764 |
|
|
765 |
"Created: 16.4.1996 / 12:34:04 / cg"
|
|
766 |
"Modified: 16.4.1996 / 12:49:06 / cg"
|
|
767 |
!
|
|
768 |
|
50
|
769 |
lineNumberTable
|
|
770 |
^ lineNumberTable
|
|
771 |
|
|
772 |
"Created: 16.4.1996 / 12:34:04 / cg"
|
|
773 |
"Modified: 16.4.1996 / 12:49:06 / cg"
|
|
774 |
!
|
|
775 |
|
618
|
776 |
literalsDetect:aBlock ifNone:exceptionBlock
|
|
777 |
"execute a one arg block for each of our literals.
|
|
778 |
return the first literal for which aBlock returns true"
|
|
779 |
|
|
780 |
"/ sigh - must first extract all accessed literals ...
|
|
781 |
"/ must deparse the byteCode in order to do this.
|
|
782 |
|
|
783 |
|walker|
|
|
784 |
|
|
785 |
walker := JavaByteCodeEnumerator new.
|
|
786 |
walker literalAction:[:pc :slotIndex :const | Transcript showCR:const].
|
|
787 |
walker decompile:self to:nil.
|
|
788 |
self halt.
|
|
789 |
|
|
790 |
"Created: / 9.11.1999 / 15:21:40 / cg"
|
|
791 |
"Modified: / 9.11.1999 / 15:36:02 / cg"
|
|
792 |
!
|
|
793 |
|
85
|
794 |
localVariableTable
|
|
795 |
^ localVariableTable
|
|
796 |
|
|
797 |
"
|
|
798 |
JavaMethod allInstancesDo:[:m| m localVariableTable notNil ifTrue:[self halt]]
|
|
799 |
"
|
|
800 |
!
|
|
801 |
|
31
|
802 |
methodArgAndVarNames
|
|
803 |
^ ((1 to:self numArgs) collect:[:i | 'arg' , i printString])
|
|
804 |
,
|
|
805 |
((1 to:self numVars) collect:[:i | 'local' , i printString])
|
|
806 |
|
|
807 |
!
|
|
808 |
|
|
809 |
methodArgNames
|
252
|
810 |
|nA|
|
|
811 |
|
|
812 |
nA := self numArgs.
|
102
|
813 |
localVariableTable notNil ifTrue:[
|
252
|
814 |
^ (1 to:nA) collect:
|
|
815 |
[:argIndex |
|
|
816 |
|slot name|
|
|
817 |
"/ search for an entry with that index (slot),
|
|
818 |
"/ which has is valid at PC 0
|
102
|
819 |
|
252
|
820 |
self isStatic ifTrue:[
|
|
821 |
slot := argIndex
|
|
822 |
] ifFalse:[
|
|
823 |
slot := argIndex + 1
|
|
824 |
].
|
|
825 |
name := localVariableTable nameForSlot:slot atPC:0.
|
|
826 |
name isNil ifTrue:[
|
|
827 |
'arg' , argIndex printString
|
|
828 |
] ifFalse:[
|
|
829 |
name
|
|
830 |
].
|
|
831 |
]
|
102
|
832 |
].
|
252
|
833 |
^ (1 to:nA) collect:[:i | 'arg' , i printString]
|
31
|
834 |
!
|
|
835 |
|
29
|
836 |
name
|
252
|
837 |
^ (selector copyWithoutLast:signature size) asSymbol
|
29
|
838 |
|
|
839 |
"Created: 16.4.1996 / 11:34:22 / cg"
|
|
840 |
!
|
|
841 |
|
252
|
842 |
numLocals
|
|
843 |
^super numVars.
|
|
844 |
"/ numLocals isNil ifTrue:[^ 0].
|
|
845 |
"/ ^ numLocals
|
27
|
846 |
|
252
|
847 |
"Modified: / 3.1.1998 / 21:15:38 / cg"
|
118
|
848 |
!
|
|
849 |
|
261
|
850 |
numVars
|
|
851 |
|n|
|
118
|
852 |
|
261
|
853 |
"/ a Java-stackframe includes the args in the locals
|
|
854 |
n := self numLocals - self numArgs.
|
|
855 |
^ n
|
|
856 |
|
|
857 |
"Modified: / 13.1.1998 / 17:34:37 / cg"
|
27
|
858 |
!
|
|
859 |
|
175
|
860 |
previousVersion
|
|
861 |
^ nil
|
|
862 |
|
|
863 |
"Created: 30.7.1997 / 15:56:18 / cg"
|
|
864 |
!
|
|
865 |
|
29
|
866 |
retValSignature
|
255
|
867 |
^ self class retValSpecFromSignature:signature in:nil
|
29
|
868 |
|
255
|
869 |
"Modified: / 8.1.1998 / 19:06:40 / cg"
|
29
|
870 |
!
|
|
871 |
|
123
|
872 |
returnType
|
378
|
873 |
"/ ^ returnType
|
|
874 |
^ self class typeFromSignature:signature in:nil.
|
|
875 |
|
|
876 |
"Modified: / 16.10.1998 / 00:17:43 / cg"
|
123
|
877 |
!
|
|
878 |
|
322
|
879 |
returnTypeClass
|
378
|
880 |
|cls returnType|
|
322
|
881 |
|
378
|
882 |
(returnType := self returnType) isNil ifTrue:[
|
506
|
883 |
self halt.
|
322
|
884 |
].
|
|
885 |
cls := Java at:returnType.
|
|
886 |
cls notNil ifTrue:[^ cls].
|
|
887 |
|
|
888 |
returnType == #void ifTrue:[
|
506
|
889 |
^ nil
|
322
|
890 |
].
|
|
891 |
returnType == #double ifTrue:[
|
506
|
892 |
'warning: no returnTypeClass for double' printCR.
|
334
|
893 |
"/ self halt:'no returnTypeClass for double'.
|
506
|
894 |
^ nil
|
322
|
895 |
].
|
|
896 |
returnType == #float ifTrue:[
|
506
|
897 |
'warning: no returnTypeClass for float' printCR.
|
334
|
898 |
"/ self halt:'no returnTypeClass for float'.
|
506
|
899 |
^ nil
|
322
|
900 |
].
|
|
901 |
returnType == #long ifTrue:[
|
506
|
902 |
'warning: no returnTypeClass for long' printCR.
|
334
|
903 |
"/ self halt:'no returnTypeClass for long'.
|
506
|
904 |
^ nil
|
334
|
905 |
].
|
|
906 |
returnType == #int ifTrue:[
|
506
|
907 |
'warning: no returnTypeClass for int' printCR.
|
334
|
908 |
"/ self halt:'no returnTypeClass for int'.
|
506
|
909 |
^ nil
|
334
|
910 |
].
|
|
911 |
returnType == #boolean ifTrue:[
|
506
|
912 |
'warning: no returnTypeClass for boolean' printCR.
|
334
|
913 |
"/ self halt:'no returnTypeClass for boolean'.
|
506
|
914 |
^ nil
|
322
|
915 |
].
|
|
916 |
self halt.
|
|
917 |
^ nil
|
|
918 |
|
|
919 |
"Created: / 13.2.1998 / 15:08:26 / cg"
|
378
|
920 |
"Modified: / 16.10.1998 / 00:16:07 / cg"
|
322
|
921 |
!
|
|
922 |
|
116
|
923 |
returnsDouble
|
378
|
924 |
^ self returnType == #double
|
|
925 |
|
|
926 |
"Modified: / 16.10.1998 / 00:18:24 / cg"
|
116
|
927 |
!
|
|
928 |
|
72
|
929 |
returnsLong
|
378
|
930 |
^ self returnType == #long
|
|
931 |
|
|
932 |
"Modified: / 16.10.1998 / 00:18:41 / cg"
|
72
|
933 |
!
|
|
934 |
|
27
|
935 |
returnsVoid
|
378
|
936 |
^ self returnType == #void
|
|
937 |
|
|
938 |
"Modified: / 16.10.1998 / 00:18:53 / cg"
|
27
|
939 |
!
|
|
940 |
|
255
|
941 |
selector
|
378
|
942 |
"/ could theoretically be extracted from my classes
|
|
943 |
"/ methodDictionary via:
|
|
944 |
"/ ^ javaClass methodDictionary keyAtValue:self ifAbsent:nil.
|
|
945 |
|
255
|
946 |
^ selector
|
|
947 |
|
|
948 |
"Created: / 7.1.1998 / 14:05:11 / cg"
|
378
|
949 |
"Modified: / 16.10.1998 / 13:41:06 / cg"
|
255
|
950 |
!
|
|
951 |
|
5
|
952 |
setAccessFlags:flags
|
|
953 |
accessFlags := flags.
|
|
954 |
|
|
955 |
"Created: 16.4.1996 / 11:34:14 / cg"
|
|
956 |
!
|
|
957 |
|
29
|
958 |
setCode:codeBytes maxStack:max_stack maxLocals:max_locals u1:unknown1 u2:unknown2
|
184
|
959 |
"/ javaByteCode := codeBytes.
|
|
960 |
byteCode := codeBytes.
|
252
|
961 |
"/ numStack := max_stack.
|
|
962 |
"/ numLocals := max_locals.
|
|
963 |
super numberOfVars:max_locals.
|
|
964 |
super stackSize:max_stack.
|
5
|
965 |
|
43
|
966 |
"/ self displayString printNL.
|
|
967 |
"/ ' nStack: ' print. numStack print.
|
|
968 |
"/ ' nLocal: ' print. numLocals print.
|
|
969 |
"/ ' u1: ' print. unknown1 print.
|
|
970 |
"/ ' u2: ' print. unknown2 printNL.
|
29
|
971 |
|
184
|
972 |
"Modified: 1.8.1997 / 00:08:32 / cg"
|
5
|
973 |
!
|
|
974 |
|
|
975 |
setJavaClass:aJavaClass
|
|
976 |
javaClass := aJavaClass
|
|
977 |
|
|
978 |
"Modified: 16.4.1996 / 12:36:27 / cg"
|
|
979 |
"Created: 16.4.1996 / 15:28:15 / cg"
|
|
980 |
!
|
|
981 |
|
90
|
982 |
setLineNumberTable:anArrayOfPCtoLineAssociations
|
|
983 |
"since this uses up lots of memory, compress it"
|
|
984 |
|
|
985 |
|allBytes allWords idx|
|
|
986 |
|
|
987 |
allBytes := allWords := true.
|
|
988 |
|
|
989 |
anArrayOfPCtoLineAssociations do:[:assoc |
|
252
|
990 |
assoc key > 255 ifTrue:[
|
|
991 |
allBytes := false.
|
|
992 |
assoc key > 16rFFFF ifTrue:[
|
|
993 |
allWords := false.
|
|
994 |
].
|
|
995 |
].
|
|
996 |
assoc value > 255 ifTrue:[
|
|
997 |
allBytes := false.
|
|
998 |
assoc value > 16rFFFF ifTrue:[
|
|
999 |
allWords := false
|
|
1000 |
].
|
|
1001 |
].
|
90
|
1002 |
].
|
|
1003 |
allBytes ifTrue:[
|
252
|
1004 |
lineNumberTable := ByteArray new:(anArrayOfPCtoLineAssociations size * 2).
|
90
|
1005 |
] ifFalse:[
|
252
|
1006 |
allWords ifTrue:[
|
|
1007 |
lineNumberTable := WordArray new:(anArrayOfPCtoLineAssociations size * 2).
|
|
1008 |
] ifFalse:[
|
|
1009 |
lineNumberTable := Array new:(anArrayOfPCtoLineAssociations size * 2).
|
|
1010 |
]
|
90
|
1011 |
].
|
|
1012 |
|
|
1013 |
idx := 1.
|
|
1014 |
anArrayOfPCtoLineAssociations do:[:assoc |
|
252
|
1015 |
lineNumberTable at:idx put:assoc key.
|
|
1016 |
lineNumberTable at:idx+1 put:assoc value.
|
|
1017 |
idx := idx + 2.
|
90
|
1018 |
].
|
5
|
1019 |
|
|
1020 |
"Created: 16.4.1996 / 12:34:04 / cg"
|
|
1021 |
"Modified: 16.4.1996 / 12:49:06 / cg"
|
|
1022 |
!
|
|
1023 |
|
50
|
1024 |
setLocalVariableTable:anArray
|
83
|
1025 |
localVariableTable := anArray.
|
50
|
1026 |
!
|
|
1027 |
|
252
|
1028 |
setName:nameString signature:signatureString
|
|
1029 |
selector := (nameString , signatureString) asSymbol.
|
|
1030 |
self setSignature:signatureString
|
5
|
1031 |
!
|
|
1032 |
|
|
1033 |
setSignature:aString
|
378
|
1034 |
|numArgs tooManyArgs returnType|
|
275
|
1035 |
|
29
|
1036 |
signature := aString asSymbol.
|
|
1037 |
|
275
|
1038 |
numArgs := self class numArgsFromSignature:aString.
|
|
1039 |
(tooManyArgs := (numArgs > self class maxNumberOfArguments)) ifTrue:[
|
506
|
1040 |
numArgs := 0.
|
275
|
1041 |
].
|
|
1042 |
self numberOfArgs:numArgs.
|
255
|
1043 |
returnType := self class typeFromSignature:aString in:nil.
|
27
|
1044 |
|
252
|
1045 |
"/ for the convenience of the VM, also mirror the return type in
|
|
1046 |
"/ the flags ...
|
|
1047 |
|
|
1048 |
returnType == #void ifTrue:[
|
506
|
1049 |
accessFlags := accessFlags bitOr:R_VOID
|
252
|
1050 |
] ifFalse:[
|
506
|
1051 |
returnType == #long ifTrue:[
|
|
1052 |
accessFlags := accessFlags bitOr:R_LONG
|
|
1053 |
] ifFalse:[
|
|
1054 |
returnType == #double ifTrue:[
|
|
1055 |
accessFlags := accessFlags bitOr:R_DOUBLE
|
|
1056 |
]
|
|
1057 |
]
|
252
|
1058 |
].
|
275
|
1059 |
tooManyArgs ifTrue:[
|
506
|
1060 |
^ ArgumentSignal
|
|
1061 |
raiseRequestWith:self
|
|
1062 |
errorString:'too many args in method'
|
275
|
1063 |
].
|
252
|
1064 |
|
255
|
1065 |
"Created: / 16.4.1996 / 11:34:29 / cg"
|
378
|
1066 |
"Modified: / 16.10.1998 / 00:17:12 / cg"
|
27
|
1067 |
!
|
|
1068 |
|
|
1069 |
signature
|
|
1070 |
^ signature
|
5
|
1071 |
|
|
1072 |
"Created: 16.4.1996 / 11:34:29 / cg"
|
31
|
1073 |
!
|
|
1074 |
|
|
1075 |
source
|
75
|
1076 |
|classSource|
|
31
|
1077 |
|
252
|
1078 |
"/ self isNative ifTrue:[
|
|
1079 |
"/ ^ 'native method'
|
|
1080 |
"/ ].
|
220
|
1081 |
|
169
|
1082 |
ForceByteCodeDisplay == true ifTrue:[
|
255
|
1083 |
^ self decompiledBytecode
|
169
|
1084 |
].
|
|
1085 |
|
75
|
1086 |
lineNumberTable notNil ifTrue:[
|
255
|
1087 |
classSource := javaClass source.
|
|
1088 |
classSource notNil ifTrue:[^ classSource].
|
75
|
1089 |
].
|
|
1090 |
|
|
1091 |
^ self decompiledSource
|
169
|
1092 |
|
252
|
1093 |
"Modified: / 4.1.1998 / 13:48:35 / cg"
|
31
|
1094 |
!
|
|
1095 |
|
|
1096 |
sourceFilename
|
|
1097 |
^ javaClass sourceFile
|
175
|
1098 |
!
|
|
1099 |
|
|
1100 |
sourceLineNumber
|
|
1101 |
ForceByteCodeDisplay == true ifTrue:[
|
252
|
1102 |
^ 1
|
175
|
1103 |
].
|
|
1104 |
|
|
1105 |
lineNumberTable notNil ifTrue:[
|
252
|
1106 |
^ lineNumberTable at:2
|
175
|
1107 |
].
|
|
1108 |
|
|
1109 |
^ 1
|
|
1110 |
|
|
1111 |
"Created: 30.7.1997 / 15:40:45 / cg"
|
|
1112 |
"Modified: 30.7.1997 / 15:46:12 / cg"
|
8
|
1113 |
! !
|
|
1114 |
|
255
|
1115 |
!JavaMethod methodsFor:'debugging'!
|
|
1116 |
|
|
1117 |
breakPoint
|
|
1118 |
Debugger enter:thisContext sender withMessage:'breakpoint'
|
|
1119 |
|
|
1120 |
"Modified: / 9.1.1998 / 23:01:17 / cg"
|
|
1121 |
!
|
|
1122 |
|
|
1123 |
clearBreakPoint
|
449
|
1124 |
self hasCode ifTrue:[
|
506
|
1125 |
MessageTracer unwrapMethod:self
|
449
|
1126 |
].
|
|
1127 |
accessFlags := (accessFlags bitClear:A_BREAKPOINT).
|
|
1128 |
|
|
1129 |
"Modified: / 13.11.1998 / 23:31:00 / cg"
|
255
|
1130 |
!
|
|
1131 |
|
257
|
1132 |
isCounting
|
|
1133 |
^ false.
|
|
1134 |
|
|
1135 |
"Created: / 12.1.1998 / 20:02:23 / cg"
|
|
1136 |
!
|
|
1137 |
|
|
1138 |
isCountingMemoryUsage
|
|
1139 |
^ false.
|
|
1140 |
|
|
1141 |
"Created: / 12.1.1998 / 20:03:22 / cg"
|
|
1142 |
!
|
|
1143 |
|
255
|
1144 |
setBreakPoint
|
449
|
1145 |
self hasCode ifTrue:[
|
506
|
1146 |
MessageTracer trapMethod:self
|
449
|
1147 |
].
|
|
1148 |
accessFlags := (accessFlags bitOr:A_BREAKPOINT).
|
|
1149 |
|
|
1150 |
"Modified: / 13.11.1998 / 23:30:45 / cg"
|
257
|
1151 |
!
|
|
1152 |
|
|
1153 |
setTraceFullPoint
|
|
1154 |
"not yet implemented"
|
|
1155 |
|
|
1156 |
"Modified: / 9.1.1998 / 23:01:17 / cg"
|
|
1157 |
"Created: / 12.1.1998 / 20:04:45 / cg"
|
|
1158 |
!
|
|
1159 |
|
|
1160 |
setTracePoint
|
|
1161 |
"not yet implemented"
|
|
1162 |
|
|
1163 |
"Modified: / 9.1.1998 / 23:01:17 / cg"
|
|
1164 |
"Created: / 12.1.1998 / 20:04:02 / cg"
|
|
1165 |
!
|
|
1166 |
|
|
1167 |
setTraceSenderPoint
|
|
1168 |
"not yet implemented"
|
|
1169 |
|
|
1170 |
"Modified: / 9.1.1998 / 23:01:17 / cg"
|
|
1171 |
"Created: / 12.1.1998 / 20:04:35 / cg"
|
|
1172 |
!
|
|
1173 |
|
|
1174 |
startCounting
|
|
1175 |
"not yet implemented"
|
|
1176 |
|
|
1177 |
"Modified: / 9.1.1998 / 23:01:17 / cg"
|
|
1178 |
"Created: / 12.1.1998 / 20:05:01 / cg"
|
|
1179 |
!
|
|
1180 |
|
|
1181 |
startCountingMemoryUsage
|
|
1182 |
"not yet implemented"
|
|
1183 |
|
|
1184 |
"Modified: / 9.1.1998 / 23:01:17 / cg"
|
|
1185 |
"Created: / 12.1.1998 / 20:05:04 / cg"
|
|
1186 |
!
|
|
1187 |
|
|
1188 |
startTiming
|
|
1189 |
"not yet implemented"
|
|
1190 |
|
|
1191 |
"Modified: / 9.1.1998 / 23:01:17 / cg"
|
|
1192 |
"Created: / 12.1.1998 / 20:04:57 / cg"
|
255
|
1193 |
! !
|
|
1194 |
|
18
|
1195 |
!JavaMethod methodsFor:'decompiling'!
|
|
1196 |
|
175
|
1197 |
decompileSourceTo:aStream
|
252
|
1198 |
"/ self isNative ifFalse:[
|
|
1199 |
"/ self isAbstract ifFalse:[
|
506
|
1200 |
aStream nextPutAll:'// '; cr.
|
|
1201 |
aStream nextPutAll:'// decompiled source'; cr.
|
|
1202 |
aStream nextPutAll:'// '; cr.
|
|
1203 |
aStream cr.
|
|
1204 |
SignalSet anySignal handle:[:ex |
|
|
1205 |
ex signal == Object haltSignal ifTrue:[ex reject].
|
|
1206 |
ex signal == MessageTracer breakpointSignal ifTrue:[ex reject].
|
|
1207 |
ex signal == Signal noHandlerSignal ifTrue:[ex reject].
|
|
1208 |
|
|
1209 |
aStream nextPutAll:'error while decompiling:'.
|
|
1210 |
aStream cr; cr; spaces:4.
|
|
1211 |
aStream nextPutAll:ex errorString.
|
|
1212 |
aStream cr.
|
|
1213 |
aStream nextPutAll:ex suspendedContext printString.
|
|
1214 |
aStream cr.
|
|
1215 |
aStream nextPutAll:ex suspendedContext sender printString.
|
|
1216 |
aStream cr.
|
|
1217 |
aStream nextPutAll:ex suspendedContext sender sender printString.
|
|
1218 |
aStream cr.
|
|
1219 |
aStream nextPutAll:ex suspendedContext sender sender sender printString.
|
|
1220 |
aStream cr.
|
|
1221 |
aStream nextPutAll:ex suspendedContext sender sender sender sender printString.
|
|
1222 |
aStream cr.
|
|
1223 |
aStream nextPutAll:ex suspendedContext sender sender sender sender sender printString.
|
|
1224 |
aStream cr.
|
|
1225 |
|
|
1226 |
JavaDecompiler decompile:self to:aStream.
|
|
1227 |
ex return
|
|
1228 |
] do:[
|
|
1229 |
aStream nextPutAll:(JavaDeparser decompile:self).
|
|
1230 |
].
|
252
|
1231 |
"/ ].
|
|
1232 |
"/ ].
|
18
|
1233 |
|
252
|
1234 |
"Created: / 30.7.1997 / 16:28:09 / cg"
|
404
|
1235 |
"Modified: / 20.10.1998 / 10:01:08 / cg"
|
175
|
1236 |
!
|
|
1237 |
|
|
1238 |
decompiler
|
|
1239 |
^ JavaDecompiler
|
|
1240 |
|
|
1241 |
"Created: 30.7.1997 / 16:36:48 / cg"
|
261
|
1242 |
!
|
|
1243 |
|
449
|
1244 |
isMethod
|
|
1245 |
"return true, if the receiver is some kind of method;
|
|
1246 |
true returned here - the method is redefined from Object."
|
|
1247 |
|
|
1248 |
^ true
|
|
1249 |
|
|
1250 |
"Created: / 13.11.1998 / 23:57:40 / cg"
|
|
1251 |
!
|
|
1252 |
|
261
|
1253 |
originalMethod
|
|
1254 |
^ self
|
|
1255 |
|
|
1256 |
"Created: / 13.1.1998 / 15:03:05 / cg"
|
18
|
1257 |
! !
|
|
1258 |
|
277
|
1259 |
!JavaMethod methodsFor:'error handling'!
|
|
1260 |
|
|
1261 |
invalidByteCode
|
|
1262 |
self isAbstract ifTrue:[
|
506
|
1263 |
^ AbstractMethodInvokationSignal raise.
|
277
|
1264 |
].
|
309
|
1265 |
((self class numArgsFromSignature:signature) > self class maxNumberOfArguments) ifTrue:[
|
|
1266 |
^ self error:'method cannot be executed - too many args'
|
|
1267 |
].
|
277
|
1268 |
^ super invalidByteCode
|
|
1269 |
|
|
1270 |
"Created: / 27.1.1998 / 21:48:01 / cg"
|
|
1271 |
"Modified: / 27.1.1998 / 21:50:19 / cg"
|
378
|
1272 |
!
|
|
1273 |
|
|
1274 |
invalidMethodRef
|
|
1275 |
self halt.
|
|
1276 |
^ nil.
|
|
1277 |
|
|
1278 |
"Modified: / 27.1.1998 / 21:50:19 / cg"
|
|
1279 |
"Created: / 16.10.1998 / 11:27:21 / cg"
|
594
|
1280 |
!
|
|
1281 |
|
|
1282 |
nullClassPointer
|
|
1283 |
JavaVM throwClassNotFoundException
|
277
|
1284 |
! !
|
|
1285 |
|
118
|
1286 |
!JavaMethod methodsFor:'methodref interchangability'!
|
|
1287 |
|
|
1288 |
method
|
|
1289 |
^ self
|
|
1290 |
! !
|
|
1291 |
|
148
|
1292 |
!JavaMethod methodsFor:'misc'!
|
|
1293 |
|
378
|
1294 |
fromMethod:aJavaMethod
|
|
1295 |
"copy values from another javaMethod"
|
149
|
1296 |
|
378
|
1297 |
flags := aJavaMethod flags.
|
|
1298 |
byteCode := aJavaMethod byteCode.
|
|
1299 |
accessFlags := aJavaMethod accessFlags.
|
|
1300 |
selector := aJavaMethod selector.
|
|
1301 |
javaClass := aJavaMethod javaClass.
|
|
1302 |
signature := aJavaMethod signature.
|
|
1303 |
lineNumberTable := aJavaMethod lineNumberTable.
|
|
1304 |
localVariableTable := aJavaMethod localVariableTable.
|
148
|
1305 |
|
378
|
1306 |
"Modified: / 16.10.1998 / 01:27:19 / cg"
|
255
|
1307 |
!
|
252
|
1308 |
|
255
|
1309 |
updateClassRefsFrom:oldClass to:newClass
|
|
1310 |
javaClass == oldClass ifTrue:[
|
506
|
1311 |
"/ invalidate
|
|
1312 |
byteCode := nil.
|
255
|
1313 |
]
|
252
|
1314 |
|
255
|
1315 |
"Created: / 6.1.1998 / 18:19:48 / cg"
|
252
|
1316 |
! !
|
|
1317 |
|
8
|
1318 |
!JavaMethod methodsFor:'printing & storing'!
|
|
1319 |
|
29
|
1320 |
displayString
|
168
|
1321 |
javaClass isNil ifTrue:[
|
611
|
1322 |
^ self class name , '(???)'
|
168
|
1323 |
].
|
611
|
1324 |
^ self class name , '(' , javaClass displayString , '::' , self signatureName , ')'
|
423
|
1325 |
|
611
|
1326 |
"Modified: / 25.9.1999 / 23:04:01 / cg"
|
29
|
1327 |
!
|
|
1328 |
|
252
|
1329 |
printStringForBrowserWithSelector:dummySelector
|
43
|
1330 |
"/ self isStatic ifTrue:[
|
|
1331 |
"/ ^ 'static ' , self signatureName
|
|
1332 |
"/ ].
|
168
|
1333 |
"/ self isBreakpointed ifTrue:[
|
|
1334 |
"/ ^ (LabelAndIcon '!! ' , self signatureName
|
|
1335 |
"/ ].
|
175
|
1336 |
|
252
|
1337 |
self name = #'<init>' ifTrue:[
|
506
|
1338 |
^ self class specTextFromSignature:signature withName:(javaClass lastName).
|
166
|
1339 |
].
|
175
|
1340 |
^ self signatureNameText
|
166
|
1341 |
|
423
|
1342 |
"Modified: / 5.11.1998 / 19:44:55 / cg"
|
10
|
1343 |
!
|
|
1344 |
|
118
|
1345 |
shortDisplayString
|
|
1346 |
^ javaClass name , '::' , self signatureNameWithoutReturnType
|
|
1347 |
!
|
|
1348 |
|
10
|
1349 |
signatureName
|
|
1350 |
"return a string to be used when browsing"
|
|
1351 |
|
255
|
1352 |
^ self class specFromSignature:signature withName:(self name) in:nil
|
|
1353 |
|
|
1354 |
"Modified: / 8.1.1998 / 19:15:33 / cg"
|
113
|
1355 |
!
|
|
1356 |
|
164
|
1357 |
signatureNameFor:name withArgsIn:aPackage
|
|
1358 |
"return a string to be used when decompiling"
|
|
1359 |
|
|
1360 |
^ self class specWithArgsFromSignature:signature withName:name in:aPackage
|
|
1361 |
|
|
1362 |
"Created: 25.3.1997 / 18:49:45 / cg"
|
|
1363 |
!
|
|
1364 |
|
142
|
1365 |
signatureNameIn:aPackage
|
|
1366 |
"return a string to be used when browsing"
|
|
1367 |
|
252
|
1368 |
^ self class specFromSignature:signature withName:(self name) in:aPackage
|
142
|
1369 |
|
|
1370 |
"Created: 18.3.1997 / 11:11:01 / cg"
|
|
1371 |
!
|
|
1372 |
|
175
|
1373 |
signatureNameText
|
|
1374 |
"return a text to be used when browsing"
|
|
1375 |
|
252
|
1376 |
^ self class specTextFromSignature:signature withName:(self name)
|
175
|
1377 |
|
|
1378 |
"Created: 30.7.1997 / 14:40:29 / cg"
|
|
1379 |
!
|
|
1380 |
|
189
|
1381 |
signatureNameTextFor:name withArgsIn:aPackage
|
|
1382 |
"return a text to be used when decompiling"
|
|
1383 |
|
|
1384 |
^ self class specTextWithArgsFromSignature:signature withName:name in:aPackage
|
|
1385 |
|
|
1386 |
"Created: 25.3.1997 / 18:49:45 / cg"
|
|
1387 |
"Modified: 1.8.1997 / 10:44:28 / cg"
|
|
1388 |
!
|
|
1389 |
|
255
|
1390 |
signatureNameWithArgNames:argNames
|
|
1391 |
"return a string to be used when browsing"
|
|
1392 |
|
|
1393 |
|myName|
|
|
1394 |
|
|
1395 |
myName := self name.
|
|
1396 |
myName = '<init>' ifTrue:[
|
506
|
1397 |
myName := javaClass name
|
255
|
1398 |
].
|
|
1399 |
^ self class specFromSignature:signature withName:myName argNames:argNames in:nil
|
|
1400 |
|
|
1401 |
"Created: / 8.1.1998 / 21:04:03 / cg"
|
|
1402 |
"Modified: / 8.1.1998 / 21:22:38 / cg"
|
|
1403 |
!
|
|
1404 |
|
|
1405 |
signatureNameWithArgNames:argNames in:package
|
|
1406 |
"return a string to be used when browsing"
|
|
1407 |
|
|
1408 |
|myName|
|
|
1409 |
|
|
1410 |
myName := self name.
|
|
1411 |
myName = '<init>' ifTrue:[
|
506
|
1412 |
myName := javaClass name
|
255
|
1413 |
].
|
|
1414 |
^ self class specFromSignature:signature withName:myName argNames:argNames in:package
|
|
1415 |
|
|
1416 |
"Modified: / 8.1.1998 / 21:05:52 / cg"
|
|
1417 |
"Created: / 8.1.1998 / 21:23:03 / cg"
|
|
1418 |
!
|
|
1419 |
|
154
|
1420 |
signatureNameWithArgsIn:aPackage
|
|
1421 |
"return a string to be used when browsing"
|
|
1422 |
|
252
|
1423 |
^ self class specWithArgsFromSignature:signature withName:(self name) in:aPackage
|
154
|
1424 |
|
|
1425 |
"Created: 20.3.1997 / 12:44:17 / cg"
|
|
1426 |
!
|
|
1427 |
|
113
|
1428 |
signatureNameWithoutReturnType
|
|
1429 |
"return a string to be used when browsing"
|
|
1430 |
|
252
|
1431 |
^ self class argSpecFromSignature:signature withName:(self name)
|
113
|
1432 |
|
8
|
1433 |
! !
|
|
1434 |
|
|
1435 |
!JavaMethod methodsFor:'queries'!
|
|
1436 |
|
111
|
1437 |
handlerFor:anException at:pc
|
611
|
1438 |
"return an exceptionHandlers pc, for an exception of the given type,
|
|
1439 |
occurring at pc. Returns nil, if there is none."
|
|
1440 |
|
|
1441 |
|handlerTable|
|
|
1442 |
|
|
1443 |
(handlerTable := self exceptionHandlerTable) isNil ifTrue:[^ nil].
|
|
1444 |
|
|
1445 |
handlerTable do:[:entry |
|
|
1446 |
|hpc|
|
|
1447 |
|
|
1448 |
hpc := entry handlerPCFor:anException at:pc in:self.
|
|
1449 |
hpc notNil ifTrue:[^ hpc].
|
|
1450 |
].
|
|
1451 |
|
378
|
1452 |
^ nil
|
48
|
1453 |
|
611
|
1454 |
"Created: / 16.10.1998 / 01:18:40 / cg"
|
|
1455 |
"Modified: / 25.9.1999 / 23:07:01 / cg"
|
31
|
1456 |
!
|
|
1457 |
|
127
|
1458 |
hasResource
|
|
1459 |
^ false
|
|
1460 |
!
|
|
1461 |
|
19
|
1462 |
isAbstract
|
252
|
1463 |
^ (accessFlags bitAnd:A_ABSTRACT) ~~ 0
|
19
|
1464 |
!
|
|
1465 |
|
80
|
1466 |
isBreakpointed
|
256
|
1467 |
^ (accessFlags bitAnd:A_BREAKPOINT) ~~ 0
|
|
1468 |
|
|
1469 |
"Modified: / 11.1.1998 / 13:28:43 / cg"
|
80
|
1470 |
!
|
|
1471 |
|
19
|
1472 |
isFinal
|
252
|
1473 |
^ (accessFlags bitAnd:A_FINAL) ~~ 0
|
19
|
1474 |
!
|
|
1475 |
|
175
|
1476 |
isIgnored
|
|
1477 |
"not really a java attribute;
|
|
1478 |
added to allow browsing"
|
|
1479 |
|
|
1480 |
^ false.
|
|
1481 |
|
|
1482 |
"Created: 30.7.1997 / 15:34:33 / cg"
|
|
1483 |
!
|
|
1484 |
|
625
|
1485 |
isJavaClassRef
|
|
1486 |
^ false
|
|
1487 |
|
|
1488 |
"Created: / 9.11.1999 / 17:16:20 / cg"
|
|
1489 |
!
|
|
1490 |
|
431
|
1491 |
isJavaMethod
|
|
1492 |
^ true
|
|
1493 |
|
|
1494 |
"Created: / 10.11.1998 / 18:24:51 / cg"
|
|
1495 |
!
|
|
1496 |
|
19
|
1497 |
isNative
|
252
|
1498 |
^ (accessFlags bitAnd:A_NATIVE) ~~ 0
|
19
|
1499 |
!
|
|
1500 |
|
|
1501 |
isPrivate
|
252
|
1502 |
^ (accessFlags bitAnd:A_PRIVATE) ~~ 0
|
19
|
1503 |
!
|
|
1504 |
|
|
1505 |
isProtected
|
252
|
1506 |
^ (accessFlags bitAnd:A_PROTECTED) ~~ 0
|
19
|
1507 |
!
|
|
1508 |
|
|
1509 |
isPublic
|
252
|
1510 |
^ (accessFlags bitAnd:A_PUBLIC) ~~ 0
|
19
|
1511 |
!
|
|
1512 |
|
|
1513 |
isStatic
|
252
|
1514 |
^ (accessFlags bitAnd:A_STATIC) ~~ 0
|
19
|
1515 |
!
|
|
1516 |
|
|
1517 |
isSynchronized
|
252
|
1518 |
^ (accessFlags bitAnd:A_SYNCHRONIZED) ~~ 0
|
18
|
1519 |
!
|
|
1520 |
|
256
|
1521 |
isTraced
|
|
1522 |
^ false
|
|
1523 |
|
|
1524 |
"Modified: / 11.1.1998 / 13:28:43 / cg"
|
|
1525 |
"Created: / 11.1.1998 / 13:38:11 / cg"
|
|
1526 |
!
|
|
1527 |
|
8
|
1528 |
isUnloaded
|
|
1529 |
^ false
|
18
|
1530 |
!
|
|
1531 |
|
256
|
1532 |
isWrapped
|
|
1533 |
^ self isBreakpointed
|
|
1534 |
|
|
1535 |
"Modified: / 11.1.1998 / 13:28:43 / cg"
|
|
1536 |
"Created: / 11.1.1998 / 13:38:04 / cg"
|
|
1537 |
!
|
|
1538 |
|
31
|
1539 |
lineNumberForPC:pc
|
75
|
1540 |
|last num text classSource|
|
31
|
1541 |
|
|
1542 |
num := nil.
|
|
1543 |
|
207
|
1544 |
ForceByteCodeDisplay == true ifFalse:[
|
169
|
1545 |
|
506
|
1546 |
lineNumberTable notNil ifTrue:[
|
|
1547 |
classSource := javaClass source.
|
|
1548 |
classSource notNil ifTrue:[
|
|
1549 |
lineNumberTable pairWiseDo:[:lPc :lNr |
|
|
1550 |
lPc >= pc ifTrue:[
|
|
1551 |
lPc == pc ifTrue:[^ lNr].
|
|
1552 |
last isNil ifTrue:[^ lNr].
|
|
1553 |
^ last.
|
|
1554 |
].
|
|
1555 |
last := lNr.
|
|
1556 |
].
|
|
1557 |
last notNil ifTrue:[
|
|
1558 |
^ last
|
|
1559 |
].
|
|
1560 |
^ lineNumberTable at:2
|
|
1561 |
].
|
|
1562 |
].
|
46
|
1563 |
].
|
31
|
1564 |
|
46
|
1565 |
"/ decompile and look which line the pc falls into
|
209
|
1566 |
|
|
1567 |
ForceByteCodeDisplay == true ifTrue:[
|
506
|
1568 |
text := self decompiledBytecode asCollectionOfLines.
|
209
|
1569 |
] ifFalse:[
|
506
|
1570 |
text := self decompiledSource asCollectionOfLines.
|
209
|
1571 |
].
|
31
|
1572 |
|
46
|
1573 |
text keysAndValuesDo:[:lineNr :line |
|
506
|
1574 |
|nr|
|
|
1575 |
|
|
1576 |
(line startsWith:' ') ifFalse:[
|
|
1577 |
nr := Integer readFrom:line onError:0.
|
|
1578 |
nr >= pc ifTrue:[
|
|
1579 |
^ lineNr
|
|
1580 |
]
|
|
1581 |
]
|
31
|
1582 |
].
|
|
1583 |
^ num
|
141
|
1584 |
|
261
|
1585 |
"Modified: / 14.1.1998 / 13:30:54 / cg"
|
31
|
1586 |
!
|
|
1587 |
|
156
|
1588 |
package
|
|
1589 |
^ 'none'
|
|
1590 |
|
|
1591 |
"Created: 5.2.1997 / 11:31:26 / cg"
|
|
1592 |
!
|
|
1593 |
|
428
|
1594 |
quickLineNumberForPC:pc
|
|
1595 |
|last|
|
|
1596 |
|
|
1597 |
lineNumberTable notNil ifTrue:[
|
506
|
1598 |
lineNumberTable pairWiseDo:[:lPc :lNr |
|
|
1599 |
lPc >= pc ifTrue:[
|
|
1600 |
lPc == pc ifTrue:[^ lNr].
|
|
1601 |
last isNil ifTrue:[^ lNr].
|
|
1602 |
^ last.
|
|
1603 |
].
|
|
1604 |
last := lNr.
|
|
1605 |
].
|
|
1606 |
last notNil ifTrue:[
|
|
1607 |
^ last
|
|
1608 |
].
|
|
1609 |
^ lineNumberTable at:2
|
428
|
1610 |
].
|
|
1611 |
^ nil
|
|
1612 |
|
|
1613 |
"Modified: / 14.1.1998 / 13:30:54 / cg"
|
|
1614 |
"Created: / 10.11.1998 / 14:18:22 / cg"
|
|
1615 |
!
|
|
1616 |
|
625
|
1617 |
referencesGlobal:aGlobalName
|
|
1618 |
"return true, if this method refers to a global named aGlobalName"
|
|
1619 |
|
|
1620 |
|walker any|
|
|
1621 |
|
|
1622 |
"/ quick check, if constantPool includes a methodRef for this
|
|
1623 |
"/ selector.
|
|
1624 |
|
|
1625 |
any := false.
|
|
1626 |
self javaClass constantPool do:[:const |
|
|
1627 |
(const isNumber
|
|
1628 |
or:[const isString
|
|
1629 |
or:[const isNil]]) ifFalse:[
|
|
1630 |
const isJavaClass ifTrue:[
|
|
1631 |
any := any or:[const fullName = aGlobalName].
|
|
1632 |
] ifFalse:[
|
|
1633 |
const isJavaClassRef ifTrue:[
|
|
1634 |
any := any or:[const fullName = aGlobalName].
|
|
1635 |
]
|
|
1636 |
].
|
|
1637 |
].
|
|
1638 |
].
|
|
1639 |
any ifFalse:[^ false].
|
|
1640 |
|
|
1641 |
"/ sigh - must extract all accessed literals ...
|
|
1642 |
"/ must deparse the byteCode in order to do this.
|
|
1643 |
|
|
1644 |
walker := JavaByteCodeEnumerator new.
|
|
1645 |
walker
|
|
1646 |
literalAction:
|
|
1647 |
[:pc :slotIndex :const |
|
|
1648 |
|mSel|
|
|
1649 |
|
|
1650 |
(const isNumber
|
|
1651 |
or:[const isString
|
|
1652 |
or:[const isNil]]) ifFalse:[
|
|
1653 |
const isJavaClass ifTrue:[
|
|
1654 |
mSel := const fullName.
|
|
1655 |
] ifFalse:[
|
|
1656 |
const isJavaClassRef ifTrue:[
|
|
1657 |
mSel := const fullName.
|
|
1658 |
]
|
|
1659 |
].
|
|
1660 |
].
|
|
1661 |
mSel notNil ifTrue:[
|
|
1662 |
"/ Transcript showCR:mSel.
|
|
1663 |
mSel = aGlobalName ifTrue:[
|
|
1664 |
^ true
|
|
1665 |
]
|
|
1666 |
].
|
|
1667 |
].
|
|
1668 |
walker decompile:self to:nil.
|
|
1669 |
|
|
1670 |
"Created: / 9.11.1999 / 17:15:46 / cg"
|
|
1671 |
"Modified: / 9.11.1999 / 17:18:02 / cg"
|
|
1672 |
!
|
|
1673 |
|
618
|
1674 |
sends:aSelectorSymbol
|
|
1675 |
"return true, if this method contains a message-send
|
|
1676 |
with aSelectorSymbol as selector."
|
|
1677 |
|
|
1678 |
|walker any|
|
|
1679 |
|
|
1680 |
"/ quick check, if constantPool includes a methodRef for this
|
|
1681 |
"/ selector.
|
|
1682 |
|
|
1683 |
any := false.
|
|
1684 |
self javaClass constantPool do:[:const |
|
|
1685 |
(const isNumber
|
|
1686 |
or:[const isString
|
|
1687 |
or:[const isNil]]) ifFalse:[
|
|
1688 |
const isJavaMethod ifTrue:[
|
|
1689 |
any := any or:[const selector = aSelectorSymbol].
|
|
1690 |
] ifFalse:[
|
|
1691 |
const isJavaMethodRef ifTrue:[
|
|
1692 |
any := any or:[const signature = aSelectorSymbol].
|
|
1693 |
]
|
|
1694 |
].
|
|
1695 |
].
|
|
1696 |
].
|
|
1697 |
any ifFalse:[^ false].
|
|
1698 |
|
625
|
1699 |
"/ sigh - must extract all accessed literals ...
|
|
1700 |
"/ must deparse the byteCode in order to do this.
|
|
1701 |
|
618
|
1702 |
walker := JavaByteCodeEnumerator new.
|
|
1703 |
walker
|
|
1704 |
literalAction:
|
|
1705 |
[:pc :slotIndex :const |
|
|
1706 |
|mSel|
|
|
1707 |
|
|
1708 |
(const isNumber
|
|
1709 |
or:[const isString
|
|
1710 |
or:[const isNil]]) ifFalse:[
|
|
1711 |
const isJavaMethod ifTrue:[
|
|
1712 |
mSel := const selector.
|
|
1713 |
] ifFalse:[
|
|
1714 |
const isJavaMethodRef ifTrue:[
|
|
1715 |
mSel := const signature.
|
|
1716 |
]
|
|
1717 |
].
|
|
1718 |
].
|
|
1719 |
mSel notNil ifTrue:[
|
|
1720 |
"/ Transcript showCR:mSel.
|
|
1721 |
mSel = aSelectorSymbol ifTrue:[
|
|
1722 |
^ true
|
|
1723 |
]
|
|
1724 |
].
|
|
1725 |
].
|
|
1726 |
walker decompile:self to:nil.
|
|
1727 |
|
|
1728 |
"Created: / 9.11.1999 / 15:38:14 / cg"
|
625
|
1729 |
"Modified: / 9.11.1999 / 17:06:03 / cg"
|
618
|
1730 |
!
|
|
1731 |
|
18
|
1732 |
who
|
|
1733 |
"return the class and selector of where I am defined in."
|
|
1734 |
|
64
|
1735 |
|sel|
|
18
|
1736 |
|
252
|
1737 |
javaClass isNil ifTrue:[^ nil].
|
378
|
1738 |
sel := selector.
|
|
1739 |
"/ sel := javaClass methodDictionary keyAtValue:self ifAbsent:nil.
|
64
|
1740 |
sel isNil ifTrue:[^ nil].
|
129
|
1741 |
^ Method::MethodWhoInfo class:javaClass selector:sel.
|
378
|
1742 |
|
|
1743 |
"Modified: / 16.10.1998 / 13:42:10 / cg"
|
5
|
1744 |
! !
|
|
1745 |
|
154
|
1746 |
!JavaMethod methodsFor:'signature parsing'!
|
|
1747 |
|
255
|
1748 |
XXXspecWithArgsFromSignature:aSignature withName:name in:aPackage
|
154
|
1749 |
"given a signature, return a spec with args"
|
|
1750 |
|
|
1751 |
|s argSpec retvalSpec|
|
|
1752 |
|
|
1753 |
s := aSignature readStream.
|
|
1754 |
s next ~~ $( ifTrue:[self halt. ^ name].
|
|
1755 |
|
|
1756 |
argSpec := self argSpecWithArgsFromStream:s in:aPackage.
|
|
1757 |
|
|
1758 |
s next ~~ $) ifTrue:[self halt. ^ name].
|
|
1759 |
|
|
1760 |
retvalSpec := self retvalSpecFromStream:s in:aPackage.
|
|
1761 |
|
|
1762 |
^ retvalSpec , ' ' , name , ' (' , argSpec , ')'
|
|
1763 |
|
|
1764 |
"
|
|
1765 |
JavaMethod specFromSignature:'(LObject;)V' withName:'foo'
|
|
1766 |
JavaMethod specFromSignature:'(BB)S' withName:'foo'
|
|
1767 |
"
|
|
1768 |
|
255
|
1769 |
"Created: / 8.1.1998 / 19:17:58 / cg"
|
154
|
1770 |
! !
|
|
1771 |
|
129
|
1772 |
!JavaMethod class methodsFor:'documentation'!
|
2
|
1773 |
|
|
1774 |
version
|
625
|
1775 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethod.st,v 1.90 1999/11/09 16:58:38 cg Exp $'
|
2
|
1776 |
! !
|
8
|
1777 |
JavaMethod initialize!
|