Chris@87
|
1 #ifndef Py_OPCODE_H
|
Chris@87
|
2 #define Py_OPCODE_H
|
Chris@87
|
3 #ifdef __cplusplus
|
Chris@87
|
4 extern "C" {
|
Chris@87
|
5 #endif
|
Chris@87
|
6
|
Chris@87
|
7
|
Chris@87
|
8 /* Instruction opcodes for compiled code */
|
Chris@87
|
9
|
Chris@87
|
10 #define STOP_CODE 0
|
Chris@87
|
11 #define POP_TOP 1
|
Chris@87
|
12 #define ROT_TWO 2
|
Chris@87
|
13 #define ROT_THREE 3
|
Chris@87
|
14 #define DUP_TOP 4
|
Chris@87
|
15 #define ROT_FOUR 5
|
Chris@87
|
16 #define NOP 9
|
Chris@87
|
17
|
Chris@87
|
18 #define UNARY_POSITIVE 10
|
Chris@87
|
19 #define UNARY_NEGATIVE 11
|
Chris@87
|
20 #define UNARY_NOT 12
|
Chris@87
|
21 #define UNARY_CONVERT 13
|
Chris@87
|
22
|
Chris@87
|
23 #define UNARY_INVERT 15
|
Chris@87
|
24
|
Chris@87
|
25 #define BINARY_POWER 19
|
Chris@87
|
26
|
Chris@87
|
27 #define BINARY_MULTIPLY 20
|
Chris@87
|
28 #define BINARY_DIVIDE 21
|
Chris@87
|
29 #define BINARY_MODULO 22
|
Chris@87
|
30 #define BINARY_ADD 23
|
Chris@87
|
31 #define BINARY_SUBTRACT 24
|
Chris@87
|
32 #define BINARY_SUBSCR 25
|
Chris@87
|
33 #define BINARY_FLOOR_DIVIDE 26
|
Chris@87
|
34 #define BINARY_TRUE_DIVIDE 27
|
Chris@87
|
35 #define INPLACE_FLOOR_DIVIDE 28
|
Chris@87
|
36 #define INPLACE_TRUE_DIVIDE 29
|
Chris@87
|
37
|
Chris@87
|
38 #define SLICE 30
|
Chris@87
|
39 /* Also uses 31-33 */
|
Chris@87
|
40
|
Chris@87
|
41 #define STORE_SLICE 40
|
Chris@87
|
42 /* Also uses 41-43 */
|
Chris@87
|
43
|
Chris@87
|
44 #define DELETE_SLICE 50
|
Chris@87
|
45 /* Also uses 51-53 */
|
Chris@87
|
46
|
Chris@87
|
47 #define STORE_MAP 54
|
Chris@87
|
48 #define INPLACE_ADD 55
|
Chris@87
|
49 #define INPLACE_SUBTRACT 56
|
Chris@87
|
50 #define INPLACE_MULTIPLY 57
|
Chris@87
|
51 #define INPLACE_DIVIDE 58
|
Chris@87
|
52 #define INPLACE_MODULO 59
|
Chris@87
|
53 #define STORE_SUBSCR 60
|
Chris@87
|
54 #define DELETE_SUBSCR 61
|
Chris@87
|
55
|
Chris@87
|
56 #define BINARY_LSHIFT 62
|
Chris@87
|
57 #define BINARY_RSHIFT 63
|
Chris@87
|
58 #define BINARY_AND 64
|
Chris@87
|
59 #define BINARY_XOR 65
|
Chris@87
|
60 #define BINARY_OR 66
|
Chris@87
|
61 #define INPLACE_POWER 67
|
Chris@87
|
62 #define GET_ITER 68
|
Chris@87
|
63
|
Chris@87
|
64 #define PRINT_EXPR 70
|
Chris@87
|
65 #define PRINT_ITEM 71
|
Chris@87
|
66 #define PRINT_NEWLINE 72
|
Chris@87
|
67 #define PRINT_ITEM_TO 73
|
Chris@87
|
68 #define PRINT_NEWLINE_TO 74
|
Chris@87
|
69 #define INPLACE_LSHIFT 75
|
Chris@87
|
70 #define INPLACE_RSHIFT 76
|
Chris@87
|
71 #define INPLACE_AND 77
|
Chris@87
|
72 #define INPLACE_XOR 78
|
Chris@87
|
73 #define INPLACE_OR 79
|
Chris@87
|
74 #define BREAK_LOOP 80
|
Chris@87
|
75 #define WITH_CLEANUP 81
|
Chris@87
|
76 #define LOAD_LOCALS 82
|
Chris@87
|
77 #define RETURN_VALUE 83
|
Chris@87
|
78 #define IMPORT_STAR 84
|
Chris@87
|
79 #define EXEC_STMT 85
|
Chris@87
|
80 #define YIELD_VALUE 86
|
Chris@87
|
81 #define POP_BLOCK 87
|
Chris@87
|
82 #define END_FINALLY 88
|
Chris@87
|
83 #define BUILD_CLASS 89
|
Chris@87
|
84
|
Chris@87
|
85 #define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */
|
Chris@87
|
86
|
Chris@87
|
87 #define STORE_NAME 90 /* Index in name list */
|
Chris@87
|
88 #define DELETE_NAME 91 /* "" */
|
Chris@87
|
89 #define UNPACK_SEQUENCE 92 /* Number of sequence items */
|
Chris@87
|
90 #define FOR_ITER 93
|
Chris@87
|
91 #define LIST_APPEND 94
|
Chris@87
|
92
|
Chris@87
|
93 #define STORE_ATTR 95 /* Index in name list */
|
Chris@87
|
94 #define DELETE_ATTR 96 /* "" */
|
Chris@87
|
95 #define STORE_GLOBAL 97 /* "" */
|
Chris@87
|
96 #define DELETE_GLOBAL 98 /* "" */
|
Chris@87
|
97 #define DUP_TOPX 99 /* number of items to duplicate */
|
Chris@87
|
98 #define LOAD_CONST 100 /* Index in const list */
|
Chris@87
|
99 #define LOAD_NAME 101 /* Index in name list */
|
Chris@87
|
100 #define BUILD_TUPLE 102 /* Number of tuple items */
|
Chris@87
|
101 #define BUILD_LIST 103 /* Number of list items */
|
Chris@87
|
102 #define BUILD_SET 104 /* Number of set items */
|
Chris@87
|
103 #define BUILD_MAP 105 /* Always zero for now */
|
Chris@87
|
104 #define LOAD_ATTR 106 /* Index in name list */
|
Chris@87
|
105 #define COMPARE_OP 107 /* Comparison operator */
|
Chris@87
|
106 #define IMPORT_NAME 108 /* Index in name list */
|
Chris@87
|
107 #define IMPORT_FROM 109 /* Index in name list */
|
Chris@87
|
108 #define JUMP_FORWARD 110 /* Number of bytes to skip */
|
Chris@87
|
109
|
Chris@87
|
110 #define JUMP_IF_FALSE_OR_POP 111 /* Target byte offset from beginning
|
Chris@87
|
111 of code */
|
Chris@87
|
112 #define JUMP_IF_TRUE_OR_POP 112 /* "" */
|
Chris@87
|
113 #define JUMP_ABSOLUTE 113 /* "" */
|
Chris@87
|
114 #define POP_JUMP_IF_FALSE 114 /* "" */
|
Chris@87
|
115 #define POP_JUMP_IF_TRUE 115 /* "" */
|
Chris@87
|
116
|
Chris@87
|
117 #define LOAD_GLOBAL 116 /* Index in name list */
|
Chris@87
|
118
|
Chris@87
|
119 #define CONTINUE_LOOP 119 /* Start of loop (absolute) */
|
Chris@87
|
120 #define SETUP_LOOP 120 /* Target address (relative) */
|
Chris@87
|
121 #define SETUP_EXCEPT 121 /* "" */
|
Chris@87
|
122 #define SETUP_FINALLY 122 /* "" */
|
Chris@87
|
123
|
Chris@87
|
124 #define LOAD_FAST 124 /* Local variable number */
|
Chris@87
|
125 #define STORE_FAST 125 /* Local variable number */
|
Chris@87
|
126 #define DELETE_FAST 126 /* Local variable number */
|
Chris@87
|
127
|
Chris@87
|
128 #define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */
|
Chris@87
|
129 /* CALL_FUNCTION_XXX opcodes defined below depend on this definition */
|
Chris@87
|
130 #define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */
|
Chris@87
|
131 #define MAKE_FUNCTION 132 /* #defaults */
|
Chris@87
|
132 #define BUILD_SLICE 133 /* Number of items */
|
Chris@87
|
133
|
Chris@87
|
134 #define MAKE_CLOSURE 134 /* #free vars */
|
Chris@87
|
135 #define LOAD_CLOSURE 135 /* Load free variable from closure */
|
Chris@87
|
136 #define LOAD_DEREF 136 /* Load and dereference from closure cell */
|
Chris@87
|
137 #define STORE_DEREF 137 /* Store into cell */
|
Chris@87
|
138
|
Chris@87
|
139 /* The next 3 opcodes must be contiguous and satisfy
|
Chris@87
|
140 (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */
|
Chris@87
|
141 #define CALL_FUNCTION_VAR 140 /* #args + (#kwargs<<8) */
|
Chris@87
|
142 #define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */
|
Chris@87
|
143 #define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */
|
Chris@87
|
144
|
Chris@87
|
145 #define SETUP_WITH 143
|
Chris@87
|
146
|
Chris@87
|
147 /* Support for opargs more than 16 bits long */
|
Chris@87
|
148 #define EXTENDED_ARG 145
|
Chris@87
|
149
|
Chris@87
|
150 #define SET_ADD 146
|
Chris@87
|
151 #define MAP_ADD 147
|
Chris@87
|
152
|
Chris@87
|
153
|
Chris@87
|
154 enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, PyCmp_GT=Py_GT, PyCmp_GE=Py_GE,
|
Chris@87
|
155 PyCmp_IN, PyCmp_NOT_IN, PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD};
|
Chris@87
|
156
|
Chris@87
|
157 #define HAS_ARG(op) ((op) >= HAVE_ARGUMENT)
|
Chris@87
|
158
|
Chris@87
|
159 #ifdef __cplusplus
|
Chris@87
|
160 }
|
Chris@87
|
161 #endif
|
Chris@87
|
162 #endif /* !Py_OPCODE_H */
|