py-cvs-rel2_1 (Rev 1.2) merge
[python/dscho.git] / Include / opcode.h
blobc1e83628538c704ed98106fc8bf7af6b5f35330d
1 #ifndef Py_OPCODE_H
2 #define Py_OPCODE_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
8 /* Instruction opcodes for compiled code */
10 #define STOP_CODE 0
11 #define POP_TOP 1
12 #define ROT_TWO 2
13 #define ROT_THREE 3
14 #define DUP_TOP 4
15 #define ROT_FOUR 5
17 #define UNARY_POSITIVE 10
18 #define UNARY_NEGATIVE 11
19 #define UNARY_NOT 12
20 #define UNARY_CONVERT 13
22 #define UNARY_INVERT 15
24 #define BINARY_POWER 19
26 #define BINARY_MULTIPLY 20
27 #define BINARY_DIVIDE 21
28 #define BINARY_MODULO 22
29 #define BINARY_ADD 23
30 #define BINARY_SUBTRACT 24
31 #define BINARY_SUBSCR 25
33 #define SLICE 30
34 /* Also uses 31-33 */
36 #define STORE_SLICE 40
37 /* Also uses 41-43 */
39 #define DELETE_SLICE 50
40 /* Also uses 51-53 */
42 #define INPLACE_ADD 55
43 #define INPLACE_SUBTRACT 56
44 #define INPLACE_MULTIPLY 57
45 #define INPLACE_DIVIDE 58
46 #define INPLACE_MODULO 59
47 #define STORE_SUBSCR 60
48 #define DELETE_SUBSCR 61
50 #define BINARY_LSHIFT 62
51 #define BINARY_RSHIFT 63
52 #define BINARY_AND 64
53 #define BINARY_XOR 65
54 #define BINARY_OR 66
55 #define INPLACE_POWER 67
56 #define GET_ITER 68
58 #define PRINT_EXPR 70
59 #define PRINT_ITEM 71
60 #define PRINT_NEWLINE 72
61 #define PRINT_ITEM_TO 73
62 #define PRINT_NEWLINE_TO 74
63 #define INPLACE_LSHIFT 75
64 #define INPLACE_RSHIFT 76
65 #define INPLACE_AND 77
66 #define INPLACE_XOR 78
67 #define INPLACE_OR 79
68 #define BREAK_LOOP 80
70 #define LOAD_LOCALS 82
71 #define RETURN_VALUE 83
72 #define IMPORT_STAR 84
73 #define EXEC_STMT 85
74 #define YIELD_VALUE 86
76 #define POP_BLOCK 87
77 #define END_FINALLY 88
78 #define BUILD_CLASS 89
80 #define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */
82 #define STORE_NAME 90 /* Index in name list */
83 #define DELETE_NAME 91 /* "" */
84 #define UNPACK_SEQUENCE 92 /* Number of sequence items */
85 #define FOR_ITER 93
87 #define STORE_ATTR 95 /* Index in name list */
88 #define DELETE_ATTR 96 /* "" */
89 #define STORE_GLOBAL 97 /* "" */
90 #define DELETE_GLOBAL 98 /* "" */
91 #define DUP_TOPX 99 /* number of items to duplicate */
92 #define LOAD_CONST 100 /* Index in const list */
93 #define LOAD_NAME 101 /* Index in name list */
94 #define BUILD_TUPLE 102 /* Number of tuple items */
95 #define BUILD_LIST 103 /* Number of list items */
96 #define BUILD_MAP 104 /* Always zero for now */
97 #define LOAD_ATTR 105 /* Index in name list */
98 #define COMPARE_OP 106 /* Comparison operator */
99 #define IMPORT_NAME 107 /* Index in name list */
100 #define IMPORT_FROM 108 /* Index in name list */
102 #define JUMP_FORWARD 110 /* Number of bytes to skip */
103 #define JUMP_IF_FALSE 111 /* "" */
104 #define JUMP_IF_TRUE 112 /* "" */
105 #define JUMP_ABSOLUTE 113 /* Target byte offset from beginning of code */
106 #define FOR_LOOP 114 /* Number of bytes to skip */
108 #define LOAD_GLOBAL 116 /* Index in name list */
110 #define CONTINUE_LOOP 119 /* Start of loop (absolute) */
111 #define SETUP_LOOP 120 /* Target address (absolute) */
112 #define SETUP_EXCEPT 121 /* "" */
113 #define SETUP_FINALLY 122 /* "" */
115 #define LOAD_FAST 124 /* Local variable number */
116 #define STORE_FAST 125 /* Local variable number */
117 #define DELETE_FAST 126 /* Local variable number */
119 #define SET_LINENO 127 /* Current line number */
121 #define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */
122 /* CALL_FUNCTION_XXX opcodes defined below depend on this definition */
123 #define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */
124 #define MAKE_FUNCTION 132 /* #defaults */
125 #define BUILD_SLICE 133 /* Number of items */
127 #define MAKE_CLOSURE 134 /* #free vars */
128 #define LOAD_CLOSURE 135 /* Load free variable from closure */
129 #define LOAD_DEREF 136 /* Load and dereference from closure cell */
130 #define STORE_DEREF 137 /* Store into cell */
132 /* The next 3 opcodes must be contiguous and satisfy
133 (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */
134 #define CALL_FUNCTION_VAR 140 /* #args + (#kwargs<<8) */
135 #define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */
136 #define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */
138 /* Support for opargs more than 16 bits long */
139 #define EXTENDED_ARG 143
141 /* Comparison operator codes (argument to COMPARE_OP) */
142 enum cmp_op {LT=Py_LT, LE=Py_LE, EQ=Py_EQ, NE=Py_NE, GT=Py_GT, GE=Py_GE,
143 IN, NOT_IN, IS, IS_NOT, EXC_MATCH, BAD};
145 #define HAS_ARG(op) ((op) >= HAVE_ARGUMENT)
147 #ifdef __cplusplus
149 #endif
150 #endif /* !Py_OPCODE_H */