mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
Backport 1.37: dis.dis() also supports modules, (also backport other changes back to 1.33 since these all apply to 2.2)
This commit is contained in:
@@ -38,7 +38,8 @@ The \module{dis} module defines the following functions and constants:
|
||||
|
||||
\begin{funcdesc}{dis}{\optional{bytesource}}
|
||||
Disassemble the \var{bytesource} object. \var{bytesource} can denote
|
||||
either a class, a method, a function, or a code object. For a class,
|
||||
either a module, a class, a method, a function, or a code object.
|
||||
For a module, it disassembles all functions. For a class,
|
||||
it disassembles all methods. For a single code sequence, it prints
|
||||
one line per byte code instruction. If no object is provided, it
|
||||
disassembles the last traceback.
|
||||
@@ -166,6 +167,10 @@ Implements \code{TOS = `TOS`}.
|
||||
Implements \code{TOS = \~{}TOS}.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{GET_ITER}{}
|
||||
Implements \code{TOS = iter(TOS)}.
|
||||
\end{opcodedesc}
|
||||
|
||||
Binary operations remove the top of the stack (TOS) and the second top-most
|
||||
stack item (TOS1) from the stack. They perform the operation, and put the
|
||||
result back on the stack.
|
||||
@@ -179,7 +184,17 @@ Implements \code{TOS = TOS1 * TOS}.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{BINARY_DIVIDE}{}
|
||||
Implements \code{TOS = TOS1 / TOS}.
|
||||
Implements \code{TOS = TOS1 / TOS} when
|
||||
\code{from __future__ import division} is not in effect.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{BINARY_FLOOR_DIVIDE}{}
|
||||
Implements \code{TOS = TOS1 // TOS}.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{BINARY_TRUE_DIVIDE}{}
|
||||
Implements \code{TOS = TOS1 / TOS} when
|
||||
\code{from __future__ import division} is in effect.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{BINARY_MODULO}{}
|
||||
@@ -232,7 +247,17 @@ Implements in-place \code{TOS = TOS1 * TOS}.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{INPLACE_DIVIDE}{}
|
||||
Implements in-place \code{TOS = TOS1 / TOS}.
|
||||
Implements in-place \code{TOS = TOS1 / TOS} when
|
||||
\code{from __future__ import division} is not in effect.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{INPLACE_FLOOR_DIVIDE}{}
|
||||
Implements in-place \code{TOS = TOS1 // TOS}.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{INPLACE_TRUE_DIVIDE}{}
|
||||
Implements in-place \code{TOS = TOS1 / TOS} when
|
||||
\code{from __future__ import division} is in effect.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{INPLACE_MODULO}{}
|
||||
@@ -328,6 +353,8 @@ Implements \code{TOS1[TOS] = TOS2}.
|
||||
Implements \code{del TOS1[TOS]}.
|
||||
\end{opcodedesc}
|
||||
|
||||
Miscellaneous opcodes.
|
||||
|
||||
\begin{opcodedesc}{PRINT_EXPR}{}
|
||||
Implements the expression statement for the interactive mode. TOS is
|
||||
removed from the stack and printed. In non-interactive mode, an
|
||||
@@ -359,6 +386,12 @@ object on the TOS. This is used by the extended print statement.
|
||||
Terminates a loop due to a \keyword{break} statement.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{CONTINUE_LOOP}{target}
|
||||
Continues a loop due to a \keyword{continue} statement. \var{target}
|
||||
is the address to jump to (which should be a \code{FOR_ITER}
|
||||
instruction).
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{LOAD_LOCALS}{}
|
||||
Pushes a reference to the locals of the current scope on the stack.
|
||||
This is used in the code for a class definition: After the class body
|
||||
@@ -369,6 +402,10 @@ is evaluated, the locals are passed to the class definition.
|
||||
Returns with TOS to the caller of the function.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{YIELD_VALUE}{}
|
||||
Pops \code{TOS} and yields it from a generator.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{IMPORT_STAR}{}
|
||||
Loads all symbols not starting with \character{_} directly from the module TOS
|
||||
to the local namespace. The module is popped after loading all names.
|
||||
@@ -513,13 +550,17 @@ is not changed.
|
||||
Set byte code counter to \var{target}.
|
||||
\end{opcodedesc}
|
||||
|
||||
\begin{opcodedesc}{FOR_LOOP}{delta}
|
||||
Iterate over a sequence. TOS is the current index, TOS1 the sequence.
|
||||
First, the next element is computed. If the sequence is exhausted,
|
||||
increment byte code counter by \var{delta}. Otherwise, push the
|
||||
sequence, the incremented counter, and the current item onto the stack.
|
||||
\begin{opcodedesc}{FOR_ITER}{delta}
|
||||
\code{TOS} is an iterator. Call its \method{next()} method. If this
|
||||
yields a new value, push it on the stack (leaving the iterator below
|
||||
it). If the iterator indicates it is exhausted \code{TOS} is
|
||||
popped, and the byte code counter is incremented by \var{delta}.
|
||||
\end{opcodedesc}
|
||||
|
||||
%\begin{opcodedesc}{FOR_LOOP}{delta}
|
||||
%This opcode is obsolete.
|
||||
%\end{opcodedesc}
|
||||
|
||||
%\begin{opcodedesc}{LOAD_LOCAL}{namei}
|
||||
%This opcode is obsolete.
|
||||
%\end{opcodedesc}
|
||||
|
||||
Reference in New Issue
Block a user