Skip to main content

jclass/common/
opcode.rs

1/* Opcodes */
2pub mod opcodes {
3    pub const AALOAD: u8 = 50;
4    pub const AASTORE: u8 = 83;
5    pub const ACONST_NULL: u8 = 1;
6    pub const ALOAD: u8 = 25;
7    pub const ALOAD_0: u8 = 42;
8    pub const ALOAD_1: u8 = 43;
9    pub const ALOAD_2: u8 = 44;
10    pub const ALOAD_3: u8 = 45;
11    pub const ANEWARRAY: u8 = 189;
12    pub const ARETURN: u8 = 176;
13    pub const ARRAYLENGTH: u8 = 190;
14    pub const ASTORE: u8 = 58;
15    pub const ASTORE_0: u8 = 75;
16    pub const ASTORE_1: u8 = 76;
17    pub const ASTORE_2: u8 = 77;
18    pub const ASTORE_3: u8 = 78;
19    pub const ATHROW: u8 = 191;
20    pub const BALOAD: u8 = 51;
21    pub const BASTORE: u8 = 84;
22    pub const BIPUSH: u8 = 16;
23    pub const CALOAD: u8 = 52;
24    pub const CASTORE: u8 = 85;
25    pub const CHECKCAST: u8 = 192;
26    pub const D2F: u8 = 144;
27    pub const D2I: u8 = 142;
28    pub const D2L: u8 = 143;
29    pub const DADD: u8 = 99;
30    pub const DALOAD: u8 = 49;
31    pub const DASTORE: u8 = 82;
32    pub const DCMPG: u8 = 152;
33    pub const DCMPL: u8 = 151;
34    pub const DCONST_0: u8 = 14;
35    pub const DCONST_1: u8 = 15;
36    pub const DDIV: u8 = 111;
37    pub const DLOAD: u8 = 24;
38    pub const DLOAD_0: u8 = 38;
39    pub const DLOAD_1: u8 = 39;
40    pub const DLOAD_2: u8 = 40;
41    pub const DLOAD_3: u8 = 41;
42    pub const DMUL: u8 = 107;
43    pub const DNEG: u8 = 119;
44    pub const DREM: u8 = 115;
45    pub const DRETURN: u8 = 175;
46    pub const DSTORE: u8 = 57;
47    pub const DSTORE_0: u8 = 71;
48    pub const DSTORE_1: u8 = 72;
49    pub const DSTORE_2: u8 = 73;
50    pub const DSTORE_3: u8 = 74;
51    pub const DSUB: u8 = 103;
52    pub const DUP: u8 = 89;
53    pub const DUP2: u8 = 92;
54    pub const DUP2_X1: u8 = 93;
55    pub const DUP2_X2: u8 = 94;
56    pub const DUP_X1: u8 = 90;
57    pub const DUP_X2: u8 = 91;
58    pub const F2D: u8 = 141;
59    pub const F2I: u8 = 139;
60    pub const F2L: u8 = 140;
61    pub const FADD: u8 = 98;
62    pub const FALOAD: u8 = 48;
63    pub const FASTORE: u8 = 81;
64    pub const FCMPG: u8 = 150;
65    pub const FCMPL: u8 = 149;
66    pub const FCONST_0: u8 = 11;
67    pub const FCONST_1: u8 = 12;
68    pub const FCONST_2: u8 = 13;
69    pub const FDIV: u8 = 110;
70    pub const FLOAD: u8 = 23;
71    pub const FLOAD_0: u8 = 34;
72    pub const FLOAD_1: u8 = 35;
73    pub const FLOAD_2: u8 = 36;
74    pub const FLOAD_3: u8 = 37;
75    pub const FMUL: u8 = 106;
76    pub const FNEG: u8 = 118;
77    pub const FREM: u8 = 114;
78    pub const FRETURN: u8 = 174;
79    pub const FSTORE: u8 = 56;
80    pub const FSTORE_0: u8 = 67;
81    pub const FSTORE_1: u8 = 68;
82    pub const FSTORE_2: u8 = 69;
83    pub const FSTORE_3: u8 = 70;
84    pub const FSUB: u8 = 102;
85    pub const GETFIELD: u8 = 180;
86    pub const GETSTATIC: u8 = 178;
87    pub const GOTO: u8 = 167;
88    pub const GOTO_W: u8 = 200;
89    pub const I2B: u8 = 145;
90    pub const I2C: u8 = 146;
91    pub const I2D: u8 = 135;
92    pub const I2F: u8 = 134;
93    pub const I2L: u8 = 133;
94    pub const I2S: u8 = 147;
95    pub const IADD: u8 = 96;
96    pub const IALOAD: u8 = 46;
97    pub const IAND: u8 = 126;
98    pub const IASTORE: u8 = 79;
99    pub const ICONST_0: u8 = 3;
100    pub const ICONST_1: u8 = 4;
101    pub const ICONST_2: u8 = 5;
102    pub const ICONST_3: u8 = 6;
103    pub const ICONST_4: u8 = 7;
104    pub const ICONST_5: u8 = 8;
105    pub const ICONST_M1: u8 = 2;
106    pub const IDIV: u8 = 108;
107    pub const IFEQ: u8 = 153;
108    pub const IFGE: u8 = 156;
109    pub const IFGT: u8 = 157;
110    pub const IFLE: u8 = 158;
111    pub const IFLT: u8 = 155;
112    pub const IFNE: u8 = 154;
113    pub const IFNONNULL: u8 = 199;
114    pub const IFNULL: u8 = 198;
115    pub const IF_ACMPEQ: u8 = 165;
116    pub const IF_ACMPNE: u8 = 166;
117    pub const IF_ICMPEQ: u8 = 159;
118    pub const IF_ICMPGE: u8 = 162;
119    pub const IF_ICMPGT: u8 = 163;
120    pub const IF_ICMPLE: u8 = 164;
121    pub const IF_ICMPLT: u8 = 161;
122    pub const IF_ICMPNE: u8 = 160;
123    pub const IINC: u8 = 132;
124    pub const ILOAD: u8 = 21;
125    pub const ILOAD_0: u8 = 26;
126    pub const ILOAD_1: u8 = 27;
127    pub const ILOAD_2: u8 = 28;
128    pub const ILOAD_3: u8 = 29;
129    pub const IMUL: u8 = 104;
130    pub const INEG: u8 = 116;
131    pub const INSTANCEOF: u8 = 193;
132    pub const INVOKEDYNAMIC: u8 = 186;
133    pub const INVOKEINTERFACE: u8 = 185;
134    pub const INVOKESPECIAL: u8 = 183;
135    pub const INVOKESTATIC: u8 = 184;
136    pub const INVOKEVIRTUAL: u8 = 182;
137    pub const IOR: u8 = 128;
138    pub const IREM: u8 = 112;
139    pub const IRETURN: u8 = 172;
140    pub const ISHL: u8 = 120;
141    pub const ISHR: u8 = 122;
142    pub const ISTORE: u8 = 54;
143    pub const ISTORE_0: u8 = 59;
144    pub const ISTORE_1: u8 = 60;
145    pub const ISTORE_2: u8 = 61;
146    pub const ISTORE_3: u8 = 62;
147    pub const ISUB: u8 = 100;
148    pub const IUSHR: u8 = 124;
149    pub const IXOR: u8 = 130;
150    pub const JSR: u8 = 168;
151    pub const JSR_W: u8 = 201;
152    pub const L2D: u8 = 138;
153    pub const L2F: u8 = 137;
154    pub const L2I: u8 = 136;
155    pub const LADD: u8 = 97;
156    pub const LALOAD: u8 = 47;
157    pub const LAND: u8 = 127;
158    pub const LASTORE: u8 = 80;
159    pub const LCMP: u8 = 148;
160    pub const LCONST_0: u8 = 9;
161    pub const LCONST_1: u8 = 10;
162    pub const LDC: u8 = 18;
163    pub const LDC2_W: u8 = 20;
164    pub const LDC_W: u8 = 19;
165    pub const LDIV: u8 = 109;
166    pub const LLOAD: u8 = 22;
167    pub const LLOAD_0: u8 = 30;
168    pub const LLOAD_1: u8 = 31;
169    pub const LLOAD_2: u8 = 32;
170    pub const LLOAD_3: u8 = 33;
171    pub const LMUL: u8 = 105;
172    pub const LNEG: u8 = 117;
173    pub const LOOKUPSWITCH: u8 = 171;
174    pub const LOR: u8 = 129;
175    pub const LREM: u8 = 113;
176    pub const LRETURN: u8 = 173;
177    pub const LSHL: u8 = 121;
178    pub const LSHR: u8 = 123;
179    pub const LSTORE: u8 = 55;
180    pub const LSTORE_0: u8 = 63;
181    pub const LSTORE_1: u8 = 64;
182    pub const LSTORE_2: u8 = 65;
183    pub const LSTORE_3: u8 = 66;
184    pub const LSUB: u8 = 101;
185    pub const LUSHR: u8 = 125;
186    pub const LXOR: u8 = 131;
187    pub const MONITORENTER: u8 = 194;
188    pub const MONITOREXIT: u8 = 195;
189    pub const MULTIANEWARRAY: u8 = 197;
190    pub const NEW: u8 = 187;
191    pub const NEWARRAY: u8 = 188;
192    pub const NOP: u8 = 0;
193    pub const POP: u8 = 87;
194    pub const POP2: u8 = 88;
195    pub const PUTFIELD: u8 = 181;
196    pub const PUTSTATIC: u8 = 179;
197    pub const RET: u8 = 169;
198    pub const RETURN: u8 = 177;
199    pub const SALOAD: u8 = 53;
200    pub const SASTORE: u8 = 86;
201    pub const SIPUSH: u8 = 17;
202    pub const SWAP: u8 = 95;
203    pub const TABLESWITCH: u8 = 170;
204    pub const WIDE: u8 = 196;
205}
206
207/* array-type code for the newarray instruction */
208pub mod array_type {
209    pub const T_BOOLEAN: u8 = 4;
210    pub const T_CHAR: u8 = 5;
211    pub const T_FLOAT: u8 = 6;
212    pub const T_DOUBLE: u8 = 7;
213    pub const T_BYTE: u8 = 8;
214    pub const T_SHORT: u8 = 9;
215    pub const T_INT: u8 = 10;
216    pub const T_LONG: u8 = 11;
217}
218
219/* how many values are pushed on the operand stack. */
220pub const STACK_GROW: &[i16] = &[
221    0, // nop, 0
222    1, // aconst_null, 1
223    1, // iconst_m1, 2
224    1, // iconst_0, 3
225    1, // iconst_1, 4
226    1, // iconst_2, 5
227    1, // iconst_3, 6
228    1, // iconst_4, 7
229    1, // iconst_5, 8
230    2, // lconst_0, 9
231    2, // lconst_1, 10
232    1, // fconst_0, 11
233    1, // fconst_1, 12
234    1, // fconst_2, 13
235    2, // dconst_0, 14
236    2, // dconst_1, 15
237    1, // bipush, 16
238    1, // sipush, 17
239    1, // ldc, 18
240    1, // ldc_w, 19
241    2, // ldc2_w, 20
242    1, // iload, 21
243    2, // lload, 22
244    1, // fload, 23
245    2, // dload, 24
246    1, // aload, 25
247    1, // iload_0, 26
248    1, // iload_1, 27
249    1, // iload_2, 28
250    1, // iload_3, 29
251    2, // lload_0, 30
252    2, // lload_1, 31
253    2, // lload_2, 32
254    2, // lload_3, 33
255    1, // fload_0, 34
256    1, // fload_1, 35
257    1, // fload_2, 36
258    1, // fload_3, 37
259    2, // dload_0, 38
260    2, // dload_1, 39
261    2, // dload_2, 40
262    2, // dload_3, 41
263    1, // aload_0, 42
264    1, // aload_1, 43
265    1, // aload_2, 44
266    1, // aload_3, 45
267    -1, // iaload, 46
268    0, // laload, 47
269    -1, // faload, 48
270    0, // daload, 49
271    -1, // aaload, 50
272    -1, // baload, 51
273    -1, // caload, 52
274    -1, // saload, 53
275    -1, // istore, 54
276    -2, // lstore, 55
277    -1, // fstore, 56
278    -2, // dstore, 57
279    -1, // astore, 58
280    -1, // istore_0, 59
281    -1, // istore_1, 60
282    -1, // istore_2, 61
283    -1, // istore_3, 62
284    -2, // lstore_0, 63
285    -2, // lstore_1, 64
286    -2, // lstore_2, 65
287    -2, // lstore_3, 66
288    -1, // fstore_0, 67
289    -1, // fstore_1, 68
290    -1, // fstore_2, 69
291    -1, // fstore_3, 70
292    -2, // dstore_0, 71
293    -2, // dstore_1, 72
294    -2, // dstore_2, 73
295    -2, // dstore_3, 74
296    -1, // astore_0, 75
297    -1, // astore_1, 76
298    -1, // astore_2, 77
299    -1, // astore_3, 78
300    -3, // iastore, 79
301    -4, // lastore, 80
302    -3, // fastore, 81
303    -4, // dastore, 82
304    -3, // aastore, 83
305    -3, // bastore, 84
306    -3, // castore, 85
307    -3, // sastore, 86
308    -1, // pop, 87
309    -2, // pop2, 88
310    1, // dup, 89
311    1, // dup_x1, 90
312    1, // dup_x2, 91
313    2, // dup2, 92
314    2, // dup2_x1, 93
315    2, // dup2_x2, 94
316    0, // swap, 95
317    -1, // iadd, 96
318    -2, // ladd, 97
319    -1, // fadd, 98
320    -2, // dadd, 99
321    -1, // isub, 100
322    -2, // lsub, 101
323    -1, // fsub, 102
324    -2, // dsub, 103
325    -1, // imul, 104
326    -2, // lmul, 105
327    -1, // fmul, 106
328    -2, // dmul, 107
329    -1, // idiv, 108
330    -2, // ldiv, 109
331    -1, // fdiv, 110
332    -2, // ddiv, 111
333    -1, // irem, 112
334    -2, // lrem, 113
335    -1, // frem, 114
336    -2, // drem, 115
337    0, // ineg, 116
338    0, // lneg, 117
339    0, // fneg, 118
340    0, // dneg, 119
341    -1, // ishl, 120
342    -1, // lshl, 121
343    -1, // ishr, 122
344    -1, // lshr, 123
345    -1, // iushr, 124
346    -1, // lushr, 125
347    -1, // iand, 126
348    -2, // land, 127
349    -1, // ior, 128
350    -2, // lor, 129
351    -1, // ixor, 130
352    -2, // lxor, 131
353    0, // iinc, 132
354    1, // i2l, 133
355    0, // i2f, 134
356    1, // i2d, 135
357    -1, // l2i, 136
358    -1, // l2f, 137
359    0, // l2d, 138
360    0, // f2i, 139
361    1, // f2l, 140
362    1, // f2d, 141
363    -1, // d2i, 142
364    0, // d2l, 143
365    -1, // d2f, 144
366    0, // i2b, 145
367    0, // i2c, 146
368    0, // i2s, 147
369    -3, // lcmp, 148
370    -1, // fcmpl, 149
371    -1, // fcmpg, 150
372    -3, // dcmpl, 151
373    -3, // dcmpg, 152
374    -1, // ifeq, 153
375    -1, // ifne, 154
376    -1, // iflt, 155
377    -1, // ifge, 156
378    -1, // ifgt, 157
379    -1, // ifle, 158
380    -2, // if_icmpeq, 159
381    -2, // if_icmpne, 160
382    -2, // if_icmplt, 161
383    -2, // if_icmpge, 162
384    -2, // if_icmpgt, 163
385    -2, // if_icmple, 164
386    -2, // if_acmpeq, 165
387    -2, // if_acmpne, 166
388    0, // goto, 167
389    1, // jsr, 168
390    0, // ret, 169
391    -1, // tableswitch, 170
392    -1, // lookupswitch, 171
393    -1, // ireturn, 172
394    -2, // lreturn, 173
395    -1, // freturn, 174
396    -2, // dreturn, 175
397    -1, // areturn, 176
398    0, // return, 177
399    0, // getstatic, 178            depends on the type
400    0, // putstatic, 179            depends on the type
401    0, // getfield, 180             depends on the type
402    0, // putfield, 181             depends on the type
403    0, // invokevirtual, 182        depends on the type
404    0, // invokespecial, 183        depends on the type
405    0, // invokestatic, 184         depends on the type
406    0, // invokeinterface, 185      depends on the type
407    0, // invokedynaimc, 186        depends on the type
408    1, // new, 187
409    0, // newarray, 188
410    0, // anewarray, 189
411    0, // arraylength, 190
412    -1, // athrow, 191              stack is cleared
413    0, // checkcast, 192
414    0, // instanceof, 193
415    -1, // monitorenter, 194
416    -1, // monitorexit, 195
417    0, // wide, 196                 depends on the following opcode
418    0, // multianewarray, 197       depends on the dimensions
419    -1, // ifnull, 198
420    -1, // ifnonnull, 199
421    0, // goto_w, 200
422    1 // jsr_w, 201
423];