Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the Micro Python project, http://micropython.org/ |
| 3 | * |
| 4 | * The MIT License (MIT) |
| 5 | * |
| 6 | * Copyright (c) 2013, 2014 Damien P. George |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | * of this software and associated documentation files (the "Software"), to deal |
| 10 | * in the Software without restriction, including without limitation the rights |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | * copies of the Software, and to permit persons to whom the Software is |
| 13 | * furnished to do so, subject to the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice shall be included in |
| 16 | * all copies or substantial portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | * THE SOFTWARE. |
| 25 | */ |
Damien George | 51dfcb4 | 2015-01-01 20:27:54 +0000 | [diff] [blame] | 26 | #ifndef __MICROPY_INCLUDED_PY_BC0_H__ |
| 27 | #define __MICROPY_INCLUDED_PY_BC0_H__ |
Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 28 | |
Damien George | e9906ac | 2014-01-04 18:44:46 +0000 | [diff] [blame] | 29 | // Micro Python byte-codes. |
| 30 | // The comment at the end of the line (if it exists) tells the arguments to the byte-code. |
| 31 | |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 32 | #define MP_BC_LOAD_CONST_FALSE (0x10) |
| 33 | #define MP_BC_LOAD_CONST_NONE (0x11) |
| 34 | #define MP_BC_LOAD_CONST_TRUE (0x12) |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 35 | #define MP_BC_LOAD_CONST_SMALL_INT (0x14) // signed var-int |
Damien George | 7d414a1 | 2015-02-08 01:57:40 +0000 | [diff] [blame] | 36 | #define MP_BC_LOAD_CONST_STRING (0x16) // qstr |
| 37 | #define MP_BC_LOAD_CONST_OBJ (0x17) // ptr |
| 38 | #define MP_BC_LOAD_NULL (0x18) |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 39 | |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 40 | #define MP_BC_LOAD_FAST_N (0x1a) // uint |
| 41 | #define MP_BC_LOAD_DEREF (0x1b) // uint |
| 42 | #define MP_BC_LOAD_NAME (0x1c) // qstr |
| 43 | #define MP_BC_LOAD_GLOBAL (0x1d) // qstr |
| 44 | #define MP_BC_LOAD_ATTR (0x1e) // qstr |
| 45 | #define MP_BC_LOAD_METHOD (0x1f) // qstr |
| 46 | #define MP_BC_LOAD_BUILD_CLASS (0x20) |
| 47 | #define MP_BC_LOAD_SUBSCR (0x21) |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 48 | |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 49 | #define MP_BC_STORE_FAST_N (0x22) // uint |
| 50 | #define MP_BC_STORE_DEREF (0x23) // uint |
| 51 | #define MP_BC_STORE_NAME (0x24) // qstr |
| 52 | #define MP_BC_STORE_GLOBAL (0x25) // qstr |
| 53 | #define MP_BC_STORE_ATTR (0x26) // qstr |
| 54 | #define MP_BC_STORE_SUBSCR (0x27) |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 55 | |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 56 | #define MP_BC_DELETE_FAST (0x28) // uint |
| 57 | #define MP_BC_DELETE_DEREF (0x29) // uint |
| 58 | #define MP_BC_DELETE_NAME (0x2a) // qstr |
| 59 | #define MP_BC_DELETE_GLOBAL (0x2b) // qstr |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 60 | |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 61 | #define MP_BC_DUP_TOP (0x30) |
| 62 | #define MP_BC_DUP_TOP_TWO (0x31) |
| 63 | #define MP_BC_POP_TOP (0x32) |
| 64 | #define MP_BC_ROT_TWO (0x33) |
| 65 | #define MP_BC_ROT_THREE (0x34) |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 66 | |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 67 | #define MP_BC_JUMP (0x35) // rel byte code offset, 16-bit signed, in excess |
| 68 | #define MP_BC_POP_JUMP_IF_TRUE (0x36) // rel byte code offset, 16-bit signed, in excess |
| 69 | #define MP_BC_POP_JUMP_IF_FALSE (0x37) // rel byte code offset, 16-bit signed, in excess |
| 70 | #define MP_BC_JUMP_IF_TRUE_OR_POP (0x38) // rel byte code offset, 16-bit signed, in excess |
| 71 | #define MP_BC_JUMP_IF_FALSE_OR_POP (0x39) // rel byte code offset, 16-bit signed, in excess |
| 72 | #define MP_BC_SETUP_WITH (0x3d) // rel byte code offset, 16-bit unsigned |
| 73 | #define MP_BC_WITH_CLEANUP (0x3e) |
| 74 | #define MP_BC_SETUP_EXCEPT (0x3f) // rel byte code offset, 16-bit unsigned |
| 75 | #define MP_BC_SETUP_FINALLY (0x40) // rel byte code offset, 16-bit unsigned |
| 76 | #define MP_BC_END_FINALLY (0x41) |
| 77 | #define MP_BC_GET_ITER (0x42) |
| 78 | #define MP_BC_FOR_ITER (0x43) // rel byte code offset, 16-bit unsigned |
| 79 | #define MP_BC_POP_BLOCK (0x44) |
| 80 | #define MP_BC_POP_EXCEPT (0x45) |
| 81 | #define MP_BC_UNWIND_JUMP (0x46) // rel byte code offset, 16-bit signed, in excess; then a byte |
Damien George | f4df3aa | 2016-01-09 23:59:52 +0000 | [diff] [blame] | 82 | #define MP_BC_GET_ITER_STACK (0x47) |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 83 | |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 84 | #define MP_BC_BUILD_TUPLE (0x50) // uint |
| 85 | #define MP_BC_BUILD_LIST (0x51) // uint |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 86 | #define MP_BC_BUILD_MAP (0x53) // uint |
| 87 | #define MP_BC_STORE_MAP (0x54) |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 88 | #define MP_BC_BUILD_SET (0x56) // uint |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 89 | #define MP_BC_BUILD_SLICE (0x58) // uint |
Damien George | adaf0d8 | 2016-09-19 08:46:01 +1000 | [diff] [blame] | 90 | #define MP_BC_STORE_COMP (0x57) // uint |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 91 | #define MP_BC_UNPACK_SEQUENCE (0x59) // uint |
| 92 | #define MP_BC_UNPACK_EX (0x5a) // uint |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 93 | |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 94 | #define MP_BC_RETURN_VALUE (0x5b) |
| 95 | #define MP_BC_RAISE_VARARGS (0x5c) // byte |
| 96 | #define MP_BC_YIELD_VALUE (0x5d) |
| 97 | #define MP_BC_YIELD_FROM (0x5e) |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 98 | |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 99 | #define MP_BC_MAKE_FUNCTION (0x60) // uint |
| 100 | #define MP_BC_MAKE_FUNCTION_DEFARGS (0x61) // uint |
| 101 | #define MP_BC_MAKE_CLOSURE (0x62) // uint |
| 102 | #define MP_BC_MAKE_CLOSURE_DEFARGS (0x63) // uint |
| 103 | #define MP_BC_CALL_FUNCTION (0x64) // uint |
| 104 | #define MP_BC_CALL_FUNCTION_VAR_KW (0x65) // uint |
| 105 | #define MP_BC_CALL_METHOD (0x66) // uint |
| 106 | #define MP_BC_CALL_METHOD_VAR_KW (0x67) // uint |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 107 | |
Damien George | 8456cc0 | 2014-10-25 16:43:46 +0100 | [diff] [blame] | 108 | #define MP_BC_IMPORT_NAME (0x68) // qstr |
| 109 | #define MP_BC_IMPORT_FROM (0x69) // qstr |
| 110 | #define MP_BC_IMPORT_STAR (0x6a) |
| 111 | |
| 112 | #define MP_BC_LOAD_CONST_SMALL_INT_MULTI (0x70) // + N(64) |
| 113 | #define MP_BC_LOAD_FAST_MULTI (0xb0) // + N(16) |
| 114 | #define MP_BC_STORE_FAST_MULTI (0xc0) // + N(16) |
Damien George | bdbe8c9 | 2015-12-08 12:28:11 +0000 | [diff] [blame] | 115 | #define MP_BC_UNARY_OP_MULTI (0xd0) // + op(7) |
| 116 | #define MP_BC_BINARY_OP_MULTI (0xd7) // + op(36) |
Damien George | 51dfcb4 | 2015-01-01 20:27:54 +0000 | [diff] [blame] | 117 | |
| 118 | #endif // __MICROPY_INCLUDED_PY_BC0_H__ |