| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package org.mozilla.javascript; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
abstract class Icode { |
| 13 |
|
| 14 |
static final int |
| 15 |
|
| 16 |
|
| 17 |
Icode_DELNAME = 0, |
| 18 |
|
| 19 |
|
| 20 |
Icode_DUP = -1, |
| 21 |
|
| 22 |
|
| 23 |
Icode_DUP2 = -2, |
| 24 |
|
| 25 |
|
| 26 |
Icode_SWAP = -3, |
| 27 |
|
| 28 |
|
| 29 |
Icode_POP = -4, |
| 30 |
|
| 31 |
|
| 32 |
Icode_POP_RESULT = -5, |
| 33 |
|
| 34 |
|
| 35 |
Icode_IFEQ_POP = -6, |
| 36 |
|
| 37 |
|
| 38 |
Icode_VAR_INC_DEC = -7, |
| 39 |
Icode_NAME_INC_DEC = -8, |
| 40 |
Icode_PROP_INC_DEC = -9, |
| 41 |
Icode_ELEM_INC_DEC = -10, |
| 42 |
Icode_REF_INC_DEC = -11, |
| 43 |
|
| 44 |
|
| 45 |
Icode_SCOPE_LOAD = -12, |
| 46 |
Icode_SCOPE_SAVE = -13, |
| 47 |
|
| 48 |
Icode_TYPEOFNAME = -14, |
| 49 |
|
| 50 |
|
| 51 |
Icode_NAME_AND_THIS = -15, |
| 52 |
Icode_PROP_AND_THIS = -16, |
| 53 |
Icode_ELEM_AND_THIS = -17, |
| 54 |
Icode_VALUE_AND_THIS = -18, |
| 55 |
|
| 56 |
|
| 57 |
Icode_CLOSURE_EXPR = -19, |
| 58 |
Icode_CLOSURE_STMT = -20, |
| 59 |
|
| 60 |
|
| 61 |
Icode_CALLSPECIAL = -21, |
| 62 |
|
| 63 |
|
| 64 |
Icode_RETUNDEF = -22, |
| 65 |
|
| 66 |
|
| 67 |
Icode_GOSUB = -23, |
| 68 |
Icode_STARTSUB = -24, |
| 69 |
Icode_RETSUB = -25, |
| 70 |
|
| 71 |
|
| 72 |
Icode_LINE = -26, |
| 73 |
|
| 74 |
|
| 75 |
Icode_SHORTNUMBER = -27, |
| 76 |
Icode_INTNUMBER = -28, |
| 77 |
|
| 78 |
|
| 79 |
Icode_LITERAL_NEW = -29, |
| 80 |
Icode_LITERAL_SET = -30, |
| 81 |
|
| 82 |
|
| 83 |
Icode_SPARE_ARRAYLIT = -31, |
| 84 |
|
| 85 |
|
| 86 |
Icode_REG_IND_C0 = -32, |
| 87 |
Icode_REG_IND_C1 = -33, |
| 88 |
Icode_REG_IND_C2 = -34, |
| 89 |
Icode_REG_IND_C3 = -35, |
| 90 |
Icode_REG_IND_C4 = -36, |
| 91 |
Icode_REG_IND_C5 = -37, |
| 92 |
Icode_REG_IND1 = -38, |
| 93 |
Icode_REG_IND2 = -39, |
| 94 |
Icode_REG_IND4 = -40, |
| 95 |
|
| 96 |
|
| 97 |
Icode_REG_STR_C0 = -41, |
| 98 |
Icode_REG_STR_C1 = -42, |
| 99 |
Icode_REG_STR_C2 = -43, |
| 100 |
Icode_REG_STR_C3 = -44, |
| 101 |
Icode_REG_STR1 = -45, |
| 102 |
Icode_REG_STR2 = -46, |
| 103 |
Icode_REG_STR4 = -47, |
| 104 |
|
| 105 |
|
| 106 |
Icode_GETVAR1 = -48, |
| 107 |
Icode_SETVAR1 = -49, |
| 108 |
|
| 109 |
|
| 110 |
Icode_UNDEF = -50, |
| 111 |
Icode_ZERO = -51, |
| 112 |
Icode_ONE = -52, |
| 113 |
|
| 114 |
|
| 115 |
Icode_ENTERDQ = -53, |
| 116 |
Icode_LEAVEDQ = -54, |
| 117 |
|
| 118 |
Icode_TAIL_CALL = -55, |
| 119 |
|
| 120 |
|
| 121 |
Icode_LOCAL_CLEAR = -56, |
| 122 |
|
| 123 |
|
| 124 |
Icode_LITERAL_GETTER = -57, |
| 125 |
Icode_LITERAL_SETTER = -58, |
| 126 |
|
| 127 |
|
| 128 |
Icode_SETCONST = -59, |
| 129 |
Icode_SETCONSTVAR = -60, |
| 130 |
Icode_SETCONSTVAR1 = -61, |
| 131 |
|
| 132 |
|
| 133 |
Icode_GENERATOR = -62, |
| 134 |
Icode_GENERATOR_END = -63, |
| 135 |
|
| 136 |
Icode_DEBUGGER = -64, |
| 137 |
|
| 138 |
|
| 139 |
MIN_ICODE = -64; |
| 140 |
|
| 141 |
static String bytecodeName(int bytecode) |
| 142 |
{ |
| 143 |
if (!validBytecode(bytecode)) { |
| 144 |
throw new IllegalArgumentException(String.valueOf(bytecode)); |
| 145 |
} |
| 146 |
|
| 147 |
if (!Token.printICode) { |
| 148 |
return String.valueOf(bytecode); |
| 149 |
} |
| 150 |
|
| 151 |
if (validTokenCode(bytecode)) { |
| 152 |
return Token.name(bytecode); |
| 153 |
} |
| 154 |
|
| 155 |
switch (bytecode) { |
| 156 |
case Icode_DUP: return "DUP"; |
| 157 |
case Icode_DUP2: return "DUP2"; |
| 158 |
case Icode_SWAP: return "SWAP"; |
| 159 |
case Icode_POP: return "POP"; |
| 160 |
case Icode_POP_RESULT: return "POP_RESULT"; |
| 161 |
case Icode_IFEQ_POP: return "IFEQ_POP"; |
| 162 |
case Icode_VAR_INC_DEC: return "VAR_INC_DEC"; |
| 163 |
case Icode_NAME_INC_DEC: return "NAME_INC_DEC"; |
| 164 |
case Icode_PROP_INC_DEC: return "PROP_INC_DEC"; |
| 165 |
case Icode_ELEM_INC_DEC: return "ELEM_INC_DEC"; |
| 166 |
case Icode_REF_INC_DEC: return "REF_INC_DEC"; |
| 167 |
case Icode_SCOPE_LOAD: return "SCOPE_LOAD"; |
| 168 |
case Icode_SCOPE_SAVE: return "SCOPE_SAVE"; |
| 169 |
case Icode_TYPEOFNAME: return "TYPEOFNAME"; |
| 170 |
case Icode_NAME_AND_THIS: return "NAME_AND_THIS"; |
| 171 |
case Icode_PROP_AND_THIS: return "PROP_AND_THIS"; |
| 172 |
case Icode_ELEM_AND_THIS: return "ELEM_AND_THIS"; |
| 173 |
case Icode_VALUE_AND_THIS: return "VALUE_AND_THIS"; |
| 174 |
case Icode_CLOSURE_EXPR: return "CLOSURE_EXPR"; |
| 175 |
case Icode_CLOSURE_STMT: return "CLOSURE_STMT"; |
| 176 |
case Icode_CALLSPECIAL: return "CALLSPECIAL"; |
| 177 |
case Icode_RETUNDEF: return "RETUNDEF"; |
| 178 |
case Icode_GOSUB: return "GOSUB"; |
| 179 |
case Icode_STARTSUB: return "STARTSUB"; |
| 180 |
case Icode_RETSUB: return "RETSUB"; |
| 181 |
case Icode_LINE: return "LINE"; |
| 182 |
case Icode_SHORTNUMBER: return "SHORTNUMBER"; |
| 183 |
case Icode_INTNUMBER: return "INTNUMBER"; |
| 184 |
case Icode_LITERAL_NEW: return "LITERAL_NEW"; |
| 185 |
case Icode_LITERAL_SET: return "LITERAL_SET"; |
| 186 |
case Icode_SPARE_ARRAYLIT: return "SPARE_ARRAYLIT"; |
| 187 |
case Icode_REG_IND_C0: return "REG_IND_C0"; |
| 188 |
case Icode_REG_IND_C1: return "REG_IND_C1"; |
| 189 |
case Icode_REG_IND_C2: return "REG_IND_C2"; |
| 190 |
case Icode_REG_IND_C3: return "REG_IND_C3"; |
| 191 |
case Icode_REG_IND_C4: return "REG_IND_C4"; |
| 192 |
case Icode_REG_IND_C5: return "REG_IND_C5"; |
| 193 |
case Icode_REG_IND1: return "LOAD_IND1"; |
| 194 |
case Icode_REG_IND2: return "LOAD_IND2"; |
| 195 |
case Icode_REG_IND4: return "LOAD_IND4"; |
| 196 |
case Icode_REG_STR_C0: return "REG_STR_C0"; |
| 197 |
case Icode_REG_STR_C1: return "REG_STR_C1"; |
| 198 |
case Icode_REG_STR_C2: return "REG_STR_C2"; |
| 199 |
case Icode_REG_STR_C3: return "REG_STR_C3"; |
| 200 |
case Icode_REG_STR1: return "LOAD_STR1"; |
| 201 |
case Icode_REG_STR2: return "LOAD_STR2"; |
| 202 |
case Icode_REG_STR4: return "LOAD_STR4"; |
| 203 |
case Icode_GETVAR1: return "GETVAR1"; |
| 204 |
case Icode_SETVAR1: return "SETVAR1"; |
| 205 |
case Icode_UNDEF: return "UNDEF"; |
| 206 |
case Icode_ZERO: return "ZERO"; |
| 207 |
case Icode_ONE: return "ONE"; |
| 208 |
case Icode_ENTERDQ: return "ENTERDQ"; |
| 209 |
case Icode_LEAVEDQ: return "LEAVEDQ"; |
| 210 |
case Icode_TAIL_CALL: return "TAIL_CALL"; |
| 211 |
case Icode_LOCAL_CLEAR: return "LOCAL_CLEAR"; |
| 212 |
case Icode_LITERAL_GETTER: return "LITERAL_GETTER"; |
| 213 |
case Icode_LITERAL_SETTER: return "LITERAL_SETTER"; |
| 214 |
case Icode_SETCONST: return "SETCONST"; |
| 215 |
case Icode_SETCONSTVAR: return "SETCONSTVAR"; |
| 216 |
case Icode_SETCONSTVAR1: return "SETCONSTVAR1"; |
| 217 |
case Icode_GENERATOR: return "GENERATOR"; |
| 218 |
case Icode_GENERATOR_END: return "GENERATOR_END"; |
| 219 |
case Icode_DEBUGGER: return "DEBUGGER"; |
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
throw new IllegalStateException(String.valueOf(bytecode)); |
| 224 |
} |
| 225 |
|
| 226 |
static boolean validIcode(int icode) |
| 227 |
{ |
| 228 |
return MIN_ICODE <= icode && icode <= 0; |
| 229 |
} |
| 230 |
|
| 231 |
static boolean validTokenCode(int token) |
| 232 |
{ |
| 233 |
return Token.FIRST_BYTECODE_TOKEN <= token |
| 234 |
&& token <= Token.LAST_BYTECODE_TOKEN; |
| 235 |
} |
| 236 |
|
| 237 |
static boolean validBytecode(int bytecode) |
| 238 |
{ |
| 239 |
return validIcode(bytecode) || validTokenCode(bytecode); |
| 240 |
} |
| 241 |
} |