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