Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{dis} --- |
Fred Drake | f8ca7d8 | 2000-10-10 17:03:45 +0000 | [diff] [blame] | 2 | Disassembler for Python byte code} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 | |
Fred Drake | f8ca7d8 | 2000-10-10 17:03:45 +0000 | [diff] [blame] | 4 | \declaremodule{standard}{dis} |
Fred Drake | 2c4f554 | 2000-10-10 22:00:03 +0000 | [diff] [blame] | 5 | \modulesynopsis{Disassembler for Python byte code.} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 6 | |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 7 | |
Fred Drake | dff21a6 | 1998-04-03 05:42:10 +0000 | [diff] [blame] | 8 | The \module{dis} module supports the analysis of Python byte code by |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 9 | disassembling it. Since there is no Python assembler, this module |
| 10 | defines the Python assembly language. The Python byte code which |
| 11 | this module takes as an input is defined in the file |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 12 | \file{Include/opcode.h} and used by the compiler and the interpreter. |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 13 | |
Fred Drake | dff21a6 | 1998-04-03 05:42:10 +0000 | [diff] [blame] | 14 | Example: Given the function \function{myfunc}: |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 15 | |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 16 | \begin{verbatim} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 17 | def myfunc(alist): |
Fred Drake | dff21a6 | 1998-04-03 05:42:10 +0000 | [diff] [blame] | 18 | return len(alist) |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 19 | \end{verbatim} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 20 | |
Fred Drake | dff21a6 | 1998-04-03 05:42:10 +0000 | [diff] [blame] | 21 | the following command can be used to get the disassembly of |
| 22 | \function{myfunc()}: |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 23 | |
| 24 | \begin{verbatim} |
| 25 | >>> dis.dis(myfunc) |
| 26 | 0 SET_LINENO 1 |
| 27 | |
| 28 | 3 SET_LINENO 2 |
| 29 | 6 LOAD_GLOBAL 0 (len) |
| 30 | 9 LOAD_FAST 0 (alist) |
| 31 | 12 CALL_FUNCTION 1 |
| 32 | 15 RETURN_VALUE |
| 33 | 16 LOAD_CONST 0 (None) |
| 34 | 19 RETURN_VALUE |
| 35 | \end{verbatim} |
| 36 | |
Fred Drake | 2c4f554 | 2000-10-10 22:00:03 +0000 | [diff] [blame] | 37 | The \module{dis} module defines the following functions and constants: |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 38 | |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 39 | \begin{funcdesc}{dis}{\optional{bytesource}} |
| 40 | Disassemble the \var{bytesource} object. \var{bytesource} can denote |
| 41 | either a class, a method, a function, or a code object. For a class, |
| 42 | it disassembles all methods. For a single code sequence, it prints |
| 43 | one line per byte code instruction. If no object is provided, it |
| 44 | disassembles the last traceback. |
| 45 | \end{funcdesc} |
| 46 | |
| 47 | \begin{funcdesc}{distb}{\optional{tb}} |
| 48 | Disassembles the top-of-stack function of a traceback, using the last |
| 49 | traceback if none was passed. The instruction causing the exception |
| 50 | is indicated. |
| 51 | \end{funcdesc} |
| 52 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 53 | \begin{funcdesc}{disassemble}{code\optional{, lasti}} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 54 | Disassembles a code object, indicating the last instruction if \var{lasti} |
| 55 | was provided. The output is divided in the following columns: |
Fred Drake | 810349b | 1998-04-07 14:16:41 +0000 | [diff] [blame] | 56 | |
Fred Drake | 3e7a48e | 1998-04-13 16:15:02 +0000 | [diff] [blame] | 57 | \begin{enumerate} |
Fred Drake | dff21a6 | 1998-04-03 05:42:10 +0000 | [diff] [blame] | 58 | \item the current instruction, indicated as \samp{-->}, |
Fred Drake | c054c75 | 2001-04-13 17:25:38 +0000 | [diff] [blame] | 59 | \item a labelled instruction, indicated with \samp{>\code{>}}, |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 60 | \item the address of the instruction, |
| 61 | \item the operation code name, |
| 62 | \item operation parameters, and |
| 63 | \item interpretation of the parameters in parentheses. |
Fred Drake | 3e7a48e | 1998-04-13 16:15:02 +0000 | [diff] [blame] | 64 | \end{enumerate} |
Fred Drake | 810349b | 1998-04-07 14:16:41 +0000 | [diff] [blame] | 65 | |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 66 | The parameter interpretation recognizes local and global |
| 67 | variable names, constant values, branch targets, and compare |
| 68 | operators. |
| 69 | \end{funcdesc} |
| 70 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 71 | \begin{funcdesc}{disco}{code\optional{, lasti}} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 72 | A synonym for disassemble. It is more convenient to type, and kept |
| 73 | for compatibility with earlier Python releases. |
| 74 | \end{funcdesc} |
| 75 | |
| 76 | \begin{datadesc}{opname} |
Fred Drake | 2c4f554 | 2000-10-10 22:00:03 +0000 | [diff] [blame] | 77 | Sequence of operation names, indexable using the byte code. |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 78 | \end{datadesc} |
| 79 | |
| 80 | \begin{datadesc}{cmp_op} |
| 81 | Sequence of all compare operation names. |
| 82 | \end{datadesc} |
| 83 | |
| 84 | \begin{datadesc}{hasconst} |
| 85 | Sequence of byte codes that have a constant parameter. |
| 86 | \end{datadesc} |
| 87 | |
Fred Drake | 47cdf6f | 2002-03-28 19:34:53 +0000 | [diff] [blame] | 88 | \begin{datadesc}{hasfree} |
| 89 | Sequence of byte codes that access a free variable. |
| 90 | \end{datadesc} |
| 91 | |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 92 | \begin{datadesc}{hasname} |
Fred Drake | 2c4f554 | 2000-10-10 22:00:03 +0000 | [diff] [blame] | 93 | Sequence of byte codes that access an attribute by name. |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 94 | \end{datadesc} |
| 95 | |
| 96 | \begin{datadesc}{hasjrel} |
| 97 | Sequence of byte codes that have a relative jump target. |
| 98 | \end{datadesc} |
| 99 | |
| 100 | \begin{datadesc}{hasjabs} |
| 101 | Sequence of byte codes that have an absolute jump target. |
| 102 | \end{datadesc} |
| 103 | |
| 104 | \begin{datadesc}{haslocal} |
Fred Drake | 2c4f554 | 2000-10-10 22:00:03 +0000 | [diff] [blame] | 105 | Sequence of byte codes that access a local variable. |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 106 | \end{datadesc} |
| 107 | |
| 108 | \begin{datadesc}{hascompare} |
Fred Drake | 6c81e2a | 2001-10-01 17:04:10 +0000 | [diff] [blame] | 109 | Sequence of byte codes of Boolean operations. |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 110 | \end{datadesc} |
| 111 | |
| 112 | \subsection{Python Byte Code Instructions} |
Fred Drake | 83efb54 | 1998-02-19 20:07:39 +0000 | [diff] [blame] | 113 | \label{bytecodes} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 114 | |
| 115 | The Python compiler currently generates the following byte code |
| 116 | instructions. |
| 117 | |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 118 | \setindexsubitem{(byte code insns)} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 119 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 120 | \begin{opcodedesc}{STOP_CODE}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 121 | Indicates end-of-code to the compiler, not used by the interpreter. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 122 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 123 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 124 | \begin{opcodedesc}{POP_TOP}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 125 | Removes the top-of-stack (TOS) item. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 126 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 127 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 128 | \begin{opcodedesc}{ROT_TWO}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 129 | Swaps the two top-most stack items. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 130 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 131 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 132 | \begin{opcodedesc}{ROT_THREE}{} |
| 133 | Lifts second and third stack item one position up, moves top down |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 134 | to position three. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 135 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 136 | |
Thomas Wouters | 12bba85 | 2000-08-24 20:06:04 +0000 | [diff] [blame] | 137 | \begin{opcodedesc}{ROT_FOUR}{} |
| 138 | Lifts second, third and forth stack item one position up, moves top down to |
| 139 | position four. |
| 140 | \end{opcodedesc} |
| 141 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 142 | \begin{opcodedesc}{DUP_TOP}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 143 | Duplicates the reference on top of the stack. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 144 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 145 | |
| 146 | Unary Operations take the top of the stack, apply the operation, and |
| 147 | push the result back on the stack. |
| 148 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 149 | \begin{opcodedesc}{UNARY_POSITIVE}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 150 | Implements \code{TOS = +TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 151 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 152 | |
Fred Drake | 4c3f797 | 2000-08-31 16:26:35 +0000 | [diff] [blame] | 153 | \begin{opcodedesc}{UNARY_NEGATIVE}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 154 | Implements \code{TOS = -TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 155 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 156 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 157 | \begin{opcodedesc}{UNARY_NOT}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 158 | Implements \code{TOS = not TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 159 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 160 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 161 | \begin{opcodedesc}{UNARY_CONVERT}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 162 | Implements \code{TOS = `TOS`}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 163 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 164 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 165 | \begin{opcodedesc}{UNARY_INVERT}{} |
Fred Drake | 9e759df | 2000-06-15 18:44:30 +0000 | [diff] [blame] | 166 | Implements \code{TOS = \~{}TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 167 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 168 | |
Guido van Rossum | e3fdc97 | 2002-06-12 15:33:08 +0000 | [diff] [blame] | 169 | \begin{opcodedesc}{GET_ITER}{} |
| 170 | Implements \code{TOS = iter(TOS)}. |
| 171 | \end{opcodedesc} |
| 172 | |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 173 | Binary operations remove the top of the stack (TOS) and the second top-most |
| 174 | stack item (TOS1) from the stack. They perform the operation, and put the |
| 175 | result back on the stack. |
| 176 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 177 | \begin{opcodedesc}{BINARY_POWER}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 178 | Implements \code{TOS = TOS1 ** TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 179 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 180 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 181 | \begin{opcodedesc}{BINARY_MULTIPLY}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 182 | Implements \code{TOS = TOS1 * TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 183 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 184 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 185 | \begin{opcodedesc}{BINARY_DIVIDE}{} |
Guido van Rossum | e3fdc97 | 2002-06-12 15:33:08 +0000 | [diff] [blame] | 186 | Implements \code{TOS = TOS1 / TOS} when |
| 187 | \code{from __future__ import division} is not in effect. |
| 188 | \end{opcodedesc} |
| 189 | |
| 190 | \begin{opcodedesc}{BINARY_FLOOR_DIVIDE}{} |
| 191 | Implements \code{TOS = TOS1 // TOS}. |
| 192 | \end{opcodedesc} |
| 193 | |
| 194 | \begin{opcodedesc}{BINARY_TRUE_DIVIDE}{} |
| 195 | Implements \code{TOS = TOS1 / TOS} when |
| 196 | \code{from __future__ import division} is in effect. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 197 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 198 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 199 | \begin{opcodedesc}{BINARY_MODULO}{} |
Fred Drake | 9e759df | 2000-06-15 18:44:30 +0000 | [diff] [blame] | 200 | Implements \code{TOS = TOS1 \%{} TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 201 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 202 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 203 | \begin{opcodedesc}{BINARY_ADD}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 204 | Implements \code{TOS = TOS1 + TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 205 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 206 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 207 | \begin{opcodedesc}{BINARY_SUBTRACT}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 208 | Implements \code{TOS = TOS1 - TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 209 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 210 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 211 | \begin{opcodedesc}{BINARY_SUBSCR}{} |
Fred Drake | 1cf8749 | 1997-12-04 04:57:56 +0000 | [diff] [blame] | 212 | Implements \code{TOS = TOS1[TOS]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 213 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 214 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 215 | \begin{opcodedesc}{BINARY_LSHIFT}{} |
Fred Drake | 2c4f554 | 2000-10-10 22:00:03 +0000 | [diff] [blame] | 216 | Implements \code{TOS = TOS1 <\code{}< TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 217 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 218 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 219 | \begin{opcodedesc}{BINARY_RSHIFT}{} |
Fred Drake | 2c4f554 | 2000-10-10 22:00:03 +0000 | [diff] [blame] | 220 | Implements \code{TOS = TOS1 >\code{}> TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 221 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 222 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 223 | \begin{opcodedesc}{BINARY_AND}{} |
Fred Drake | 9e759df | 2000-06-15 18:44:30 +0000 | [diff] [blame] | 224 | Implements \code{TOS = TOS1 \&\ TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 225 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 226 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 227 | \begin{opcodedesc}{BINARY_XOR}{} |
Fred Drake | d7feffd | 1997-12-29 20:02:55 +0000 | [diff] [blame] | 228 | Implements \code{TOS = TOS1 \^\ TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 229 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 230 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 231 | \begin{opcodedesc}{BINARY_OR}{} |
Fred Drake | 9e759df | 2000-06-15 18:44:30 +0000 | [diff] [blame] | 232 | Implements \code{TOS = TOS1 | TOS}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 233 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 234 | |
Thomas Wouters | 12bba85 | 2000-08-24 20:06:04 +0000 | [diff] [blame] | 235 | In-place operations are like binary operations, in that they remove TOS and |
| 236 | TOS1, and push the result back on the stack, but the operation is done |
| 237 | in-place when TOS1 supports it, and the resulting TOS may be (but does not |
| 238 | have to be) the original TOS1. |
| 239 | |
| 240 | \begin{opcodedesc}{INPLACE_POWER}{} |
| 241 | Implements in-place \code{TOS = TOS1 ** TOS}. |
| 242 | \end{opcodedesc} |
| 243 | |
| 244 | \begin{opcodedesc}{INPLACE_MULTIPLY}{} |
| 245 | Implements in-place \code{TOS = TOS1 * TOS}. |
| 246 | \end{opcodedesc} |
| 247 | |
| 248 | \begin{opcodedesc}{INPLACE_DIVIDE}{} |
Guido van Rossum | e3fdc97 | 2002-06-12 15:33:08 +0000 | [diff] [blame] | 249 | Implements in-place \code{TOS = TOS1 / TOS} when |
| 250 | \code{from __future__ import division} is not in effect. |
| 251 | \end{opcodedesc} |
| 252 | |
| 253 | \begin{opcodedesc}{INPLACE_FLOOR_DIVIDE}{} |
| 254 | Implements in-place \code{TOS = TOS1 // TOS}. |
| 255 | \end{opcodedesc} |
| 256 | |
| 257 | \begin{opcodedesc}{INPLACE_TRUE_DIVIDE}{} |
| 258 | Implements in-place \code{TOS = TOS1 / TOS} when |
| 259 | \code{from __future__ import division} is in effect. |
Thomas Wouters | 12bba85 | 2000-08-24 20:06:04 +0000 | [diff] [blame] | 260 | \end{opcodedesc} |
| 261 | |
| 262 | \begin{opcodedesc}{INPLACE_MODULO}{} |
| 263 | Implements in-place \code{TOS = TOS1 \%{} TOS}. |
| 264 | \end{opcodedesc} |
| 265 | |
| 266 | \begin{opcodedesc}{INPLACE_ADD}{} |
| 267 | Implements in-place \code{TOS = TOS1 + TOS}. |
| 268 | \end{opcodedesc} |
| 269 | |
| 270 | \begin{opcodedesc}{INPLACE_SUBTRACT}{} |
| 271 | Implements in-place \code{TOS = TOS1 - TOS}. |
| 272 | \end{opcodedesc} |
| 273 | |
| 274 | \begin{opcodedesc}{INPLACE_LSHIFT}{} |
Fred Drake | 2c4f554 | 2000-10-10 22:00:03 +0000 | [diff] [blame] | 275 | Implements in-place \code{TOS = TOS1 <\code{}< TOS}. |
Thomas Wouters | 12bba85 | 2000-08-24 20:06:04 +0000 | [diff] [blame] | 276 | \end{opcodedesc} |
| 277 | |
| 278 | \begin{opcodedesc}{INPLACE_RSHIFT}{} |
Fred Drake | 2c4f554 | 2000-10-10 22:00:03 +0000 | [diff] [blame] | 279 | Implements in-place \code{TOS = TOS1 >\code{}> TOS}. |
Thomas Wouters | 12bba85 | 2000-08-24 20:06:04 +0000 | [diff] [blame] | 280 | \end{opcodedesc} |
| 281 | |
| 282 | \begin{opcodedesc}{INPLACE_AND}{} |
| 283 | Implements in-place \code{TOS = TOS1 \&\ TOS}. |
| 284 | \end{opcodedesc} |
| 285 | |
| 286 | \begin{opcodedesc}{INPLACE_XOR}{} |
| 287 | Implements in-place \code{TOS = TOS1 \^\ TOS}. |
| 288 | \end{opcodedesc} |
| 289 | |
| 290 | \begin{opcodedesc}{INPLACE_OR}{} |
| 291 | Implements in-place \code{TOS = TOS1 | TOS}. |
| 292 | \end{opcodedesc} |
| 293 | |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 294 | The slice opcodes take up to three parameters. |
| 295 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 296 | \begin{opcodedesc}{SLICE+0}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 297 | Implements \code{TOS = TOS[:]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 298 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 299 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 300 | \begin{opcodedesc}{SLICE+1}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 301 | Implements \code{TOS = TOS1[TOS:]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 302 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 303 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 304 | \begin{opcodedesc}{SLICE+2}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 305 | Implements \code{TOS = TOS1[:TOS1]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 306 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 307 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 308 | \begin{opcodedesc}{SLICE+3}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 309 | Implements \code{TOS = TOS2[TOS1:TOS]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 310 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 311 | |
| 312 | Slice assignment needs even an additional parameter. As any statement, |
| 313 | they put nothing on the stack. |
| 314 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 315 | \begin{opcodedesc}{STORE_SLICE+0}{} |
Fred Drake | 7381e28 | 1997-12-04 04:51:12 +0000 | [diff] [blame] | 316 | Implements \code{TOS[:] = TOS1}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 317 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 318 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 319 | \begin{opcodedesc}{STORE_SLICE+1}{} |
Fred Drake | 7381e28 | 1997-12-04 04:51:12 +0000 | [diff] [blame] | 320 | Implements \code{TOS1[TOS:] = TOS2}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 321 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 322 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 323 | \begin{opcodedesc}{STORE_SLICE+2}{} |
Fred Drake | 7381e28 | 1997-12-04 04:51:12 +0000 | [diff] [blame] | 324 | Implements \code{TOS1[:TOS] = TOS2}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 325 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 326 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 327 | \begin{opcodedesc}{STORE_SLICE+3}{} |
Fred Drake | 7381e28 | 1997-12-04 04:51:12 +0000 | [diff] [blame] | 328 | Implements \code{TOS2[TOS1:TOS] = TOS3}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 329 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 330 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 331 | \begin{opcodedesc}{DELETE_SLICE+0}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 332 | Implements \code{del TOS[:]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 333 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 334 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 335 | \begin{opcodedesc}{DELETE_SLICE+1}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 336 | Implements \code{del TOS1[TOS:]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 337 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 338 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 339 | \begin{opcodedesc}{DELETE_SLICE+2}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 340 | Implements \code{del TOS1[:TOS]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 341 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 342 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 343 | \begin{opcodedesc}{DELETE_SLICE+3}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 344 | Implements \code{del TOS2[TOS1:TOS]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 345 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 346 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 347 | \begin{opcodedesc}{STORE_SUBSCR}{} |
Fred Drake | 7381e28 | 1997-12-04 04:51:12 +0000 | [diff] [blame] | 348 | Implements \code{TOS1[TOS] = TOS2}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 349 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 350 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 351 | \begin{opcodedesc}{DELETE_SUBSCR}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 352 | Implements \code{del TOS1[TOS]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 353 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 354 | |
Guido van Rossum | e3fdc97 | 2002-06-12 15:33:08 +0000 | [diff] [blame] | 355 | Miscellaneous opcodes. |
| 356 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 357 | \begin{opcodedesc}{PRINT_EXPR}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 358 | Implements the expression statement for the interactive mode. TOS is |
| 359 | removed from the stack and printed. In non-interactive mode, an |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 360 | expression statement is terminated with \code{POP_STACK}. |
| 361 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 362 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 363 | \begin{opcodedesc}{PRINT_ITEM}{} |
Barry Warsaw | 9087688 | 2000-08-21 17:19:00 +0000 | [diff] [blame] | 364 | Prints TOS to the file-like object bound to \code{sys.stdout}. There |
| 365 | is one such instruction for each item in the \keyword{print} statement. |
| 366 | \end{opcodedesc} |
| 367 | |
| 368 | \begin{opcodedesc}{PRINT_ITEM_TO}{} |
| 369 | Like \code{PRINT_ITEM}, but prints the item second from TOS to the |
| 370 | file-like object at TOS. This is used by the extended print statement. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 371 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 372 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 373 | \begin{opcodedesc}{PRINT_NEWLINE}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 374 | Prints a new line on \code{sys.stdout}. This is generated as the |
Fred Drake | 304faf9 | 2000-08-18 02:15:55 +0000 | [diff] [blame] | 375 | last operation of a \keyword{print} statement, unless the statement |
| 376 | ends with a comma. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 377 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 378 | |
Barry Warsaw | 9087688 | 2000-08-21 17:19:00 +0000 | [diff] [blame] | 379 | \begin{opcodedesc}{PRINT_NEWLINE_TO}{} |
| 380 | Like \code{PRINT_NEWLINE}, but prints the new line on the file-like |
| 381 | object on the TOS. This is used by the extended print statement. |
| 382 | \end{opcodedesc} |
| 383 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 384 | \begin{opcodedesc}{BREAK_LOOP}{} |
Fred Drake | 304faf9 | 2000-08-18 02:15:55 +0000 | [diff] [blame] | 385 | Terminates a loop due to a \keyword{break} statement. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 386 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 387 | |
Guido van Rossum | e3fdc97 | 2002-06-12 15:33:08 +0000 | [diff] [blame] | 388 | \begin{opcodedesc}{CONTINUE_LOOP}{target} |
| 389 | Continues a loop due to a \keyword{continue} statement. \var{target} |
| 390 | is the address to jump to (which should be a \code{FOR_ITER} |
| 391 | instruction). |
| 392 | \end{opcodedesc} |
| 393 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 394 | \begin{opcodedesc}{LOAD_LOCALS}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 395 | Pushes a reference to the locals of the current scope on the stack. |
| 396 | This is used in the code for a class definition: After the class body |
| 397 | is evaluated, the locals are passed to the class definition. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 398 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 399 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 400 | \begin{opcodedesc}{RETURN_VALUE}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 401 | Returns with TOS to the caller of the function. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 402 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 403 | |
Guido van Rossum | e3fdc97 | 2002-06-12 15:33:08 +0000 | [diff] [blame] | 404 | \begin{opcodedesc}{YIELD_VALUE}{} |
| 405 | Pops \code{TOS} and yields it from a generator. |
| 406 | \end{opcodedesc} |
| 407 | |
Thomas Wouters | 5215225 | 2000-08-17 22:55:00 +0000 | [diff] [blame] | 408 | \begin{opcodedesc}{IMPORT_STAR}{} |
Fred Drake | 304faf9 | 2000-08-18 02:15:55 +0000 | [diff] [blame] | 409 | Loads all symbols not starting with \character{_} directly from the module TOS |
Thomas Wouters | 5215225 | 2000-08-17 22:55:00 +0000 | [diff] [blame] | 410 | to the local namespace. The module is popped after loading all names. |
Fred Drake | 304faf9 | 2000-08-18 02:15:55 +0000 | [diff] [blame] | 411 | This opcode implements \code{from module import *}. |
| 412 | \end{opcodedesc} |
Thomas Wouters | 5215225 | 2000-08-17 22:55:00 +0000 | [diff] [blame] | 413 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 414 | \begin{opcodedesc}{EXEC_STMT}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 415 | Implements \code{exec TOS2,TOS1,TOS}. The compiler fills |
Fred Drake | 304faf9 | 2000-08-18 02:15:55 +0000 | [diff] [blame] | 416 | missing optional parameters with \code{None}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 417 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 418 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 419 | \begin{opcodedesc}{POP_BLOCK}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 420 | Removes one block from the block stack. Per frame, there is a |
| 421 | stack of blocks, denoting nested loops, try statements, and such. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 422 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 423 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 424 | \begin{opcodedesc}{END_FINALLY}{} |
Fred Drake | 304faf9 | 2000-08-18 02:15:55 +0000 | [diff] [blame] | 425 | Terminates a \keyword{finally} clause. The interpreter recalls |
| 426 | whether the exception has to be re-raised, or whether the function |
| 427 | returns, and continues with the outer-next block. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 428 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 429 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 430 | \begin{opcodedesc}{BUILD_CLASS}{} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 431 | Creates a new class object. TOS is the methods dictionary, TOS1 |
| 432 | the tuple of the names of the base classes, and TOS2 the class name. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 433 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 434 | |
| 435 | All of the following opcodes expect arguments. An argument is two |
| 436 | bytes, with the more significant byte last. |
| 437 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 438 | \begin{opcodedesc}{STORE_NAME}{namei} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 439 | Implements \code{name = TOS}. \var{namei} is the index of \var{name} |
Fred Drake | dff21a6 | 1998-04-03 05:42:10 +0000 | [diff] [blame] | 440 | in the attribute \member{co_names} of the code object. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 441 | The compiler tries to use \code{STORE_LOCAL} or \code{STORE_GLOBAL} |
| 442 | if possible. |
| 443 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 444 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 445 | \begin{opcodedesc}{DELETE_NAME}{namei} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 446 | Implements \code{del name}, where \var{namei} is the index into |
Fred Drake | dff21a6 | 1998-04-03 05:42:10 +0000 | [diff] [blame] | 447 | \member{co_names} attribute of the code object. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 448 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 449 | |
Thomas Wouters | 0be5aab | 2000-08-11 22:15:52 +0000 | [diff] [blame] | 450 | \begin{opcodedesc}{UNPACK_SEQUENCE}{count} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 451 | Unpacks TOS into \var{count} individual values, which are put onto |
| 452 | the stack right-to-left. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 453 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 454 | |
Thomas Wouters | 0be5aab | 2000-08-11 22:15:52 +0000 | [diff] [blame] | 455 | %\begin{opcodedesc}{UNPACK_LIST}{count} |
| 456 | %This opcode is obsolete. |
| 457 | %\end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 458 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 459 | %\begin{opcodedesc}{UNPACK_ARG}{count} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 460 | %This opcode is obsolete. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 461 | %\end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 462 | |
Thomas Wouters | 12bba85 | 2000-08-24 20:06:04 +0000 | [diff] [blame] | 463 | \begin{opcodedesc}{DUP_TOPX}{count} |
| 464 | Duplicate \var{count} items, keeping them in the same order. Due to |
| 465 | implementation limits, \var{count} should be between 1 and 5 inclusive. |
| 466 | \end{opcodedesc} |
| 467 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 468 | \begin{opcodedesc}{STORE_ATTR}{namei} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 469 | Implements \code{TOS.name = TOS1}, where \var{namei} is the index |
Fred Drake | dff21a6 | 1998-04-03 05:42:10 +0000 | [diff] [blame] | 470 | of name in \member{co_names}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 471 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 472 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 473 | \begin{opcodedesc}{DELETE_ATTR}{namei} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 474 | Implements \code{del TOS.name}, using \var{namei} as index into |
Fred Drake | dff21a6 | 1998-04-03 05:42:10 +0000 | [diff] [blame] | 475 | \member{co_names}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 476 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 477 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 478 | \begin{opcodedesc}{STORE_GLOBAL}{namei} |
| 479 | Works as \code{STORE_NAME}, but stores the name as a global. |
| 480 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 481 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 482 | \begin{opcodedesc}{DELETE_GLOBAL}{namei} |
| 483 | Works as \code{DELETE_NAME}, but deletes a global name. |
| 484 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 485 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 486 | %\begin{opcodedesc}{UNPACK_VARARG}{argc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 487 | %This opcode is obsolete. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 488 | %\end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 489 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 490 | \begin{opcodedesc}{LOAD_CONST}{consti} |
Fred Drake | dff21a6 | 1998-04-03 05:42:10 +0000 | [diff] [blame] | 491 | Pushes \samp{co_consts[\var{consti}]} onto the stack. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 492 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 493 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 494 | \begin{opcodedesc}{LOAD_NAME}{namei} |
Fred Drake | dff21a6 | 1998-04-03 05:42:10 +0000 | [diff] [blame] | 495 | Pushes the value associated with \samp{co_names[\var{namei}]} onto the stack. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 496 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 497 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 498 | \begin{opcodedesc}{BUILD_TUPLE}{count} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 499 | Creates a tuple consuming \var{count} items from the stack, and pushes |
| 500 | the resulting tuple onto the stack. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 501 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 502 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 503 | \begin{opcodedesc}{BUILD_LIST}{count} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 504 | Works as \code{BUILD_TUPLE}, but creates a list. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 505 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 506 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 507 | \begin{opcodedesc}{BUILD_MAP}{zero} |
Fred Drake | 304faf9 | 2000-08-18 02:15:55 +0000 | [diff] [blame] | 508 | Pushes a new empty dictionary object onto the stack. The argument is |
| 509 | ignored and set to zero by the compiler. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 510 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 511 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 512 | \begin{opcodedesc}{LOAD_ATTR}{namei} |
Fred Drake | 304faf9 | 2000-08-18 02:15:55 +0000 | [diff] [blame] | 513 | Replaces TOS with \code{getattr(TOS, co_names[\var{namei}]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 514 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 515 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 516 | \begin{opcodedesc}{COMPARE_OP}{opname} |
Fred Drake | 6c81e2a | 2001-10-01 17:04:10 +0000 | [diff] [blame] | 517 | Performs a Boolean operation. The operation name can be found |
Fred Drake | dd1f6cc | 1998-02-12 03:32:18 +0000 | [diff] [blame] | 518 | in \code{cmp_op[\var{opname}]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 519 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 520 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 521 | \begin{opcodedesc}{IMPORT_NAME}{namei} |
Fred Drake | dd1f6cc | 1998-02-12 03:32:18 +0000 | [diff] [blame] | 522 | Imports the module \code{co_names[\var{namei}]}. The module object is |
Fred Drake | 1349437 | 2000-09-12 16:23:48 +0000 | [diff] [blame] | 523 | pushed onto the stack. The current namespace is not affected: for a |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 524 | proper import statement, a subsequent \code{STORE_FAST} instruction |
Fred Drake | 1349437 | 2000-09-12 16:23:48 +0000 | [diff] [blame] | 525 | modifies the namespace. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 526 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 527 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 528 | \begin{opcodedesc}{IMPORT_FROM}{namei} |
Thomas Wouters | 5215225 | 2000-08-17 22:55:00 +0000 | [diff] [blame] | 529 | Loads the attribute \code{co_names[\var{namei}]} from the module found in |
| 530 | TOS. The resulting object is pushed onto the stack, to be subsequently |
| 531 | stored by a \code{STORE_FAST} instruction. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 532 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 533 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 534 | \begin{opcodedesc}{JUMP_FORWARD}{delta} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 535 | Increments byte code counter by \var{delta}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 536 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 537 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 538 | \begin{opcodedesc}{JUMP_IF_TRUE}{delta} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 539 | If TOS is true, increment the byte code counter by \var{delta}. TOS is |
| 540 | left on the stack. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 541 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 542 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 543 | \begin{opcodedesc}{JUMP_IF_FALSE}{delta} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 544 | If TOS is false, increment the byte code counter by \var{delta}. TOS |
| 545 | is not changed. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 546 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 547 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 548 | \begin{opcodedesc}{JUMP_ABSOLUTE}{target} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 549 | Set byte code counter to \var{target}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 550 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 551 | |
Guido van Rossum | e3fdc97 | 2002-06-12 15:33:08 +0000 | [diff] [blame] | 552 | \begin{opcodedesc}{FOR_ITER}{delta} |
| 553 | \code{TOS} is an iterator. Call its \method{next()} method. If this |
| 554 | yields a new value, push it on the stack (leaving the iterator below |
| 555 | it). If the iterator indicates it is exhausted \code{TOS} is |
| 556 | popped, and the byte code counter is incremented by \var{delta}. |
| 557 | \end{opcodedesc} |
| 558 | |
Guido van Rossum | fea59e7 | 2002-06-13 17:59:51 +0000 | [diff] [blame] | 559 | %\begin{opcodedesc}{FOR_LOOP}{delta} |
| 560 | %This opcode is obsolete. |
| 561 | %\end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 562 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 563 | %\begin{opcodedesc}{LOAD_LOCAL}{namei} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 564 | %This opcode is obsolete. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 565 | %\end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 566 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 567 | \begin{opcodedesc}{LOAD_GLOBAL}{namei} |
Fred Drake | dd1f6cc | 1998-02-12 03:32:18 +0000 | [diff] [blame] | 568 | Loads the global named \code{co_names[\var{namei}]} onto the stack. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 569 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 570 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 571 | %\begin{opcodedesc}{SET_FUNC_ARGS}{argc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 572 | %This opcode is obsolete. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 573 | %\end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 574 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 575 | \begin{opcodedesc}{SETUP_LOOP}{delta} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 576 | Pushes a block for a loop onto the block stack. The block spans |
| 577 | from the current instruction with a size of \var{delta} bytes. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 578 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 579 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 580 | \begin{opcodedesc}{SETUP_EXCEPT}{delta} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 581 | Pushes a try block from a try-except clause onto the block stack. |
| 582 | \var{delta} points to the first except block. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 583 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 584 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 585 | \begin{opcodedesc}{SETUP_FINALLY}{delta} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 586 | Pushes a try block from a try-except clause onto the block stack. |
| 587 | \var{delta} points to the finally block. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 588 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 589 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 590 | \begin{opcodedesc}{LOAD_FAST}{var_num} |
Fred Drake | dd1f6cc | 1998-02-12 03:32:18 +0000 | [diff] [blame] | 591 | Pushes a reference to the local \code{co_varnames[\var{var_num}]} onto |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 592 | the stack. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 593 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 594 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 595 | \begin{opcodedesc}{STORE_FAST}{var_num} |
Fred Drake | dd1f6cc | 1998-02-12 03:32:18 +0000 | [diff] [blame] | 596 | Stores TOS into the local \code{co_varnames[\var{var_num}]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 597 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 598 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 599 | \begin{opcodedesc}{DELETE_FAST}{var_num} |
Fred Drake | dd1f6cc | 1998-02-12 03:32:18 +0000 | [diff] [blame] | 600 | Deletes local \code{co_varnames[\var{var_num}]}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 601 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 602 | |
Jeremy Hylton | aa90adc | 2001-03-23 17:23:50 +0000 | [diff] [blame] | 603 | \begin{opcodedesc}{LOAD_CLOSURE}{i} |
| 604 | Pushes a reference to the cell contained in slot \var{i} of the |
| 605 | cell and free variable storage. The name of the variable is |
| 606 | \code{co_cellvars[\var{i}]} if \var{i} is less than the length of |
| 607 | \var{co_cellvars}. Otherwise it is |
| 608 | \code{co_freevars[\var{i} - len(co_cellvars)]}. |
| 609 | \end{opcodedesc} |
| 610 | |
| 611 | \begin{opcodedesc}{LOAD_DEREF}{i} |
| 612 | Loads the cell contained in slot \var{i} of the cell and free variable |
| 613 | storage. Pushes a reference to the object the cell contains on the |
| 614 | stack. |
| 615 | \end{opcodedesc} |
| 616 | |
| 617 | \begin{opcodedesc}{STORE_DEREF}{i} |
| 618 | Stores TOS into the cell contained in slot \var{i} of the cell and |
| 619 | free variable storage. |
| 620 | \end{opcodedesc} |
| 621 | |
Fred Drake | 338da93 | 1999-05-17 20:57:07 +0000 | [diff] [blame] | 622 | \begin{opcodedesc}{SET_LINENO}{lineno} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 623 | Sets the current line number to \var{lineno}. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 624 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 625 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 626 | \begin{opcodedesc}{RAISE_VARARGS}{argc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 627 | Raises an exception. \var{argc} indicates the number of parameters |
Fred Drake | 304faf9 | 2000-08-18 02:15:55 +0000 | [diff] [blame] | 628 | to the raise statement, ranging from 0 to 3. The handler will find |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 629 | the traceback as TOS2, the parameter as TOS1, and the exception |
| 630 | as TOS. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 631 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 632 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 633 | \begin{opcodedesc}{CALL_FUNCTION}{argc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 634 | Calls a function. The low byte of \var{argc} indicates the number of |
| 635 | positional parameters, the high byte the number of keyword parameters. |
| 636 | On the stack, the opcode finds the keyword parameters first. For each |
| 637 | keyword argument, the value is on top of the key. Below the keyword |
| 638 | parameters, the positional parameters are on the stack, with the |
| 639 | right-most parameter on top. Below the parameters, the function object |
| 640 | to call is on the stack. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 641 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 642 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 643 | \begin{opcodedesc}{MAKE_FUNCTION}{argc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 644 | Pushes a new function object on the stack. TOS is the code associated |
| 645 | with the function. The function object is defined to have \var{argc} |
| 646 | default parameters, which are found below TOS. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 647 | \end{opcodedesc} |
Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 648 | |
Jeremy Hylton | aa90adc | 2001-03-23 17:23:50 +0000 | [diff] [blame] | 649 | \begin{opcodedesc}{MAKE_CLOSURE}{argc} |
| 650 | Creates a new function object, sets its \var{func_closure} slot, and |
| 651 | pushes it on the stack. TOS is the code associated with the function. |
| 652 | If the code object has N free variables, the next N items on the stack |
| 653 | are the cells for these variables. The function also has \var{argc} |
| 654 | default parameters, where are found before the cells. |
| 655 | \end{opcodedesc} |
| 656 | |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 657 | \begin{opcodedesc}{BUILD_SLICE}{argc} |
Guido van Rossum | da62398 | 1998-02-12 03:53:02 +0000 | [diff] [blame] | 658 | Pushes a slice object on the stack. \var{argc} must be 2 or 3. If it |
| 659 | is 2, \code{slice(TOS1, TOS)} is pushed; if it is 3, |
| 660 | \code{slice(TOS2, TOS1, TOS)} is pushed. |
Fred Drake | 304faf9 | 2000-08-18 02:15:55 +0000 | [diff] [blame] | 661 | See the \code{slice()}\bifuncindex{slice} built-in function for more |
| 662 | information. |
Fred Drake | 456035f | 1997-12-03 04:06:57 +0000 | [diff] [blame] | 663 | \end{opcodedesc} |
Fred Drake | 25699f9 | 2000-08-17 22:19:26 +0000 | [diff] [blame] | 664 | |
Fred Drake | 093272e | 2000-08-24 00:37:50 +0000 | [diff] [blame] | 665 | \begin{opcodedesc}{EXTENDED_ARG}{ext} |
| 666 | Prefixes any opcode which has an argument too big to fit into the |
| 667 | default two bytes. \var{ext} holds two additional bytes which, taken |
| 668 | together with the subsequent opcode's argument, comprise a four-byte |
Fred Drake | 4c3f797 | 2000-08-31 16:26:35 +0000 | [diff] [blame] | 669 | argument, \var{ext} being the two most-significant bytes. |
Fred Drake | 093272e | 2000-08-24 00:37:50 +0000 | [diff] [blame] | 670 | \end{opcodedesc} |
| 671 | |
Fred Drake | 25699f9 | 2000-08-17 22:19:26 +0000 | [diff] [blame] | 672 | \begin{opcodedesc}{CALL_FUNCTION_VAR}{argc} |
| 673 | Calls a function. \var{argc} is interpreted as in \code{CALL_FUNCTION}. |
| 674 | The top element on the stack contains the variable argument list, followed |
| 675 | by keyword and positional arguments. |
| 676 | \end{opcodedesc} |
| 677 | |
| 678 | \begin{opcodedesc}{CALL_FUNCTION_KW}{argc} |
| 679 | Calls a function. \var{argc} is interpreted as in \code{CALL_FUNCTION}. |
| 680 | The top element on the stack contains the keyword arguments dictionary, |
| 681 | followed by explicit keyword and positional arguments. |
| 682 | \end{opcodedesc} |
| 683 | |
| 684 | \begin{opcodedesc}{CALL_FUNCTION_VAR_KW}{argc} |
| 685 | Calls a function. \var{argc} is interpreted as in |
| 686 | \code{CALL_FUNCTION}. The top element on the stack contains the |
| 687 | keyword arguments dictionary, followed by the variable-arguments |
| 688 | tuple, followed by explicit keyword and positional arguments. |
| 689 | \end{opcodedesc} |