Minor nits.

Indent code sample to use 4-space indents.
This commit is contained in:
Fred Drake 1998-04-03 05:42:10 +00:00
parent 16a19c46a9
commit dff21a6b93
2 changed files with 30 additions and 34 deletions

View file

@ -1,22 +1,22 @@
\section{Standard Module \sectcode{dis}} \section{Standard Module \module{dis}}
\stmodindex{dis} \stmodindex{dis}
\label{module-dis} \label{module-dis}
The \code{dis} module supports the analysis of Python byte code by The \module{dis} module supports the analysis of Python byte code by
disassembling it. Since there is no Python assembler, this module disassembling it. Since there is no Python assembler, this module
defines the Python assembly language. The Python byte code which defines the Python assembly language. The Python byte code which
this module takes as an input is defined in the file this module takes as an input is defined in the file
\file{Include/opcode.h} and used by the compiler and the interpreter. \file{Include/opcode.h} and used by the compiler and the interpreter.
Example: Given the function myfunc Example: Given the function \function{myfunc}:
\begin{verbatim} \begin{verbatim}
def myfunc(alist): def myfunc(alist):
return len(alist) return len(alist)
\end{verbatim} \end{verbatim}
the following command can be used to get the disassembly of \code{myfunc()}: the following command can be used to get the disassembly of
\function{myfunc()}:
\begin{verbatim} \begin{verbatim}
>>> dis.dis(myfunc) >>> dis.dis(myfunc)
@ -31,9 +31,7 @@ the following command can be used to get the disassembly of \code{myfunc()}:
19 RETURN_VALUE 19 RETURN_VALUE
\end{verbatim} \end{verbatim}
The \code{dis} module defines the following functions: The \module{dis} module defines the following functions:
\setindexsubitem{(in module dis)}
\begin{funcdesc}{dis}{\optional{bytesource}} \begin{funcdesc}{dis}{\optional{bytesource}}
Disassemble the \var{bytesource} object. \var{bytesource} can denote Disassemble the \var{bytesource} object. \var{bytesource} can denote
@ -53,8 +51,8 @@ is indicated.
Disassembles a code object, indicating the last instruction if \var{lasti} Disassembles a code object, indicating the last instruction if \var{lasti}
was provided. The output is divided in the following columns: was provided. The output is divided in the following columns:
\begin{itemize} \begin{itemize}
\item the current instruction, indicated as \code{-->}, \item the current instruction, indicated as \samp{-->},
\item a labelled instruction, indicated with \code{>>}, \item a labelled instruction, indicated with \samp{>>},
\item the address of the instruction, \item the address of the instruction,
\item the operation code name, \item the operation code name,
\item operation parameters, and \item operation parameters, and
@ -324,14 +322,14 @@ bytes, with the more significant byte last.
\begin{opcodedesc}{STORE_NAME}{namei} \begin{opcodedesc}{STORE_NAME}{namei}
Implements \code{name = TOS}. \var{namei} is the index of \var{name} Implements \code{name = TOS}. \var{namei} is the index of \var{name}
in the attribute \code{co_names} of the code object. in the attribute \member{co_names} of the code object.
The compiler tries to use \code{STORE_LOCAL} or \code{STORE_GLOBAL} The compiler tries to use \code{STORE_LOCAL} or \code{STORE_GLOBAL}
if possible. if possible.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{DELETE_NAME}{namei} \begin{opcodedesc}{DELETE_NAME}{namei}
Implements \code{del name}, where \var{namei} is the index into Implements \code{del name}, where \var{namei} is the index into
\code{co_names} attribute of the code object. \member{co_names} attribute of the code object.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{UNPACK_TUPLE}{count} \begin{opcodedesc}{UNPACK_TUPLE}{count}
@ -349,12 +347,12 @@ Unpacks TOS into \var{count} individual values.
\begin{opcodedesc}{STORE_ATTR}{namei} \begin{opcodedesc}{STORE_ATTR}{namei}
Implements \code{TOS.name = TOS1}, where \var{namei} is the index Implements \code{TOS.name = TOS1}, where \var{namei} is the index
of name in \code{co_names}. of name in \member{co_names}.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{DELETE_ATTR}{namei} \begin{opcodedesc}{DELETE_ATTR}{namei}
Implements \code{del TOS.name}, using \var{namei} as index into Implements \code{del TOS.name}, using \var{namei} as index into
\code{co_names}. \member{co_names}.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{STORE_GLOBAL}{namei} \begin{opcodedesc}{STORE_GLOBAL}{namei}
@ -370,11 +368,11 @@ Works as \code{DELETE_NAME}, but deletes a global name.
%\end{opcodedesc} %\end{opcodedesc}
\begin{opcodedesc}{LOAD_CONST}{consti} \begin{opcodedesc}{LOAD_CONST}{consti}
Pushes \code{co_consts[\var{consti}]} onto the stack. Pushes \samp{co_consts[\var{consti}]} onto the stack.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{LOAD_NAME}{namei} \begin{opcodedesc}{LOAD_NAME}{namei}
Pushes the value associated with \code{co_names[\var{namei}]} onto the stack. Pushes the value associated with \samp{co_names[\var{namei}]} onto the stack.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{BUILD_TUPLE}{count} \begin{opcodedesc}{BUILD_TUPLE}{count}

