1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| package com.jeantessier.classreader.impl; |
34 |
| |
35 |
| import com.jeantessier.classreader.LocalVariableFinder; |
36 |
| import com.jeantessier.classreader.Visitor; |
37 |
| |
38 |
| public class Instruction implements com.jeantessier.classreader.Instruction { |
39 |
| private static final int NB_OPCODES = 0x100; |
40 |
| |
41 |
| private static String[] opcode = new String[NB_OPCODES]; |
42 |
| private static int[] length = new int[NB_OPCODES]; |
43 |
| |
44 |
| static { |
45 |
2
| opcode[0x00] = "nop";
|
46 |
2
| length[0x00] = 1;
|
47 |
2
| opcode[0x01] = "aconst_null";
|
48 |
2
| length[0x01] = 1;
|
49 |
2
| opcode[0x02] = "iconst_m1";
|
50 |
2
| length[0x02] = 1;
|
51 |
2
| opcode[0x03] = "iconst_0";
|
52 |
2
| length[0x03] = 1;
|
53 |
2
| opcode[0x04] = "iconst_1";
|
54 |
2
| length[0x04] = 1;
|
55 |
2
| opcode[0x05] = "iconst_2";
|
56 |
2
| length[0x05] = 1;
|
57 |
2
| opcode[0x06] = "iconst_3";
|
58 |
2
| length[0x06] = 1;
|
59 |
2
| opcode[0x07] = "iconst_4";
|
60 |
2
| length[0x07] = 1;
|
61 |
2
| opcode[0x08] = "iconst_5";
|
62 |
2
| length[0x08] = 1;
|
63 |
2
| opcode[0x09] = "lconst_0";
|
64 |
2
| length[0x09] = 1;
|
65 |
2
| opcode[0x0a] = "lconst_1";
|
66 |
2
| length[0x0a] = 1;
|
67 |
2
| opcode[0x0b] = "fconst_0";
|
68 |
2
| length[0x0b] = 1;
|
69 |
2
| opcode[0x0c] = "fconst_1";
|
70 |
2
| length[0x0c] = 1;
|
71 |
2
| opcode[0x0d] = "fconst_2";
|
72 |
2
| length[0x0d] = 1;
|
73 |
2
| opcode[0x0e] = "dconst_0";
|
74 |
2
| length[0x0e] = 1;
|
75 |
2
| opcode[0x0f] = "dconst_1";
|
76 |
2
| length[0x0f] = 1;
|
77 |
| |
78 |
2
| opcode[0x10] = "bipush";
|
79 |
2
| length[0x10] = 2;
|
80 |
2
| opcode[0x11] = "sipush";
|
81 |
2
| length[0x11] = 3;
|
82 |
2
| opcode[0x12] = "ldc";
|
83 |
2
| length[0x12] = 2;
|
84 |
2
| opcode[0x13] = "ldc_w";
|
85 |
2
| length[0x13] = 3;
|
86 |
2
| opcode[0x14] = "ldc2_w";
|
87 |
2
| length[0x14] = 3;
|
88 |
2
| opcode[0x15] = "iload";
|
89 |
2
| length[0x15] = 2;
|
90 |
2
| opcode[0x16] = "lload";
|
91 |
2
| length[0x16] = 2;
|
92 |
2
| opcode[0x17] = "fload";
|
93 |
2
| length[0x17] = 2;
|
94 |
2
| opcode[0x18] = "dload";
|
95 |
2
| length[0x18] = 2;
|
96 |
2
| opcode[0x19] = "aload";
|
97 |
2
| length[0x19] = 2;
|
98 |
2
| opcode[0x1a] = "iload_0";
|
99 |
2
| length[0x1a] = 1;
|
100 |
2
| opcode[0x1b] = "iload_1";
|
101 |
2
| length[0x1b] = 1;
|
102 |
2
| opcode[0x1c] = "iload_2";
|
103 |
2
| length[0x1c] = 1;
|
104 |
2
| opcode[0x1d] = "iload_3";
|
105 |
2
| length[0x1d] = 1;
|
106 |
2
| opcode[0x1e] = "lload_0";
|
107 |
2
| length[0x1e] = 1;
|
108 |
2
| opcode[0x1f] = "lload_1";
|
109 |
2
| length[0x1f] = 1;
|
110 |
| |
111 |
2
| opcode[0x20] = "lload_2";
|
112 |
2
| length[0x20] = 1;
|
113 |
2
| opcode[0x21] = "lload_3";
|
114 |
2
| length[0x21] = 1;
|
115 |
2
| opcode[0x22] = "fload_0";
|
116 |
2
| length[0x22] = 1;
|
117 |
2
| opcode[0x23] = "fload_1";
|
118 |
2
| length[0x23] = 1;
|
119 |
2
| opcode[0x24] = "fload_2";
|
120 |
2
| length[0x24] = 1;
|
121 |
2
| opcode[0x25] = "fload_3";
|
122 |
2
| length[0x25] = 1;
|
123 |
2
| opcode[0x26] = "dload_0";
|
124 |
2
| length[0x26] = 1;
|
125 |
2
| opcode[0x27] = "dload_1";
|
126 |
2
| length[0x27] = 1;
|
127 |
2
| opcode[0x28] = "dload_2";
|
128 |
2
| length[0x28] = 1;
|
129 |
2
| opcode[0x29] = "dload_3";
|
130 |
2
| length[0x29] = 1;
|
131 |
2
| opcode[0x2a] = "aload_0";
|
132 |
2
| length[0x2a] = 1;
|
133 |
2
| opcode[0x2b] = "aload_1";
|
134 |
2
| length[0x2b] = 1;
|
135 |
2
| opcode[0x2c] = "aload_2";
|
136 |
2
| length[0x2c] = 1;
|
137 |
2
| opcode[0x2d] = "aload_3";
|
138 |
2
| length[0x2d] = 1;
|
139 |
2
| opcode[0x2e] = "iaload";
|
140 |
2
| length[0x2e] = 1;
|
141 |
2
| opcode[0x2f] = "laload";
|
142 |
2
| length[0x2f] = 1;
|
143 |
| |
144 |
2
| opcode[0x30] = "faload";
|
145 |
2
| length[0x30] = 1;
|
146 |
2
| opcode[0x31] = "daload";
|
147 |
2
| length[0x31] = 1;
|
148 |
2
| opcode[0x32] = "aaload";
|
149 |
2
| length[0x32] = 1;
|
150 |
2
| opcode[0x33] = "baload";
|
151 |
2
| length[0x33] = 1;
|
152 |
2
| opcode[0x34] = "caload";
|
153 |
2
| length[0x34] = 1;
|
154 |
2
| opcode[0x35] = "saload";
|
155 |
2
| length[0x35] = 1;
|
156 |
2
| opcode[0x36] = "istore";
|
157 |
2
| length[0x36] = 2;
|
158 |
2
| opcode[0x37] = "lstore";
|
159 |
2
| length[0x37] = 2;
|
160 |
2
| opcode[0x38] = "fstore";
|
161 |
2
| length[0x38] = 2;
|
162 |
2
| opcode[0x39] = "dstore";
|
163 |
2
| length[0x39] = 2;
|
164 |
2
| opcode[0x3a] = "astore";
|
165 |
2
| length[0x3a] = 2;
|
166 |
2
| opcode[0x3b] = "istore_0";
|
167 |
2
| length[0x3b] = 1;
|
168 |
2
| opcode[0x3c] = "istore_1";
|
169 |
2
| length[0x3c] = 1;
|
170 |
2
| opcode[0x3d] = "istore_2";
|
171 |
2
| length[0x3d] = 1;
|
172 |
2
| opcode[0x3e] = "istore_3";
|
173 |
2
| length[0x3e] = 1;
|
174 |
2
| opcode[0x3f] = "lstore_0";
|
175 |
2
| length[0x3f] = 1;
|
176 |
| |
177 |
2
| opcode[0x40] = "lstore_1";
|
178 |
2
| length[0x40] = 1;
|
179 |
2
| opcode[0x41] = "lstore_2";
|
180 |
2
| length[0x41] = 1;
|
181 |
2
| opcode[0x42] = "lstore_3";
|
182 |
2
| length[0x42] = 1;
|
183 |
2
| opcode[0x43] = "fstore_0";
|
184 |
2
| length[0x43] = 1;
|
185 |
2
| opcode[0x44] = "fstore_1";
|
186 |
2
| length[0x44] = 1;
|
187 |
2
| opcode[0x45] = "fstore_2";
|
188 |
2
| length[0x45] = 1;
|
189 |
2
| opcode[0x46] = "fstore_3";
|
190 |
2
| length[0x46] = 1;
|
191 |
2
| opcode[0x47] = "dstore_0";
|
192 |
2
| length[0x47] = 1;
|
193 |
2
| opcode[0x48] = "dstore_1";
|
194 |
2
| length[0x48] = 1;
|
195 |
2
| opcode[0x49] = "dstore_2";
|
196 |
2
| length[0x49] = 1;
|
197 |
2
| opcode[0x4a] = "dstore_3";
|
198 |
2
| length[0x4a] = 1;
|
199 |
2
| opcode[0x4b] = "astore_0";
|
200 |
2
| length[0x4b] = 1;
|
201 |
2
| opcode[0x4c] = "astore_1";
|
202 |
2
| length[0x4c] = 1;
|
203 |
2
| opcode[0x4d] = "astore_2";
|
204 |
2
| length[0x4d] = 1;
|
205 |
2
| opcode[0x4e] = "astore_3";
|
206 |
2
| length[0x4e] = 1;
|
207 |
2
| opcode[0x4f] = "iastore";
|
208 |
2
| length[0x4f] = 1;
|
209 |
| |
210 |
2
| opcode[0x50] = "lastore";
|
211 |
2
| length[0x50] = 1;
|
212 |
2
| opcode[0x51] = "fastore";
|
213 |
2
| length[0x51] = 1;
|
214 |
2
| opcode[0x52] = "dastore";
|
215 |
2
| length[0x52] = 1;
|
216 |
2
| opcode[0x53] = "aastore";
|
217 |
2
| length[0x53] = 1;
|
218 |
2
| opcode[0x54] = "bastore";
|
219 |
2
| length[0x54] = 1;
|
220 |
2
| opcode[0x55] = "castore";
|
221 |
2
| length[0x55] = 1;
|
222 |
2
| opcode[0x56] = "sastore";
|
223 |
2
| length[0x56] = 1;
|
224 |
2
| opcode[0x57] = "pop";
|
225 |
2
| length[0x57] = 1;
|
226 |
2
| opcode[0x58] = "pop2";
|
227 |
2
| length[0x58] = 1;
|
228 |
2
| opcode[0x59] = "dup";
|
229 |
2
| length[0x59] = 1;
|
230 |
2
| opcode[0x5a] = "dup_x1";
|
231 |
2
| length[0x5a] = 1;
|
232 |
2
| opcode[0x5b] = "dup_x2";
|
233 |
2
| length[0x5b] = 1;
|
234 |
2
| opcode[0x5c] = "dup2";
|
235 |
2
| length[0x5c] = 1;
|
236 |
2
| opcode[0x5d] = "dup2_x1";
|
237 |
2
| length[0x5d] = 1;
|
238 |
2
| opcode[0x5e] = "dup2_x2";
|
239 |
2
| length[0x5e] = 1;
|
240 |
2
| opcode[0x5f] = "swap";
|
241 |
2
| length[0x5f] = 1;
|
242 |
| |
243 |
2
| opcode[0x60] = "iadd";
|
244 |
2
| length[0x60] = 1;
|
245 |
2
| opcode[0x61] = "ladd";
|
246 |
2
| length[0x61] = 1;
|
247 |
2
| opcode[0x62] = "fadd";
|
248 |
2
| length[0x62] = 1;
|
249 |
2
| opcode[0x63] = "dadd";
|
250 |
2
| length[0x63] = 1;
|
251 |
2
| opcode[0x64] = "isub";
|
252 |
2
| length[0x64] = 1;
|
253 |
2
| opcode[0x65] = "lsub";
|
254 |
2
| length[0x65] = 1;
|
255 |
2
| opcode[0x66] = "fsub";
|
256 |
2
| length[0x66] = 1;
|
257 |
2
| opcode[0x67] = "dsub";
|
258 |
2
| length[0x67] = 1;
|
259 |
2
| opcode[0x68] = "imul";
|
260 |
2
| length[0x68] = 1;
|
261 |
2
| opcode[0x69] = "lmul";
|
262 |
2
| length[0x69] = 1;
|
263 |
2
| opcode[0x6a] = "fmul";
|
264 |
2
| length[0x6a] = 1;
|
265 |
2
| opcode[0x6b] = "dmul";
|
266 |
2
| length[0x6b] = 1;
|
267 |
2
| opcode[0x6c] = "idiv";
|
268 |
2
| length[0x6c] = 1;
|
269 |
2
| opcode[0x6d] = "ldiv";
|
270 |
2
| length[0x6d] = 1;
|
271 |
2
| opcode[0x6e] = "fdiv";
|
272 |
2
| length[0x6e] = 1;
|
273 |
2
| opcode[0x6f] = "ddiv";
|
274 |
2
| length[0x6f] = 1;
|
275 |
| |
276 |
2
| opcode[0x70] = "irem";
|
277 |
2
| length[0x70] = 1;
|
278 |
2
| opcode[0x71] = "lrem";
|
279 |
2
| length[0x71] = 1;
|
280 |
2
| opcode[0x72] = "frem";
|
281 |
2
| length[0x72] = 1;
|
282 |
2
| opcode[0x73] = "drem";
|
283 |
2
| length[0x73] = 1;
|
284 |
2
| opcode[0x74] = "ineg";
|
285 |
2
| length[0x74] = 1;
|
286 |
2
| opcode[0x75] = "lneg";
|
287 |
2
| length[0x75] = 1;
|
288 |
2
| opcode[0x76] = "fneg";
|
289 |
2
| length[0x76] = 1;
|
290 |
2
| opcode[0x77] = "dneg";
|
291 |
2
| length[0x77] = 1;
|
292 |
2
| opcode[0x78] = "ishl";
|
293 |
2
| length[0x78] = 1;
|
294 |
2
| opcode[0x79] = "lshl";
|
295 |
2
| length[0x79] = 1;
|
296 |
2
| opcode[0x7a] = "ishr";
|
297 |
2
| length[0x7a] = 1;
|
298 |
2
| opcode[0x7b] = "lshr";
|
299 |
2
| length[0x7b] = 1;
|
300 |
2
| opcode[0x7c] = "iushr";
|
301 |
2
| length[0x7c] = 1;
|
302 |
2
| opcode[0x7d] = "lushr";
|
303 |
2
| length[0x7d] = 1;
|
304 |
2
| opcode[0x7e] = "iand";
|
305 |
2
| length[0x7e] = 1;
|
306 |
2
| opcode[0x7f] = "land";
|
307 |
2
| length[0x7f] = 1;
|
308 |
| |
309 |
2
| opcode[0x80] = "ior";
|
310 |
2
| length[0x80] = 1;
|
311 |
2
| opcode[0x81] = "lor";
|
312 |
2
| length[0x81] = 1;
|
313 |
2
| opcode[0x82] = "ixor";
|
314 |
2
| length[0x82] = 1;
|
315 |
2
| opcode[0x83] = "lxor";
|
316 |
2
| length[0x83] = 1;
|
317 |
2
| opcode[0x84] = "iinc";
|
318 |
2
| length[0x84] = 3;
|
319 |
2
| opcode[0x85] = "i2l";
|
320 |
2
| length[0x85] = 1;
|
321 |
2
| opcode[0x86] = "i2f";
|
322 |
2
| length[0x86] = 1;
|
323 |
2
| opcode[0x87] = "i2d";
|
324 |
2
| length[0x87] = 1;
|
325 |
2
| opcode[0x88] = "l2i";
|
326 |
2
| length[0x88] = 1;
|
327 |
2
| opcode[0x89] = "l2f";
|
328 |
2
| length[0x89] = 1;
|
329 |
2
| opcode[0x8a] = "l2d";
|
330 |
2
| length[0x8a] = 1;
|
331 |
2
| opcode[0x8b] = "f2i";
|
332 |
2
| length[0x8b] = 1;
|
333 |
2
| opcode[0x8c] = "f2l";
|
334 |
2
| length[0x8c] = 1;
|
335 |
2
| opcode[0x8d] = "f2d";
|
336 |
2
| length[0x8d] = 1;
|
337 |
2
| opcode[0x8e] = "d2i";
|
338 |
2
| length[0x8e] = 1;
|
339 |
2
| opcode[0x8f] = "d2l";
|
340 |
2
| length[0x8f] = 1;
|
341 |
| |
342 |
2
| opcode[0x90] = "d2f";
|
343 |
2
| length[0x90] = 1;
|
344 |
2
| opcode[0x91] = "i2b";
|
345 |
2
| length[0x91] = 1;
|
346 |
2
| opcode[0x92] = "i2c";
|
347 |
2
| length[0x92] = 1;
|
348 |
2
| opcode[0x93] = "i2s";
|
349 |
2
| length[0x93] = 1;
|
350 |
2
| opcode[0x94] = "lcmp";
|
351 |
2
| length[0x94] = 1;
|
352 |
2
| opcode[0x95] = "fcmpl";
|
353 |
2
| length[0x95] = 1;
|
354 |
2
| opcode[0x96] = "fcmpg";
|
355 |
2
| length[0x96] = 1;
|
356 |
2
| opcode[0x97] = "dcmpl";
|
357 |
2
| length[0x97] = 1;
|
358 |
2
| opcode[0x98] = "dcmpg";
|
359 |
2
| length[0x98] = 1;
|
360 |
2
| opcode[0x99] = "ifeq";
|
361 |
2
| length[0x99] = 3;
|
362 |
2
| opcode[0x9a] = "ifne";
|
363 |
2
| length[0x9a] = 3;
|
364 |
2
| opcode[0x9b] = "iflt";
|
365 |
2
| length[0x9b] = 3;
|
366 |
2
| opcode[0x9c] = "ifge";
|
367 |
2
| length[0x9c] = 3;
|
368 |
2
| opcode[0x9d] = "ifgt";
|
369 |
2
| length[0x9d] = 3;
|
370 |
2
| opcode[0x9e] = "ifle";
|
371 |
2
| length[0x9e] = 3;
|
372 |
2
| opcode[0x9f] = "if_icmpeq";
|
373 |
2
| length[0x9f] = 3;
|
374 |
| |
375 |
2
| opcode[0xa0] = "if_icmpne";
|
376 |
2
| length[0xa0] = 3;
|
377 |
2
| opcode[0xa1] = "if_icmplt";
|
378 |
2
| length[0xa1] = 3;
|
379 |
2
| opcode[0xa2] = "if_icmpge";
|
380 |
2
| length[0xa2] = 3;
|
381 |
2
| opcode[0xa3] = "if_icmpgt";
|
382 |
2
| length[0xa3] = 3;
|
383 |
2
| opcode[0xa4] = "if_icmple";
|
384 |
2
| length[0xa4] = 3;
|
385 |
2
| opcode[0xa5] = "if_acmpeq";
|
386 |
2
| length[0xa5] = 3;
|
387 |
2
| opcode[0xa6] = "if_acmpne";
|
388 |
2
| length[0xa6] = 3;
|
389 |
2
| opcode[0xa7] = "goto";
|
390 |
2
| length[0xa7] = 3;
|
391 |
2
| opcode[0xa8] = "jsr";
|
392 |
2
| length[0xa8] = 3;
|
393 |
2
| opcode[0xa9] = "ret";
|
394 |
2
| length[0xa9] = 2;
|
395 |
2
| opcode[0xaa] = "tableswitch";
|
396 |
2
| length[0xaa] = -1;
|
397 |
2
| opcode[0xab] = "lookupswitch";
|
398 |
2
| length[0xab] = -1;
|
399 |
2
| opcode[0xac] = "ireturn";
|
400 |
2
| length[0xac] = 1;
|
401 |
2
| opcode[0xad] = "lreturn";
|
402 |
2
| length[0xad] = 1;
|
403 |
2
| opcode[0xae] = "freturn";
|
404 |
2
| length[0xae] = 1;
|
405 |
2
| opcode[0xaf] = "dreturn";
|
406 |
2
| length[0xaf] = 1;
|
407 |
| |
408 |
2
| opcode[0xb0] = "areturn";
|
409 |
2
| length[0xb0] = 1;
|
410 |
2
| opcode[0xb1] = "return";
|
411 |
2
| length[0xb1] = 1;
|
412 |
2
| opcode[0xb2] = "getstatic";
|
413 |
2
| length[0xb2] = 3;
|
414 |
2
| opcode[0xb3] = "putstatic";
|
415 |
2
| length[0xb3] = 3;
|
416 |
2
| opcode[0xb4] = "getfield";
|
417 |
2
| length[0xb4] = 3;
|
418 |
2
| opcode[0xb5] = "putfield";
|
419 |
2
| length[0xb5] = 3;
|
420 |
2
| opcode[0xb6] = "invokevirtual";
|
421 |
2
| length[0xb6] = 3;
|
422 |
2
| opcode[0xb7] = "invokespecial";
|
423 |
2
| length[0xb7] = 3;
|
424 |
2
| opcode[0xb8] = "invokestatic";
|
425 |
2
| length[0xb8] = 3;
|
426 |
2
| opcode[0xb9] = "invokeinterface";
|
427 |
2
| length[0xb9] = 5;
|
428 |
2
| opcode[0xba] = "invokedynamic";
|
429 |
2
| length[0xba] = 3;
|
430 |
2
| opcode[0xbb] = "new";
|
431 |
2
| length[0xbb] = 3;
|
432 |
2
| opcode[0xbc] = "newarray";
|
433 |
2
| length[0xbc] = 2;
|
434 |
2
| opcode[0xbd] = "anewarray";
|
435 |
2
| length[0xbd] = 3;
|
436 |
2
| opcode[0xbe] = "arraylength";
|
437 |
2
| length[0xbe] = 1;
|
438 |
2
| opcode[0xbf] = "athrow";
|
439 |
2
| length[0xbf] = 1;
|
440 |
| |
441 |
2
| opcode[0xc0] = "checkcast";
|
442 |
2
| length[0xc0] = 3;
|
443 |
2
| opcode[0xc1] = "instanceof";
|
444 |
2
| length[0xc1] = 3;
|
445 |
2
| opcode[0xc2] = "monitorenter";
|
446 |
2
| length[0xc2] = 1;
|
447 |
2
| opcode[0xc3] = "monitorexit";
|
448 |
2
| length[0xc3] = 1;
|
449 |
2
| opcode[0xc4] = "wide";
|
450 |
2
| length[0xc4] = -1;
|
451 |
2
| opcode[0xc5] = "multianewarray";
|
452 |
2
| length[0xc5] = 4;
|
453 |
2
| opcode[0xc6] = "ifnull";
|
454 |
2
| length[0xc6] = 3;
|
455 |
2
| opcode[0xc7] = "ifnonnull";
|
456 |
2
| length[0xc7] = 3;
|
457 |
2
| opcode[0xc8] = "goto_w";
|
458 |
2
| length[0xc8] = 5;
|
459 |
2
| opcode[0xc9] = "jsr_w";
|
460 |
2
| length[0xc9] = 5;
|
461 |
2
| opcode[0xca] = "breakpoint";
|
462 |
2
| length[0xca] = 1;
|
463 |
2
| opcode[0xcb] = "xxxundefinedxxx";
|
464 |
2
| length[0xcb] = 1;
|
465 |
2
| opcode[0xcc] = "xxxundefinedxxx";
|
466 |
2
| length[0xcc] = 1;
|
467 |
2
| opcode[0xcd] = "xxxundefinedxxx";
|
468 |
2
| length[0xcd] = 1;
|
469 |
2
| opcode[0xce] = "xxxundefinedxxx";
|
470 |
2
| length[0xce] = 1;
|
471 |
2
| opcode[0xcf] = "xxxundefinedxxx";
|
472 |
2
| length[0xcf] = 1;
|
473 |
| |
474 |
2
| opcode[0xd0] = "xxxundefinedxxx";
|
475 |
2
| length[0xd0] = 1;
|
476 |
2
| opcode[0xd1] = "xxxundefinedxxx";
|
477 |
2
| length[0xd1] = 1;
|
478 |
2
| opcode[0xd2] = "xxxundefinedxxx";
|
479 |
2
| length[0xd2] = 1;
|
480 |
2
| opcode[0xd3] = "xxxundefinedxxx";
|
481 |
2
| length[0xd3] = 1;
|
482 |
2
| opcode[0xd4] = "xxxundefinedxxx";
|
483 |
2
| length[0xd4] = 1;
|
484 |
2
| opcode[0xd5] = "xxxundefinedxxx";
|
485 |
2
| length[0xd5] = 1;
|
486 |
2
| opcode[0xd6] = "xxxundefinedxxx";
|
487 |
2
| length[0xd6] = 1;
|
488 |
2
| opcode[0xd7] = "xxxundefinedxxx";
|
489 |
2
| length[0xd7] = 1;
|
490 |
2
| opcode[0xd8] = "xxxundefinedxxx";
|
491 |
2
| length[0xd8] = 1;
|
492 |
2
| opcode[0xd9] = "xxxundefinedxxx";
|
493 |
2
| length[0xd9] = 1;
|
494 |
2
| opcode[0xda] = "xxxundefinedxxx";
|
495 |
2
| length[0xda] = 1;
|
496 |
2
| opcode[0xdb] = "xxxundefinedxxx";
|
497 |
2
| length[0xdb] = 1;
|
498 |
2
| opcode[0xdc] = "xxxundefinedxxx";
|
499 |
2
| length[0xdc] = 1;
|
500 |
2
| opcode[0xdd] = "xxxundefinedxxx";
|
501 |
2
| length[0xdd] = 1;
|
502 |
2
| opcode[0xde] = "xxxundefinedxxx";
|
503 |
2
| length[0xde] = 1;
|
504 |
2
| opcode[0xdf] = "xxxundefinedxxx";
|
505 |
2
| length[0xdf] = 1;
|
506 |
| |
507 |
2
| opcode[0xe0] = "xxxundefinedxxx";
|
508 |
2
| length[0xe0] = 1;
|
509 |
2
| opcode[0xe1] = "xxxundefinedxxx";
|
510 |
2
| length[0xe1] = 1;
|
511 |
2
| opcode[0xe2] = "xxxundefinedxxx";
|
512 |
2
| length[0xe2] = 1;
|
513 |
2
| opcode[0xe3] = "xxxundefinedxxx";
|
514 |
2
| length[0xe3] = 1;
|
515 |
2
| opcode[0xe4] = "xxxundefinedxxx";
|
516 |
2
| length[0xe4] = 1;
|
517 |
2
| opcode[0xe5] = "xxxundefinedxxx";
|
518 |
2
| length[0xe5] = 1;
|
519 |
2
| opcode[0xe6] = "xxxundefinedxxx";
|
520 |
2
| length[0xe6] = 1;
|
521 |
2
| opcode[0xe7] = "xxxundefinedxxx";
|
522 |
2
| length[0xe7] = 1;
|
523 |
2
| opcode[0xe8] = "xxxundefinedxxx";
|
524 |
2
| length[0xe8] = 1;
|
525 |
2
| opcode[0xe9] = "xxxundefinedxxx";
|
526 |
2
| length[0xe9] = 1;
|
527 |
2
| opcode[0xea] = "xxxundefinedxxx";
|
528 |
2
| length[0xea] = 1;
|
529 |
2
| opcode[0xeb] = "xxxundefinedxxx";
|
530 |
2
| length[0xeb] = 1;
|
531 |
2
| opcode[0xec] = "xxxundefinedxxx";
|
532 |
2
| length[0xec] = 1;
|
533 |
2
| opcode[0xed] = "xxxundefinedxxx";
|
534 |
2
| length[0xed] = 1;
|
535 |
2
| opcode[0xee] = "xxxundefinedxxx";
|
536 |
2
| length[0xee] = 1;
|
537 |
2
| opcode[0xef] = "xxxundefinedxxx";
|
538 |
2
| length[0xef] = 1;
|
539 |
| |
540 |
2
| opcode[0xf0] = "xxxundefinedxxx";
|
541 |
2
| length[0xf0] = 1;
|
542 |
2
| opcode[0xf1] = "xxxundefinedxxx";
|
543 |
2
| length[0xf1] = 1;
|
544 |
2
| opcode[0xf2] = "xxxundefinedxxx";
|
545 |
2
| length[0xf2] = 1;
|
546 |
2
| opcode[0xf3] = "xxxundefinedxxx";
|
547 |
2
| length[0xf3] = 1;
|
548 |
2
| opcode[0xf4] = "xxxundefinedxxx";
|
549 |
2
| length[0xf4] = 1;
|
550 |
2
| opcode[0xf5] = "xxxundefinedxxx";
|
551 |
2
| length[0xf5] = 1;
|
552 |
2
| opcode[0xf6] = "xxxundefinedxxx";
|
553 |
2
| length[0xf6] = 1;
|
554 |
2
| opcode[0xf7] = "xxxundefinedxxx";
|
555 |
2
| length[0xf7] = 1;
|
556 |
2
| opcode[0xf8] = "xxxundefinedxxx";
|
557 |
2
| length[0xf8] = 1;
|
558 |
2
| opcode[0xf9] = "xxxundefinedxxx";
|
559 |
2
| length[0xf9] = 1;
|
560 |
2
| opcode[0xfa] = "xxxundefinedxxx";
|
561 |
2
| length[0xfa] = 1;
|
562 |
2
| opcode[0xfb] = "xxxundefinedxxx";
|
563 |
2
| length[0xfb] = 1;
|
564 |
2
| opcode[0xfc] = "xxxundefinedxxx";
|
565 |
2
| length[0xfc] = 1;
|
566 |
2
| opcode[0xfd] = "xxxundefinedxxx";
|
567 |
2
| length[0xfd] = 1;
|
568 |
2
| opcode[0xfe] = "impdep1";
|
569 |
2
| length[0xfe] = 1;
|
570 |
2
| opcode[0xff] = "impdep2";
|
571 |
2
| length[0xff] = 1;
|
572 |
| } |
573 |
| |
574 |
| private Code_attribute code; |
575 |
| private byte[] bytecode; |
576 |
| private int start; |
577 |
| |
578 |
71086
| public Instruction(Code_attribute code, byte[] bytecode, int start) {
|
579 |
71086
| this.code = code;
|
580 |
71086
| this.bytecode = bytecode;
|
581 |
71086
| this.start = start;
|
582 |
| } |
583 |
| |
584 |
247117
| public byte[] getBytecode() {
|
585 |
247117
| return bytecode;
|
586 |
| } |
587 |
| |
588 |
247313
| public int getStart() {
|
589 |
247313
| return start;
|
590 |
| } |
591 |
| |
592 |
231387
| public int getOpcode() {
|
593 |
231387
| return getByte(0);
|
594 |
| } |
595 |
| |
596 |
444
| public static String getMnemonic(int instruction) {
|
597 |
444
| return opcode[instruction];
|
598 |
| } |
599 |
| |
600 |
431
| public String getMnemonic() {
|
601 |
431
| String result = getMnemonic(getOpcode());
|
602 |
| |
603 |
431
| if (getOpcode() == 0xc4 ) {
|
604 |
13
| result += " " + getMnemonic(getByte(1));
|
605 |
| } |
606 |
| |
607 |
431
| return result;
|
608 |
| } |
609 |
| |
610 |
71086
| public int getLength() {
|
611 |
71086
| int result = length[getOpcode()];
|
612 |
| |
613 |
71086
| int padding, low, high, npairs;
|
614 |
| |
615 |
71086
| switch (getOpcode()) {
|
616 |
14
| case 0xaa:
|
617 |
| |
618 |
14
| padding = 3 - (start % 4);
|
619 |
14
| low =
|
620 |
| (getByte(padding+5) << 24) | |
621 |
| (getByte(padding+6) << 16) | |
622 |
| (getByte(padding+7) << 8) | |
623 |
| (getByte(padding+8)); |
624 |
14
| high =
|
625 |
| (getByte(padding+9) << 24) | |
626 |
| (getByte(padding+10) << 16) | |
627 |
| (getByte(padding+11) << 8) | |
628 |
| (getByte(padding+12)); |
629 |
14
| result =
|
630 |
| 1 + |
631 |
| padding + |
632 |
| 12 + |
633 |
| (high - low + 1) * 4; |
634 |
14
| break;
|
635 |
| |
636 |
2
| case 0xab:
|
637 |
| |
638 |
2
| padding = 3 - (start % 4);
|
639 |
2
| npairs =
|
640 |
| (getByte(padding+5) << 24) | |
641 |
| (getByte(padding+6) << 16) | |
642 |
| (getByte(padding+7) << 8) | |
643 |
| (getByte(padding+8)); |
644 |
2
| result =
|
645 |
| 1 + |
646 |
| padding + |
647 |
| 8 + |
648 |
| (npairs * 8); |
649 |
2
| break;
|
650 |
| |
651 |
15
| case 0xc4:
|
652 |
| |
653 |
15
| if (getByte(1) == 0x84 ) {
|
654 |
2
| result = 6;
|
655 |
| } else { |
656 |
13
| result = 4;
|
657 |
| } |
658 |
15
| break;
|
659 |
| |
660 |
71055
| default:
|
661 |
| |
662 |
71055
| break;
|
663 |
| } |
664 |
| |
665 |
71086
| return result;
|
666 |
| } |
667 |
| |
668 |
8804
| public int getIndex() {
|
669 |
8804
| int result;
|
670 |
| |
671 |
8804
| switch (getOpcode()) {
|
672 |
1
| case 0x13:
|
673 |
1
| case 0x14:
|
674 |
1341
| case 0xb2:
|
675 |
146
| case 0xb3:
|
676 |
794
| case 0xb4:
|
677 |
61
| case 0xb5:
|
678 |
2537
| case 0xb6:
|
679 |
1444
| case 0xb7:
|
680 |
617
| case 0xb8:
|
681 |
1
| case 0xb9:
|
682 |
1
| case 0xba:
|
683 |
5
| case 0xbb:
|
684 |
1
| case 0xbd:
|
685 |
1
| case 0xc0:
|
686 |
1
| case 0xc1:
|
687 |
1
| case 0xc5:
|
688 |
6953
| result = (getByte(1) << 8) | getByte(2);
|
689 |
6953
| break;
|
690 |
1
| case 0x1a:
|
691 |
1
| case 0x1e:
|
692 |
1
| case 0x22:
|
693 |
1
| case 0x26:
|
694 |
37
| case 0x2a:
|
695 |
1
| case 0x3b:
|
696 |
1
| case 0x3f:
|
697 |
1
| case 0x43:
|
698 |
1
| case 0x47:
|
699 |
1
| case 0x4b:
|
700 |
46
| result = 0;
|
701 |
46
| break;
|
702 |
1
| case 0x1b:
|
703 |
1
| case 0x1f:
|
704 |
5
| case 0x23:
|
705 |
1
| case 0x27:
|
706 |
5
| case 0x2b:
|
707 |
3
| case 0x3c:
|
708 |
1
| case 0x40:
|
709 |
1
| case 0x44:
|
710 |
1
| case 0x48:
|
711 |
9
| case 0x4c:
|
712 |
28
| result = 1;
|
713 |
28
| break;
|
714 |
1
| case 0x1c:
|
715 |
1
| case 0x20:
|
716 |
1
| case 0x24:
|
717 |
1
| case 0x28:
|
718 |
1
| case 0x2c:
|
719 |
1
| case 0x3d:
|
720 |
1
| case 0x41:
|
721 |
3
| case 0x45:
|
722 |
1
| case 0x49:
|
723 |
1
| case 0x4d:
|
724 |
12
| result = 2;
|
725 |
12
| break;
|
726 |
1
| case 0x1d:
|
727 |
1
| case 0x21:
|
728 |
1
| case 0x25:
|
729 |
1
| case 0x29:
|
730 |
1
| case 0x2d:
|
731 |
1
| case 0x3e:
|
732 |
1
| case 0x42:
|
733 |
1
| case 0x46:
|
734 |
1
| case 0x4a:
|
735 |
1
| case 0x4e:
|
736 |
10
| result = 3;
|
737 |
10
| break;
|
738 |
1529
| case 0x12:
|
739 |
4
| case 0x15:
|
740 |
1
| case 0x16:
|
741 |
1
| case 0x17:
|
742 |
1
| case 0x18:
|
743 |
1
| case 0x19:
|
744 |
3
| case 0x36:
|
745 |
1
| case 0x37:
|
746 |
1
| case 0x38:
|
747 |
1
| case 0x39:
|
748 |
1
| case 0x3a:
|
749 |
1
| case 0x84:
|
750 |
1
| case 0xa9:
|
751 |
1546
| result = getByte(1);
|
752 |
1546
| break;
|
753 |
17
| case 0xc4:
|
754 |
17
| result = (getByte(2) << 8) | getByte(3);
|
755 |
17
| break;
|
756 |
192
| default:
|
757 |
192
| result = -1;
|
758 |
192
| break;
|
759 |
| } |
760 |
| |
761 |
8804
| return result;
|
762 |
| } |
763 |
| |
764 |
278
| public int getOffset() {
|
765 |
278
| int result;
|
766 |
| |
767 |
278
| switch(getOpcode()) {
|
768 |
1
| case 0x99:
|
769 |
1
| case 0x9a:
|
770 |
1
| case 0x9b:
|
771 |
1
| case 0x9c:
|
772 |
1
| case 0x9d:
|
773 |
1
| case 0x9e:
|
774 |
1
| case 0x9f:
|
775 |
1
| case 0xa0:
|
776 |
1
| case 0xa1:
|
777 |
1
| case 0xa2:
|
778 |
1
| case 0xa3:
|
779 |
1
| case 0xa4:
|
780 |
1
| case 0xa5:
|
781 |
1
| case 0xa6:
|
782 |
6
| case 0xa7:
|
783 |
1
| case 0xa8:
|
784 |
1
| case 0xc6:
|
785 |
1
| case 0xc7:
|
786 |
23
| result = (getSignedByte(1) << 8) | getByte(2);
|
787 |
23
| break;
|
788 |
2
| case 0xc8:
|
789 |
1
| case 0xc9:
|
790 |
3
| result = (getSignedByte(1) << 24) | (getByte(2) << 16) | (getByte(3) << 8) | getByte(4);
|
791 |
3
| break;
|
792 |
252
| default:
|
793 |
252
| result = 0;
|
794 |
252
| break;
|
795 |
| } |
796 |
| |
797 |
278
| return result;
|
798 |
| } |
799 |
| |
800 |
288
| public int getValue() {
|
801 |
288
| int result;
|
802 |
| |
803 |
288
| switch(getOpcode()) {
|
804 |
1
| case 0x02:
|
805 |
1
| result = -1;
|
806 |
1
| break;
|
807 |
2
| case 0x03:
|
808 |
1
| case 0x09:
|
809 |
1
| case 0x0b:
|
810 |
1
| case 0x0e:
|
811 |
5
| result = 0;
|
812 |
5
| break;
|
813 |
9
| case 0x04:
|
814 |
1
| case 0x0a:
|
815 |
1
| case 0x0c:
|
816 |
1
| case 0x0f:
|
817 |
12
| result = 1;
|
818 |
12
| break;
|
819 |
1
| case 0x05:
|
820 |
1
| case 0x0d:
|
821 |
2
| result = 2;
|
822 |
2
| break;
|
823 |
1
| case 0x06:
|
824 |
1
| result = 3;
|
825 |
1
| break;
|
826 |
2
| case 0x07:
|
827 |
2
| result = 4;
|
828 |
2
| break;
|
829 |
1
| case 0x08:
|
830 |
1
| result = 5;
|
831 |
1
| break;
|
832 |
2
| case 0x10:
|
833 |
2
| result = getSignedByte(1);
|
834 |
2
| break;
|
835 |
6
| case 0x11:
|
836 |
6
| result = (getSignedByte(1) << 8) | getByte(2);
|
837 |
6
| break;
|
838 |
1
| case 0x84:
|
839 |
1
| result = getSignedByte(2);
|
840 |
1
| break;
|
841 |
13
| case 0xc4:
|
842 |
13
| if (getByte(1) == 0x84 ) {
|
843 |
2
| result = (getSignedByte(4) << 8) | getByte(5);
|
844 |
| } else { |
845 |
11
| result = 0;
|
846 |
| } |
847 |
13
| break;
|
848 |
242
| default:
|
849 |
242
| result = 0;
|
850 |
242
| break;
|
851 |
| } |
852 |
| |
853 |
288
| return result;
|
854 |
| } |
855 |
| |
856 |
247080
| public int getByte(int offset) {
|
857 |
247080
| return getSignedByte(offset) & 0xff;
|
858 |
| } |
859 |
| |
860 |
247117
| private byte getSignedByte(int offset) {
|
861 |
247117
| return getBytecode()[getStart() + offset];
|
862 |
| } |
863 |
| |
864 |
10317
| public com.jeantessier.classreader.ConstantPoolEntry getIndexedConstantPoolEntry() {
|
865 |
10317
| com.jeantessier.classreader.ConstantPoolEntry result;
|
866 |
| |
867 |
10317
| switch (getOpcode()) {
|
868 |
1522
| case 0x12:
|
869 |
0
| case 0x13:
|
870 |
0
| case 0x14:
|
871 |
1330
| case 0xb2:
|
872 |
145
| case 0xb3:
|
873 |
785
| case 0xb4:
|
874 |
60
| case 0xb5:
|
875 |
2532
| case 0xb6:
|
876 |
1425
| case 0xb7:
|
877 |
614
| case 0xb8:
|
878 |
0
| case 0xb9:
|
879 |
0
| case 0xba:
|
880 |
2
| case 0xbb:
|
881 |
0
| case 0xbd:
|
882 |
0
| case 0xc0:
|
883 |
0
| case 0xc1:
|
884 |
0
| case 0xc5:
|
885 |
8415
| result = code.getConstantPool().get(getIndex());
|
886 |
8415
| break;
|
887 |
1902
| default:
|
888 |
1902
| result = null;
|
889 |
1902
| break;
|
890 |
| } |
891 |
| |
892 |
10317
| return result;
|
893 |
| } |
894 |
| |
895 |
38
| public com.jeantessier.classreader.LocalVariable getIndexedLocalVariable() {
|
896 |
38
| com.jeantessier.classreader.LocalVariable result;
|
897 |
| |
898 |
38
| switch(getOpcode()) {
|
899 |
0
| case 0x1a:
|
900 |
0
| case 0x1e:
|
901 |
0
| case 0x22:
|
902 |
0
| case 0x26:
|
903 |
18
| case 0x2a:
|
904 |
0
| case 0x1b:
|
905 |
0
| case 0x1f:
|
906 |
2
| case 0x23:
|
907 |
0
| case 0x27:
|
908 |
2
| case 0x2b:
|
909 |
0
| case 0x1c:
|
910 |
0
| case 0x20:
|
911 |
0
| case 0x24:
|
912 |
0
| case 0x28:
|
913 |
0
| case 0x2c:
|
914 |
0
| case 0x1d:
|
915 |
0
| case 0x21:
|
916 |
0
| case 0x25:
|
917 |
0
| case 0x29:
|
918 |
0
| case 0x2d:
|
919 |
3
| case 0x15:
|
920 |
0
| case 0x16:
|
921 |
0
| case 0x17:
|
922 |
0
| case 0x18:
|
923 |
0
| case 0x19:
|
924 |
0
| case 0x84:
|
925 |
0
| case 0xa9:
|
926 |
25
| result = locateLocalVariable(getStart());
|
927 |
25
| break;
|
928 |
0
| case 0x3b:
|
929 |
0
| case 0x3f:
|
930 |
0
| case 0x43:
|
931 |
0
| case 0x47:
|
932 |
0
| case 0x4b:
|
933 |
1
| case 0x3c:
|
934 |
0
| case 0x40:
|
935 |
0
| case 0x44:
|
936 |
0
| case 0x48:
|
937 |
4
| case 0x4c:
|
938 |
0
| case 0x3d:
|
939 |
0
| case 0x41:
|
940 |
1
| case 0x45:
|
941 |
0
| case 0x49:
|
942 |
0
| case 0x4d:
|
943 |
0
| case 0x3e:
|
944 |
0
| case 0x42:
|
945 |
0
| case 0x46:
|
946 |
0
| case 0x4a:
|
947 |
0
| case 0x4e:
|
948 |
2
| case 0x36:
|
949 |
0
| case 0x37:
|
950 |
0
| case 0x38:
|
951 |
0
| case 0x39:
|
952 |
0
| case 0x3a:
|
953 |
8
| result = locateLocalVariable(getStart() + getLength());
|
954 |
8
| break;
|
955 |
4
| case 0xc4:
|
956 |
4
| if (getByte(1) >= 0x36 && getByte(1) <= 0x3a) {
|
957 |
2
| result = locateLocalVariable(getStart() + getLength());
|
958 |
| } else { |
959 |
2
| result = locateLocalVariable(getStart());
|
960 |
| } |
961 |
4
| break;
|
962 |
1
| default:
|
963 |
1
| result = null;
|
964 |
1
| break;
|
965 |
| } |
966 |
| |
967 |
38
| return result;
|
968 |
| } |
969 |
| |
970 |
37
| private com.jeantessier.classreader.LocalVariable locateLocalVariable(int pc) {
|
971 |
37
| com.jeantessier.classreader.LocalVariable result;
|
972 |
| |
973 |
37
| LocalVariableFinder finder = new LocalVariableFinder(getIndex(), pc);
|
974 |
37
| code.accept(finder);
|
975 |
37
| result = finder.getLocalVariable();
|
976 |
| |
977 |
37
| return result;
|
978 |
| } |
979 |
| |
980 |
14
| public int hashCode() {
|
981 |
14
| int result = getOpcode();
|
982 |
| |
983 |
14
| if (getIndexedConstantPoolEntry() != null) {
|
984 |
4
| result ^= getIndexedConstantPoolEntry().hashCode();
|
985 |
| } else { |
986 |
10
| for (int i=1; i<getLength(); i++) {
|
987 |
0
| result ^= bytecode[start+i];
|
988 |
| } |
989 |
| } |
990 |
| |
991 |
14
| return result;
|
992 |
| } |
993 |
| |
994 |
1326
| public boolean equals(Object object) {
|
995 |
1326
| boolean result;
|
996 |
| |
997 |
1326
| if (this == object) {
|
998 |
1
| result = true;
|
999 |
1325
| } else if (object == null || getClass() != object.getClass()) {
|
1000 |
1
| result = false;
|
1001 |
| } else { |
1002 |
1324
| Instruction other = (Instruction) object;
|
1003 |
1324
| result = getOpcode() == other.getOpcode();
|
1004 |
| |
1005 |
1324
| ConstantPoolEntry thisEntry = (ConstantPoolEntry) ((code != null) ? getIndexedConstantPoolEntry() : null);
|
1006 |
1324
| ConstantPoolEntry otherEntry = (ConstantPoolEntry) ((other.code != null) ? other.getIndexedConstantPoolEntry() : null);
|
1007 |
| |
1008 |
1324
| if (result && thisEntry != null && otherEntry != null) {
|
1009 |
378
| result = thisEntry.equals(otherEntry);
|
1010 |
| } else { |
1011 |
946
| for (int i=1; result && i<getLength(); i++) {
|
1012 |
0
| result = bytecode[start+i] == other.bytecode[other.start+i];
|
1013 |
| } |
1014 |
| } |
1015 |
| } |
1016 |
| |
1017 |
1326
| return result;
|
1018 |
| } |
1019 |
| |
1020 |
157
| public String toString() {
|
1021 |
157
| return getMnemonic();
|
1022 |
| } |
1023 |
| |
1024 |
67067
| public void accept(Visitor visitor) {
|
1025 |
67067
| visitor.visitInstruction(this);
|
1026 |
| } |
1027 |
| } |