author | Claus Gittinger <cg@exept.de> |
Thu, 24 Nov 2011 12:53:34 +0100 | |
changeset 2267 | ee8926ac5ea2 |
parent 2256 | ee48f7dd70a9 |
child 2353 | fa7400d022a0 |
permissions | -rw-r--r-- |
454 | 1 |
" |
2151 | 2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
454 | 3 |
|
4 |
This software is furnished under a license and may be used |
|
5 |
only in accordance with the terms of that license and with the |
|
6 |
inclusion of the above copyright notice. This software may not |
|
7 |
be provided or otherwise made available to, or used by, any |
|
8 |
other person. No title to or ownership of the software is |
|
9 |
hereby transferred. |
|
2151 | 10 |
" |
701 | 11 |
"{ Package: 'stx:libjava' }" |
12 |
||
6 | 13 |
Object subclass:#JavaDecompiler |
454 | 14 |
instanceVariableNames:'code pc javaMethod outStream classToCompileFor isStaticMethod |
15 |
lastConstIndex lastConstant accessedInstvars modifiedInstvars |
|
16 |
accessedStaticVars modifiedStaticVars sentMessages' |
|
6 | 17 |
classVariableNames:'DecoderTable' |
18 |
poolDictionaries:'' |
|
2108 | 19 |
category:'Languages-Java-Support-Decompiling' |
6 | 20 |
! |
21 |
||
454 | 22 |
!JavaDecompiler class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
2151 | 26 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
454 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
2095 | 34 |
" |
454 | 35 |
! |
36 |
||
37 |
examples |
|
38 |
" |
|
39 |
||
40 |
[exBegin] |
|
41 |
|m| |
|
42 |
||
43 |
m := JAVA::java::lang::Object compiledMethodAt:#'toString()Ljava/lang/String;'. |
|
44 |
JavaDecompiler decompile:m to:Transcript. |
|
45 |
[exEnd] |
|
46 |
||
47 |
||
48 |
||
49 |
[exBegin] |
|
50 |
|m| |
|
51 |
||
52 |
m := JAVA::java::lang::Object compiledMethodAt:#'toString()Ljava/lang/String;'. |
|
53 |
JavaDecompiler decompile:m to:nil. |
|
54 |
[exEnd] |
|
55 |
||
56 |
" |
|
57 |
||
58 |
! ! |
|
6 | 59 |
|
129 | 60 |
!JavaDecompiler class methodsFor:'initialization'! |
6 | 61 |
|
62 |
initialize |
|
63 |
DecoderTable := #( |
|
64 |
(nop) "/ 0 |
|
65 |
(aconst_null) "/ 1 |
|
66 |
(iconst_m1) "/ 2 |
|
67 |
(iconst_0) "/ 3 |
|
68 |
(iconst_1) "/ 4 |
|
69 |
(iconst_2) "/ 5 |
|
70 |
(iconst_3) "/ 6 |
|
71 |
(iconst_4) "/ 7 |
|
72 |
(iconst_5) "/ 8 |
|
73 |
(lconst_0) "/ 9 |
|
74 |
||
75 |
(lconst_1) "/ 10 |
|
76 |
(fconst_0) "/ 11 |
|
77 |
(fconst_1) "/ 12 |
|
78 |
(fconst_2) "/ 13 |
|
79 |
(dconst_0) "/ 14 |
|
80 |
(dconst_1) "/ 15 |
|
81 |
(bipush signedByte) "/ 16 |
|
82 |
(sipush signedShort) "/ 17 |
|
454 | 83 |
(ldc1 constIndexByte remember_ldc1) "/ 18 |
84 |
(ldc2 constIndexShort remember_ldc2) "/ 19 |
|
6 | 85 |
|
454 | 86 |
(ldc2w constIndexShort remember_ldc2w) "/ 20 |
6 | 87 |
(iload localIndexByte) "/ 21 |
88 |
(lload localIndexByte) "/ 22 |
|
89 |
(fload localIndexByte) "/ 23 |
|
90 |
(dload localIndexByte) "/ 24 |
|
91 |
(aload localIndexByte) "/ 25 |
|
24 | 92 |
(iload_0) "/ 26 |
6 | 93 |
(iload_1) "/ 27 |
94 |
(iload_2) "/ 28 |
|
95 |
(iload_3) "/ 29 |
|
96 |
||
97 |
(lload_0) "/ 30 |
|
98 |
(lload_1) "/ 31 |
|
99 |
(lload_2) "/ 32 |
|
100 |
(lload_3) "/ 33 |
|
101 |
(fload_0) "/ 34 |
|
102 |
(fload_1) "/ 35 |
|
103 |
(fload_2) "/ 36 |
|
104 |
(fload_3) "/ 37 |
|
105 |
(dload_0) "/ 38 |
|
106 |
(dload_1) "/ 39 |
|
107 |
||
108 |
(dload_2) "/ 40 |
|
109 |
(dload_3) "/ 41 |
|
110 |
(aload_0) "/ 42 |
|
111 |
(aload_1) "/ 43 |
|
112 |
(aload_2) "/ 44 |
|
113 |
(aload_3) "/ 45 |
|
114 |
(iaload) "/ 46 |
|
115 |
(laload) "/ 47 |
|
116 |
(faload) "/ 48 |
|
117 |
(daload) "/ 49 |
|
118 |
||
119 |
(aaload) "/ 50 |
|
120 |
(baload) "/ 51 |
|
121 |
(caload) "/ 52 |
|
122 |
(saload) "/ 53 |
|
123 |
(istore localIndexByte) "/ 54 |
|
124 |
(lstore localIndexByte) "/ 55 |
|
125 |
(fstore localIndexByte) "/ 56 |
|
126 |
(dstore localIndexByte) "/ 57 |
|
127 |
(astore localIndexByte) "/ 58 |
|
128 |
(istore_0) "/ 59 |
|
129 |
||
130 |
(istore_1) "/ 60 |
|
131 |
(istore_2) "/ 61 |
|
132 |
(istore_3) "/ 62 |
|
133 |
(lstore_0) "/ 63 |
|
134 |
(lstore_1) "/ 64 |
|
135 |
(lstore_2) "/ 65 |
|
136 |
(lstore_3) "/ 66 |
|
137 |
(fstore_0) "/ 67 |
|
138 |
(fstore_1) "/ 68 |
|
139 |
(fstore_2) "/ 69 |
|
140 |
||
141 |
(fstore_3) "/ 70 |
|
142 |
(dstore_0) "/ 71 |
|
143 |
(dstore_1) "/ 72 |
|
144 |
(dstore_2) "/ 73 |
|
145 |
(dstore_3) "/ 74 |
|
146 |
(astore_0) "/ 75 |
|
147 |
(astore_1) "/ 76 |
|
148 |
(astore_2) "/ 77 |
|
149 |
(astore_3) "/ 78 |
|
150 |
(iastore) "/ 79 |
|
151 |
||
152 |
(lastore) "/ 80 |
|
153 |
(fastore) "/ 81 |
|
154 |
(dastore) "/ 82 |
|
155 |
(aastore) "/ 83 |
|
156 |
(bastore) "/ 84 |
|
157 |
(castore) "/ 85 |
|
158 |
(sastore) "/ 86 |
|
159 |
(pop) "/ 87 |
|
160 |
(pop2) "/ 88 |
|
161 |
(dup) "/ 89 |
|
162 |
||
163 |
(dup_x1) "/ 90 |
|
164 |
(dup_x2) "/ 91 |
|
165 |
(dup2) "/ 92 |
|
166 |
(dup2_x1) "/ 93 |
|
167 |
(dup2_x2) "/ 94 |
|
168 |
(swap) "/ 95 |
|
169 |
(iadd) "/ 96 |
|
170 |
(ladd) "/ 97 |
|
171 |
(fadd) "/ 98 |
|
172 |
(dadd) "/ 99 |
|
173 |
||
174 |
(isub) "/ 100 |
|
175 |
(lsub) "/ 101 |
|
176 |
(fsub) "/ 102 |
|
177 |
(dsub) "/ 103 |
|
178 |
(imul) "/ 104 |
|
179 |
(lmul) "/ 105 |
|
180 |
(fmul) "/ 106 |
|
181 |
(dmul) "/ 107 |
|
182 |
(idiv) "/ 108 |
|
183 |
(ldiv) "/ 109 |
|
184 |
||
185 |
(fdiv) "/ 110 |
|
186 |
(ddiv) "/ 111 |
|
91 | 187 |
"/ (imod) "/ 112 "/ obsolete |
188 |
(irem) "/ 112 |
|
189 |
"/ (lmod) "/ 113 "/ obsolete |
|
190 |
(lrem) "/ 113 |
|
191 |
"/ (fmod) "/ 114 "/ obsolete |
|
192 |
(frem) "/ 114 |
|
193 |
"/ (dmod) "/ 115 "/ obsolete |
|
194 |
(drem) "/ 115 |
|
6 | 195 |
(ineg) "/ 116 |
196 |
(lneg) "/ 117 |
|
197 |
(fneg) "/ 118 |
|
198 |
(dneg) "/ 119 |
|
199 |
||
200 |
(ishl) "/ 120 |
|
201 |
(lshl) "/ 121 |
|
202 |
(ishr) "/ 122 |
|
203 |
(lshr) "/ 123 |
|
204 |
(iushr) "/ 124 |
|
205 |
(lushr) "/ 125 |
|
206 |
(iand) "/ 126 |
|
207 |
(land) "/ 127 |
|
208 |
(ior) "/ 128 |
|
209 |
(lor) "/ 129 |
|
210 |
||
211 |
(ixor) "/ 130 |
|
212 |
(lxor) "/ 131 |
|
39 | 213 |
(iinc localIndexByte signedByte) "/ 132 |
68 | 214 |
(i2l) "/ 133 |
44 | 215 |
(i2f) "/ 134 |
52 | 216 |
(i2d) "/ 135 |
44 | 217 |
(l2i) "/ 136 |
6 | 218 |
(l2f) "/ 137 |
219 |
(l2d) "/ 138 |
|
44 | 220 |
(f2i) "/ 139 |
6 | 221 |
|
222 |
(f2l) "/ 140 |
|
223 |
(f2d) "/ 141 |
|
224 |
(d2i) "/ 142 |
|
225 |
(d2l) "/ 143 |
|
226 |
(d2f) "/ 144 |
|
227 |
(int2byte) "/ 145 |
|
228 |
(int2char) "/ 146 |
|
229 |
(int2short) "/ 147 |
|
230 |
(lcmp) "/ 148 |
|
231 |
(fcmpl) "/ 149 |
|
232 |
||
233 |
(fcmpg) "/ 150 |
|
234 |
(dcmpl) "/ 151 |
|
235 |
(dcmpg) "/ 152 |
|
236 |
(ifeq signedBranchShort) "/ 153 |
|
237 |
(ifne signedBranchShort) "/ 154 |
|
238 |
(iflt signedBranchShort) "/ 155 |
|
239 |
(ifge signedBranchShort) "/ 156 |
|
240 |
(ifgt signedBranchShort) "/ 157 |
|
241 |
(ifle signedBranchShort) "/ 158 |
|
242 |
(if_icmpeq signedBranchShort) "/ 159 |
|
243 |
||
244 |
(if_icmpne signedBranchShort) "/ 160 |
|
245 |
(if_icmplt signedBranchShort) "/ 161 |
|
246 |
(if_icmpge signedBranchShort) "/ 162 |
|
247 |
(if_icmpgt signedBranchShort) "/ 163 |
|
248 |
(if_icmple signedBranchShort) "/ 164 |
|
249 |
(if_acmpeq signedBranchShort) "/ 165 |
|
250 |
(if_acmpne signedBranchShort) "/ 166 |
|
251 |
(goto signedBranchShort) "/ 167 |
|
252 |
(jsr signedBranchShort) "/ 168 |
|
253 |
(ret localIndexByte) "/ 169 |
|
254 |
||
255 |
(tableswitch tableSwitchBytes) "/ 170 |
|
256 |
(lookupswitch lookupSwitchBytes) "/ 171 |
|
257 |
(ireturn) "/ 172 |
|
258 |
(lreturn) "/ 173 |
|
259 |
(freturn) "/ 174 |
|
260 |
(dreturn) "/ 175 |
|
261 |
(areturn) "/ 176 |
|
262 |
(return) "/ 177 |
|
454 | 263 |
(getstatic constIndexShort remember_getstatic) "/ 178 |
264 |
(putstatic constIndexShort remember_putstatic) "/ 179 |
|
6 | 265 |
|
454 | 266 |
(getfield constIndexShort remember_getfield) "/ 180 |
267 |
(putfield constIndexShort remember_putfield) "/ 181 |
|
268 |
(invokevirtual constIndexShort remember_invokevirtual) "/ 182 |
|
269 |
(invokenonvirtual constIndexShort remember_invokenonvirtual) "/ 183 |
|
270 |
(invokestatic constIndexShort remember_invokestatic) "/ 184 |
|
271 |
(invokeinterface constIndexShort nargsByte reservedByte remember_invokeinterface) "/ 185 |
|
6 | 272 |
(newfromname) "/ 186 |
454 | 273 |
(new constIndexShort remember_new) "/ 187 |
6 | 274 |
(newarray arrayTypeByte) "/ 188 |
275 |
(anewarray constIndexShort) "/ 189 |
|
276 |
||
277 |
(arraylength) "/ 190 |
|
454 | 278 |
(athrow remember_athrow) "/ 191 |
27 | 279 |
(checkcast constIndexShort) "/ 192 |
6 | 280 |
(instanceof constIndexShort) "/ 193 |
281 |
(monitorenter) "/ 194 |
|
282 |
(monitorexit) "/ 195 |
|
68 | 283 |
"/ (verifystack) "/ 196 obsolete (Alpha release) |
198 | 284 |
(wide) "/ 196 |
68 | 285 |
(multianewarray constIndexShort dimensionsByte) "/ 197 |
41 | 286 |
|
68 | 287 |
(ifnull signedBranchShort) "/ 198 |
288 |
(ifnonnull signedBranchShort) "/ 199 |
|
6 | 289 |
|
68 | 290 |
(#'goto_w' signedBranchLong) "/ 200 |
291 |
(#'jsr_w' signedBranchShort) "/ 201 |
|
292 |
||
293 |
(breakpoint) "/ 202 |
|
294 |
||
6 | 295 |
nil "/ 203 |
296 |
nil "/ 204 |
|
297 |
nil "/ 205 |
|
68 | 298 |
nil "/ 206 |
6 | 299 |
nil "/ 207 |
300 |
nil "/ 208 |
|
68 | 301 |
(#'ret_w' signedBranchShort) "/ 209 |
6 | 302 |
|
303 |
nil "/ 210 |
|
304 |
nil "/ 211 |
|
305 |
nil "/ 212 |
|
306 |
nil "/ 213 |
|
307 |
nil "/ 214 |
|
308 |
nil "/ 215 |
|
309 |
nil "/ 216 |
|
310 |
nil "/ 217 |
|
311 |
nil "/ 218 |
|
312 |
nil "/ 219 |
|
313 |
||
314 |
nil "/ 220 |
|
315 |
nil "/ 221 |
|
316 |
nil "/ 222 |
|
317 |
nil "/ 223 |
|
318 |
nil "/ 224 |
|
319 |
nil "/ 225 |
|
320 |
nil "/ 226 |
|
321 |
nil "/ 227 |
|
322 |
nil "/ 228 |
|
323 |
nil "/ 229 |
|
324 |
||
325 |
nil "/ 230 |
|
326 |
nil "/ 231 |
|
327 |
nil "/ 232 |
|
328 |
nil "/ 233 |
|
329 |
nil "/ 234 |
|
330 |
nil "/ 235 |
|
331 |
nil "/ 236 |
|
332 |
nil "/ 237 |
|
333 |
nil "/ 238 |
|
334 |
nil "/ 239 |
|
335 |
||
336 |
nil "/ 240 |
|
337 |
nil "/ 241 |
|
338 |
nil "/ 242 |
|
339 |
nil "/ 243 |
|
340 |
nil "/ 244 |
|
341 |
nil "/ 245 |
|
342 |
nil "/ 246 |
|
343 |
nil "/ 247 |
|
344 |
nil "/ 248 |
|
345 |
nil "/ 249 |
|
346 |
||
347 |
nil "/ 250 |
|
348 |
nil "/ 251 |
|
349 |
nil "/ 252 |
|
350 |
nil "/ 253 |
|
351 |
nil "/ 254 |
|
124 | 352 |
(invokenonvirtual_d constIndexShort) "/ 255 special - dummy invokenonvirtual |
6 | 353 |
) |
354 |
||
355 |
" |
|
356 |
JavaDecompiler initialize |
|
357 |
" |
|
358 |
||
454 | 359 |
"Modified: / 16.11.1998 / 15:55:49 / cg" |
6 | 360 |
! ! |
361 |
||
129 | 362 |
!JavaDecompiler class methodsFor:'accessing'! |
27 | 363 |
|
364 |
instructionTable |
|
365 |
^ DecoderTable |
|
366 |
! ! |
|
367 |
||
161 | 368 |
!JavaDecompiler class methodsFor:'class definition generation'! |
369 |
||
370 |
definitionOf:aJavaClass on:s |
|
371 |
|pckgName needCR fields staticFields superClass |
|
450 | 372 |
interfaces methodList staticMethods nonStaticMethods |
187 | 373 |
accessAttributeStyle codeStyle classNameStyle methodNameStyle| |
374 |
||
375 |
accessAttributeStyle := Java prettyPrintStyle at:#accessAttribute. |
|
376 |
codeStyle := Java prettyPrintStyle at:#code. |
|
377 |
classNameStyle := Java prettyPrintStyle at:#className. |
|
378 |
methodNameStyle := Java prettyPrintStyle at:#className. |
|
161 | 379 |
|
380 |
pckgName := aJavaClass package. |
|
175 | 381 |
pckgName ~= aJavaClass name ifTrue:[ |
360 | 382 |
s nextPutAll:'package ' , (pckgName copyReplaceAll:$/ with:$.). |
175 | 383 |
s nextPutAll:';'; cr; cr. |
384 |
]. |
|
161 | 385 |
|
386 |
needCR := false. |
|
187 | 387 |
s emphasis:accessAttributeStyle. |
388 |
||
161 | 389 |
aJavaClass isPublic ifTrue:[ |
390 |
s nextPutAll:'public '. |
|
391 |
needCR := true. |
|
392 |
]. |
|
393 |
aJavaClass isAbstract ifTrue:[ |
|
394 |
s nextPutAll:'abstract '. |
|
395 |
needCR := true. |
|
396 |
]. |
|
397 |
aJavaClass isFinal ifTrue:[ |
|
398 |
s nextPutAll:'final '. |
|
399 |
needCR := true. |
|
400 |
]. |
|
187 | 401 |
s emphasis:codeStyle. |
161 | 402 |
|
403 |
needCR ifTrue:[ |
|
404 |
s cr |
|
405 |
]. |
|
406 |
aJavaClass isInterface ifTrue:[ |
|
407 |
s nextPutAll:'interface '. |
|
408 |
] ifFalse:[ |
|
409 |
s nextPutAll:'class '. |
|
410 |
]. |
|
187 | 411 |
s emphasis:classNameStyle; |
423 | 412 |
nextPutAll:aJavaClass lastName; |
187 | 413 |
emphasis:codeStyle; |
414 |
space. |
|
161 | 415 |
superClass := aJavaClass superclass. |
416 |
||
591 | 417 |
(superClass ~~ (Java at:'java.lang.Object') |
418 |
and:[superClass isJavaClass]) ifTrue:[ |
|
161 | 419 |
s nextPutAll:'extends '. |
187 | 420 |
s emphasis:classNameStyle. |
161 | 421 |
(superClass package ~= 'java/lang' |
422 |
and:[superClass package ~= pckgName]) ifTrue:[ |
|
187 | 423 |
s nextPutAll:(superClass displayString). |
161 | 424 |
] ifFalse:[ |
423 | 425 |
s nextPutAll:(superClass lastName). |
187 | 426 |
]. |
427 |
s emphasis:codeStyle. |
|
428 |
s space. |
|
161 | 429 |
]. |
430 |
||
431 |
(interfaces := aJavaClass interfaces) size > 0 ifTrue:[ |
|
165 | 432 |
(aJavaClass isInterface |
433 |
and:[interfaces size == 1]) ifTrue:[ |
|
434 |
s nextPutAll:'extends '. |
|
435 |
] ifFalse:[ |
|
436 |
s nextPutAll:'implements '. |
|
437 |
]. |
|
161 | 438 |
interfaces keysAndValuesDo:[:nr :if | |
443 | 439 |
|nameString| |
440 |
||
161 | 441 |
nr ~~ 1 ifTrue:[ |
442 |
s nextPutAll:', '. |
|
443 |
]. |
|
187 | 444 |
s emphasis:classNameStyle. |
161 | 445 |
(if package ~= 'java/lang' |
446 |
and:[if package ~= pckgName]) ifTrue:[ |
|
443 | 447 |
if isJavaClass ifFalse:[ |
448 |
"/ ought to be an unresolved class ... |
|
449 |
nameString := if fullName copyReplaceAll:$/ with:$. |
|
450 |
] ifTrue:[ |
|
451 |
nameString := if displayString |
|
452 |
]. |
|
161 | 453 |
] ifFalse:[ |
443 | 454 |
nameString := if lastName |
187 | 455 |
]. |
443 | 456 |
s nextPutAll:nameString. |
187 | 457 |
s emphasis:codeStyle. |
161 | 458 |
]. |
459 |
s space. |
|
460 |
]. |
|
461 |
||
462 |
s nextPutAll:'{'; cr. |
|
463 |
||
464 |
needCR := false. |
|
465 |
staticFields := aJavaClass staticFields. |
|
466 |
staticFields size > 0 ifTrue:[ |
|
467 |
needCR := true. |
|
468 |
||
469 |
staticFields do:[:aField | |
|
470 |
|type v| |
|
471 |
||
472 |
s nextPutAll:' '. |
|
187 | 473 |
s emphasis:accessAttributeStyle. |
161 | 474 |
aField isPublic ifTrue:[ |
475 |
s nextPutAll:'public '. |
|
476 |
] ifFalse:[ |
|
487 | 477 |
aField isPrivate ifTrue:[ |
478 |
s nextPutAll:'private '. |
|
479 |
] ifFalse:[ |
|
480 |
aField isProtected ifTrue:[ |
|
481 |
s nextPutAll:'protected '. |
|
482 |
] |
|
483 |
] |
|
161 | 484 |
]. |
485 |
s nextPutAll:'static '. |
|
486 |
aField isFinal ifTrue:[ |
|
487 |
s nextPutAll:'final '. |
|
488 |
]. |
|
488 | 489 |
aField isVolatile ifTrue:[ |
490 |
s nextPutAll:'volatile '. |
|
491 |
]. |
|
187 | 492 |
s emphasis:codeStyle. |
161 | 493 |
|
594 | 494 |
(((type := aField type) startsWith:pckgName) |
495 |
or:[type startsWith:(pckgName copyReplaceAll:$/ with:$.)]) ifTrue:[ |
|
161 | 496 |
type := type copyFrom:(pckgName size + 1 + 1). |
497 |
] ifFalse:[ |
|
498 |
(type startsWith:'java.lang.') ifTrue:[ |
|
499 |
type := type copyFrom:(11). |
|
500 |
] |
|
501 |
]. |
|
502 |
type := type copy replaceAll:$/ with:$.. |
|
503 |
s nextPutAll:type; space; |
|
504 |
nextPutAll:aField name. |
|
505 |
||
506 |
(v := aField constantValue) notNil ifTrue:[ |
|
507 |
s nextPutAll:' = '; nextPutAll:v displayString. |
|
508 |
]. |
|
509 |
||
510 |
s nextPutAll:';'; cr. |
|
511 |
needCR := true. |
|
512 |
]. |
|
513 |
]. |
|
514 |
||
515 |
||
516 |
fields := aJavaClass fields. |
|
517 |
fields size > 0 ifTrue:[ |
|
518 |
needCR ifTrue:[ |
|
519 |
s cr |
|
520 |
]. |
|
521 |
needCR := true. |
|
522 |
||
523 |
fields do:[:aField | |
|
593 | 524 |
|type v| |
161 | 525 |
|
526 |
s nextPutAll:' '. |
|
187 | 527 |
s emphasis:accessAttributeStyle. |
161 | 528 |
aField isPublic ifTrue:[ |
529 |
s nextPutAll:'public '. |
|
530 |
] ifFalse:[ |
|
487 | 531 |
aField isPrivate ifTrue:[ |
532 |
s nextPutAll:'private '. |
|
533 |
] ifFalse:[ |
|
534 |
aField isProtected ifTrue:[ |
|
535 |
s nextPutAll:'protected '. |
|
536 |
] |
|
537 |
] |
|
161 | 538 |
]. |
539 |
aField isFinal ifTrue:[ |
|
540 |
s nextPutAll:'final '. |
|
541 |
]. |
|
488 | 542 |
aField isTransient ifTrue:[ |
543 |
s nextPutAll:'transient '. |
|
544 |
]. |
|
545 |
aField isVolatile ifTrue:[ |
|
546 |
s nextPutAll:'volatile '. |
|
547 |
]. |
|
187 | 548 |
s emphasis:codeStyle. |
161 | 549 |
|
594 | 550 |
(((type := aField type) startsWith:pckgName) |
551 |
or:[type startsWith:(pckgName copyReplaceAll:$/ with:$.)]) ifTrue:[ |
|
161 | 552 |
type := type copyFrom:(pckgName size + 1 + 1). |
553 |
]. |
|
554 |
type := type copy replaceAll:$/ with:$.. |
|
555 |
s nextPutAll:type; space; |
|
593 | 556 |
nextPutAll:aField name. |
557 |
||
558 |
(v := aField constantValue) notNil ifTrue:[ |
|
559 |
s nextPutAll:' = '; nextPutAll:v displayString. |
|
560 |
]. |
|
561 |
s nextPutAll:';'; cr. |
|
161 | 562 |
]. |
563 |
]. |
|
564 |
||
565 |
aJavaClass methodDictionary size > 0 ifTrue:[ |
|
566 |
needCR ifTrue:[ |
|
190 | 567 |
s cr. |
568 |
needCR := false. |
|
161 | 569 |
]. |
570 |
||
450 | 571 |
staticMethods := OrderedCollection new. |
572 |
nonStaticMethods := OrderedCollection new. |
|
190 | 573 |
"/ |
574 |
"/ static methods first ... |
|
575 |
"/ |
|
576 |
aJavaClass methodDictionary do:[:aMethod | |
|
450 | 577 |
|m| |
578 |
||
579 |
m := aMethod. |
|
580 |
m isWrapped ifTrue:[ |
|
581 |
m := m originalMethod |
|
161 | 582 |
]. |
450 | 583 |
m isStatic ifTrue:[ |
584 |
staticMethods add:m. |
|
585 |
] ifFalse:[ |
|
586 |
nonStaticMethods add:m. |
|
587 |
] |
|
190 | 588 |
]. |
161 | 589 |
|
450 | 590 |
staticMethods notEmpty ifTrue:[ |
591 |
staticMethods sort:[:a :b | a name < b name]. |
|
592 |
staticMethods do:[:aMethod | |
|
190 | 593 |
self methodDefinitionOf:aMethod inPackage:pckgName on:s. |
161 | 594 |
]. |
190 | 595 |
s cr. |
596 |
]. |
|
161 | 597 |
|
190 | 598 |
"/ |
599 |
"/ instance methods ... |
|
600 |
"/ |
|
450 | 601 |
nonStaticMethods notEmpty ifTrue:[ |
602 |
nonStaticMethods sort:[:a :b | a name < b name]. |
|
603 |
nonStaticMethods do:[:aMethod | |
|
190 | 604 |
self methodDefinitionOf:aMethod inPackage:pckgName on:s. |
161 | 605 |
]. |
606 |
]. |
|
607 |
]. |
|
608 |
||
609 |
s nextPutAll:'}'; cr. |
|
610 |
||
360 | 611 |
"Created: / 22.3.1997 / 14:29:37 / cg" |
488 | 612 |
"Modified: / 5.12.1998 / 15:58:37 / cg" |
190 | 613 |
! |
614 |
||
2151 | 615 |
methodDefinitionOf: m inPackage: pckgName on: s |
616 |
| aMethod nm specComponents accessAttributeStyle codeStyle methodNameStyle | |
|
450 | 617 |
|
618 |
aMethod := m. |
|
2151 | 619 |
m isWrapped ifTrue: [ |
450 | 620 |
aMethod := m originalMethod |
621 |
]. |
|
2151 | 622 |
accessAttributeStyle := Java prettyPrintStyle at: #accessAttribute. |
623 |
codeStyle := Java prettyPrintStyle at: #code. |
|
624 |
methodNameStyle := Java prettyPrintStyle at: #methodName. |
|
625 |
s nextPutAll: ' '. |
|
626 |
s emphasis: accessAttributeStyle. |
|
627 |
aMethod isPublic ifTrue: [ |
|
628 |
s nextPutAll: 'public '. |
|
629 |
] ifFalse: [ |
|
630 |
aMethod isProtected ifTrue: [ |
|
631 |
s nextPutAll: 'protected '. |
|
632 |
] ifFalse: [ s nextPutAll: 'private '. ] |
|
190 | 633 |
]. |
2151 | 634 |
aMethod isFinal ifTrue: [ |
635 |
s nextPutAll: 'final '. |
|
190 | 636 |
]. |
2151 | 637 |
aMethod isStatic ifTrue: [ |
638 |
s nextPutAll: 'static '. |
|
190 | 639 |
]. |
2151 | 640 |
aMethod isNative ifTrue: [ |
641 |
s nextPutAll: 'native '. |
|
190 | 642 |
]. |
2151 | 643 |
aMethod isSynchronized ifTrue: [ |
644 |
s nextPutAll: 'synchronized '. |
|
190 | 645 |
]. |
2151 | 646 |
s emphasis: codeStyle. |
647 |
(nm := aMethod name) = '<init>' ifTrue: [ |
|
423 | 648 |
nm := aMethod javaClass lastName. |
190 | 649 |
]. |
2151 | 650 |
specComponents := JavaMethod |
651 |
specComponentsWithArgsFromSignature: (aMethod instVarNamed:#descriptor) |
|
652 |
withName: nm |
|
653 |
in: (aMethod javaClass package). |
|
654 |
s nextPutAll: (specComponents at: 1). |
|
190 | 655 |
s space. |
2151 | 656 |
s emphasis: methodNameStyle. |
657 |
s nextPutAll: (specComponents at: 2). |
|
658 |
s emphasis: codeStyle. |
|
659 |
s nextPutAll: ' ('. |
|
660 |
s nextPutAll: (specComponents at: 3). |
|
661 |
s nextPutAll: ')'. |
|
662 |
aMethod exceptionTable size > 0 ifTrue: [ |
|
663 |
s nextPutAll: ' throws '. |
|
664 |
aMethod exceptionTable |
|
665 |
keysAndValuesDo: [ |
|
666 |
:index :aClassRef | |
|
667 |
| nm | |
|
190 | 668 |
|
2151 | 669 |
nm := aClassRef name. |
670 |
(nm startsWith: pckgName) ifTrue: [ |
|
671 |
nm := nm copyFrom: pckgName size + 2 |
|
672 |
] ifFalse: [ |
|
673 |
(nm startsWith: 'java/lang') ifTrue: [ |
|
674 |
nm := nm copyFrom: 'java/lang' size + 2. |
|
675 |
]. |
|
190 | 676 |
]. |
2151 | 677 |
index ~~ 1 ifTrue: [ s nextPutAll: ', ' ]. |
678 |
s nextPutAll: (nm copyReplaceAll: $/ with: $.) |
|
679 |
] |
|
190 | 680 |
]. |
2151 | 681 |
s |
682 |
nextPutAll: ';'; |
|
683 |
cr. |
|
190 | 684 |
|
2151 | 685 |
"Created: / 01-08-1997 / 12:24:11 / cg" |
686 |
"Modified: / 14-11-1998 / 00:03:09 / cg" |
|
687 |
"Modified: / 04-06-2011 / 17:18:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
688 |
"Modified: / 15-08-2011 / 08:52:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
161 | 689 |
! ! |
690 |
||
129 | 691 |
!JavaDecompiler class methodsFor:'decompiling'! |
6 | 692 |
|
693 |
decompile:aJavaMethod |
|
18 | 694 |
self decompile:aJavaMethod to:Transcript |
695 |
! |
|
696 |
||
697 |
decompile:aJavaMethod to:aStream |
|
698 |
self new decompile:aJavaMethod to:aStream |
|
6 | 699 |
! ! |
700 |
||
701 |
!JavaDecompiler methodsFor:'decompiling'! |
|
702 |
||
18 | 703 |
decompile:aJavaMethod to:aStream |
620 | 704 |
|who endPC| |
18 | 705 |
|
706 |
outStream := aStream. |
|
707 |
||
454 | 708 |
isStaticMethod := aJavaMethod isStatic. |
709 |
||
18 | 710 |
who := aJavaMethod who. |
711 |
who notNil ifTrue:[ |
|
129 | 712 |
classToCompileFor := who methodClass. |
454 | 713 |
outStream notNil ifTrue:[ |
714 |
outStream cr. |
|
715 |
"/ outStream showCR:'decompiling ' , classToCompileFor name , '>>' , (who methodSelector) , ':'. |
|
716 |
outStream showCR:'decompiling ' , aJavaMethod displayString , ':'. |
|
717 |
isStaticMethod ifTrue:[ |
|
718 |
outStream show:'static method'. |
|
719 |
]. |
|
720 |
outStream cr. |
|
721 |
outStream cr. |
|
722 |
] |
|
18 | 723 |
]. |
6 | 724 |
|
725 |
javaMethod := aJavaMethod. |
|
726 |
code := aJavaMethod javaByteCode. |
|
727 |
endPC := code size. |
|
18 | 728 |
endPC == 0 ifTrue:[ |
454 | 729 |
outStream notNil ifTrue:[ |
730 |
javaMethod isNative ifTrue:[ |
|
731 |
outStream nextPutAll:'// native method'; cr |
|
732 |
] ifFalse:[ |
|
733 |
outStream nextPutAll:'{} // no bytecode'; cr |
|
734 |
]. |
|
18 | 735 |
]. |
736 |
^ self |
|
737 |
]. |
|
738 |
||
620 | 739 |
self enumerateInstructions. |
740 |
||
741 |
"Modified: / 9.11.1999 / 15:33:20 / cg" |
|
742 |
! |
|
743 |
||
744 |
enumerateInstructions |
|
745 |
|who endPC insn spec op wide| |
|
746 |
||
198 | 747 |
wide := false. |
6 | 748 |
pc := 1. |
620 | 749 |
endPC := code size. |
6 | 750 |
[pc <= endPC] whileTrue:[ |
751 |
insn := code at:pc. |
|
752 |
pc := pc + 1. |
|
620 | 753 |
|
6 | 754 |
spec := DecoderTable at:(insn + 1). |
27 | 755 |
spec isNil ifTrue:[ |
620 | 756 |
op := '** invalid opcode: ', insn printString, ' **' |
27 | 757 |
] ifFalse:[ |
758 |
op := spec at:1 |
|
759 |
]. |
|
454 | 760 |
|
761 |
outStream notNil ifTrue:[ |
|
762 |
outStream |
|
763 |
show:((pc - 1 - 1) printStringPaddedTo:4); |
|
764 |
show:' '. |
|
765 |
outStream |
|
766 |
show:(wide ifTrue:[op , '(w)'] ifFalse:[op]). |
|
767 |
outStream |
|
768 |
show:' '. |
|
769 |
]. |
|
23 | 770 |
|
198 | 771 |
op == #wide ifTrue:[ |
772 |
wide := true. |
|
773 |
] ifFalse:[ |
|
620 | 774 |
self instructionHookPC:(pc-1) op:op spec:spec. |
775 |
||
198 | 776 |
spec notNil ifTrue:[ |
777 |
spec from:2 to:spec size do:[:what | |
|
778 |
wide ifTrue:[ |
|
779 |
self perform:(what , '_wide') asSymbol. |
|
780 |
] ifFalse:[ |
|
781 |
self perform:what |
|
782 |
] |
|
783 |
]. |
|
27 | 784 |
]. |
198 | 785 |
wide := false. |
6 | 786 |
]. |
620 | 787 |
|
454 | 788 |
outStream notNil ifTrue:[ |
789 |
outStream cr. |
|
790 |
] |
|
6 | 791 |
] |
792 |
||
620 | 793 |
"Created: / 9.11.1999 / 15:32:49 / cg" |
794 |
"Modified: / 9.11.1999 / 15:36:22 / cg" |
|
795 |
! |
|
796 |
||
797 |
instructionHookPC:pc op:op spec:spec |
|
798 |
||
799 |
"Created: / 9.11.1999 / 15:35:19 / cg" |
|
6 | 800 |
! ! |
801 |
||
802 |
!JavaDecompiler methodsFor:'operand decoding'! |
|
803 |
||
23 | 804 |
arrayTypeByte |
805 |
|hi low index type| |
|
806 |
||
807 |
index := code at:pc. |
|
808 |
pc := pc + 1. |
|
809 |
||
445 | 810 |
type := #('T_ARRAY' 'invalid2' 'invalid3' 'T_BOOLEAN' |
811 |
'T_CHAR' 'T_FLOAT' 'T_DOUBLE' 'T_BYTE' |
|
812 |
'T_SHORT' 'T_INT' 'T_LONG' ) at:index ifAbsent:['invalid' , index printString]. |
|
23 | 813 |
|
454 | 814 |
outStream notNil ifTrue:[ |
815 |
outStream |
|
816 |
show:index; |
|
817 |
show:' ['; |
|
818 |
show:type; |
|
819 |
show:']' |
|
820 |
] |
|
23 | 821 |
|
454 | 822 |
"Created: / 16.11.1998 / 15:41:47 / cg" |
823 |
"Modified: / 16.11.1998 / 15:43:27 / cg" |
|
23 | 824 |
! |
825 |
||
826 |
constIndexByte |
|
454 | 827 |
lastConstIndex := code at:pc. |
23 | 828 |
pc := pc + 1. |
829 |
||
454 | 830 |
lastConstant := javaMethod constantPool at:lastConstIndex ifAbsent:nil. |
23 | 831 |
|
454 | 832 |
outStream notNil ifTrue:[ |
833 |
outStream |
|
834 |
show:lastConstIndex; |
|
835 |
show:' ['; |
|
836 |
show:(lastConstant ? '??') displayString; |
|
837 |
show:'] ' |
|
838 |
] |
|
839 |
||
840 |
"Created: / 16.11.1998 / 15:42:56 / cg" |
|
841 |
"Modified: / 16.11.1998 / 15:58:52 / cg" |
|
23 | 842 |
! |
843 |
||
6 | 844 |
constIndexShort |
701 | 845 |
|s| |
846 |
||
454 | 847 |
lastConstIndex := code wordAt:pc MSB:true. |
24 | 848 |
pc := pc + 2. |
6 | 849 |
|
454 | 850 |
lastConstant := javaMethod constantPool at:lastConstIndex ifAbsent:nil. |
851 |
outStream notNil ifTrue:[ |
|
701 | 852 |
s := (lastConstant ? '??') displayString. |
853 |
s isString ifTrue:[ |
|
854 |
s bitsPerCharacter > 8 ifTrue:[ |
|
855 |
s := '...a 2-byte string...' |
|
856 |
] |
|
857 |
]. |
|
454 | 858 |
outStream |
859 |
show:lastConstIndex; |
|
860 |
show:' ['; |
|
701 | 861 |
show:s; |
454 | 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 |
|
2256
ee48f7dd70a9
fixed: #version_SVN ($ to §)
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
1238 |
^ '$Header: /cvs/stx/stx/libjava/JavaDecompiler.st,v 1.52 2011-11-24 11:52:38 cg Exp $' |
ee48f7dd70a9
fixed: #version_SVN ($ to §)
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
1239 |
! |
ee48f7dd70a9
fixed: #version_SVN ($ to §)
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
1240 |
|
ee48f7dd70a9
fixed: #version_SVN ($ to §)
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
1241 |
version_CVS |
ee48f7dd70a9
fixed: #version_SVN ($ to §)
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
1242 |
^ '$Header: /cvs/stx/stx/libjava/JavaDecompiler.st,v 1.52 2011-11-24 11:52:38 cg Exp $' |
2151 | 1243 |
! |
1244 |
||
1245 |
version_SVN |
|
2166 | 1246 |
^ '§Id: JavaDecompiler.st,v 1.50 2011/08/18 18:42:48 vrany Exp §' |
6 | 1247 |
! ! |
2108 | 1248 |
|
2095 | 1249 |
JavaDecompiler initialize! |