annotate Include/opcode.h @ 13778:f6e4a9dd67cd legacy-trunk

Rename the "parser" package to "parsers" to be compatible with the PyXML project.
author Fred Drake <fdrake@acm.org>
date Mon, 31 Jul 2000 23:59:54 +0000
parents 87ee82e5c56d
children 4eaa463c031a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
1 #ifndef Py_OPCODE_H
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
2 #define Py_OPCODE_H
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
3 #ifdef __cplusplus
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
4 extern "C" {
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
5 #endif
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
6
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
7 /***********************************************************
13255
916fb024ce94 Change copyright notice.
Guido van Rossum <guido@python.org>
parents: 12085
diff changeset
8 Copyright (c) 2000, BeOpen.com.
916fb024ce94 Change copyright notice.
Guido van Rossum <guido@python.org>
parents: 12085
diff changeset
9 Copyright (c) 1995-2000, Corporation for National Research Initiatives.
916fb024ce94 Change copyright notice.
Guido van Rossum <guido@python.org>
parents: 12085
diff changeset
10 Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
916fb024ce94 Change copyright notice.
Guido van Rossum <guido@python.org>
parents: 12085
diff changeset
11 All rights reserved.
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
12
13255
916fb024ce94 Change copyright notice.
Guido van Rossum <guido@python.org>
parents: 12085
diff changeset
13 See the file "Misc/COPYRIGHT" for information on usage and
916fb024ce94 Change copyright notice.
Guido van Rossum <guido@python.org>
parents: 12085
diff changeset
14 redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
15 ******************************************************************/
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
16
69
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 /* Instruction opcodes for compiled code */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
18
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 78
diff changeset
19 #define STOP_CODE 0
69
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 #define POP_TOP 1
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 #define ROT_TWO 2
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 #define ROT_THREE 3
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 78
diff changeset
23 #define DUP_TOP 4
69
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 #define UNARY_POSITIVE 10
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 #define UNARY_NEGATIVE 11
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 #define UNARY_NOT 12
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 #define UNARY_CONVERT 13
2841
64928f6a8e80 keyword arguments and faster function calls
Guido van Rossum <guido@python.org>
parents: 2803
diff changeset
29
409
b5fe6482072f Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents: 178
diff changeset
30 #define UNARY_INVERT 15
69
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
3320
4e6d0b26efaf changes for ** (power) operator
Guido van Rossum <guido@python.org>
parents: 2841
diff changeset
32 #define BINARY_POWER 19
4e6d0b26efaf changes for ** (power) operator
Guido van Rossum <guido@python.org>
parents: 2841
diff changeset
33
69
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 #define BINARY_MULTIPLY 20
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 #define BINARY_DIVIDE 21
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 #define BINARY_MODULO 22
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 #define BINARY_ADD 23
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 #define BINARY_SUBTRACT 24
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 #define BINARY_SUBSCR 25
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
40
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 #define SLICE 30
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 /* Also uses 31-33 */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
43
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 #define STORE_SLICE 40
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 /* Also uses 41-43 */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
46
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 #define DELETE_SLICE 50
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 /* Also uses 51-53 */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
49
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 #define STORE_SUBSCR 60
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 #define DELETE_SUBSCR 61
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
52
409
b5fe6482072f Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents: 178
diff changeset
53 #define BINARY_LSHIFT 62
b5fe6482072f Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents: 178
diff changeset
54 #define BINARY_RSHIFT 63
b5fe6482072f Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents: 178
diff changeset
55 #define BINARY_AND 64
b5fe6482072f Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents: 178
diff changeset
56 #define BINARY_XOR 65
b5fe6482072f Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents: 178
diff changeset
57 #define BINARY_OR 66
b5fe6482072f Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents: 178
diff changeset
58
b5fe6482072f Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents: 178
diff changeset
59
69
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 #define PRINT_EXPR 70
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 #define PRINT_ITEM 71
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 #define PRINT_NEWLINE 72
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
63
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 #define BREAK_LOOP 80
2841
64928f6a8e80 keyword arguments and faster function calls
Guido van Rossum <guido@python.org>
parents: 2803
diff changeset
65
78
b1fb4e1f6e51 Added opcodes for classes.
Guido van Rossum <guido@python.org>
parents: 69
diff changeset
66 #define LOAD_LOCALS 82
69
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 #define RETURN_VALUE 83
2841
64928f6a8e80 keyword arguments and faster function calls
Guido van Rossum <guido@python.org>
parents: 2803
diff changeset
68
1354
fccd415e2eb8 * bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents: 1329
diff changeset
69 #define EXEC_STMT 85
1262
f820e6917f07 Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
70
69
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 #define POP_BLOCK 87
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 #define END_FINALLY 88
78
b1fb4e1f6e51 Added opcodes for classes.
Guido van Rossum <guido@python.org>
parents: 69
diff changeset
73 #define BUILD_CLASS 89
69
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
74
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 #define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
76
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
77 #define STORE_NAME 90 /* Index in name list */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 #define DELETE_NAME 91 /* "" */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
79 #define UNPACK_TUPLE 92 /* Number of tuple items */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 #define UNPACK_LIST 93 /* Number of list items */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 #define STORE_ATTR 95 /* Index in name list */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 #define DELETE_ATTR 96 /* "" */
474
19365201dcfa Added _GLOBAL opcodes.
Guido van Rossum <guido@python.org>
parents: 409
diff changeset
83 #define STORE_GLOBAL 97 /* "" */
19365201dcfa Added _GLOBAL opcodes.
Guido van Rossum <guido@python.org>
parents: 409
diff changeset
84 #define DELETE_GLOBAL 98 /* "" */
69
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
85
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 #define LOAD_CONST 100 /* Index in const list */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
87 #define LOAD_NAME 101 /* Index in name list */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 #define BUILD_TUPLE 102 /* Number of tuple items */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
89 #define BUILD_LIST 103 /* Number of list items */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 #define BUILD_MAP 104 /* Always zero for now */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
91 #define LOAD_ATTR 105 /* Index in name list */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
92 #define COMPARE_OP 106 /* Comparison operator */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
93 #define IMPORT_NAME 107 /* Index in name list */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
94 #define IMPORT_FROM 108 /* Index in name list */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
95
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 #define JUMP_FORWARD 110 /* Number of bytes to skip */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
97 #define JUMP_IF_FALSE 111 /* "" */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
98 #define JUMP_IF_TRUE 112 /* "" */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
99 #define JUMP_ABSOLUTE 113 /* Target byte offset from beginning of code */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 #define FOR_LOOP 114 /* Number of bytes to skip */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
101
178
fb6367d5ff46 Added opcodes to load local/global variables
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
102 #define LOAD_GLOBAL 116 /* Index in name list */
fb6367d5ff46 Added opcodes to load local/global variables
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
103
69
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
104 #define SETUP_LOOP 120 /* Target address (absolute) */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
105 #define SETUP_EXCEPT 121 /* "" */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 #define SETUP_FINALLY 122 /* "" */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
107
1262
f820e6917f07 Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
108 #define LOAD_FAST 124 /* Local variable number */
f820e6917f07 Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
109 #define STORE_FAST 125 /* Local variable number */
f820e6917f07 Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
110 #define DELETE_FAST 126 /* Local variable number */
f820e6917f07 Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
111
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 78
diff changeset
112 #define SET_LINENO 127 /* Current line number */
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 78
diff changeset
113
2803
a2363b6e9c86 new opcodes RAISE_VARARGS, CALL_FUNCTION
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
114 /* It used to be the case that opcodes should fit in 7 bits. This is
a2363b6e9c86 new opcodes RAISE_VARARGS, CALL_FUNCTION
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
115 no longer the case -- 8 bits is fine (the instruction stream is now
a2363b6e9c86 new opcodes RAISE_VARARGS, CALL_FUNCTION
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
116 a sequence of unsigned characters). We gladly use the new space
a2363b6e9c86 new opcodes RAISE_VARARGS, CALL_FUNCTION
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
117 for new opcodes. */
a2363b6e9c86 new opcodes RAISE_VARARGS, CALL_FUNCTION
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
118
a2363b6e9c86 new opcodes RAISE_VARARGS, CALL_FUNCTION
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
119 #define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */
12082
603db0d0aed1 slightly modified version of Greg Ewing's extended call syntax patch
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 8627
diff changeset
120 /* CALL_FUNCTION_XXX opcodes defined below depend on this definition */
2803
a2363b6e9c86 new opcodes RAISE_VARARGS, CALL_FUNCTION
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
121 #define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */
2841
64928f6a8e80 keyword arguments and faster function calls
Guido van Rossum <guido@python.org>
parents: 2803
diff changeset
122 #define MAKE_FUNCTION 132 /* #defaults */
3832
039bc3e4e64e Added BUILD_SLICE opcode.
Guido van Rossum <guido@python.org>
parents: 3320
diff changeset
123 #define BUILD_SLICE 133 /* Number of items */
2803
a2363b6e9c86 new opcodes RAISE_VARARGS, CALL_FUNCTION
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
124
12082
603db0d0aed1 slightly modified version of Greg Ewing's extended call syntax patch
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 8627
diff changeset
125 /* The next 3 opcodes must be contiguous and satisfy
12085
25b63367385e remove reference to CALL_FUNCTION_STAR in comment
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 12082
diff changeset
126 (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */
12082
603db0d0aed1 slightly modified version of Greg Ewing's extended call syntax patch
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 8627
diff changeset
127 #define CALL_FUNCTION_VAR 140 /* #args + (#kwargs<<8) */
603db0d0aed1 slightly modified version of Greg Ewing's extended call syntax patch
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 8627
diff changeset
128 #define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */
603db0d0aed1 slightly modified version of Greg Ewing's extended call syntax patch
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 8627
diff changeset
129 #define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */
603db0d0aed1 slightly modified version of Greg Ewing's extended call syntax patch
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 8627
diff changeset
130
69
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
131 /* Comparison operator codes (argument to COMPARE_OP) */
cccd534f2280 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
132 enum cmp_op {LT, LE, EQ, NE, GT, GE, IN, NOT_IN, IS, IS_NOT, EXC_MATCH, BAD};
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 78
diff changeset
133
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 78
diff changeset
134 #define HAS_ARG(op) ((op) >= HAVE_ARGUMENT)
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
135
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
136 #ifdef __cplusplus
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
137 }
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
138 #endif
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
139 #endif /* !Py_OPCODE_H */