-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconstants.js
290 lines (274 loc) · 8.07 KB
/
constants.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
//
// constants.js
//
// Kopiluwak. Copyright (c) 2020 Ben Zotto
//
// This module contains the constants defined within the JVM spec.
//
//
// Constant pool tags
//
const CONSTANT_Class = 7;
const CONSTANT_Fieldref = 9;
const CONSTANT_Methodref = 10;
const CONSTANT_InterfaceMethodref = 11;
const CONSTANT_String = 8;
const CONSTANT_Integer = 3;
const CONSTANT_Float = 4;
const CONSTANT_Long = 5;
const CONSTANT_Double = 6;
const CONSTANT_NameAndType = 12;
const CONSTANT_Utf8 = 1;
const CONSTANT_MethodHandle = 15;
const CONSTANT_MethodType = 16;
const CONSTANT_InvokeDynamic = 18;
//
// Access flags for classes, fields, and methods. Some values are reused.
//
const ACC_PUBLIC = 0x0001; // Declared public; may be accessed from outside its package.
const ACC_PRIVATE = 0x0002; // Declared private; accessible only within the defining class.
const ACC_PROTECTED = 0x0004; // Declared protected; may be accessed within subclasses.
const ACC_STATIC = 0x0008; // Declared static.
const ACC_FINAL = 0x0010; // Declared final; must not be overridden (§5.4.5) / no subclasses allowed.
const ACC_SYNCHRONIZED = 0x0020; // Declared synchronized; invocation is wrapped by a monitor use.
const ACC_SUPER = 0x0020; // Treat superclass methods specially when invoked by the invokespecial instruction.
const ACC_BRIDGE = 0x0040; // A bridge method, generated by the compiler.
const ACC_VOLATILE = 0x0040; // Declared volatile; cannot be cached.
const ACC_TRANSIENT = 0x0080; // Declared transient; not written or read by a persistent object manager.
const ACC_VARARGS = 0x0080; // Declared with variable number of arguments.
const ACC_NATIVE = 0x0100; // Declared native; implemented in a language other than Java.
const ACC_INTERFACE = 0x0200; // Is an interface, not a class.
const ACC_ABSTRACT = 0x0400; // Declared abstract; no implementation is provided.
const ACC_STRICT = 0x0800; // Declared strictfp; floating-point mode is FP-strict.
const ACC_SYNTHETIC = 0x1000; // Declared synthetic; not present in the source code
const ACC_ANNOTATION = 0x2000; // Declared as an annotation type.
const ACC_ENUM = 0x4000; // Declared as an enum type.
function AccessFlagIsSet(field, flag) { return (field & flag) != 0; }
//
// Method handle kinds
//
const REF_getField = 1;
const REF_getStatic = 2;
const REF_putField = 3;
const REF_putStatic = 4;
const REF_invokeVirtual = 5;
const REF_invokeStatic = 6;
const REF_invokeSpecial = 7;
const REF_newInvokeSpecial = 8;
const REF_invokeInterface = 9;
//
// Array types
//
const T_BOOLEAN = 4;
const T_CHAR = 5;
const T_FLOAT = 6;
const T_DOUBLE = 7;
const T_BYTE = 8;
const T_SHORT = 9;
const T_INT = 10;
const T_LONG = 11;
//
// VM Instructions and their opcodes
//
const INSTR_aaload = 0x32;
const INSTR_aastore = 0x53;
const INSTR_aconst_null = 0x01;
const INSTR_aload = 0x19;
const INSTR_aload_0 = 0x2A;
const INSTR_aload_1 = 0x2B;
const INSTR_aload_2 = 0x2C;
const INSTR_aload_3 = 0x2D;
const INSTR_anewarray = 0xBD;
const INSTR_areturn = 0xB0;
const INSTR_arraylength = 0xBE;
const INSTR_astore = 0x3A;
const INSTR_astore_0 = 0x4B;
const INSTR_astore_1 = 0x4C;
const INSTR_astore_2 = 0x4D;
const INSTR_astore_3 = 0x4E;
const INSTR_athrow = 0xBF;
const INSTR_baload = 0x33;
const INSTR_bastore = 0x54;
const INSTR_bipush = 0x10;
const INSTR_caload = 0x34;
const INSTR_castore = 0x55;
const INSTR_checkcast = 0xC0;
const INSTR_d2f = 0x90;
const INSTR_d2i = 0x8E;
const INSTR_d2l = 0x8F;
const INSTR_dadd = 0x63;
const INSTR_daload = 0x31;
const INSTR_dastore = 0x52;
const INSTR_dcmpg = 0x98;
const INSTR_dcmpl = 0x97;
const INSTR_dconst_0 = 0x0E;
const INSTR_dconst_1 = 0x0F;
const INSTR_ddiv = 0x6F;
const INSTR_dload = 0x18;
const INSTR_dload_0 = 0x26;
const INSTR_dload_1 = 0x27;
const INSTR_dload_2 = 0x28;
const INSTR_dload_3 = 0x29;
const INSTR_dmul = 0x6B;
const INSTR_dneg = 0x77;
const INSTR_drem = 0x73;
const INSTR_dreturn = 0xAF;
const INSTR_dstore = 0x39;
const INSTR_dstore_0 = 0x47;
const INSTR_dstore_1 = 0x48;
const INSTR_dstore_2 = 0x49;
const INSTR_dstore_3 = 0x4A;
const INSTR_dsub = 0x67;
const INSTR_dup = 0x59;
const INSTR_dup_x1 = 0x5A;
const INSTR_dup_x2 = 0x5B;
const INSTR_dup2 = 0x5C;
const INSTR_dup2_x1 = 0x5D;
const INSTR_dup2_x2 = 0x5E;
const INSTR_f2d = 0x8D;
const INSTR_f2i = 0x8B;
const INSTR_f2l = 0x8C;
const INSTR_fadd = 0x62;
const INSTR_faload = 0x30;
const INSTR_fastore = 0x51;
const INSTR_fcmpg = 0x96;
const INSTR_fcmpl = 0x95;
const INSTR_fconst_0 = 0x0B;
const INSTR_fconst_1 = 0x0C;
const INSTR_fconst_2 = 0x0D;
const INSTR_fdiv = 0x6E;
const INSTR_fload = 0x17;
const INSTR_fload_0 = 0x22;
const INSTR_fload_1 = 0x23;
const INSTR_fload_2 = 0x24;
const INSTR_fload_3 = 0x25;
const INSTR_fmul = 0x6A;
const INSTR_fneg = 0x76;
const INSTR_frem = 0x72;
const INSTR_freturn = 0xAE;
const INSTR_fstore = 0x38;
const INSTR_fstore_0 = 0x43;
const INSTR_fstore_1 = 0x44;
const INSTR_fstore_2 = 0x45;
const INSTR_fstore_3 = 0x46;
const INSTR_fsub = 0x66;
const INSTR_getfield = 0xB4;
const INSTR_getstatic = 0xB2;
const INSTR_goto = 0xA7;
const INSTR_goto_w = 0xC8;
const INSTR_i2b = 0x91;
const INSTR_i2c = 0x92;
const INSTR_i2d = 0x87;
const INSTR_i2f = 0x86;
const INSTR_i2l = 0x85;
const INSTR_i2s = 0x93;
const INSTR_iadd = 0x60;
const INSTR_iaload = 0x2E;
const INSTR_iand = 0x7E;
const INSTR_iastore = 0x4F;
const INSTR_iconst_m1 = 0x02;
const INSTR_iconst_0 = 0x03;
const INSTR_iconst_1 = 0x04;
const INSTR_iconst_2 = 0x05;
const INSTR_iconst_3 = 0x06;
const INSTR_iconst_4 = 0x07;
const INSTR_iconst_5 = 0x08;
const INSTR_idiv = 0x6C;
const INSTR_if_acmpeq = 0xA5;
const INSTR_if_acmpne = 0xA6;
const INSTR_if_icmpeq = 0x9F;
const INSTR_if_icmpne = 0xA0;
const INSTR_if_icmplt = 0xA1;
const INSTR_if_icmpge = 0xA2;
const INSTR_if_icmpgt = 0xA3;
const INSTR_if_icmple = 0xA4;
const INSTR_ifeq = 0x99;
const INSTR_ifne = 0x9A;
const INSTR_iflt = 0x9B;
const INSTR_ifge = 0x9C;
const INSTR_ifgt = 0x9D;
const INSTR_ifle = 0x9E;
const INSTR_ifnonnull = 0xC7;
const INSTR_ifnull = 0xC6;
const INSTR_iinc = 0x84;
const INSTR_iload = 0x15;
const INSTR_iload_0 = 0x1A;
const INSTR_iload_1 = 0x1B;
const INSTR_iload_2 = 0x1C;
const INSTR_iload_3 = 0x1D;
const INSTR_imul = 0x68;
const INSTR_ineg = 0x74;
const INSTR_instanceof = 0xC1;
const INSTR_invokedynamic = 0xBA;
const INSTR_invokeinterface = 0xB9;
const INSTR_invokespecial = 0xB7;
const INSTR_invokestatic = 0xB8;
const INSTR_invokevirtual = 0xB6;
const INSTR_ior = 0x80;
const INSTR_irem = 0x70;
const INSTR_ireturn = 0xAC;
const INSTR_ishl = 0x78;
const INSTR_ishr = 0x7A;
const INSTR_istore = 0x36;
const INSTR_istore_0 = 0x3B;
const INSTR_istore_1 = 0x3C;
const INSTR_istore_2 = 0x3D;
const INSTR_istore_3 = 0x3E;
const INSTR_isub = 0x64;
const INSTR_iushr = 0x7C;
const INSTR_ixor = 0x82;
const INSTR_jsr = 0xA8;
const INSTR_jsr_w = 0xC9;
const INSTR_l2d = 0x8A;
const INSTR_l2f = 0x89;
const INSTR_l2i = 0x88;
const INSTR_ladd = 0x61;
const INSTR_laload = 0x2F;
const INSTR_land = 0x7F;
const INSTR_lastore = 0x50;
const INSTR_lcmp = 0x94;
const INSTR_lconst_0 = 0x09;
const INSTR_lconst_1 = 0x0A;
const INSTR_ldc = 0x12;
const INSTR_ldc_w = 0x13;
const INSTR_ldc2_w = 0x14;
const INSTR_ldiv = 0x6D;
const INSTR_lload = 0x16;
const INSTR_lload_0 = 0x1E;
const INSTR_lload_1 = 0x1F;
const INSTR_lload_2 = 0x20;
const INSTR_lload_3 = 0x21;
const INSTR_lmul = 0x69;
const INSTR_lneg = 0x75;
const INSTR_lookupswitch = 0xAB;
const INSTR_lor = 0x81;
const INSTR_lrem = 0x71;
const INSTR_lreturn = 0xAD;
const INSTR_lshl = 0x79;
const INSTR_lshr = 0x7B;
const INSTR_lstore = 0x37;
const INSTR_lstore_0 = 0x3F;
const INSTR_lstore_1 = 0x40;
const INSTR_lstore_2 = 0x41;
const INSTR_lstore_3 = 0x42;
const INSTR_lsub = 0x65;
const INSTR_lushr = 0x7D;
const INSTR_lxor = 0x83;
const INSTR_monitorenter = 0xC2;
const INSTR_monitorexit = 0xC3;
const INSTR_multianewarray = 0xC5;
const INSTR_new = 0xBB;
const INSTR_newarray = 0xBC;
const INSTR_nop = 0x00;
const INSTR_pop = 0x57;
const INSTR_pop2 = 0x58;
const INSTR_putfield = 0xB5;
const INSTR_putstatic = 0xB3;
const INSTR_ret = 0xA9;
const INSTR_return = 0xB1;
const INSTR_saload = 0x35;
const INSTR_sastore = 0x56;
const INSTR_sipush = 0x11;
const INSTR_swap = 0x5F;
const INSTR_tableswitch = 0xAA;
const INSTR_wide = 0xC4;