6
|
1 |
Object subclass:#JavaDecompiler
|
18
|
2 |
instanceVariableNames:'code pc javaMethod outStream classToCompileFor'
|
6
|
3 |
classVariableNames:'DecoderTable'
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Java-Support'
|
|
6 |
!
|
|
7 |
|
|
8 |
|
68
|
9 |
!JavaDecompiler class methodsFor:'initialization'!
|
6
|
10 |
|
|
11 |
initialize
|
|
12 |
DecoderTable := #(
|
|
13 |
(nop) "/ 0
|
|
14 |
(aconst_null) "/ 1
|
|
15 |
(iconst_m1) "/ 2
|
|
16 |
(iconst_0) "/ 3
|
|
17 |
(iconst_1) "/ 4
|
|
18 |
(iconst_2) "/ 5
|
|
19 |
(iconst_3) "/ 6
|
|
20 |
(iconst_4) "/ 7
|
|
21 |
(iconst_5) "/ 8
|
|
22 |
(lconst_0) "/ 9
|
|
23 |
|
|
24 |
(lconst_1) "/ 10
|
|
25 |
(fconst_0) "/ 11
|
|
26 |
(fconst_1) "/ 12
|
|
27 |
(fconst_2) "/ 13
|
|
28 |
(dconst_0) "/ 14
|
|
29 |
(dconst_1) "/ 15
|
|
30 |
(bipush signedByte) "/ 16
|
|
31 |
(sipush signedShort) "/ 17
|
|
32 |
(ldc1 constIndexByte) "/ 18
|
|
33 |
(ldc2 constIndexShort) "/ 19
|
|
34 |
|
|
35 |
(ldc2w constIndexShort) "/ 20
|
|
36 |
(iload localIndexByte) "/ 21
|
|
37 |
(lload localIndexByte) "/ 22
|
|
38 |
(fload localIndexByte) "/ 23
|
|
39 |
(dload localIndexByte) "/ 24
|
|
40 |
(aload localIndexByte) "/ 25
|
24
|
41 |
(iload_0) "/ 26
|
6
|
42 |
(iload_1) "/ 27
|
|
43 |
(iload_2) "/ 28
|
|
44 |
(iload_3) "/ 29
|
|
45 |
|
|
46 |
(lload_0) "/ 30
|
|
47 |
(lload_1) "/ 31
|
|
48 |
(lload_2) "/ 32
|
|
49 |
(lload_3) "/ 33
|
|
50 |
(fload_0) "/ 34
|
|
51 |
(fload_1) "/ 35
|
|
52 |
(fload_2) "/ 36
|
|
53 |
(fload_3) "/ 37
|
|
54 |
(dload_0) "/ 38
|
|
55 |
(dload_1) "/ 39
|
|
56 |
|
|
57 |
(dload_2) "/ 40
|
|
58 |
(dload_3) "/ 41
|
|
59 |
(aload_0) "/ 42
|
|
60 |
(aload_1) "/ 43
|
|
61 |
(aload_2) "/ 44
|
|
62 |
(aload_3) "/ 45
|
|
63 |
(iaload) "/ 46
|
|
64 |
(laload) "/ 47
|
|
65 |
(faload) "/ 48
|
|
66 |
(daload) "/ 49
|
|
67 |
|
|
68 |
(aaload) "/ 50
|
|
69 |
(baload) "/ 51
|
|
70 |
(caload) "/ 52
|
|
71 |
(saload) "/ 53
|
|
72 |
(istore localIndexByte) "/ 54
|
|
73 |
(lstore localIndexByte) "/ 55
|
|
74 |
(fstore localIndexByte) "/ 56
|
|
75 |
(dstore localIndexByte) "/ 57
|
|
76 |
(astore localIndexByte) "/ 58
|
|
77 |
(istore_0) "/ 59
|
|
78 |
|
|
79 |
(istore_1) "/ 60
|
|
80 |
(istore_2) "/ 61
|
|
81 |
(istore_3) "/ 62
|
|
82 |
(lstore_0) "/ 63
|
|
83 |
(lstore_1) "/ 64
|
|
84 |
(lstore_2) "/ 65
|
|
85 |
(lstore_3) "/ 66
|
|
86 |
(fstore_0) "/ 67
|
|
87 |
(fstore_1) "/ 68
|
|
88 |
(fstore_2) "/ 69
|
|
89 |
|
|
90 |
(fstore_3) "/ 70
|
|
91 |
(dstore_0) "/ 71
|
|
92 |
(dstore_1) "/ 72
|
|
93 |
(dstore_2) "/ 73
|
|
94 |
(dstore_3) "/ 74
|
|
95 |
(astore_0) "/ 75
|
|
96 |
(astore_1) "/ 76
|
|
97 |
(astore_2) "/ 77
|
|
98 |
(astore_3) "/ 78
|
|
99 |
(iastore) "/ 79
|
|
100 |
|
|
101 |
(lastore) "/ 80
|
|
102 |
(fastore) "/ 81
|
|
103 |
(dastore) "/ 82
|
|
104 |
(aastore) "/ 83
|
|
105 |
(bastore) "/ 84
|
|
106 |
(castore) "/ 85
|
|
107 |
(sastore) "/ 86
|
|
108 |
(pop) "/ 87
|
|
109 |
(pop2) "/ 88
|
|
110 |
(dup) "/ 89
|
|
111 |
|
|
112 |
(dup_x1) "/ 90
|
|
113 |
(dup_x2) "/ 91
|
|
114 |
(dup2) "/ 92
|
|
115 |
(dup2_x1) "/ 93
|
|
116 |
(dup2_x2) "/ 94
|
|
117 |
(swap) "/ 95
|
|
118 |
(iadd) "/ 96
|
|
119 |
(ladd) "/ 97
|
|
120 |
(fadd) "/ 98
|
|
121 |
(dadd) "/ 99
|
|
122 |
|
|
123 |
(isub) "/ 100
|
|
124 |
(lsub) "/ 101
|
|
125 |
(fsub) "/ 102
|
|
126 |
(dsub) "/ 103
|
|
127 |
(imul) "/ 104
|
|
128 |
(lmul) "/ 105
|
|
129 |
(fmul) "/ 106
|
|
130 |
(dmul) "/ 107
|
|
131 |
(idiv) "/ 108
|
|
132 |
(ldiv) "/ 109
|
|
133 |
|
|
134 |
(fdiv) "/ 110
|
|
135 |
(ddiv) "/ 111
|
91
|
136 |
"/ (imod) "/ 112 "/ obsolete
|
|
137 |
(irem) "/ 112
|
|
138 |
"/ (lmod) "/ 113 "/ obsolete
|
|
139 |
(lrem) "/ 113
|
|
140 |
"/ (fmod) "/ 114 "/ obsolete
|
|
141 |
(frem) "/ 114
|
|
142 |
"/ (dmod) "/ 115 "/ obsolete
|
|
143 |
(drem) "/ 115
|
6
|
144 |
(ineg) "/ 116
|
|
145 |
(lneg) "/ 117
|
|
146 |
(fneg) "/ 118
|
|
147 |
(dneg) "/ 119
|
|
148 |
|
|
149 |
(ishl) "/ 120
|
|
150 |
(lshl) "/ 121
|
|
151 |
(ishr) "/ 122
|
|
152 |
(lshr) "/ 123
|
|
153 |
(iushr) "/ 124
|
|
154 |
(lushr) "/ 125
|
|
155 |
(iand) "/ 126
|
|
156 |
(land) "/ 127
|
|
157 |
(ior) "/ 128
|
|
158 |
(lor) "/ 129
|
|
159 |
|
|
160 |
(ixor) "/ 130
|
|
161 |
(lxor) "/ 131
|
39
|
162 |
(iinc localIndexByte signedByte) "/ 132
|
68
|
163 |
(i2l) "/ 133
|
44
|
164 |
(i2f) "/ 134
|
52
|
165 |
(i2d) "/ 135
|
44
|
166 |
(l2i) "/ 136
|
6
|
167 |
(l2f) "/ 137
|
|
168 |
(l2d) "/ 138
|
44
|
169 |
(f2i) "/ 139
|
6
|
170 |
|
|
171 |
(f2l) "/ 140
|
|
172 |
(f2d) "/ 141
|
|
173 |
(d2i) "/ 142
|
|
174 |
(d2l) "/ 143
|
|
175 |
(d2f) "/ 144
|
|
176 |
(int2byte) "/ 145
|
|
177 |
(int2char) "/ 146
|
|
178 |
(int2short) "/ 147
|
|
179 |
(lcmp) "/ 148
|
|
180 |
(fcmpl) "/ 149
|
|
181 |
|
|
182 |
(fcmpg) "/ 150
|
|
183 |
(dcmpl) "/ 151
|
|
184 |
(dcmpg) "/ 152
|
|
185 |
(ifeq signedBranchShort) "/ 153
|
|
186 |
(ifne signedBranchShort) "/ 154
|
|
187 |
(iflt signedBranchShort) "/ 155
|
|
188 |
(ifge signedBranchShort) "/ 156
|
|
189 |
(ifgt signedBranchShort) "/ 157
|
|
190 |
(ifle signedBranchShort) "/ 158
|
|
191 |
(if_icmpeq signedBranchShort) "/ 159
|
|
192 |
|
|
193 |
(if_icmpne signedBranchShort) "/ 160
|
|
194 |
(if_icmplt signedBranchShort) "/ 161
|
|
195 |
(if_icmpge signedBranchShort) "/ 162
|
|
196 |
(if_icmpgt signedBranchShort) "/ 163
|
|
197 |
(if_icmple signedBranchShort) "/ 164
|
|
198 |
(if_acmpeq signedBranchShort) "/ 165
|
|
199 |
(if_acmpne signedBranchShort) "/ 166
|
|
200 |
(goto signedBranchShort) "/ 167
|
|
201 |
(jsr signedBranchShort) "/ 168
|
|
202 |
(ret localIndexByte) "/ 169
|
|
203 |
|
|
204 |
(tableswitch tableSwitchBytes) "/ 170
|
|
205 |
(lookupswitch lookupSwitchBytes) "/ 171
|
|
206 |
(ireturn) "/ 172
|
|
207 |
(lreturn) "/ 173
|
|
208 |
(freturn) "/ 174
|
|
209 |
(dreturn) "/ 175
|
|
210 |
(areturn) "/ 176
|
|
211 |
(return) "/ 177
|
|
212 |
(getstatic constIndexShort) "/ 178
|
|
213 |
(putstatic constIndexShort) "/ 179
|
|
214 |
|
|
215 |
(getfield constIndexShort) "/ 180
|
|
216 |
(putfield constIndexShort) "/ 181
|
|
217 |
(invokevirtual constIndexShort) "/ 182
|
|
218 |
(invokenonvirtual constIndexShort) "/ 183
|
|
219 |
(invokestatic constIndexShort) "/ 184
|
|
220 |
(invokeinterface constIndexShort nargsByte reservedByte) "/ 185
|
|
221 |
(newfromname) "/ 186
|
|
222 |
(new constIndexShort) "/ 187
|
|
223 |
(newarray arrayTypeByte) "/ 188
|
|
224 |
(anewarray constIndexShort) "/ 189
|
|
225 |
|
|
226 |
(arraylength) "/ 190
|
32
|
227 |
(athrow) "/ 191
|
27
|
228 |
(checkcast constIndexShort) "/ 192
|
6
|
229 |
(instanceof constIndexShort) "/ 193
|
|
230 |
(monitorenter) "/ 194
|
|
231 |
(monitorexit) "/ 195
|
68
|
232 |
"/ (verifystack) "/ 196 obsolete (Alpha release)
|
|
233 |
(wide localIndexByte) "/ 196
|
|
234 |
(multianewarray constIndexShort dimensionsByte) "/ 197
|
41
|
235 |
|
68
|
236 |
(ifnull signedBranchShort) "/ 198
|
|
237 |
(ifnonnull signedBranchShort) "/ 199
|
6
|
238 |
|
68
|
239 |
(#'goto_w' signedBranchLong) "/ 200
|
|
240 |
(#'jsr_w' signedBranchShort) "/ 201
|
|
241 |
|
|
242 |
(breakpoint) "/ 202
|
|
243 |
|
6
|
244 |
nil "/ 203
|
|
245 |
nil "/ 204
|
|
246 |
nil "/ 205
|
68
|
247 |
nil "/ 206
|
6
|
248 |
nil "/ 207
|
|
249 |
nil "/ 208
|
68
|
250 |
(#'ret_w' signedBranchShort) "/ 209
|
6
|
251 |
|
|
252 |
nil "/ 210
|
|
253 |
nil "/ 211
|
|
254 |
nil "/ 212
|
|
255 |
nil "/ 213
|
|
256 |
nil "/ 214
|
|
257 |
nil "/ 215
|
|
258 |
nil "/ 216
|
|
259 |
nil "/ 217
|
|
260 |
nil "/ 218
|
|
261 |
nil "/ 219
|
|
262 |
|
|
263 |
nil "/ 220
|
|
264 |
nil "/ 221
|
|
265 |
nil "/ 222
|
|
266 |
nil "/ 223
|
|
267 |
nil "/ 224
|
|
268 |
nil "/ 225
|
|
269 |
nil "/ 226
|
|
270 |
nil "/ 227
|
|
271 |
nil "/ 228
|
|
272 |
nil "/ 229
|
|
273 |
|
|
274 |
nil "/ 230
|
|
275 |
nil "/ 231
|
|
276 |
nil "/ 232
|
|
277 |
nil "/ 233
|
|
278 |
nil "/ 234
|
|
279 |
nil "/ 235
|
|
280 |
nil "/ 236
|
|
281 |
nil "/ 237
|
|
282 |
nil "/ 238
|
|
283 |
nil "/ 239
|
|
284 |
|
|
285 |
nil "/ 240
|
|
286 |
nil "/ 241
|
|
287 |
nil "/ 242
|
|
288 |
nil "/ 243
|
|
289 |
nil "/ 244
|
|
290 |
nil "/ 245
|
|
291 |
nil "/ 246
|
|
292 |
nil "/ 247
|
|
293 |
nil "/ 248
|
|
294 |
nil "/ 249
|
|
295 |
|
|
296 |
nil "/ 250
|
|
297 |
nil "/ 251
|
|
298 |
nil "/ 252
|
|
299 |
nil "/ 253
|
|
300 |
nil "/ 254
|
|
301 |
nil "/ 255
|
|
302 |
)
|
|
303 |
|
|
304 |
"
|
|
305 |
JavaDecompiler initialize
|
|
306 |
"
|
|
307 |
|
|
308 |
"Modified: 16.4.1996 / 14:56:13 / cg"
|
|
309 |
! !
|
|
310 |
|
68
|
311 |
!JavaDecompiler class methodsFor:'accessing'!
|
27
|
312 |
|
|
313 |
instructionTable
|
|
314 |
^ DecoderTable
|
|
315 |
! !
|
|
316 |
|
68
|
317 |
!JavaDecompiler class methodsFor:'decompiling'!
|
6
|
318 |
|
|
319 |
decompile:aJavaMethod
|
18
|
320 |
self decompile:aJavaMethod to:Transcript
|
|
321 |
!
|
|
322 |
|
|
323 |
decompile:aJavaMethod to:aStream
|
|
324 |
self new decompile:aJavaMethod to:aStream
|
6
|
325 |
! !
|
|
326 |
|
|
327 |
!JavaDecompiler methodsFor:'decompiling'!
|
|
328 |
|
18
|
329 |
decompile:aJavaMethod to:aStream
|
27
|
330 |
|who endPC insn spec op|
|
18
|
331 |
|
|
332 |
outStream := aStream.
|
|
333 |
|
|
334 |
who := aJavaMethod who.
|
|
335 |
who notNil ifTrue:[
|
|
336 |
classToCompileFor := who first.
|
|
337 |
aStream cr.
|
61
|
338 |
"/ aStream showCR:'decompiling ' , classToCompileFor name , '>>' , (who at:2) , ':'.
|
|
339 |
aStream showCR:'decompiling ' , aJavaMethod displayString , ':'.
|
119
|
340 |
aJavaMethod isStatic ifTrue:[
|
|
341 |
aStream show:'static method'.
|
|
342 |
].
|
|
343 |
aStream cr.
|
18
|
344 |
aStream cr.
|
|
345 |
].
|
6
|
346 |
|
|
347 |
javaMethod := aJavaMethod.
|
|
348 |
code := aJavaMethod javaByteCode.
|
|
349 |
endPC := code size.
|
18
|
350 |
endPC == 0 ifTrue:[
|
19
|
351 |
javaMethod isNative ifTrue:[
|
18
|
352 |
outStream nextPutAll:'implemented in C'; cr
|
|
353 |
] ifFalse:[
|
|
354 |
outStream nextPutAll:'no bytecode'; cr
|
|
355 |
].
|
|
356 |
^ self
|
|
357 |
].
|
|
358 |
|
6
|
359 |
pc := 1.
|
|
360 |
[pc <= endPC] whileTrue:[
|
|
361 |
insn := code at:pc.
|
|
362 |
pc := pc + 1.
|
|
363 |
spec := DecoderTable at:(insn + 1).
|
27
|
364 |
spec isNil ifTrue:[
|
|
365 |
op := '** invalid opcode: ',insn printString, ' **'
|
|
366 |
] ifFalse:[
|
|
367 |
op := spec at:1
|
|
368 |
].
|
23
|
369 |
outStream
|
|
370 |
show:((pc - 1) printStringPaddedTo:4);
|
|
371 |
show:' ';
|
27
|
372 |
show:op;
|
23
|
373 |
show:' '.
|
|
374 |
|
27
|
375 |
spec notNil ifTrue:[
|
|
376 |
spec from:2 to:spec size do:[:what |
|
|
377 |
self perform:what
|
|
378 |
].
|
6
|
379 |
].
|
18
|
380 |
outStream cr.
|
6
|
381 |
]
|
|
382 |
|
|
383 |
"Created: 16.4.1996 / 14:59:29 / cg"
|
|
384 |
"Modified: 16.4.1996 / 15:27:05 / cg"
|
|
385 |
! !
|
|
386 |
|
|
387 |
!JavaDecompiler methodsFor:'operand decoding'!
|
|
388 |
|
23
|
389 |
arrayTypeByte
|
|
390 |
|hi low index type|
|
|
391 |
|
|
392 |
index := code at:pc.
|
|
393 |
pc := pc + 1.
|
|
394 |
|
|
395 |
type := #('T_ARRAY' 'invalid' 'invalid' 'T_BOOLEAN'
|
|
396 |
'T_CHAR' 'T_FLOAT' 'T_DOUBLE' 'T_BYTE'
|
|
397 |
'T_INT' 'T_LONG' ) at:index ifAbsent:'invalid'.
|
|
398 |
|
|
399 |
outStream
|
|
400 |
show:index;
|
|
401 |
show:' [';
|
|
402 |
show:type;
|
|
403 |
show:']'
|
|
404 |
|
|
405 |
"Created: 16.4.1996 / 15:00:04 / cg"
|
|
406 |
"Modified: 16.4.1996 / 15:30:55 / cg"
|
|
407 |
!
|
|
408 |
|
|
409 |
constIndexByte
|
|
410 |
|hi low index constants|
|
|
411 |
|
|
412 |
index := code at:pc.
|
|
413 |
pc := pc + 1.
|
|
414 |
|
|
415 |
outStream
|
|
416 |
show:index;
|
|
417 |
show:' [';
|
27
|
418 |
show:(javaMethod constantPool at:index ifAbsent:['??']) displayString;
|
|
419 |
show:'] '
|
23
|
420 |
|
|
421 |
"Created: 16.4.1996 / 15:00:04 / cg"
|
|
422 |
"Modified: 16.4.1996 / 15:30:55 / cg"
|
|
423 |
!
|
|
424 |
|
6
|
425 |
constIndexShort
|
24
|
426 |
|index constants|
|
6
|
427 |
|
24
|
428 |
index := code wordAt:pc MSB:true.
|
|
429 |
pc := pc + 2.
|
6
|
430 |
|
18
|
431 |
outStream
|
6
|
432 |
show:index;
|
|
433 |
show:' [';
|
27
|
434 |
show:(javaMethod constantPool at:index ifAbsent:'???') displayString;
|
|
435 |
show:'] '
|
6
|
436 |
|
|
437 |
"Created: 16.4.1996 / 15:00:04 / cg"
|
|
438 |
"Modified: 16.4.1996 / 15:30:55 / cg"
|
23
|
439 |
!
|
|
440 |
|
27
|
441 |
dimensionsByte
|
108
|
442 |
outStream show:' dims= '.
|
27
|
443 |
self unsignedByte
|
|
444 |
!
|
|
445 |
|
23
|
446 |
localIndexByte
|
|
447 |
|hi low index constants|
|
|
448 |
|
|
449 |
index := code at:pc.
|
|
450 |
pc := pc + 1.
|
|
451 |
|
|
452 |
outStream
|
|
453 |
show:index;
|
39
|
454 |
show:' '
|
23
|
455 |
|
|
456 |
"Created: 16.4.1996 / 15:00:04 / cg"
|
|
457 |
"Modified: 16.4.1996 / 15:30:55 / cg"
|
|
458 |
!
|
|
459 |
|
27
|
460 |
lookupSwitchBytes
|
|
461 |
|defaultOffset delta nPairs match pc0|
|
|
462 |
|
|
463 |
pc0 := pc-1. "/ i.e. the pc of the tableSwitch op
|
|
464 |
|
|
465 |
[(pc-1) \\ 4 ~~ 0] whileTrue:[
|
|
466 |
pc := pc + 1
|
|
467 |
].
|
|
468 |
|
|
469 |
defaultOffset := code signedDoubleWordAt:pc MSB:true.
|
|
470 |
pc := pc + 4.
|
|
471 |
nPairs := code signedDoubleWordAt:pc MSB:true.
|
|
472 |
pc := pc + 4.
|
|
473 |
|
|
474 |
outStream show:'n='; show:nPairs; cr.
|
|
475 |
|
|
476 |
nPairs timesRepeat:[
|
|
477 |
match := code signedDoubleWordAt:pc MSB:true.
|
|
478 |
pc := pc + 4.
|
|
479 |
delta := code signedDoubleWordAt:pc MSB:true.
|
|
480 |
pc := pc + 4.
|
|
481 |
outStream show:' ';
|
|
482 |
show:match;
|
|
483 |
show:' -> ';
|
|
484 |
show:delta;
|
|
485 |
show:' [';
|
|
486 |
show:(pc0 + delta);
|
|
487 |
show:']';
|
|
488 |
cr.
|
|
489 |
].
|
|
490 |
|
|
491 |
outStream show:' ';
|
|
492 |
show:'default';
|
|
493 |
show:' -> ';
|
|
494 |
show:defaultOffset;
|
|
495 |
show:' [';
|
|
496 |
show:(pc0 + defaultOffset);
|
|
497 |
show:']'.
|
|
498 |
!
|
|
499 |
|
|
500 |
nargsByte
|
|
501 |
|byte constants|
|
|
502 |
|
|
503 |
byte := code byteAt:pc.
|
|
504 |
pc := pc + 1.
|
|
505 |
|
|
506 |
outStream
|
|
507 |
show:byte
|
|
508 |
|
|
509 |
"Created: 16.4.1996 / 15:00:04 / cg"
|
|
510 |
"Modified: 16.4.1996 / 15:30:55 / cg"
|
|
511 |
!
|
|
512 |
|
|
513 |
reservedByte
|
|
514 |
|byte constants|
|
|
515 |
|
|
516 |
byte := code byteAt:pc.
|
|
517 |
pc := pc + 1.
|
|
518 |
|
|
519 |
outStream
|
|
520 |
show:byte
|
|
521 |
|
|
522 |
"Created: 16.4.1996 / 15:00:04 / cg"
|
|
523 |
"Modified: 16.4.1996 / 15:30:55 / cg"
|
|
524 |
!
|
|
525 |
|
23
|
526 |
signedBranchShort
|
24
|
527 |
|index constants|
|
23
|
528 |
|
24
|
529 |
index := code signedWordAt:pc MSB:true.
|
23
|
530 |
|
|
531 |
outStream
|
|
532 |
show:index;
|
|
533 |
show:' [';
|
25
|
534 |
show:(pc + index - 1);
|
|
535 |
show:']'.
|
|
536 |
|
|
537 |
pc := pc + 2.
|
23
|
538 |
|
|
539 |
"Created: 16.4.1996 / 15:00:04 / cg"
|
|
540 |
"Modified: 16.4.1996 / 15:30:55 / cg"
|
24
|
541 |
!
|
|
542 |
|
|
543 |
signedByte
|
|
544 |
|byte constants|
|
|
545 |
|
|
546 |
byte := code signedByteAt:pc.
|
|
547 |
pc := pc + 1.
|
|
548 |
|
|
549 |
outStream
|
|
550 |
show:byte
|
|
551 |
|
|
552 |
"Created: 16.4.1996 / 15:00:04 / cg"
|
|
553 |
"Modified: 16.4.1996 / 15:30:55 / cg"
|
|
554 |
!
|
|
555 |
|
|
556 |
signedShort
|
|
557 |
|word constants|
|
|
558 |
|
|
559 |
word := code signedWordAt:pc MSB:true.
|
|
560 |
pc := pc + 2.
|
|
561 |
|
|
562 |
outStream
|
|
563 |
show:word
|
|
564 |
|
|
565 |
"Created: 16.4.1996 / 15:00:04 / cg"
|
|
566 |
"Modified: 16.4.1996 / 15:30:55 / cg"
|
|
567 |
!
|
|
568 |
|
|
569 |
tableSwitchBytes
|
|
570 |
|defaultOffset delta low high pc0|
|
|
571 |
|
|
572 |
pc0 := pc-1. "/ i.e. the pc of the tableSwitch op
|
|
573 |
|
|
574 |
[(pc-1) \\ 4 ~~ 0] whileTrue:[
|
|
575 |
pc := pc + 1
|
|
576 |
].
|
|
577 |
|
|
578 |
defaultOffset := code signedDoubleWordAt:pc MSB:true.
|
|
579 |
pc := pc + 4.
|
|
580 |
low := code signedDoubleWordAt:pc MSB:true.
|
|
581 |
pc := pc + 4.
|
|
582 |
high := code signedDoubleWordAt:pc MSB:true.
|
|
583 |
pc := pc + 4.
|
|
584 |
|
|
585 |
outStream cr.
|
|
586 |
|
|
587 |
low to:high do:[:switchValue |
|
|
588 |
delta := code signedDoubleWordAt:pc MSB:true.
|
|
589 |
pc := pc + 4.
|
|
590 |
outStream show:' ';
|
|
591 |
show:switchValue;
|
|
592 |
show:' -> ';
|
|
593 |
show:delta;
|
|
594 |
show:' [';
|
|
595 |
show:(pc0 + delta);
|
|
596 |
show:']';
|
|
597 |
cr.
|
|
598 |
].
|
|
599 |
|
|
600 |
outStream show:' ';
|
|
601 |
show:'default';
|
|
602 |
show:' -> ';
|
|
603 |
show:defaultOffset;
|
|
604 |
show:' [';
|
|
605 |
show:(pc0 + defaultOffset);
|
|
606 |
show:']'.
|
|
607 |
|
|
608 |
|
27
|
609 |
!
|
|
610 |
|
|
611 |
unsignedByte
|
|
612 |
|byte constants|
|
|
613 |
|
|
614 |
byte := code byteAt:pc.
|
|
615 |
pc := pc + 1.
|
|
616 |
|
|
617 |
outStream
|
|
618 |
show:byte
|
|
619 |
|
|
620 |
"Created: 16.4.1996 / 15:00:04 / cg"
|
|
621 |
"Modified: 16.4.1996 / 15:30:55 / cg"
|
6
|
622 |
! !
|
|
623 |
|
68
|
624 |
!JavaDecompiler class methodsFor:'documentation'!
|
6
|
625 |
|
|
626 |
version
|
119
|
627 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaDecompiler.st,v 1.19 1996/07/06 18:16:23 cg Exp $'
|
6
|
628 |
! !
|
|
629 |
JavaDecompiler initialize!
|