454
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
|
6
|
14 |
Object subclass:#JavaDecompiler
|
454
|
15 |
instanceVariableNames:'code pc javaMethod outStream classToCompileFor isStaticMethod
|
|
16 |
lastConstIndex lastConstant accessedInstvars modifiedInstvars
|
|
17 |
accessedStaticVars modifiedStaticVars sentMessages'
|
6
|
18 |
classVariableNames:'DecoderTable'
|
|
19 |
poolDictionaries:''
|
620
|
20 |
category:'Java-Support-Decompiling'
|
6
|
21 |
!
|
|
22 |
|
454
|
23 |
!JavaDecompiler class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
This software is furnished under a license and may be used
|
|
31 |
only in accordance with the terms of that license and with the
|
|
32 |
inclusion of the above copyright notice. This software may not
|
|
33 |
be provided or otherwise made available to, or used by, any
|
|
34 |
other person. No title to or ownership of the software is
|
|
35 |
hereby transferred.
|
|
36 |
"
|
|
37 |
|
|
38 |
!
|
|
39 |
|
|
40 |
examples
|
|
41 |
"
|
|
42 |
|
|
43 |
[exBegin]
|
|
44 |
|m|
|
|
45 |
|
|
46 |
m := JAVA::java::lang::Object compiledMethodAt:#'toString()Ljava/lang/String;'.
|
|
47 |
JavaDecompiler decompile:m to:Transcript.
|
|
48 |
[exEnd]
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
[exBegin]
|
|
53 |
|m|
|
|
54 |
|
|
55 |
m := JAVA::java::lang::Object compiledMethodAt:#'toString()Ljava/lang/String;'.
|
|
56 |
JavaDecompiler decompile:m to:nil.
|
|
57 |
[exEnd]
|
|
58 |
|
|
59 |
"
|
|
60 |
|
|
61 |
! !
|
6
|
62 |
|
129
|
63 |
!JavaDecompiler class methodsFor:'initialization'!
|
6
|
64 |
|
|
65 |
initialize
|
|
66 |
DecoderTable := #(
|
|
67 |
(nop) "/ 0
|
|
68 |
(aconst_null) "/ 1
|
|
69 |
(iconst_m1) "/ 2
|
|
70 |
(iconst_0) "/ 3
|
|
71 |
(iconst_1) "/ 4
|
|
72 |
(iconst_2) "/ 5
|
|
73 |
(iconst_3) "/ 6
|
|
74 |
(iconst_4) "/ 7
|
|
75 |
(iconst_5) "/ 8
|
|
76 |
(lconst_0) "/ 9
|
|
77 |
|
|
78 |
(lconst_1) "/ 10
|
|
79 |
(fconst_0) "/ 11
|
|
80 |
(fconst_1) "/ 12
|
|
81 |
(fconst_2) "/ 13
|
|
82 |
(dconst_0) "/ 14
|
|
83 |
(dconst_1) "/ 15
|
|
84 |
(bipush signedByte) "/ 16
|
|
85 |
(sipush signedShort) "/ 17
|
454
|
86 |
(ldc1 constIndexByte remember_ldc1) "/ 18
|
|
87 |
(ldc2 constIndexShort remember_ldc2) "/ 19
|
6
|
88 |
|
454
|
89 |
(ldc2w constIndexShort remember_ldc2w) "/ 20
|
6
|
90 |
(iload localIndexByte) "/ 21
|
|
91 |
(lload localIndexByte) "/ 22
|
|
92 |
(fload localIndexByte) "/ 23
|
|
93 |
(dload localIndexByte) "/ 24
|
|
94 |
(aload localIndexByte) "/ 25
|
24
|
95 |
(iload_0) "/ 26
|
6
|
96 |
(iload_1) "/ 27
|
|
97 |
(iload_2) "/ 28
|
|
98 |
(iload_3) "/ 29
|
|
99 |
|
|
100 |
(lload_0) "/ 30
|
|
101 |
(lload_1) "/ 31
|
|
102 |
(lload_2) "/ 32
|
|
103 |
(lload_3) "/ 33
|
|
104 |
(fload_0) "/ 34
|
|
105 |
(fload_1) "/ 35
|
|
106 |
(fload_2) "/ 36
|
|
107 |
(fload_3) "/ 37
|
|
108 |
(dload_0) "/ 38
|
|
109 |
(dload_1) "/ 39
|
|
110 |
|
|
111 |
(dload_2) "/ 40
|
|
112 |
(dload_3) "/ 41
|
|
113 |
(aload_0) "/ 42
|
|
114 |
(aload_1) "/ 43
|
|
115 |
(aload_2) "/ 44
|
|
116 |
(aload_3) "/ 45
|
|
117 |
(iaload) "/ 46
|
|
118 |
(laload) "/ 47
|
|
119 |
(faload) "/ 48
|
|
120 |
(daload) "/ 49
|
|
121 |
|
|
122 |
(aaload) "/ 50
|
|
123 |
(baload) "/ 51
|
|
124 |
(caload) "/ 52
|
|
125 |
(saload) "/ 53
|
|
126 |
(istore localIndexByte) "/ 54
|
|
127 |
(lstore localIndexByte) "/ 55
|
|
128 |
(fstore localIndexByte) "/ 56
|
|
129 |
(dstore localIndexByte) "/ 57
|
|
130 |
(astore localIndexByte) "/ 58
|
|
131 |
(istore_0) "/ 59
|
|
132 |
|
|
133 |
(istore_1) "/ 60
|
|
134 |
(istore_2) "/ 61
|
|
135 |
(istore_3) "/ 62
|
|
136 |
(lstore_0) "/ 63
|
|
137 |
(lstore_1) "/ 64
|
|
138 |
(lstore_2) "/ 65
|
|
139 |
(lstore_3) "/ 66
|
|
140 |
(fstore_0) "/ 67
|
|
141 |
(fstore_1) "/ 68
|
|
142 |
(fstore_2) "/ 69
|
|
143 |
|
|
144 |
(fstore_3) "/ 70
|
|
145 |
(dstore_0) "/ 71
|
|
146 |
(dstore_1) "/ 72
|
|
147 |
(dstore_2) "/ 73
|
|
148 |
(dstore_3) "/ 74
|
|
149 |
(astore_0) "/ 75
|
|
150 |
(astore_1) "/ 76
|
|
151 |
(astore_2) "/ 77
|
|
152 |
(astore_3) "/ 78
|
|
153 |
(iastore) "/ 79
|
|
154 |
|
|
155 |
(lastore) "/ 80
|
|
156 |
(fastore) "/ 81
|
|
157 |
(dastore) "/ 82
|
|
158 |
(aastore) "/ 83
|
|
159 |
(bastore) "/ 84
|
|
160 |
(castore) "/ 85
|
|
161 |
(sastore) "/ 86
|
|
162 |
(pop) "/ 87
|
|
163 |
(pop2) "/ 88
|
|
164 |
(dup) "/ 89
|
|
165 |
|
|
166 |
(dup_x1) "/ 90
|
|
167 |
(dup_x2) "/ 91
|
|
168 |
(dup2) "/ 92
|
|
169 |
(dup2_x1) "/ 93
|
|
170 |
(dup2_x2) "/ 94
|
|
171 |
(swap) "/ 95
|
|
172 |
(iadd) "/ 96
|
|
173 |
(ladd) "/ 97
|
|
174 |
(fadd) "/ 98
|
|
175 |
(dadd) "/ 99
|
|
176 |
|
|
177 |
(isub) "/ 100
|
|
178 |
(lsub) "/ 101
|
|
179 |
(fsub) "/ 102
|
|
180 |
(dsub) "/ 103
|
|
181 |
(imul) "/ 104
|
|
182 |
(lmul) "/ 105
|
|
183 |
(fmul) "/ 106
|
|
184 |
(dmul) "/ 107
|
|
185 |
(idiv) "/ 108
|
|
186 |
(ldiv) "/ 109
|
|
187 |
|
|
188 |
(fdiv) "/ 110
|
|
189 |
(ddiv) "/ 111
|
91
|
190 |
"/ (imod) "/ 112 "/ obsolete
|
|
191 |
(irem) "/ 112
|
|
192 |
"/ (lmod) "/ 113 "/ obsolete
|
|
193 |
(lrem) "/ 113
|
|
194 |
"/ (fmod) "/ 114 "/ obsolete
|
|
195 |
(frem) "/ 114
|
|
196 |
"/ (dmod) "/ 115 "/ obsolete
|
|
197 |
(drem) "/ 115
|
6
|
198 |
(ineg) "/ 116
|
|
199 |
(lneg) "/ 117
|
|
200 |
(fneg) "/ 118
|
|
201 |
(dneg) "/ 119
|
|
202 |
|
|
203 |
(ishl) "/ 120
|
|
204 |
(lshl) "/ 121
|
|
205 |
(ishr) "/ 122
|
|
206 |
(lshr) "/ 123
|
|
207 |
(iushr) "/ 124
|
|
208 |
(lushr) "/ 125
|
|
209 |
(iand) "/ 126
|
|
210 |
(land) "/ 127
|
|
211 |
(ior) "/ 128
|
|
212 |
(lor) "/ 129
|
|
213 |
|
|
214 |
(ixor) "/ 130
|
|
215 |
(lxor) "/ 131
|
39
|
216 |
(iinc localIndexByte signedByte) "/ 132
|
68
|
217 |
(i2l) "/ 133
|
44
|
218 |
(i2f) "/ 134
|
52
|
219 |
(i2d) "/ 135
|
44
|
220 |
(l2i) "/ 136
|
6
|
221 |
(l2f) "/ 137
|
|
222 |
(l2d) "/ 138
|
44
|
223 |
(f2i) "/ 139
|
6
|
224 |
|
|
225 |
(f2l) "/ 140
|
|
226 |
(f2d) "/ 141
|
|
227 |
(d2i) "/ 142
|
|
228 |
(d2l) "/ 143
|
|
229 |
(d2f) "/ 144
|
|
230 |
(int2byte) "/ 145
|
|
231 |
(int2char) "/ 146
|
|
232 |
(int2short) "/ 147
|
|
233 |
(lcmp) "/ 148
|
|
234 |
(fcmpl) "/ 149
|
|
235 |
|
|
236 |
(fcmpg) "/ 150
|
|
237 |
(dcmpl) "/ 151
|
|
238 |
(dcmpg) "/ 152
|
|
239 |
(ifeq signedBranchShort) "/ 153
|
|
240 |
(ifne signedBranchShort) "/ 154
|
|
241 |
(iflt signedBranchShort) "/ 155
|
|
242 |
(ifge signedBranchShort) "/ 156
|
|
243 |
(ifgt signedBranchShort) "/ 157
|
|
244 |
(ifle signedBranchShort) "/ 158
|
|
245 |
(if_icmpeq signedBranchShort) "/ 159
|
|
246 |
|
|
247 |
(if_icmpne signedBranchShort) "/ 160
|
|
248 |
(if_icmplt signedBranchShort) "/ 161
|
|
249 |
(if_icmpge signedBranchShort) "/ 162
|
|
250 |
(if_icmpgt signedBranchShort) "/ 163
|
|
251 |
(if_icmple signedBranchShort) "/ 164
|
|
252 |
(if_acmpeq signedBranchShort) "/ 165
|
|
253 |
(if_acmpne signedBranchShort) "/ 166
|
|
254 |
(goto signedBranchShort) "/ 167
|
|
255 |
(jsr signedBranchShort) "/ 168
|
|
256 |
(ret localIndexByte) "/ 169
|
|
257 |
|
|
258 |
(tableswitch tableSwitchBytes) "/ 170
|
|
259 |
(lookupswitch lookupSwitchBytes) "/ 171
|
|
260 |
(ireturn) "/ 172
|
|
261 |
(lreturn) "/ 173
|
|
262 |
(freturn) "/ 174
|
|
263 |
(dreturn) "/ 175
|
|
264 |
(areturn) "/ 176
|
|
265 |
(return) "/ 177
|
454
|
266 |
(getstatic constIndexShort remember_getstatic) "/ 178
|
|
267 |
(putstatic constIndexShort remember_putstatic) "/ 179
|
6
|
268 |
|
454
|
269 |
(getfield constIndexShort remember_getfield) "/ 180
|
|
270 |
(putfield constIndexShort remember_putfield) "/ 181
|
|
271 |
(invokevirtual constIndexShort remember_invokevirtual) "/ 182
|
|
272 |
(invokenonvirtual constIndexShort remember_invokenonvirtual) "/ 183
|
|
273 |
(invokestatic constIndexShort remember_invokestatic) "/ 184
|
|
274 |
(invokeinterface constIndexShort nargsByte reservedByte remember_invokeinterface) "/ 185
|
6
|
275 |
(newfromname) "/ 186
|
454
|
276 |
(new constIndexShort remember_new) "/ 187
|
6
|
277 |
(newarray arrayTypeByte) "/ 188
|
|
278 |
(anewarray constIndexShort) "/ 189
|
|
279 |
|
|
280 |
(arraylength) "/ 190
|
454
|
281 |
(athrow remember_athrow) "/ 191
|
27
|
282 |
(checkcast constIndexShort) "/ 192
|
6
|
283 |
(instanceof constIndexShort) "/ 193
|
|
284 |
(monitorenter) "/ 194
|
|
285 |
(monitorexit) "/ 195
|
68
|
286 |
"/ (verifystack) "/ 196 obsolete (Alpha release)
|
198
|
287 |
(wide) "/ 196
|
68
|
288 |
(multianewarray constIndexShort dimensionsByte) "/ 197
|
41
|
289 |
|
68
|
290 |
(ifnull signedBranchShort) "/ 198
|
|
291 |
(ifnonnull signedBranchShort) "/ 199
|
6
|
292 |
|
68
|
293 |
(#'goto_w' signedBranchLong) "/ 200
|
|
294 |
(#'jsr_w' signedBranchShort) "/ 201
|
|
295 |
|
|
296 |
(breakpoint) "/ 202
|
|
297 |
|
6
|
298 |
nil "/ 203
|
|
299 |
nil "/ 204
|
|
300 |
nil "/ 205
|
68
|
301 |
nil "/ 206
|
6
|
302 |
nil "/ 207
|
|
303 |
nil "/ 208
|
68
|
304 |
(#'ret_w' signedBranchShort) "/ 209
|
6
|
305 |
|
|
306 |
nil "/ 210
|
|
307 |
nil "/ 211
|
|
308 |
nil "/ 212
|
|
309 |
nil "/ 213
|
|
310 |
nil "/ 214
|
|
311 |
nil "/ 215
|
|
312 |
nil "/ 216
|
|
313 |
nil "/ 217
|
|
314 |
nil "/ 218
|
|
315 |
nil "/ 219
|
|
316 |
|
|
317 |
nil "/ 220
|
|
318 |
nil "/ 221
|
|
319 |
nil "/ 222
|
|
320 |
nil "/ 223
|
|
321 |
nil "/ 224
|
|
322 |
nil "/ 225
|
|
323 |
nil "/ 226
|
|
324 |
nil "/ 227
|
|
325 |
nil "/ 228
|
|
326 |
nil "/ 229
|
|
327 |
|
|
328 |
nil "/ 230
|
|
329 |
nil "/ 231
|
|
330 |
nil "/ 232
|
|
331 |
nil "/ 233
|
|
332 |
nil "/ 234
|
|
333 |
nil "/ 235
|
|
334 |
nil "/ 236
|
|
335 |
nil "/ 237
|
|
336 |
nil "/ 238
|
|
337 |
nil "/ 239
|
|
338 |
|
|
339 |
nil "/ 240
|
|
340 |
nil "/ 241
|
|
341 |
nil "/ 242
|
|
342 |
nil "/ 243
|
|
343 |
nil "/ 244
|
|
344 |
nil "/ 245
|
|
345 |
nil "/ 246
|
|
346 |
nil "/ 247
|
|
347 |
nil "/ 248
|
|
348 |
nil "/ 249
|
|
349 |
|
|
350 |
nil "/ 250
|
|
351 |
nil "/ 251
|
|
352 |
nil "/ 252
|
|
353 |
nil "/ 253
|
|
354 |
nil "/ 254
|
124
|
355 |
(invokenonvirtual_d constIndexShort) "/ 255 special - dummy invokenonvirtual
|
6
|
356 |
)
|
|
357 |
|
|
358 |
"
|
|
359 |
JavaDecompiler initialize
|
|
360 |
"
|
|
361 |
|
454
|
362 |
"Modified: / 16.11.1998 / 15:55:49 / cg"
|
6
|
363 |
! !
|
|
364 |
|
129
|
365 |
!JavaDecompiler class methodsFor:'accessing'!
|
27
|
366 |
|
|
367 |
instructionTable
|
|
368 |
^ DecoderTable
|
|
369 |
! !
|
|
370 |
|
161
|
371 |
!JavaDecompiler class methodsFor:'class definition generation'!
|
|
372 |
|
|
373 |
definitionOf:aJavaClass on:s
|
|
374 |
|pckgName needCR fields staticFields superClass
|
450
|
375 |
interfaces methodList staticMethods nonStaticMethods
|
187
|
376 |
accessAttributeStyle codeStyle classNameStyle methodNameStyle|
|
|
377 |
|
|
378 |
accessAttributeStyle := Java prettyPrintStyle at:#accessAttribute.
|
|
379 |
codeStyle := Java prettyPrintStyle at:#code.
|
|
380 |
classNameStyle := Java prettyPrintStyle at:#className.
|
|
381 |
methodNameStyle := Java prettyPrintStyle at:#className.
|
161
|
382 |
|
|
383 |
pckgName := aJavaClass package.
|
175
|
384 |
pckgName ~= aJavaClass name ifTrue:[
|
360
|
385 |
s nextPutAll:'package ' , (pckgName copyReplaceAll:$/ with:$.).
|
175
|
386 |
s nextPutAll:';'; cr; cr.
|
|
387 |
].
|
161
|
388 |
|
|
389 |
needCR := false.
|
187
|
390 |
s emphasis:accessAttributeStyle.
|
|
391 |
|
161
|
392 |
aJavaClass isPublic ifTrue:[
|
|
393 |
s nextPutAll:'public '.
|
|
394 |
needCR := true.
|
|
395 |
].
|
|
396 |
aJavaClass isAbstract ifTrue:[
|
|
397 |
s nextPutAll:'abstract '.
|
|
398 |
needCR := true.
|
|
399 |
].
|
|
400 |
aJavaClass isFinal ifTrue:[
|
|
401 |
s nextPutAll:'final '.
|
|
402 |
needCR := true.
|
|
403 |
].
|
187
|
404 |
s emphasis:codeStyle.
|
161
|
405 |
|
|
406 |
needCR ifTrue:[
|
|
407 |
s cr
|
|
408 |
].
|
|
409 |
aJavaClass isInterface ifTrue:[
|
|
410 |
s nextPutAll:'interface '.
|
|
411 |
] ifFalse:[
|
|
412 |
s nextPutAll:'class '.
|
|
413 |
].
|
187
|
414 |
s emphasis:classNameStyle;
|
423
|
415 |
nextPutAll:aJavaClass lastName;
|
187
|
416 |
emphasis:codeStyle;
|
|
417 |
space.
|
161
|
418 |
superClass := aJavaClass superclass.
|
|
419 |
|
591
|
420 |
(superClass ~~ (Java at:'java.lang.Object')
|
|
421 |
and:[superClass isJavaClass]) ifTrue:[
|
161
|
422 |
s nextPutAll:'extends '.
|
187
|
423 |
s emphasis:classNameStyle.
|
161
|
424 |
(superClass package ~= 'java/lang'
|
|
425 |
and:[superClass package ~= pckgName]) ifTrue:[
|
187
|
426 |
s nextPutAll:(superClass displayString).
|
161
|
427 |
] ifFalse:[
|
423
|
428 |
s nextPutAll:(superClass lastName).
|
187
|
429 |
].
|
|
430 |
s emphasis:codeStyle.
|
|
431 |
s space.
|
161
|
432 |
].
|
|
433 |
|
|
434 |
(interfaces := aJavaClass interfaces) size > 0 ifTrue:[
|
165
|
435 |
(aJavaClass isInterface
|
|
436 |
and:[interfaces size == 1]) ifTrue:[
|
|
437 |
s nextPutAll:'extends '.
|
|
438 |
] ifFalse:[
|
|
439 |
s nextPutAll:'implements '.
|
|
440 |
].
|
161
|
441 |
interfaces keysAndValuesDo:[:nr :if |
|
443
|
442 |
|nameString|
|
|
443 |
|
161
|
444 |
nr ~~ 1 ifTrue:[
|
|
445 |
s nextPutAll:', '.
|
|
446 |
].
|
187
|
447 |
s emphasis:classNameStyle.
|
161
|
448 |
(if package ~= 'java/lang'
|
|
449 |
and:[if package ~= pckgName]) ifTrue:[
|
443
|
450 |
if isJavaClass ifFalse:[
|
|
451 |
"/ ought to be an unresolved class ...
|
|
452 |
nameString := if fullName copyReplaceAll:$/ with:$.
|
|
453 |
] ifTrue:[
|
|
454 |
nameString := if displayString
|
|
455 |
].
|
161
|
456 |
] ifFalse:[
|
443
|
457 |
nameString := if lastName
|
187
|
458 |
].
|
443
|
459 |
s nextPutAll:nameString.
|
187
|
460 |
s emphasis:codeStyle.
|
161
|
461 |
].
|
|
462 |
s space.
|
|
463 |
].
|
|
464 |
|
|
465 |
s nextPutAll:'{'; cr.
|
|
466 |
|
|
467 |
needCR := false.
|
|
468 |
staticFields := aJavaClass staticFields.
|
|
469 |
staticFields size > 0 ifTrue:[
|
|
470 |
needCR := true.
|
|
471 |
|
|
472 |
staticFields do:[:aField |
|
|
473 |
|type v|
|
|
474 |
|
|
475 |
s nextPutAll:' '.
|
187
|
476 |
s emphasis:accessAttributeStyle.
|
161
|
477 |
aField isPublic ifTrue:[
|
|
478 |
s nextPutAll:'public '.
|
|
479 |
] ifFalse:[
|
487
|
480 |
aField isPrivate ifTrue:[
|
|
481 |
s nextPutAll:'private '.
|
|
482 |
] ifFalse:[
|
|
483 |
aField isProtected ifTrue:[
|
|
484 |
s nextPutAll:'protected '.
|
|
485 |
]
|
|
486 |
]
|
161
|
487 |
].
|
|
488 |
s nextPutAll:'static '.
|
|
489 |
aField isFinal ifTrue:[
|
|
490 |
s nextPutAll:'final '.
|
|
491 |
].
|
488
|
492 |
aField isVolatile ifTrue:[
|
|
493 |
s nextPutAll:'volatile '.
|
|
494 |
].
|
187
|
495 |
s emphasis:codeStyle.
|
161
|
496 |
|
594
|
497 |
(((type := aField type) startsWith:pckgName)
|
|
498 |
or:[type startsWith:(pckgName copyReplaceAll:$/ with:$.)]) ifTrue:[
|
161
|
499 |
type := type copyFrom:(pckgName size + 1 + 1).
|
|
500 |
] ifFalse:[
|
|
501 |
(type startsWith:'java.lang.') ifTrue:[
|
|
502 |
type := type copyFrom:(11).
|
|
503 |
]
|
|
504 |
].
|
|
505 |
type := type copy replaceAll:$/ with:$..
|
|
506 |
s nextPutAll:type; space;
|
|
507 |
nextPutAll:aField name.
|
|
508 |
|
|
509 |
(v := aField constantValue) notNil ifTrue:[
|
|
510 |
s nextPutAll:' = '; nextPutAll:v displayString.
|
|
511 |
].
|
|
512 |
|
|
513 |
s nextPutAll:';'; cr.
|
|
514 |
needCR := true.
|
|
515 |
].
|
|
516 |
].
|
|
517 |
|
|
518 |
|
|
519 |
fields := aJavaClass fields.
|
|
520 |
fields size > 0 ifTrue:[
|
|
521 |
needCR ifTrue:[
|
|
522 |
s cr
|
|
523 |
].
|
|
524 |
needCR := true.
|
|
525 |
|
|
526 |
fields do:[:aField |
|
593
|
527 |
|type v|
|
161
|
528 |
|
|
529 |
s nextPutAll:' '.
|
187
|
530 |
s emphasis:accessAttributeStyle.
|
161
|
531 |
aField isPublic ifTrue:[
|
|
532 |
s nextPutAll:'public '.
|
|
533 |
] ifFalse:[
|
487
|
534 |
aField isPrivate ifTrue:[
|
|
535 |
s nextPutAll:'private '.
|
|
536 |
] ifFalse:[
|
|
537 |
aField isProtected ifTrue:[
|
|
538 |
s nextPutAll:'protected '.
|
|
539 |
]
|
|
540 |
]
|
161
|
541 |
].
|
|
542 |
aField isFinal ifTrue:[
|
|
543 |
s nextPutAll:'final '.
|
|
544 |
].
|
488
|
545 |
aField isTransient ifTrue:[
|
|
546 |
s nextPutAll:'transient '.
|
|
547 |
].
|
|
548 |
aField isVolatile ifTrue:[
|
|
549 |
s nextPutAll:'volatile '.
|
|
550 |
].
|
187
|
551 |
s emphasis:codeStyle.
|
161
|
552 |
|
594
|
553 |
(((type := aField type) startsWith:pckgName)
|
|
554 |
or:[type startsWith:(pckgName copyReplaceAll:$/ with:$.)]) ifTrue:[
|
161
|
555 |
type := type copyFrom:(pckgName size + 1 + 1).
|
|
556 |
].
|
|
557 |
type := type copy replaceAll:$/ with:$..
|
|
558 |
s nextPutAll:type; space;
|
593
|
559 |
nextPutAll:aField name.
|
|
560 |
|
|
561 |
(v := aField constantValue) notNil ifTrue:[
|
|
562 |
s nextPutAll:' = '; nextPutAll:v displayString.
|
|
563 |
].
|
|
564 |
s nextPutAll:';'; cr.
|
161
|
565 |
].
|
|
566 |
].
|
|
567 |
|
|
568 |
aJavaClass methodDictionary size > 0 ifTrue:[
|
|
569 |
needCR ifTrue:[
|
190
|
570 |
s cr.
|
|
571 |
needCR := false.
|
161
|
572 |
].
|
|
573 |
|
450
|
574 |
staticMethods := OrderedCollection new.
|
|
575 |
nonStaticMethods := OrderedCollection new.
|
190
|
576 |
"/
|
|
577 |
"/ static methods first ...
|
|
578 |
"/
|
|
579 |
aJavaClass methodDictionary do:[:aMethod |
|
450
|
580 |
|m|
|
|
581 |
|
|
582 |
m := aMethod.
|
|
583 |
m isWrapped ifTrue:[
|
|
584 |
m := m originalMethod
|
161
|
585 |
].
|
450
|
586 |
m isStatic ifTrue:[
|
|
587 |
staticMethods add:m.
|
|
588 |
] ifFalse:[
|
|
589 |
nonStaticMethods add:m.
|
|
590 |
]
|
190
|
591 |
].
|
161
|
592 |
|
450
|
593 |
staticMethods notEmpty ifTrue:[
|
|
594 |
staticMethods sort:[:a :b | a name < b name].
|
|
595 |
staticMethods do:[:aMethod |
|
190
|
596 |
self methodDefinitionOf:aMethod inPackage:pckgName on:s.
|
161
|
597 |
].
|
190
|
598 |
s cr.
|
|
599 |
].
|
161
|
600 |
|
190
|
601 |
"/
|
|
602 |
"/ instance methods ...
|
|
603 |
"/
|
450
|
604 |
nonStaticMethods notEmpty ifTrue:[
|
|
605 |
nonStaticMethods sort:[:a :b | a name < b name].
|
|
606 |
nonStaticMethods do:[:aMethod |
|
190
|
607 |
self methodDefinitionOf:aMethod inPackage:pckgName on:s.
|
161
|
608 |
].
|
|
609 |
].
|
|
610 |
].
|
|
611 |
|
|
612 |
s nextPutAll:'}'; cr.
|
|
613 |
|
360
|
614 |
"Created: / 22.3.1997 / 14:29:37 / cg"
|
488
|
615 |
"Modified: / 5.12.1998 / 15:58:37 / cg"
|
190
|
616 |
!
|
|
617 |
|
450
|
618 |
methodDefinitionOf:m inPackage:pckgName on:s
|
|
619 |
|aMethod type nm specComponents accessAttributeStyle codeStyle methodNameStyle|
|
|
620 |
|
|
621 |
aMethod := m.
|
|
622 |
m isWrapped ifTrue:[
|
|
623 |
aMethod := m originalMethod
|
|
624 |
].
|
190
|
625 |
|
|
626 |
accessAttributeStyle := Java prettyPrintStyle at:#accessAttribute.
|
|
627 |
codeStyle := Java prettyPrintStyle at:#code.
|
|
628 |
methodNameStyle := Java prettyPrintStyle at:#methodName.
|
|
629 |
|
|
630 |
s nextPutAll:' '.
|
|
631 |
s emphasis:accessAttributeStyle.
|
|
632 |
aMethod isPublic ifTrue:[
|
|
633 |
s nextPutAll:'public '.
|
|
634 |
] ifFalse:[
|
|
635 |
aMethod isProtected ifTrue:[
|
|
636 |
s nextPutAll:'protected '.
|
|
637 |
] ifFalse:[
|
|
638 |
s nextPutAll:'private '.
|
|
639 |
]
|
|
640 |
].
|
|
641 |
aMethod isFinal ifTrue:[
|
|
642 |
s nextPutAll:'final '.
|
|
643 |
].
|
|
644 |
aMethod isStatic ifTrue:[
|
|
645 |
s nextPutAll:'static '.
|
|
646 |
].
|
|
647 |
aMethod isNative ifTrue:[
|
|
648 |
s nextPutAll:'native '.
|
|
649 |
].
|
|
650 |
aMethod isSynchronized ifTrue:[
|
|
651 |
s nextPutAll:'synchronized '.
|
|
652 |
].
|
|
653 |
s emphasis:codeStyle.
|
|
654 |
|
|
655 |
(nm := aMethod name) = '<init>' ifTrue:[
|
423
|
656 |
nm := aMethod javaClass lastName.
|
190
|
657 |
].
|
|
658 |
specComponents := JavaMethod
|
|
659 |
specComponentsWithArgsFromSignature:(aMethod signature)
|
|
660 |
withName:nm
|
|
661 |
in:(aMethod javaClass package).
|
|
662 |
|
|
663 |
s nextPutAll:(specComponents at:1).
|
|
664 |
s space.
|
|
665 |
s emphasis:methodNameStyle.
|
|
666 |
s nextPutAll:(specComponents at:2).
|
|
667 |
s emphasis:codeStyle.
|
|
668 |
s nextPutAll:' ('.
|
|
669 |
s nextPutAll:(specComponents at:3).
|
|
670 |
s nextPutAll:')'.
|
|
671 |
|
|
672 |
aMethod exceptionTable size > 0 ifTrue:[
|
|
673 |
s nextPutAll:' throws '.
|
|
674 |
|
|
675 |
aMethod exceptionTable keysAndValuesDo:[:index :aClassRef |
|
|
676 |
|nm|
|
|
677 |
|
|
678 |
nm := aClassRef fullName.
|
|
679 |
(nm startsWith:pckgName) ifTrue:[
|
|
680 |
nm := nm copyFrom:pckgName size + 2
|
|
681 |
] ifFalse:[
|
|
682 |
(nm startsWith:'java/lang') ifTrue:[
|
|
683 |
nm := nm copyFrom:'java/lang' size + 2.
|
|
684 |
].
|
|
685 |
].
|
|
686 |
index ~~ 1 ifTrue:[
|
|
687 |
s nextPutAll:', '
|
|
688 |
].
|
360
|
689 |
s nextPutAll:(nm copyReplaceAll:$/ with:$.)
|
190
|
690 |
]
|
|
691 |
].
|
|
692 |
s nextPutAll:';'; cr.
|
|
693 |
|
360
|
694 |
"Created: / 1.8.1997 / 12:24:11 / cg"
|
450
|
695 |
"Modified: / 14.11.1998 / 00:03:09 / cg"
|
161
|
696 |
! !
|
|
697 |
|
129
|
698 |
!JavaDecompiler class methodsFor:'decompiling'!
|
6
|
699 |
|
|
700 |
decompile:aJavaMethod
|
18
|
701 |
self decompile:aJavaMethod to:Transcript
|
|
702 |
!
|
|
703 |
|
|
704 |
decompile:aJavaMethod to:aStream
|
|
705 |
self new decompile:aJavaMethod to:aStream
|
6
|
706 |
! !
|
|
707 |
|
|
708 |
!JavaDecompiler methodsFor:'decompiling'!
|
|
709 |
|
18
|
710 |
decompile:aJavaMethod to:aStream
|
620
|
711 |
|who endPC|
|
18
|
712 |
|
|
713 |
outStream := aStream.
|
|
714 |
|
454
|
715 |
isStaticMethod := aJavaMethod isStatic.
|
|
716 |
|
18
|
717 |
who := aJavaMethod who.
|
|
718 |
who notNil ifTrue:[
|
129
|
719 |
classToCompileFor := who methodClass.
|
454
|
720 |
outStream notNil ifTrue:[
|
|
721 |
outStream cr.
|
|
722 |
"/ outStream showCR:'decompiling ' , classToCompileFor name , '>>' , (who methodSelector) , ':'.
|
|
723 |
outStream showCR:'decompiling ' , aJavaMethod displayString , ':'.
|
|
724 |
isStaticMethod ifTrue:[
|
|
725 |
outStream show:'static method'.
|
|
726 |
].
|
|
727 |
outStream cr.
|
|
728 |
outStream cr.
|
|
729 |
]
|
18
|
730 |
].
|
6
|
731 |
|
|
732 |
javaMethod := aJavaMethod.
|
|
733 |
code := aJavaMethod javaByteCode.
|
|
734 |
endPC := code size.
|
18
|
735 |
endPC == 0 ifTrue:[
|
454
|
736 |
outStream notNil ifTrue:[
|
|
737 |
javaMethod isNative ifTrue:[
|
|
738 |
outStream nextPutAll:'// native method'; cr
|
|
739 |
] ifFalse:[
|
|
740 |
outStream nextPutAll:'{} // no bytecode'; cr
|
|
741 |
].
|
18
|
742 |
].
|
|
743 |
^ self
|
|
744 |
].
|
|
745 |
|
620
|
746 |
self enumerateInstructions.
|
|
747 |
|
|
748 |
"Modified: / 9.11.1999 / 15:33:20 / cg"
|
|
749 |
!
|
|
750 |
|
|
751 |
enumerateInstructions
|
|
752 |
|who endPC insn spec op wide|
|
|
753 |
|
198
|
754 |
wide := false.
|
6
|
755 |
pc := 1.
|
620
|
756 |
endPC := code size.
|
6
|
757 |
[pc <= endPC] whileTrue:[
|
|
758 |
insn := code at:pc.
|
|
759 |
pc := pc + 1.
|
620
|
760 |
|
6
|
761 |
spec := DecoderTable at:(insn + 1).
|
27
|
762 |
spec isNil ifTrue:[
|
620
|
763 |
op := '** invalid opcode: ', insn printString, ' **'
|
27
|
764 |
] ifFalse:[
|
|
765 |
op := spec at:1
|
|
766 |
].
|
454
|
767 |
|
|
768 |
outStream notNil ifTrue:[
|
|
769 |
outStream
|
|
770 |
show:((pc - 1 - 1) printStringPaddedTo:4);
|
|
771 |
show:' '.
|
|
772 |
outStream
|
|
773 |
show:(wide ifTrue:[op , '(w)'] ifFalse:[op]).
|
|
774 |
outStream
|
|
775 |
show:' '.
|
|
776 |
].
|
23
|
777 |
|
198
|
778 |
op == #wide ifTrue:[
|
|
779 |
wide := true.
|
|
780 |
] ifFalse:[
|
620
|
781 |
self instructionHookPC:(pc-1) op:op spec:spec.
|
|
782 |
|
198
|
783 |
spec notNil ifTrue:[
|
|
784 |
spec from:2 to:spec size do:[:what |
|
|
785 |
wide ifTrue:[
|
|
786 |
self perform:(what , '_wide') asSymbol.
|
|
787 |
] ifFalse:[
|
|
788 |
self perform:what
|
|
789 |
]
|
|
790 |
].
|
27
|
791 |
].
|
198
|
792 |
wide := false.
|
6
|
793 |
].
|
620
|
794 |
|
454
|
795 |
outStream notNil ifTrue:[
|
|
796 |
outStream cr.
|
|
797 |
]
|
6
|
798 |
]
|
|
799 |
|
620
|
800 |
"Created: / 9.11.1999 / 15:32:49 / cg"
|
|
801 |
"Modified: / 9.11.1999 / 15:36:22 / cg"
|
|
802 |
!
|
|
803 |
|
|
804 |
instructionHookPC:pc op:op spec:spec
|
|
805 |
|
|
806 |
"Created: / 9.11.1999 / 15:35:19 / cg"
|
6
|
807 |
! !
|
|
808 |
|
|
809 |
!JavaDecompiler methodsFor:'operand decoding'!
|
|
810 |
|
23
|
811 |
arrayTypeByte
|
|
812 |
|hi low index type|
|
|
813 |
|
|
814 |
index := code at:pc.
|
|
815 |
pc := pc + 1.
|
|
816 |
|
445
|
817 |
type := #('T_ARRAY' 'invalid2' 'invalid3' 'T_BOOLEAN'
|
|
818 |
'T_CHAR' 'T_FLOAT' 'T_DOUBLE' 'T_BYTE'
|
|
819 |
'T_SHORT' 'T_INT' 'T_LONG' ) at:index ifAbsent:['invalid' , index printString].
|
23
|
820 |
|
454
|
821 |
outStream notNil ifTrue:[
|
|
822 |
outStream
|
|
823 |
show:index;
|
|
824 |
show:' [';
|
|
825 |
show:type;
|
|
826 |
show:']'
|
|
827 |
]
|
23
|
828 |
|
454
|
829 |
"Created: / 16.11.1998 / 15:41:47 / cg"
|
|
830 |
"Modified: / 16.11.1998 / 15:43:27 / cg"
|
23
|
831 |
!
|
|
832 |
|
|
833 |
constIndexByte
|
454
|
834 |
lastConstIndex := code at:pc.
|
23
|
835 |
pc := pc + 1.
|
|
836 |
|
454
|
837 |
lastConstant := javaMethod constantPool at:lastConstIndex ifAbsent:nil.
|
23
|
838 |
|
454
|
839 |
outStream notNil ifTrue:[
|
|
840 |
outStream
|
|
841 |
show:lastConstIndex;
|
|
842 |
show:' [';
|
|
843 |
show:(lastConstant ? '??') displayString;
|
|
844 |
show:'] '
|
|
845 |
]
|
|
846 |
|
|
847 |
"Created: / 16.11.1998 / 15:42:56 / cg"
|
|
848 |
"Modified: / 16.11.1998 / 15:58:52 / cg"
|
23
|
849 |
!
|
|
850 |
|
6
|
851 |
constIndexShort
|
454
|
852 |
lastConstIndex := code wordAt:pc MSB:true.
|
24
|
853 |
pc := pc + 2.
|
6
|
854 |
|
454
|
855 |
lastConstant := javaMethod constantPool at:lastConstIndex ifAbsent:nil.
|
6
|
856 |
|
454
|
857 |
outStream notNil ifTrue:[
|
|
858 |
outStream
|
|
859 |
show:lastConstIndex;
|
|
860 |
show:' [';
|
|
861 |
show:(lastConstant ? '??') displayString;
|
|
862 |
show:'] '
|
|
863 |
]
|
|
864 |
|
|
865 |
"Created: / 16.4.1996 / 15:00:04 / cg"
|
|
866 |
"Modified: / 16.11.1998 / 15:59:23 / cg"
|
23
|
867 |
!
|
|
868 |
|
27
|
869 |
dimensionsByte
|
620
|
870 |
outStream notNil ifTrue:[
|
|
871 |
outStream show:' dims= '.
|
|
872 |
].
|
27
|
873 |
self unsignedByte
|
620
|
874 |
|
|
875 |
"Modified: / 9.11.1999 / 15:46:06 / cg"
|
27
|
876 |
!
|
|
877 |
|
23
|
878 |
localIndexByte
|
198
|
879 |
|index|
|
23
|
880 |
|
|
881 |
index := code at:pc.
|
|
882 |
pc := pc + 1.
|
|
883 |
|
454
|
884 |
outStream notNil ifTrue:[
|
|
885 |
outStream
|
|
886 |
show:index;
|
|
887 |
show:' '
|
|
888 |
]
|
23
|
889 |
|
454
|
890 |
"Created: / 16.4.1996 / 15:00:04 / cg"
|
|
891 |
"Modified: / 16.11.1998 / 15:43:55 / cg"
|
198
|
892 |
!
|
|
893 |
|
|
894 |
localIndexByte_wide
|
|
895 |
|index|
|
|
896 |
|
|
897 |
index := code wordAt:pc MSB:true.
|
|
898 |
pc := pc + 2.
|
|
899 |
|
454
|
900 |
outStream notNil ifTrue:[
|
|
901 |
outStream
|
|
902 |
show:index;
|
|
903 |
show:' '
|
|
904 |
]
|
198
|
905 |
|
454
|
906 |
"Created: / 4.8.1997 / 19:02:09 / cg"
|
|
907 |
"Modified: / 16.11.1998 / 15:44:02 / cg"
|
23
|
908 |
!
|
|
909 |
|
27
|
910 |
lookupSwitchBytes
|
|
911 |
|defaultOffset delta nPairs match pc0|
|
|
912 |
|
|
913 |
pc0 := pc-1. "/ i.e. the pc of the tableSwitch op
|
|
914 |
|
|
915 |
[(pc-1) \\ 4 ~~ 0] whileTrue:[
|
|
916 |
pc := pc + 1
|
|
917 |
].
|
|
918 |
|
|
919 |
defaultOffset := code signedDoubleWordAt:pc MSB:true.
|
|
920 |
pc := pc + 4.
|
|
921 |
nPairs := code signedDoubleWordAt:pc MSB:true.
|
|
922 |
pc := pc + 4.
|
|
923 |
|
620
|
924 |
outStream notNil ifTrue:[
|
|
925 |
outStream show:'n='; show:nPairs; cr.
|
|
926 |
].
|
27
|
927 |
|
|
928 |
nPairs timesRepeat:[
|
|
929 |
match := code signedDoubleWordAt:pc MSB:true.
|
|
930 |
pc := pc + 4.
|
|
931 |
delta := code signedDoubleWordAt:pc MSB:true.
|
|
932 |
pc := pc + 4.
|
454
|
933 |
outStream notNil ifTrue:[
|
|
934 |
outStream show:' ';
|
|
935 |
show:match;
|
|
936 |
show:' -> ';
|
|
937 |
show:delta;
|
|
938 |
show:' [';
|
|
939 |
show:(pc0 - 1 + delta);
|
|
940 |
show:']';
|
|
941 |
cr.
|
|
942 |
]
|
27
|
943 |
].
|
|
944 |
|
454
|
945 |
outStream notNil ifTrue:[
|
|
946 |
outStream show:' ';
|
|
947 |
show:'default';
|
|
948 |
show:' -> ';
|
|
949 |
show:defaultOffset;
|
|
950 |
show:' [';
|
|
951 |
show:(pc0 - 1 + defaultOffset);
|
|
952 |
show:']'.
|
|
953 |
]
|
252
|
954 |
|
620
|
955 |
"Modified: / 9.11.1999 / 15:45:50 / cg"
|
27
|
956 |
!
|
|
957 |
|
|
958 |
nargsByte
|
|
959 |
|byte constants|
|
|
960 |
|
|
961 |
byte := code byteAt:pc.
|
|
962 |
pc := pc + 1.
|
|
963 |
|
454
|
964 |
outStream notNil ifTrue:[
|
|
965 |
outStream
|
|
966 |
show:byte
|
|
967 |
]
|
27
|
968 |
|
454
|
969 |
"Created: / 16.4.1996 / 15:00:04 / cg"
|
|
970 |
"Modified: / 16.11.1998 / 15:44:34 / cg"
|
27
|
971 |
!
|
|
972 |
|
|
973 |
reservedByte
|
|
974 |
|byte constants|
|
|
975 |
|
|
976 |
byte := code byteAt:pc.
|
|
977 |
pc := pc + 1.
|
|
978 |
|
454
|
979 |
outStream notNil ifTrue:[
|
|
980 |
outStream
|
|
981 |
show:byte
|
|
982 |
]
|
27
|
983 |
|
454
|
984 |
"Created: / 16.4.1996 / 15:00:04 / cg"
|
|
985 |
"Modified: / 16.11.1998 / 15:44:42 / cg"
|
27
|
986 |
!
|
|
987 |
|
23
|
988 |
signedBranchShort
|
24
|
989 |
|index constants|
|
23
|
990 |
|
24
|
991 |
index := code signedWordAt:pc MSB:true.
|
23
|
992 |
|
454
|
993 |
outStream notNil ifTrue:[
|
|
994 |
outStream
|
|
995 |
show:index;
|
|
996 |
show:' [';
|
|
997 |
show:(pc - 1 + index - 1);
|
|
998 |
show:']'.
|
|
999 |
].
|
25
|
1000 |
|
|
1001 |
pc := pc + 2.
|
23
|
1002 |
|
252
|
1003 |
"Created: / 16.4.1996 / 15:00:04 / cg"
|
454
|
1004 |
"Modified: / 16.11.1998 / 15:44:51 / cg"
|
24
|
1005 |
!
|
|
1006 |
|
|
1007 |
signedByte
|
|
1008 |
|byte constants|
|
|
1009 |
|
|
1010 |
byte := code signedByteAt:pc.
|
|
1011 |
pc := pc + 1.
|
|
1012 |
|
454
|
1013 |
outStream notNil ifTrue:[
|
|
1014 |
outStream
|
|
1015 |
show:byte
|
|
1016 |
]
|
24
|
1017 |
|
454
|
1018 |
"Created: / 16.4.1996 / 15:00:04 / cg"
|
|
1019 |
"Modified: / 16.11.1998 / 15:44:58 / cg"
|
24
|
1020 |
!
|
|
1021 |
|
261
|
1022 |
signedByte_wide
|
|
1023 |
self signedShort
|
|
1024 |
|
|
1025 |
"Created: / 13.1.1998 / 23:56:36 / cg"
|
|
1026 |
!
|
|
1027 |
|
24
|
1028 |
signedShort
|
|
1029 |
|word constants|
|
|
1030 |
|
|
1031 |
word := code signedWordAt:pc MSB:true.
|
|
1032 |
pc := pc + 2.
|
|
1033 |
|
454
|
1034 |
outStream notNil ifTrue:[
|
|
1035 |
outStream
|
|
1036 |
show:word
|
|
1037 |
]
|
24
|
1038 |
|
454
|
1039 |
"Created: / 16.4.1996 / 15:00:04 / cg"
|
|
1040 |
"Modified: / 16.11.1998 / 15:45:06 / cg"
|
24
|
1041 |
!
|
|
1042 |
|
|
1043 |
tableSwitchBytes
|
|
1044 |
|defaultOffset delta low high pc0|
|
|
1045 |
|
|
1046 |
pc0 := pc-1. "/ i.e. the pc of the tableSwitch op
|
|
1047 |
|
|
1048 |
[(pc-1) \\ 4 ~~ 0] whileTrue:[
|
|
1049 |
pc := pc + 1
|
|
1050 |
].
|
|
1051 |
|
|
1052 |
defaultOffset := code signedDoubleWordAt:pc MSB:true.
|
|
1053 |
pc := pc + 4.
|
|
1054 |
low := code signedDoubleWordAt:pc MSB:true.
|
|
1055 |
pc := pc + 4.
|
|
1056 |
high := code signedDoubleWordAt:pc MSB:true.
|
|
1057 |
pc := pc + 4.
|
|
1058 |
|
620
|
1059 |
outStream notNil ifTrue:[
|
|
1060 |
outStream cr.
|
|
1061 |
].
|
24
|
1062 |
|
|
1063 |
low to:high do:[:switchValue |
|
|
1064 |
delta := code signedDoubleWordAt:pc MSB:true.
|
|
1065 |
pc := pc + 4.
|
454
|
1066 |
outStream notNil ifTrue:[
|
|
1067 |
outStream show:' ';
|
|
1068 |
show:switchValue;
|
|
1069 |
show:' -> ';
|
|
1070 |
show:delta;
|
|
1071 |
show:' [';
|
|
1072 |
show:(pc0 - 1 + delta);
|
|
1073 |
show:']';
|
|
1074 |
cr.
|
|
1075 |
].
|
24
|
1076 |
].
|
|
1077 |
|
454
|
1078 |
outStream notNil ifTrue:[
|
|
1079 |
outStream show:' ';
|
|
1080 |
show:'default';
|
|
1081 |
show:' -> ';
|
|
1082 |
show:defaultOffset;
|
|
1083 |
show:' [';
|
|
1084 |
show:(pc0 - 1 + defaultOffset);
|
|
1085 |
show:']'.
|
|
1086 |
]
|
24
|
1087 |
|
620
|
1088 |
"Modified: / 9.11.1999 / 15:44:36 / cg"
|
27
|
1089 |
!
|
|
1090 |
|
|
1091 |
unsignedByte
|
|
1092 |
|byte constants|
|
|
1093 |
|
|
1094 |
byte := code byteAt:pc.
|
|
1095 |
pc := pc + 1.
|
|
1096 |
|
454
|
1097 |
outStream notNil ifTrue:[
|
|
1098 |
outStream
|
|
1099 |
show:byte
|
|
1100 |
]
|
27
|
1101 |
|
454
|
1102 |
"Created: / 16.4.1996 / 15:00:04 / cg"
|
|
1103 |
"Modified: / 16.11.1998 / 15:45:33 / cg"
|
6
|
1104 |
! !
|
|
1105 |
|
229
|
1106 |
!JavaDecompiler methodsFor:'private'!
|
|
1107 |
|
|
1108 |
popType:type
|
|
1109 |
(type == #long) ifTrue:[
|
|
1110 |
^ self popLong
|
|
1111 |
].
|
|
1112 |
type == #double ifTrue:[
|
|
1113 |
^ self popDouble
|
|
1114 |
].
|
|
1115 |
^ self popStack
|
|
1116 |
|
|
1117 |
"Created: 16.8.1997 / 03:14:11 / cg"
|
|
1118 |
! !
|
|
1119 |
|
454
|
1120 |
!JavaDecompiler methodsFor:'statistics'!
|
|
1121 |
|
456
|
1122 |
remember_athrow
|
|
1123 |
|
|
1124 |
"Created: / 16.11.1998 / 19:37:32 / cg"
|
|
1125 |
!
|
|
1126 |
|
454
|
1127 |
remember_getfield
|
|
1128 |
|fieldRef|
|
|
1129 |
|
|
1130 |
fieldRef := lastConstant.
|
|
1131 |
"/ ....
|
|
1132 |
|
|
1133 |
"Created: / 16.11.1998 / 16:07:58 / cg"
|
|
1134 |
!
|
|
1135 |
|
|
1136 |
remember_getstatic
|
|
1137 |
|fieldRef|
|
|
1138 |
|
|
1139 |
fieldRef := lastConstant.
|
|
1140 |
"/ ....
|
|
1141 |
|
|
1142 |
"Created: / 16.11.1998 / 16:08:06 / cg"
|
|
1143 |
!
|
|
1144 |
|
|
1145 |
remember_invokeinterface
|
|
1146 |
|mthdRef|
|
|
1147 |
|
|
1148 |
mthdRef := lastConstant.
|
|
1149 |
"/ ....
|
|
1150 |
|
|
1151 |
"Created: / 16.11.1998 / 16:07:29 / cg"
|
|
1152 |
!
|
|
1153 |
|
|
1154 |
remember_invokenonvirtual
|
|
1155 |
|mthdRef|
|
|
1156 |
|
|
1157 |
mthdRef := lastConstant.
|
|
1158 |
"/ ....
|
|
1159 |
|
|
1160 |
"Created: / 16.11.1998 / 16:06:49 / cg"
|
|
1161 |
!
|
|
1162 |
|
|
1163 |
remember_invokestatic
|
|
1164 |
|mthdRef|
|
|
1165 |
|
|
1166 |
mthdRef := lastConstant.
|
|
1167 |
"/ ....
|
|
1168 |
|
|
1169 |
"Created: / 16.11.1998 / 16:06:40 / cg"
|
|
1170 |
!
|
|
1171 |
|
|
1172 |
remember_invokevirtual
|
|
1173 |
|mthdRef|
|
|
1174 |
|
|
1175 |
mthdRef := lastConstant.
|
|
1176 |
"/ ....
|
|
1177 |
|
|
1178 |
"Created: / 16.11.1998 / 16:06:32 / cg"
|
|
1179 |
!
|
|
1180 |
|
|
1181 |
remember_ldc1
|
|
1182 |
|what|
|
|
1183 |
|
|
1184 |
what := lastConstant.
|
|
1185 |
"/ ....
|
|
1186 |
|
|
1187 |
"Created: / 16.11.1998 / 16:07:12 / cg"
|
|
1188 |
!
|
|
1189 |
|
|
1190 |
remember_ldc2
|
|
1191 |
|what|
|
|
1192 |
|
|
1193 |
what := lastConstant.
|
|
1194 |
"/ ....
|
|
1195 |
|
|
1196 |
"Created: / 16.11.1998 / 16:07:19 / cg"
|
|
1197 |
!
|
|
1198 |
|
|
1199 |
remember_ldc2w
|
|
1200 |
|what|
|
|
1201 |
|
|
1202 |
what := lastConstant.
|
|
1203 |
"/ ....
|
|
1204 |
|
|
1205 |
"Created: / 16.11.1998 / 16:07:20 / cg"
|
|
1206 |
!
|
|
1207 |
|
|
1208 |
remember_new
|
|
1209 |
|class|
|
|
1210 |
|
|
1211 |
class := lastConstant.
|
|
1212 |
|
|
1213 |
"Created: / 16.11.1998 / 15:59:43 / cg"
|
|
1214 |
"Modified: / 16.11.1998 / 16:12:27 / cg"
|
|
1215 |
!
|
|
1216 |
|
|
1217 |
remember_putfield
|
|
1218 |
|fieldRef|
|
|
1219 |
|
|
1220 |
fieldRef := lastConstant.
|
|
1221 |
"/ ....
|
|
1222 |
|
|
1223 |
"Created: / 16.11.1998 / 16:08:00 / cg"
|
|
1224 |
!
|
|
1225 |
|
|
1226 |
remember_putstatic
|
|
1227 |
|fieldRef|
|
|
1228 |
|
|
1229 |
fieldRef := lastConstant.
|
|
1230 |
"/ ....
|
|
1231 |
|
|
1232 |
"Created: / 16.11.1998 / 16:08:04 / cg"
|
|
1233 |
! !
|
|
1234 |
|
129
|
1235 |
!JavaDecompiler class methodsFor:'documentation'!
|
6
|
1236 |
|
|
1237 |
version
|
620
|
1238 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaDecompiler.st,v 1.47 1999/11/09 14:56:42 cg Exp $'
|
6
|
1239 |
! !
|
|
1240 |
JavaDecompiler initialize!
|