Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 1 | #ifndef Py_OPCODE_H |
| 2 | #define Py_OPCODE_H |
| 3 | #ifdef __cplusplus |
| 4 | extern "C" { |
| 5 | #endif |
| 6 | |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 7 | /*********************************************************** |
Guido van Rossum | 5799b52 | 1995-01-04 19:06:22 +0000 | [diff] [blame] | 8 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 9 | The Netherlands. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 10 | |
| 11 | All Rights Reserved |
| 12 | |
| 13 | Permission to use, copy, modify, and distribute this software and its |
| 14 | documentation for any purpose and without fee is hereby granted, |
| 15 | provided that the above copyright notice appear in all copies and that |
| 16 | both that copyright notice and this permission notice appear in |
| 17 | supporting documentation, and that the names of Stichting Mathematisch |
| 18 | Centrum or CWI not be used in advertising or publicity pertaining to |
| 19 | distribution of the software without specific, written prior permission. |
| 20 | |
| 21 | STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
| 22 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 23 | FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
| 24 | FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 25 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 26 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 27 | OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 28 | |
| 29 | ******************************************************************/ |
| 30 | |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 31 | /* Instruction opcodes for compiled code */ |
| 32 | |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 33 | #define STOP_CODE 0 |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 34 | #define POP_TOP 1 |
| 35 | #define ROT_TWO 2 |
| 36 | #define ROT_THREE 3 |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 37 | #define DUP_TOP 4 |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 38 | |
| 39 | #define UNARY_POSITIVE 10 |
| 40 | #define UNARY_NEGATIVE 11 |
| 41 | #define UNARY_NOT 12 |
| 42 | #define UNARY_CONVERT 13 |
Guido van Rossum | 884afd6 | 1995-07-18 14:21:06 +0000 | [diff] [blame] | 43 | |
Guido van Rossum | 7928cd7 | 1991-10-24 14:59:31 +0000 | [diff] [blame] | 44 | #define UNARY_INVERT 15 |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 45 | |
Guido van Rossum | 3d1f095 | 1996-01-12 00:51:44 +0000 | [diff] [blame] | 46 | #define BINARY_POWER 19 |
| 47 | |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 48 | #define BINARY_MULTIPLY 20 |
| 49 | #define BINARY_DIVIDE 21 |
| 50 | #define BINARY_MODULO 22 |
| 51 | #define BINARY_ADD 23 |
| 52 | #define BINARY_SUBTRACT 24 |
| 53 | #define BINARY_SUBSCR 25 |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 54 | |
| 55 | #define SLICE 30 |
| 56 | /* Also uses 31-33 */ |
| 57 | |
| 58 | #define STORE_SLICE 40 |
| 59 | /* Also uses 41-43 */ |
| 60 | |
| 61 | #define DELETE_SLICE 50 |
| 62 | /* Also uses 51-53 */ |
| 63 | |
| 64 | #define STORE_SUBSCR 60 |
| 65 | #define DELETE_SUBSCR 61 |
| 66 | |
Guido van Rossum | 7928cd7 | 1991-10-24 14:59:31 +0000 | [diff] [blame] | 67 | #define BINARY_LSHIFT 62 |
| 68 | #define BINARY_RSHIFT 63 |
| 69 | #define BINARY_AND 64 |
| 70 | #define BINARY_XOR 65 |
| 71 | #define BINARY_OR 66 |
| 72 | |
| 73 | |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 74 | #define PRINT_EXPR 70 |
| 75 | #define PRINT_ITEM 71 |
| 76 | #define PRINT_NEWLINE 72 |
| 77 | |
| 78 | #define BREAK_LOOP 80 |
Guido van Rossum | 884afd6 | 1995-07-18 14:21:06 +0000 | [diff] [blame] | 79 | |
Guido van Rossum | f127027 | 1990-11-18 17:38:15 +0000 | [diff] [blame] | 80 | #define LOAD_LOCALS 82 |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 81 | #define RETURN_VALUE 83 |
Guido van Rossum | 884afd6 | 1995-07-18 14:21:06 +0000 | [diff] [blame] | 82 | |
Guido van Rossum | db3165e | 1993-10-18 17:06:59 +0000 | [diff] [blame] | 83 | #define EXEC_STMT 85 |
Guido van Rossum | 8b17d6b | 1993-03-30 13:18:41 +0000 | [diff] [blame] | 84 | |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 85 | #define POP_BLOCK 87 |
| 86 | #define END_FINALLY 88 |
Guido van Rossum | f127027 | 1990-11-18 17:38:15 +0000 | [diff] [blame] | 87 | #define BUILD_CLASS 89 |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 88 | |
| 89 | #define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */ |
| 90 | |
| 91 | #define STORE_NAME 90 /* Index in name list */ |
| 92 | #define DELETE_NAME 91 /* "" */ |
| 93 | #define UNPACK_TUPLE 92 /* Number of tuple items */ |
| 94 | #define UNPACK_LIST 93 /* Number of list items */ |
Guido van Rossum | 750bf14 | 1991-12-16 13:07:35 +0000 | [diff] [blame] | 95 | #define UNPACK_ARG 94 /* Number of arguments */ |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 96 | #define STORE_ATTR 95 /* Index in name list */ |
| 97 | #define DELETE_ATTR 96 /* "" */ |
Guido van Rossum | 97ff530 | 1991-12-10 13:59:17 +0000 | [diff] [blame] | 98 | #define STORE_GLOBAL 97 /* "" */ |
| 99 | #define DELETE_GLOBAL 98 /* "" */ |
Guido van Rossum | 22f863f | 1992-01-14 18:38:56 +0000 | [diff] [blame] | 100 | #define UNPACK_VARARG 99 /* Minimal number of arguments */ |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 101 | |
| 102 | #define LOAD_CONST 100 /* Index in const list */ |
| 103 | #define LOAD_NAME 101 /* Index in name list */ |
| 104 | #define BUILD_TUPLE 102 /* Number of tuple items */ |
| 105 | #define BUILD_LIST 103 /* Number of list items */ |
| 106 | #define BUILD_MAP 104 /* Always zero for now */ |
| 107 | #define LOAD_ATTR 105 /* Index in name list */ |
| 108 | #define COMPARE_OP 106 /* Comparison operator */ |
| 109 | #define IMPORT_NAME 107 /* Index in name list */ |
| 110 | #define IMPORT_FROM 108 /* Index in name list */ |
Guido van Rossum | 2583165 | 1993-05-19 14:50:45 +0000 | [diff] [blame] | 111 | #define ACCESS_MODE 109 /* Name (mode is int on top of stack) */ |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 112 | |
| 113 | #define JUMP_FORWARD 110 /* Number of bytes to skip */ |
| 114 | #define JUMP_IF_FALSE 111 /* "" */ |
| 115 | #define JUMP_IF_TRUE 112 /* "" */ |
| 116 | #define JUMP_ABSOLUTE 113 /* Target byte offset from beginning of code */ |
| 117 | #define FOR_LOOP 114 /* Number of bytes to skip */ |
| 118 | |
Guido van Rossum | 054ff1f | 1991-04-04 10:45:01 +0000 | [diff] [blame] | 119 | #define LOAD_LOCAL 115 /* Index in name list */ |
| 120 | #define LOAD_GLOBAL 116 /* Index in name list */ |
| 121 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 122 | #define SET_FUNC_ARGS 117 /* Argcount */ |
| 123 | |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 124 | #define SETUP_LOOP 120 /* Target address (absolute) */ |
| 125 | #define SETUP_EXCEPT 121 /* "" */ |
| 126 | #define SETUP_FINALLY 122 /* "" */ |
| 127 | |
Guido van Rossum | 8b17d6b | 1993-03-30 13:18:41 +0000 | [diff] [blame] | 128 | #define LOAD_FAST 124 /* Local variable number */ |
| 129 | #define STORE_FAST 125 /* Local variable number */ |
| 130 | #define DELETE_FAST 126 /* Local variable number */ |
| 131 | |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 132 | #define SET_LINENO 127 /* Current line number */ |
| 133 | |
Guido van Rossum | 3b46a50 | 1995-07-07 22:32:10 +0000 | [diff] [blame] | 134 | /* It used to be the case that opcodes should fit in 7 bits. This is |
| 135 | no longer the case -- 8 bits is fine (the instruction stream is now |
| 136 | a sequence of unsigned characters). We gladly use the new space |
| 137 | for new opcodes. */ |
| 138 | |
| 139 | #define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */ |
| 140 | #define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */ |
Guido van Rossum | 884afd6 | 1995-07-18 14:21:06 +0000 | [diff] [blame] | 141 | #define MAKE_FUNCTION 132 /* #defaults */ |
Guido van Rossum | 3b46a50 | 1995-07-07 22:32:10 +0000 | [diff] [blame] | 142 | |
Guido van Rossum | 10dc2e8 | 1990-11-18 17:27:39 +0000 | [diff] [blame] | 143 | /* Comparison operator codes (argument to COMPARE_OP) */ |
| 144 | enum cmp_op {LT, LE, EQ, NE, GT, GE, IN, NOT_IN, IS, IS_NOT, EXC_MATCH, BAD}; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 145 | |
| 146 | #define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 147 | |
| 148 | #ifdef __cplusplus |
| 149 | } |
| 150 | #endif |
| 151 | #endif /* !Py_OPCODE_H */ |