|
@@ -26,7 +26,7 @@
|
|
|
|
|
|
\def\racketEd{0}
|
|
|
\def\pythonEd{1}
|
|
|
-\def\edition{1}
|
|
|
+\def\edition{0}
|
|
|
|
|
|
% material that is specific to the Racket edition of the book
|
|
|
\newcommand{\racket}[1]{{\if\edition\racketEd{#1}\fi}}
|
|
@@ -14532,7 +14532,7 @@ new instructions as needed in this section. \index{subject}{x86}
|
|
|
\gray{\ASTXGlobalRacket} \\ \hline
|
|
|
\ASTXIndCallRacket \\
|
|
|
\begin{array}{lcl}
|
|
|
-\LangXIndCallM{} &::= & \PROGRAMDEFS{\itm{info}}{\LP\Def\ldots\RP}
|
|
|
+\LangXIndCallM{} &::= & \XPROGRAMDEFS{\itm{info}}{\LP\Def\ldots\RP}
|
|
|
\end{array}
|
|
|
\end{array}
|
|
|
\]
|
|
@@ -14823,6 +14823,16 @@ The conclusion of every function should do the following.
|
|
|
\item Return to the caller with the \code{retq} instruction.
|
|
|
\end{enumerate}
|
|
|
|
|
|
+The output of this pass is \LangXIndCallFlat{}, which differs from
|
|
|
+\LangXIndCall{} in that there is no longer an AST node for function
|
|
|
+definitions. Instead, a program is just an association list of basic
|
|
|
+blocks, as in \LangXGlobal{}. So we have the following grammar rule:
|
|
|
+\[
|
|
|
+\LangXIndCallFlatM{} ::= \XPROGRAM{\itm{info}}{\LP\LP\itm{label} \,\key{.}\, \Block \RP\ldots\RP}
|
|
|
+\]
|
|
|
+
|
|
|
+Figure~\ref{fig:Lfun-passes} gives an overview of the passes for
|
|
|
+compiling \LangFun{} to x86.
|
|
|
|
|
|
\begin{exercise}\normalfont\normalsize
|
|
|
Expand your compiler to handle \LangFun{} as outlined in this chapter.
|
|
@@ -14850,7 +14860,7 @@ previously created test programs.
|
|
|
\node (x86-2) at (3,-4) {\large \LangXIndCallVar{}};
|
|
|
\node (x86-3) at (6,-4) {\large \LangXIndCallVar{}};
|
|
|
\node (x86-4) at (9,-4) {\large \LangXIndCall{}};
|
|
|
-\node (x86-5) at (9,-6) {\large \LangXIndCall{}};
|
|
|
+\node (x86-5) at (9,-6) {\large \LangXIndCallFlat{}};
|
|
|
|
|
|
\node (x86-2-1) at (3,-6) {\large \LangXIndCallVar{}};
|
|
|
\node (x86-2-2) at (6,-6) {\large \LangXIndCallVar{}};
|
|
@@ -14889,8 +14899,6 @@ previously created test programs.
|
|
|
\label{fig:Lfun-passes}
|
|
|
\end{figure}
|
|
|
|
|
|
-Figure~\ref{fig:Lfun-passes} gives an overview of the passes for
|
|
|
-compiling \LangFun{} to x86.
|
|
|
|
|
|
\section{An Example Translation}
|
|
|
\label{sec:functions-example}
|