|
| 1 | +/* Instruction opcodes for compiled code */ |
| 2 | + |
| 3 | +#define DUP_TOP 0 |
| 4 | +#define POP_TOP 1 |
| 5 | +#define ROT_TWO 2 |
| 6 | +#define ROT_THREE 3 |
| 7 | + |
| 8 | +#define UNARY_POSITIVE 10 |
| 9 | +#define UNARY_NEGATIVE 11 |
| 10 | +#define UNARY_NOT 12 |
| 11 | +#define UNARY_CONVERT 13 |
| 12 | +#define UNARY_CALL 14 |
| 13 | + |
| 14 | +#define BINARY_MULTIPLY 20 |
| 15 | +#define BINARY_DIVIDE 21 |
| 16 | +#define BINARY_MODULO 22 |
| 17 | +#define BINARY_ADD 23 |
| 18 | +#define BINARY_SUBTRACT 24 |
| 19 | +#define BINARY_SUBSCR 25 |
| 20 | +#define BINARY_CALL 26 |
| 21 | + |
| 22 | +#define SLICE 30 |
| 23 | +/* Also uses 31-33 */ |
| 24 | + |
| 25 | +#define STORE_SLICE 40 |
| 26 | +/* Also uses 41-43 */ |
| 27 | + |
| 28 | +#define DELETE_SLICE 50 |
| 29 | +/* Also uses 51-53 */ |
| 30 | + |
| 31 | +#define STORE_SUBSCR 60 |
| 32 | +#define DELETE_SUBSCR 61 |
| 33 | + |
| 34 | +#define PRINT_EXPR 70 |
| 35 | +#define PRINT_ITEM 71 |
| 36 | +#define PRINT_NEWLINE 72 |
| 37 | + |
| 38 | +#define BREAK_LOOP 80 |
| 39 | +#define RAISE_EXCEPTION 81 |
| 40 | +#define RETURN_VALUE 83 |
| 41 | +#define REQUIRE_ARGS 84 |
| 42 | +#define REFUSE_ARGS 85 |
| 43 | +#define BUILD_FUNCTION 86 |
| 44 | +#define POP_BLOCK 87 |
| 45 | +#define END_FINALLY 88 |
| 46 | + |
| 47 | +#define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */ |
| 48 | + |
| 49 | +#define STORE_NAME 90 /* Index in name list */ |
| 50 | +#define DELETE_NAME 91 /* "" */ |
| 51 | +#define UNPACK_TUPLE 92 /* Number of tuple items */ |
| 52 | +#define UNPACK_LIST 93 /* Number of list items */ |
| 53 | +/* unused: 94 */ |
| 54 | +#define STORE_ATTR 95 /* Index in name list */ |
| 55 | +#define DELETE_ATTR 96 /* "" */ |
| 56 | + |
| 57 | +#define LOAD_CONST 100 /* Index in const list */ |
| 58 | +#define LOAD_NAME 101 /* Index in name list */ |
| 59 | +#define BUILD_TUPLE 102 /* Number of tuple items */ |
| 60 | +#define BUILD_LIST 103 /* Number of list items */ |
| 61 | +#define BUILD_MAP 104 /* Always zero for now */ |
| 62 | +#define LOAD_ATTR 105 /* Index in name list */ |
| 63 | +#define COMPARE_OP 106 /* Comparison operator */ |
| 64 | +#define IMPORT_NAME 107 /* Index in name list */ |
| 65 | +#define IMPORT_FROM 108 /* Index in name list */ |
| 66 | + |
| 67 | +#define JUMP_FORWARD 110 /* Number of bytes to skip */ |
| 68 | +#define JUMP_IF_FALSE 111 /* "" */ |
| 69 | +#define JUMP_IF_TRUE 112 /* "" */ |
| 70 | +#define JUMP_ABSOLUTE 113 /* Target byte offset from beginning of code */ |
| 71 | +#define FOR_LOOP 114 /* Number of bytes to skip */ |
| 72 | + |
| 73 | +#define SETUP_LOOP 120 /* Target address (absolute) */ |
| 74 | +#define SETUP_EXCEPT 121 /* "" */ |
| 75 | +#define SETUP_FINALLY 122 /* "" */ |
| 76 | + |
| 77 | +/* Comparison operator codes (argument to COMPARE_OP) */ |
| 78 | +enum cmp_op {LT, LE, EQ, NE, GT, GE, IN, NOT_IN, IS, IS_NOT, EXC_MATCH, BAD}; |
0 commit comments