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