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