|
@@ -33,8 +33,8 @@
|
|
|
% would like a command for: \if\edition\racketEd\color{olive}
|
|
|
% and : \fi\color{black}
|
|
|
|
|
|
-\newcommand{\pythonColor}[0]{\color{purple}}
|
|
|
-%\newcommand{\pythonColor}[0]{}
|
|
|
+%\newcommand{\pythonColor}[0]{\color{purple}}
|
|
|
+\newcommand{\pythonColor}[0]{}
|
|
|
|
|
|
% material that is specific to the Python edition of the book
|
|
|
\newcommand{\python}[1]{{\if\edition\pythonEd\pythonColor #1\fi}}
|
|
@@ -13245,7 +13245,8 @@ section.
|
|
|
|
|
|
In this pass we generate x86 code for most of the new operations that
|
|
|
are needed to compile tuples, including \code{Allocate},
|
|
|
-\code{Collect}, and accessing tuple elements.
|
|
|
+\code{Collect}, accessing tuple elements, and the \code{Is}
|
|
|
+comparison.
|
|
|
%
|
|
|
We compile \code{GlobalValue} to \code{Global} because the latter has a
|
|
|
different concrete syntax (see figures~\ref{fig:x86-2-concrete} and
|
|
@@ -13400,6 +13401,28 @@ available for use by the register allocator.
|
|
|
\end{lstlisting}
|
|
|
\fi}
|
|
|
|
|
|
+{\if\edition\pythonEd\pythonColor
|
|
|
+The \code{is} comparison is compiled similarly to the other comparison
|
|
|
+operators, using the \code{cmpq} instruction. Because the value of a
|
|
|
+tuple is its address, we can translate \code{is} into a simple check
|
|
|
+for equality using the \code{e} condition code. \\
|
|
|
+\begin{tabular}{lll}
|
|
|
+\begin{minipage}{0.4\textwidth}
|
|
|
+$\CASSIGN{\Var}{ \LP\CIS{\Atm_1}{\Atm_2} \RP }$
|
|
|
+\end{minipage}
|
|
|
+&
|
|
|
+$\Rightarrow$
|
|
|
+&
|
|
|
+\begin{minipage}{0.4\textwidth}
|
|
|
+\begin{lstlisting}
|
|
|
+cmpq |$\Arg_2$|, |$\Arg_1$|
|
|
|
+sete %al
|
|
|
+movzbq %al, |$\Var$|
|
|
|
+\end{lstlisting}
|
|
|
+\end{minipage}
|
|
|
+\end{tabular}
|
|
|
+\fi}
|
|
|
+
|
|
|
|
|
|
\newcommand{\GrammarXGlobal}{
|
|
|
\begin{array}{lcl}
|