Damien George | e9906ac | 2014-01-04 18:44:46 +0000 | [diff] [blame] | 1 | // Micro Python byte-codes. |
| 2 | // The comment at the end of the line (if it exists) tells the arguments to the byte-code. |
| 3 | |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 4 | #define MP_BC_LOAD_CONST_FALSE (0x10) |
| 5 | #define MP_BC_LOAD_CONST_NONE (0x11) |
| 6 | #define MP_BC_LOAD_CONST_TRUE (0x12) |
Damien George | e9906ac | 2014-01-04 18:44:46 +0000 | [diff] [blame] | 7 | #define MP_BC_LOAD_CONST_ELLIPSIS (0x13) |
| 8 | #define MP_BC_LOAD_CONST_SMALL_INT (0x14) // 24-bit, in excess |
| 9 | #define MP_BC_LOAD_CONST_INT (0x15) // qstr |
| 10 | #define MP_BC_LOAD_CONST_DEC (0x16) // qstr |
| 11 | #define MP_BC_LOAD_CONST_ID (0x17) // qstr |
| 12 | #define MP_BC_LOAD_CONST_BYTES (0x18) // qstr |
| 13 | #define MP_BC_LOAD_CONST_STRING (0x19) // qstr |
Damien George | 523b575 | 2014-03-31 11:59:23 +0100 | [diff] [blame] | 14 | #define MP_BC_LOAD_NULL (0x1a) |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 15 | |
| 16 | #define MP_BC_LOAD_FAST_0 (0x20) |
| 17 | #define MP_BC_LOAD_FAST_1 (0x21) |
| 18 | #define MP_BC_LOAD_FAST_2 (0x22) |
| 19 | #define MP_BC_LOAD_FAST_N (0x23) // uint |
| 20 | #define MP_BC_LOAD_DEREF (0x24) // uint |
Damien George | 6baf76e | 2013-12-30 22:32:17 +0000 | [diff] [blame] | 21 | #define MP_BC_LOAD_NAME (0x25) // qstr |
| 22 | #define MP_BC_LOAD_GLOBAL (0x26) // qstr |
| 23 | #define MP_BC_LOAD_ATTR (0x27) // qstr |
| 24 | #define MP_BC_LOAD_METHOD (0x28) // qstr |
| 25 | #define MP_BC_LOAD_BUILD_CLASS (0x29) |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 26 | |
| 27 | #define MP_BC_STORE_FAST_0 (0x30) |
| 28 | #define MP_BC_STORE_FAST_1 (0x31) |
| 29 | #define MP_BC_STORE_FAST_2 (0x32) |
| 30 | #define MP_BC_STORE_FAST_N (0x33) // uint |
| 31 | #define MP_BC_STORE_DEREF (0x34) // uint |
| 32 | #define MP_BC_STORE_NAME (0x35) // qstr |
| 33 | #define MP_BC_STORE_GLOBAL (0x36) // qstr |
| 34 | #define MP_BC_STORE_ATTR (0x37) // qstr |
| 35 | #define MP_BC_STORE_SUBSCR (0x38) |
| 36 | |
| 37 | #define MP_BC_DELETE_FAST_N (0x39) // uint |
| 38 | #define MP_BC_DELETE_DEREF (0x3a) // uint |
| 39 | #define MP_BC_DELETE_NAME (0x3b) // qstr |
| 40 | #define MP_BC_DELETE_GLOBAL (0x3c) // qstr |
| 41 | #define MP_BC_DELETE_ATTR (0x3d) // qstr |
| 42 | #define MP_BC_DELETE_SUBSCR (0x3e) |
| 43 | |
| 44 | #define MP_BC_DUP_TOP (0x40) |
| 45 | #define MP_BC_DUP_TOP_TWO (0x41) |
| 46 | #define MP_BC_POP_TOP (0x42) |
| 47 | #define MP_BC_ROT_TWO (0x43) |
| 48 | #define MP_BC_ROT_THREE (0x44) |
| 49 | |
| 50 | #define MP_BC_JUMP (0x45) // rel byte code offset, 16-bit signed, in excess |
| 51 | #define MP_BC_POP_JUMP_IF_TRUE (0x46) // rel byte code offset, 16-bit signed, in excess |
| 52 | #define MP_BC_POP_JUMP_IF_FALSE (0x47) // rel byte code offset, 16-bit signed, in excess |
| 53 | #define MP_BC_JUMP_IF_TRUE_OR_POP (0x48) // rel byte code offset, 16-bit signed, in excess |
| 54 | #define MP_BC_JUMP_IF_FALSE_OR_POP (0x49) // rel byte code offset, 16-bit signed, in excess |
| 55 | #define MP_BC_SETUP_LOOP (0x4a) // rel byte code offset, 16-bit unsigned |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 56 | #define MP_BC_SETUP_WITH (0x4d) // rel byte code offset, 16-bit unsigned |
| 57 | #define MP_BC_WITH_CLEANUP (0x4e) |
| 58 | #define MP_BC_SETUP_EXCEPT (0x4f) // rel byte code offset, 16-bit unsigned |
| 59 | #define MP_BC_SETUP_FINALLY (0x50) // rel byte code offset, 16-bit unsigned |
| 60 | #define MP_BC_END_FINALLY (0x51) |
| 61 | #define MP_BC_GET_ITER (0x52) |
| 62 | #define MP_BC_FOR_ITER (0x53) // rel byte code offset, 16-bit unsigned |
| 63 | #define MP_BC_POP_BLOCK (0x54) |
| 64 | #define MP_BC_POP_EXCEPT (0x55) |
Damien George | cbddb27 | 2014-02-01 20:08:18 +0000 | [diff] [blame] | 65 | #define MP_BC_UNWIND_JUMP (0x56) // rel byte code offset, 16-bit signed, in excess; then a byte |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 66 | |
Damien George | 9aa2a52 | 2014-02-01 23:04:09 +0000 | [diff] [blame] | 67 | #define MP_BC_NOT (0x60) |
| 68 | #define MP_BC_UNARY_OP (0x61) // byte |
| 69 | #define MP_BC_BINARY_OP (0x62) // byte |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 70 | |
| 71 | #define MP_BC_BUILD_TUPLE (0x70) // uint |
| 72 | #define MP_BC_BUILD_LIST (0x71) // uint |
| 73 | #define MP_BC_LIST_APPEND (0x72) // uint |
| 74 | #define MP_BC_BUILD_MAP (0x73) // uint |
| 75 | #define MP_BC_STORE_MAP (0x74) |
| 76 | #define MP_BC_MAP_ADD (0x75) // uint |
| 77 | #define MP_BC_BUILD_SET (0x76) // uint |
| 78 | #define MP_BC_SET_ADD (0x77) // uint |
| 79 | #define MP_BC_BUILD_SLICE (0x78) // uint |
| 80 | #define MP_BC_UNPACK_SEQUENCE (0x79) // uint |
| 81 | #define MP_BC_UNPACK_EX (0x7a) // uint |
| 82 | |
| 83 | #define MP_BC_RETURN_VALUE (0x80) |
Damien George | 25042b1 | 2014-01-11 09:33:39 +0000 | [diff] [blame] | 84 | #define MP_BC_RAISE_VARARGS (0x81) // byte |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 85 | #define MP_BC_YIELD_VALUE (0x82) |
| 86 | #define MP_BC_YIELD_FROM (0x83) |
| 87 | |
Damien George | 523b575 | 2014-03-31 11:59:23 +0100 | [diff] [blame] | 88 | #define MP_BC_MAKE_FUNCTION (0x90) // uint |
| 89 | #define MP_BC_MAKE_FUNCTION_DEFARGS (0x91) // uint |
| 90 | #define MP_BC_MAKE_CLOSURE (0x92) // uint |
| 91 | #define MP_BC_MAKE_CLOSURE_DEFARGS (0x93) // uint |
| 92 | #define MP_BC_CALL_FUNCTION (0x94) // uint |
| 93 | #define MP_BC_CALL_FUNCTION_VAR_KW (0x95) // uint |
| 94 | #define MP_BC_CALL_METHOD (0x96) // uint |
| 95 | #define MP_BC_CALL_METHOD_VAR_KW (0x97) // uint |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 96 | |
| 97 | #define MP_BC_IMPORT_NAME (0xe0) // qstr |
| 98 | #define MP_BC_IMPORT_FROM (0xe1) // qstr |
| 99 | #define MP_BC_IMPORT_STAR (0xe2) |
Paul Sokolovsky | 9075002 | 2014-02-01 15:05:04 +0200 | [diff] [blame] | 100 | |