6
|
1 |
Object subclass:#JavaDecompiler
|
|
2 |
instanceVariableNames:'code pc javaMethod'
|
|
3 |
classVariableNames:'DecoderTable'
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Java-Support'
|
|
6 |
!
|
|
7 |
|
|
8 |
|
|
9 |
!JavaDecompiler class methodsFor:'initialization'!
|
|
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
|
|
41 |
nil "/ 26
|
|
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
|
|
136 |
(imod) "/ 112
|
|
137 |
(lmod) "/ 113
|
|
138 |
(fmod) "/ 114
|
|
139 |
(dmod) "/ 115
|
|
140 |
(ineg) "/ 116
|
|
141 |
(lneg) "/ 117
|
|
142 |
(fneg) "/ 118
|
|
143 |
(dneg) "/ 119
|
|
144 |
|
|
145 |
(ishl) "/ 120
|
|
146 |
(lshl) "/ 121
|
|
147 |
(ishr) "/ 122
|
|
148 |
(lshr) "/ 123
|
|
149 |
(iushr) "/ 124
|
|
150 |
(lushr) "/ 125
|
|
151 |
(iand) "/ 126
|
|
152 |
(land) "/ 127
|
|
153 |
(ior) "/ 128
|
|
154 |
(lor) "/ 129
|
|
155 |
|
|
156 |
(ixor) "/ 130
|
|
157 |
(lxor) "/ 131
|
|
158 |
"/ (iinc localIndexByte signedByte) "/ 132
|
|
159 |
(i2l) "/ 132
|
|
160 |
(i2f) "/ 133
|
|
161 |
(i2d) "/ 134
|
|
162 |
nil "/ 135
|
|
163 |
(l2i) "/ 136
|
|
164 |
(l2f) "/ 137
|
|
165 |
(l2d) "/ 138
|
|
166 |
(l2i) "/ 139
|
|
167 |
|
|
168 |
(f2l) "/ 140
|
|
169 |
(f2d) "/ 141
|
|
170 |
(d2i) "/ 142
|
|
171 |
(d2l) "/ 143
|
|
172 |
(d2f) "/ 144
|
|
173 |
(int2byte) "/ 145
|
|
174 |
(int2char) "/ 146
|
|
175 |
(int2short) "/ 147
|
|
176 |
(lcmp) "/ 148
|
|
177 |
(fcmpl) "/ 149
|
|
178 |
|
|
179 |
(fcmpg) "/ 150
|
|
180 |
(dcmpl) "/ 151
|
|
181 |
(dcmpg) "/ 152
|
|
182 |
(ifeq signedBranchShort) "/ 153
|
|
183 |
(ifne signedBranchShort) "/ 154
|
|
184 |
(iflt signedBranchShort) "/ 155
|
|
185 |
(ifge signedBranchShort) "/ 156
|
|
186 |
(ifgt signedBranchShort) "/ 157
|
|
187 |
(ifle signedBranchShort) "/ 158
|
|
188 |
(if_icmpeq signedBranchShort) "/ 159
|
|
189 |
|
|
190 |
(if_icmpne signedBranchShort) "/ 160
|
|
191 |
(if_icmplt signedBranchShort) "/ 161
|
|
192 |
(if_icmpge signedBranchShort) "/ 162
|
|
193 |
(if_icmpgt signedBranchShort) "/ 163
|
|
194 |
(if_icmple signedBranchShort) "/ 164
|
|
195 |
(if_acmpeq signedBranchShort) "/ 165
|
|
196 |
(if_acmpne signedBranchShort) "/ 166
|
|
197 |
(goto signedBranchShort) "/ 167
|
|
198 |
(jsr signedBranchShort) "/ 168
|
|
199 |
(ret localIndexByte) "/ 169
|
|
200 |
|
|
201 |
(tableswitch tableSwitchBytes) "/ 170
|
|
202 |
(lookupswitch lookupSwitchBytes) "/ 171
|
|
203 |
(ireturn) "/ 172
|
|
204 |
(lreturn) "/ 173
|
|
205 |
(freturn) "/ 174
|
|
206 |
(dreturn) "/ 175
|
|
207 |
(areturn) "/ 176
|
|
208 |
(return) "/ 177
|
|
209 |
(getstatic constIndexShort) "/ 178
|
|
210 |
(putstatic constIndexShort) "/ 179
|
|
211 |
|
|
212 |
(getfield constIndexShort) "/ 180
|
|
213 |
(putfield constIndexShort) "/ 181
|
|
214 |
(invokevirtual constIndexShort) "/ 182
|
|
215 |
(invokenonvirtual constIndexShort) "/ 183
|
|
216 |
(invokestatic constIndexShort) "/ 184
|
|
217 |
(invokeinterface constIndexShort nargsByte reservedByte) "/ 185
|
|
218 |
(newfromname) "/ 186
|
|
219 |
(new constIndexShort) "/ 187
|
|
220 |
(newarray arrayTypeByte) "/ 188
|
|
221 |
(anewarray constIndexShort) "/ 189
|
|
222 |
|
|
223 |
(arraylength) "/ 190
|
|
224 |
(athrough) "/ 191
|
|
225 |
(checkcast) "/ 192
|
|
226 |
(instanceof constIndexShort) "/ 193
|
|
227 |
(monitorenter) "/ 194
|
|
228 |
(monitorexit) "/ 195
|
|
229 |
(verifystack) "/ 196
|
|
230 |
(breakpoint) "/ 197
|
|
231 |
(multianewarray constIndexShort dimensionsByte) "/ 198
|
|
232 |
nil "/ 199
|
|
233 |
|
|
234 |
nil "/ 200
|
|
235 |
nil "/ 201
|
|
236 |
nil "/ 202
|
|
237 |
nil "/ 203
|
|
238 |
nil "/ 204
|
|
239 |
nil "/ 205
|
|
240 |
nil "/ 206
|
|
241 |
nil "/ 207
|
|
242 |
nil "/ 208
|
|
243 |
nil "/ 209
|
|
244 |
|
|
245 |
nil "/ 210
|
|
246 |
nil "/ 211
|
|
247 |
nil "/ 212
|
|
248 |
nil "/ 213
|
|
249 |
nil "/ 214
|
|
250 |
nil "/ 215
|
|
251 |
nil "/ 216
|
|
252 |
nil "/ 217
|
|
253 |
nil "/ 218
|
|
254 |
nil "/ 219
|
|
255 |
|
|
256 |
nil "/ 220
|
|
257 |
nil "/ 221
|
|
258 |
nil "/ 222
|
|
259 |
nil "/ 223
|
|
260 |
nil "/ 224
|
|
261 |
nil "/ 225
|
|
262 |
nil "/ 226
|
|
263 |
nil "/ 227
|
|
264 |
nil "/ 228
|
|
265 |
nil "/ 229
|
|
266 |
|
|
267 |
nil "/ 230
|
|
268 |
nil "/ 231
|
|
269 |
nil "/ 232
|
|
270 |
nil "/ 233
|
|
271 |
nil "/ 234
|
|
272 |
nil "/ 235
|
|
273 |
nil "/ 236
|
|
274 |
nil "/ 237
|
|
275 |
nil "/ 238
|
|
276 |
nil "/ 239
|
|
277 |
|
|
278 |
nil "/ 240
|
|
279 |
nil "/ 241
|
|
280 |
nil "/ 242
|
|
281 |
nil "/ 243
|
|
282 |
nil "/ 244
|
|
283 |
nil "/ 245
|
|
284 |
nil "/ 246
|
|
285 |
nil "/ 247
|
|
286 |
nil "/ 248
|
|
287 |
nil "/ 249
|
|
288 |
|
|
289 |
nil "/ 250
|
|
290 |
nil "/ 251
|
|
291 |
nil "/ 252
|
|
292 |
nil "/ 253
|
|
293 |
nil "/ 254
|
|
294 |
nil "/ 255
|
|
295 |
)
|
|
296 |
|
|
297 |
"
|
|
298 |
JavaDecompiler initialize
|
|
299 |
"
|
|
300 |
|
|
301 |
"Modified: 16.4.1996 / 14:56:13 / cg"
|
|
302 |
! !
|
|
303 |
|
|
304 |
!JavaDecompiler class methodsFor:'decompiling'!
|
|
305 |
|
|
306 |
decompile:aJavaMethod
|
|
307 |
self new decompile:aJavaMethod
|
|
308 |
! !
|
|
309 |
|
|
310 |
!JavaDecompiler methodsFor:'decompiling'!
|
|
311 |
|
|
312 |
decompile:aJavaMethod
|
|
313 |
|endPC insn spec|
|
|
314 |
|
|
315 |
javaMethod := aJavaMethod.
|
|
316 |
code := aJavaMethod javaByteCode.
|
|
317 |
endPC := code size.
|
|
318 |
pc := 1.
|
|
319 |
[pc <= endPC] whileTrue:[
|
|
320 |
insn := code at:pc.
|
|
321 |
pc := pc + 1.
|
|
322 |
spec := DecoderTable at:(insn + 1).
|
|
323 |
Transcript show:(spec at:1); show:' '.
|
|
324 |
spec from:2 to:spec size do:[:what |
|
|
325 |
self perform:what
|
|
326 |
].
|
|
327 |
Transcript cr.
|
|
328 |
]
|
|
329 |
|
|
330 |
"Created: 16.4.1996 / 14:59:29 / cg"
|
|
331 |
"Modified: 16.4.1996 / 15:27:05 / cg"
|
|
332 |
! !
|
|
333 |
|
|
334 |
!JavaDecompiler methodsFor:'operand decoding'!
|
|
335 |
|
|
336 |
constIndexShort
|
|
337 |
|hi low index constants|
|
|
338 |
|
|
339 |
hi := code at:pc.
|
|
340 |
low := code at:pc + 1.
|
|
341 |
pc := pc + 2.
|
|
342 |
|
|
343 |
index := (hi bitShift:8) + low.
|
|
344 |
"change from unsigned 0..FFFF to signed -8000..7FFF"
|
|
345 |
index >= 16r8000 ifTrue:[
|
|
346 |
index := index - 16r10000
|
|
347 |
].
|
|
348 |
|
|
349 |
Transcript
|
|
350 |
show:index;
|
|
351 |
show:' [';
|
|
352 |
show:(javaMethod constantPool at:index) displayString;
|
|
353 |
show:']'
|
|
354 |
|
|
355 |
"Created: 16.4.1996 / 15:00:04 / cg"
|
|
356 |
"Modified: 16.4.1996 / 15:30:55 / cg"
|
|
357 |
! !
|
|
358 |
|
|
359 |
!JavaDecompiler class methodsFor:'documentation'!
|
|
360 |
|
|
361 |
version
|
|
362 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaDecompiler.st,v 1.1 1996/04/16 13:34:16 cg Exp $'
|
|
363 |
! !
|
|
364 |
JavaDecompiler initialize!
|