View file

@ -1,22 +1,22 @@
\section{Standard Module \sectcode{dis}} \section{Standard Module \module{dis}}
\stmodindex{dis} \stmodindex{dis}
\label{module-dis} \label{module-dis}
The \code{dis} module supports the analysis of Python byte code by The \module{dis} module supports the analysis of Python byte code by
disassembling it. Since there is no Python assembler, this module disassembling it. Since there is no Python assembler, this module
defines the Python assembly language. The Python byte code which defines the Python assembly language. The Python byte code which
this module takes as an input is defined in the file this module takes as an input is defined in the file
\file{Include/opcode.h} and used by the compiler and the interpreter. \file{Include/opcode.h} and used by the compiler and the interpreter.
Example: Given the function myfunc Example: Given the function \function{myfunc}:
\begin{verbatim} \begin{verbatim}
def myfunc(alist): def myfunc(alist):
return len(alist) return len(alist)
\end{verbatim} \end{verbatim}
the following command can be used to get the disassembly of \code{myfunc()}: the following command can be used to get the disassembly of
\function{myfunc()}:
\begin{verbatim} \begin{verbatim}
>>> dis.dis(myfunc) >>> dis.dis(myfunc)
@ -31,9 +31,7 @@ the following command can be used to get the disassembly of \code{myfunc()}:
19 RETURN_VALUE 19 RETURN_VALUE
\end{verbatim} \end{verbatim}
The \code{dis} module defines the following functions: The \module{dis} module defines the following functions:
\setindexsubitem{(in module dis)}
\begin{funcdesc}{dis}{\optional{bytesource}} \begin{funcdesc}{dis}{\optional{bytesource}}
Disassemble the \var{bytesource} object. \var{bytesource} can denote Disassemble the \var{bytesource} object. \var{bytesource} can denote
@ -53,8 +51,8 @@ is indicated.
Disassembles a code object, indicating the last instruction if \var{lasti} Disassembles a code object, indicating the last instruction if \var{lasti}
was provided. The output is divided in the following columns: was provided. The output is divided in the following columns:
\begin{itemize} \begin{itemize}
\item the current instruction, indicated as \code{-->}, \item the current instruction, indicated as \samp{-->},
\item a labelled instruction, indicated with \code{>>}, \item a labelled instruction, indicated with \samp{>>},
\item the address of the instruction, \item the address of the instruction,
\item the operation code name, \item the operation code name,
\item operation parameters, and \item operation parameters, and
@ -324,14 +322,14 @@ bytes, with the more significant byte last.
\begin{opcodedesc}{STORE_NAME}{namei} \begin{opcodedesc}{STORE_NAME}{namei}
Implements \code{name = TOS}. \var{namei} is the index of \var{name} Implements \code{name = TOS}. \var{namei} is the index of \var{name}
in the attribute \code{co_names} of the code object. in the attribute \member{co_names} of the code object.
The compiler tries to use \code{STORE_LOCAL} or \code{STORE_GLOBAL} The compiler tries to use \code{STORE_LOCAL} or \code{STORE_GLOBAL}
if possible. if possible.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{DELETE_NAME}{namei} \begin{opcodedesc}{DELETE_NAME}{namei}
Implements \code{del name}, where \var{namei} is the index into Implements \code{del name}, where \var{namei} is the index into
\code{co_names} attribute of the code object. \member{co_names} attribute of the code object.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{UNPACK_TUPLE}{count} \begin{opcodedesc}{UNPACK_TUPLE}{count}
@ -349,12 +347,12 @@ Unpacks TOS into \var{count} individual values.
\begin{opcodedesc}{STORE_ATTR}{namei} \begin{opcodedesc}{STORE_ATTR}{namei}
Implements \code{TOS.name = TOS1}, where \var{namei} is the index Implements \code{TOS.name = TOS1}, where \var{namei} is the index
of name in \code{co_names}. of name in \member{co_names}.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{DELETE_ATTR}{namei} \begin{opcodedesc}{DELETE_ATTR}{namei}
Implements \code{del TOS.name}, using \var{namei} as index into Implements \code{del TOS.name}, using \var{namei} as index into
\code{co_names}. \member{co_names}.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{STORE_GLOBAL}{namei} \begin{opcodedesc}{STORE_GLOBAL}{namei}
@ -370,11 +368,11 @@ Works as \code{DELETE_NAME}, but deletes a global name.
%\end{opcodedesc} %\end{opcodedesc}
\begin{opcodedesc}{LOAD_CONST}{consti} \begin{opcodedesc}{LOAD_CONST}{consti}
Pushes \code{co_consts[\var{consti}]} onto the stack. Pushes \samp{co_consts[\var{consti}]} onto the stack.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{LOAD_NAME}{namei} \begin{opcodedesc}{LOAD_NAME}{namei}
Pushes the value associated with \code{co_names[\var{namei}]} onto the stack. Pushes the value associated with \samp{co_names[\var{namei}]} onto the stack.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{BUILD_TUPLE}{count} \begin{opcodedesc}{BUILD_TUPLE}{count}