|
@@ -302,8 +302,7 @@ Lowell, and the University of Vermont.
|
|
|
|
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\begin{tikzpicture}[baseline=(current bounding box.center)]
|
|
\begin{tikzpicture}[baseline=(current bounding box.center)]
|
|
\node (C1) at (0,1.5) {\small Ch.~\ref{ch:trees-recur} Preliminaries};
|
|
\node (C1) at (0,1.5) {\small Ch.~\ref{ch:trees-recur} Preliminaries};
|
|
@@ -362,8 +361,7 @@ Lowell, and the University of Vermont.
|
|
\path[->] (C10) edge [above] node {} (C11);
|
|
\path[->] (C10) edge [above] node {} (C11);
|
|
\end{tikzpicture}
|
|
\end{tikzpicture}
|
|
\fi}
|
|
\fi}
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{Diagram of chapter dependencies.}
|
|
\caption{Diagram of chapter dependencies.}
|
|
\label{fig:chapter-dependences}
|
|
\label{fig:chapter-dependences}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -942,8 +940,7 @@ defined in Figure~\ref{fig:r0-concrete-syntax}.
|
|
|
|
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\[
|
|
\[
|
|
\begin{array}{l}
|
|
\begin{array}{l}
|
|
@@ -965,16 +962,13 @@ defined in Figure~\ref{fig:r0-concrete-syntax}.
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
\fi}
|
|
\fi}
|
|
-
|
|
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The concrete syntax of \LangInt{}.}
|
|
\caption{The concrete syntax of \LangInt{}.}
|
|
\label{fig:r0-concrete-syntax}
|
|
\label{fig:r0-concrete-syntax}
|
|
\end{figure}
|
|
\end{figure}
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\[
|
|
\[
|
|
\begin{array}{l}
|
|
\begin{array}{l}
|
|
@@ -996,8 +990,7 @@ defined in Figure~\ref{fig:r0-concrete-syntax}.
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
\fi}
|
|
\fi}
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The abstract syntax of \LangInt{}.}
|
|
\caption{The abstract syntax of \LangInt{}.}
|
|
\label{fig:r0-syntax}
|
|
\label{fig:r0-syntax}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -1197,8 +1190,9 @@ two examples at the bottom of the figure, the first is in
|
|
\LangInt{} and the second is not.
|
|
\LangInt{} and the second is not.
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{lstlisting}
|
|
(define (is_exp ast)
|
|
(define (is_exp ast)
|
|
(match ast
|
|
(match ast
|
|
[(Int n) #t]
|
|
[(Int n) #t]
|
|
@@ -1222,7 +1216,7 @@ two examples at the bottom of the figure, the first is in
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
{\if\edition\pythonEd
|
|
{\if\edition\pythonEd
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{lstlisting}
|
|
def is_exp(e):
|
|
def is_exp(e):
|
|
match e:
|
|
match e:
|
|
case Constant(n):
|
|
case Constant(n):
|
|
@@ -1259,7 +1253,7 @@ print(is_Lint(Module([Expr(BinOp(read, Sub(),
|
|
UnaryOp(Add(), Constant(8))))])))
|
|
UnaryOp(Add(), Constant(8))))])))
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
-
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{Example of recursive functions for \LangInt{}. These functions
|
|
\caption{Example of recursive functions for \LangInt{}. These functions
|
|
recognize whether an AST is in \LangInt{}.}
|
|
recognize whether an AST is in \LangInt{}.}
|
|
\label{fig:exp-predicate}
|
|
\label{fig:exp-predicate}
|
|
@@ -1329,8 +1323,9 @@ Figure~\ref{fig:interp_Lint}.
|
|
non-terminal.}
|
|
non-terminal.}
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{lstlisting}
|
|
(define (interp_exp e)
|
|
(define (interp_exp e)
|
|
(match e
|
|
(match e
|
|
[(Int n) n]
|
|
[(Int n) n]
|
|
@@ -1356,7 +1351,7 @@ Figure~\ref{fig:interp_Lint}.
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
{\if\edition\pythonEd
|
|
{\if\edition\pythonEd
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{lstlisting}
|
|
def interp_exp(e):
|
|
def interp_exp(e):
|
|
match e:
|
|
match e:
|
|
case BinOp(left, Add(), right):
|
|
case BinOp(left, Add(), right):
|
|
@@ -1386,6 +1381,8 @@ def interp_Lint(p):
|
|
interp_stmt(s)
|
|
interp_stmt(s)
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
|
|
+\end{tcolorbox}
|
|
|
|
+
|
|
\caption{Interpreter for the \LangInt{} language.}
|
|
\caption{Interpreter for the \LangInt{} language.}
|
|
\label{fig:interp_Lint}
|
|
\label{fig:interp_Lint}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -1564,8 +1561,9 @@ arithmetic. Otherwise, they create an AST node for the arithmetic
|
|
operation.
|
|
operation.
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
-{\if\edition\racketEd
|
|
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+ \begin{tcolorbox}[colback=white]
|
|
|
|
+ {\if\edition\racketEd
|
|
|
|
+\begin{lstlisting}
|
|
(define (pe_neg r)
|
|
(define (pe_neg r)
|
|
(match r
|
|
(match r
|
|
[(Int n) (Int (fx- 0 n))]
|
|
[(Int n) (Int (fx- 0 n))]
|
|
@@ -1595,7 +1593,7 @@ operation.
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
{\if\edition\pythonEd
|
|
{\if\edition\pythonEd
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{lstlisting}
|
|
def pe_neg(r):
|
|
def pe_neg(r):
|
|
match r:
|
|
match r:
|
|
case Constant(n):
|
|
case Constant(n):
|
|
@@ -1644,6 +1642,7 @@ def pe_P_int(p):
|
|
return Module(new_body)
|
|
return Module(new_body)
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
|
|
+\end{tcolorbox}
|
|
\caption{A partial evaluator for \LangInt{}.}
|
|
\caption{A partial evaluator for \LangInt{}.}
|
|
\label{fig:pe-arith}
|
|
\label{fig:pe-arith}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -1751,8 +1750,7 @@ exhibit several compilation techniques.
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
\centering
|
|
\centering
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\[
|
|
\[
|
|
\begin{array}{l}
|
|
\begin{array}{l}
|
|
@@ -1775,16 +1773,14 @@ exhibit several compilation techniques.
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
\fi}
|
|
\fi}
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The concrete syntax of \LangVar{}.}
|
|
\caption{The concrete syntax of \LangVar{}.}
|
|
\label{fig:Lvar-concrete-syntax}
|
|
\label{fig:Lvar-concrete-syntax}
|
|
\end{figure}
|
|
\end{figure}
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
\centering
|
|
\centering
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\[
|
|
\[
|
|
\begin{array}{l}
|
|
\begin{array}{l}
|
|
@@ -1807,8 +1803,7 @@ exhibit several compilation techniques.
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
\fi}
|
|
\fi}
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The abstract syntax of \LangVar{}.}
|
|
\caption{The abstract syntax of \LangVar{}.}
|
|
\label{fig:Lvar-syntax}
|
|
\label{fig:Lvar-syntax}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -2159,8 +2154,9 @@ variable, it looks up the corresponding value in the dictionary.
|
|
with the variable in the environment.}
|
|
with the variable in the environment.}
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{lstlisting}
|
|
(define interp-Lint-class
|
|
(define interp-Lint-class
|
|
(class object%
|
|
(class object%
|
|
(super-new)
|
|
(super-new)
|
|
@@ -2185,7 +2181,7 @@ variable, it looks up the corresponding value in the dictionary.
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
{\if\edition\pythonEd
|
|
{\if\edition\pythonEd
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{lstlisting}
|
|
class InterpLint:
|
|
class InterpLint:
|
|
def interp_exp(self, e, env):
|
|
def interp_exp(self, e, env):
|
|
match e:
|
|
match e:
|
|
@@ -2220,13 +2216,15 @@ def interp_Lint(p):
|
|
return InterpLint().interp(p)
|
|
return InterpLint().interp(p)
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
|
|
+\end{tcolorbox}
|
|
\caption{Interpreter for \LangInt{} as a class.}
|
|
\caption{Interpreter for \LangInt{} as a class.}
|
|
\label{fig:interp-Lint-class}
|
|
\label{fig:interp-Lint-class}
|
|
\end{figure}
|
|
\end{figure}
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{lstlisting}
|
|
(define interp-Lvar-class
|
|
(define interp-Lvar-class
|
|
(class interp-Lint-class
|
|
(class interp-Lint-class
|
|
(super-new)
|
|
(super-new)
|
|
@@ -2245,7 +2243,7 @@ def interp_Lint(p):
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
{\if\edition\pythonEd
|
|
{\if\edition\pythonEd
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{lstlisting}
|
|
class InterpLvar(InterpLint):
|
|
class InterpLvar(InterpLint):
|
|
def interp_exp(self, e, env):
|
|
def interp_exp(self, e, env):
|
|
match e:
|
|
match e:
|
|
@@ -2268,6 +2266,7 @@ def interp_Lvar(p):
|
|
return InterpLvar().interp(p)
|
|
return InterpLvar().interp(p)
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
|
|
+\end{tcolorbox}
|
|
\caption{Interpreter for the \LangVar{} language.}
|
|
\caption{Interpreter for the \LangVar{} language.}
|
|
\label{fig:interp-Lvar}
|
|
\label{fig:interp-Lvar}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -2338,8 +2337,7 @@ integer constant (called an \emph{immediate value}\index{subject}{immediate
|
|
}
|
|
}
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\[
|
|
\[
|
|
\begin{array}{l}
|
|
\begin{array}{l}
|
|
@@ -2366,8 +2364,7 @@ integer constant (called an \emph{immediate value}\index{subject}{immediate
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
\fi}
|
|
\fi}
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The syntax of the \LangXInt{} assembly language (AT\&T syntax).}
|
|
\caption{The syntax of the \LangXInt{} assembly language (AT\&T syntax).}
|
|
\label{fig:x86-int-concrete}
|
|
\label{fig:x86-int-concrete}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -2431,13 +2428,15 @@ errors.
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
\begin{minipage}{0.45\textwidth}
|
|
\begin{minipage}{0.45\textwidth}
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
|
|
+\begin{lstlisting}
|
|
.globl main
|
|
.globl main
|
|
main:
|
|
main:
|
|
movq $10, %rax
|
|
movq $10, %rax
|
|
addq $32, %rax
|
|
addq $32, %rax
|
|
retq
|
|
retq
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
|
|
+\end{tcolorbox}
|
|
\end{minipage}
|
|
\end{minipage}
|
|
|
|
|
|
\caption{An x86 program that computes
|
|
\caption{An x86 program that computes
|
|
@@ -2473,8 +2472,9 @@ at $-16\key{(\%rbp)}$, etc.
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
\begin{minipage}{0.66\textwidth}
|
|
\begin{minipage}{0.66\textwidth}
|
|
-{\if\edition\racketEd
|
|
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+ \begin{tcolorbox}[colback=white]
|
|
|
|
+ {\if\edition\racketEd
|
|
|
|
+\begin{lstlisting}
|
|
start:
|
|
start:
|
|
movq $10, -8(%rbp)
|
|
movq $10, -8(%rbp)
|
|
negq -8(%rbp)
|
|
negq -8(%rbp)
|
|
@@ -2495,7 +2495,7 @@ conclusion:
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
{\if\edition\pythonEd
|
|
{\if\edition\pythonEd
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{lstlisting}
|
|
.globl main
|
|
.globl main
|
|
main:
|
|
main:
|
|
pushq %rbp
|
|
pushq %rbp
|
|
@@ -2510,7 +2510,8 @@ main:
|
|
retq
|
|
retq
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
-\end{minipage}
|
|
|
|
|
|
+ \end{tcolorbox}
|
|
|
|
+ \end{minipage}
|
|
\caption{An x86 program that computes
|
|
\caption{An x86 program that computes
|
|
\racket{\code{(+ 52 (- 10))}}\python{52 + -10}.}
|
|
\racket{\code{(+ 52 (- 10))}}\python{52 + -10}.}
|
|
\label{fig:p1-x86}
|
|
\label{fig:p1-x86}
|
|
@@ -2638,11 +2639,10 @@ register allocation (Chapter~\ref{ch:register-allocation-Lvar}).
|
|
}
|
|
}
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.94\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\small
|
|
\small
|
|
-{\if\edition\racketEd
|
|
|
|
-\[
|
|
|
|
|
|
+{\if\edition\racketEd
|
|
|
|
+\[\arraycolsep=3pt
|
|
\begin{array}{l}
|
|
\begin{array}{l}
|
|
\ASTXIntRacket \\
|
|
\ASTXIntRacket \\
|
|
\begin{array}{lcl}
|
|
\begin{array}{lcl}
|
|
@@ -2667,8 +2667,7 @@ register allocation (Chapter~\ref{ch:register-allocation-Lvar}).
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
\fi}
|
|
\fi}
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The abstract syntax of \LangXInt{} assembly.}
|
|
\caption{The abstract syntax of \LangXInt{} assembly.}
|
|
\label{fig:x86-int-ast}
|
|
\label{fig:x86-int-ast}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -2818,8 +2817,7 @@ placing \key{select\_instructions} first, followed by the
|
|
that uses a reserved register to fix outstanding problems.
|
|
that uses a reserved register to fix outstanding problems.
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\begin{tikzpicture}[baseline=(current bounding box.center),scale=0.95]
|
|
\begin{tikzpicture}[baseline=(current bounding box.center),scale=0.95]
|
|
\node (Lvar) at (0,2) {\large \LangVar{}};
|
|
\node (Lvar) at (0,2) {\large \LangVar{}};
|
|
@@ -2859,8 +2857,7 @@ that uses a reserved register to fix outstanding problems.
|
|
\path[->,bend right=15] (x86-3) edge [below] node {\ttfamily\footnotesize prelude\_and\_concl.} (x86-4);
|
|
\path[->,bend right=15] (x86-3) edge [below] node {\ttfamily\footnotesize prelude\_and\_concl.} (x86-4);
|
|
\end{tikzpicture}
|
|
\end{tikzpicture}
|
|
\fi}
|
|
\fi}
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{Diagram of the passes for compiling \LangVar{}. }
|
|
\caption{Diagram of the passes for compiling \LangVar{}. }
|
|
\label{fig:Lvar-passes}
|
|
\label{fig:Lvar-passes}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -2956,8 +2953,7 @@ variables are uninitialized; they become initialized on their first
|
|
assignment.
|
|
assignment.
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\[
|
|
\[
|
|
\begin{array}{l}
|
|
\begin{array}{l}
|
|
\CvarGrammarRacket \\
|
|
\CvarGrammarRacket \\
|
|
@@ -2966,16 +2962,14 @@ assignment.
|
|
\end{array}
|
|
\end{array}
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The concrete syntax of the \LangCVar{} intermediate language.}
|
|
\caption{The concrete syntax of the \LangCVar{} intermediate language.}
|
|
\label{fig:c0-concrete-syntax}
|
|
\label{fig:c0-concrete-syntax}
|
|
\end{figure}
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\[
|
|
\[
|
|
\begin{array}{l}
|
|
\begin{array}{l}
|
|
\CvarASTRacket \\
|
|
\CvarASTRacket \\
|
|
@@ -2984,8 +2978,7 @@ assignment.
|
|
\end{array}
|
|
\end{array}
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The abstract syntax of the \LangCVar{} intermediate language.}
|
|
\caption{The abstract syntax of the \LangCVar{} intermediate language.}
|
|
\label{fig:c0-syntax}
|
|
\label{fig:c0-syntax}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -3055,7 +3048,8 @@ form of Racket is useful for transforming the element of a list to
|
|
produce a new list.\index{subject}{for/list}
|
|
produce a new list.\index{subject}{for/list}
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
|
|
+\begin{lstlisting}
|
|
(define (uniquify_exp env)
|
|
(define (uniquify_exp env)
|
|
(lambda (e)
|
|
(lambda (e)
|
|
(match e
|
|
(match e
|
|
@@ -3069,6 +3063,7 @@ produce a new list.\index{subject}{for/list}
|
|
(match p
|
|
(match p
|
|
[(Program '() e) (Program '() ((uniquify_exp '()) e))]))
|
|
[(Program '() e) (Program '() ((uniquify_exp '()) e))]))
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
|
|
+\end{tcolorbox}
|
|
\caption{Skeleton for the \key{uniquify} pass.}
|
|
\caption{Skeleton for the \key{uniquify} pass.}
|
|
\label{fig:uniquify-Lvar}
|
|
\label{fig:uniquify-Lvar}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -3179,8 +3174,7 @@ print(tmp_1)
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
\centering
|
|
\centering
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\[
|
|
\[
|
|
\begin{array}{l}
|
|
\begin{array}{l}
|
|
@@ -3201,8 +3195,8 @@ print(tmp_1)
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
\fi}
|
|
\fi}
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
|
|
+
|
|
\caption{\LangVarANF{} is \LangVar{} with operands restricted to
|
|
\caption{\LangVarANF{} is \LangVar{} with operands restricted to
|
|
atomic expressions.}
|
|
atomic expressions.}
|
|
\label{fig:Lvar-anf-syntax}
|
|
\label{fig:Lvar-anf-syntax}
|
|
@@ -3467,7 +3461,8 @@ start:
|
|
\end{transformation}
|
|
\end{transformation}
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
|
|
+\begin{lstlisting}
|
|
(define (explicate_tail e)
|
|
(define (explicate_tail e)
|
|
(match e
|
|
(match e
|
|
[(Var x) ___]
|
|
[(Var x) ___]
|
|
@@ -3488,6 +3483,7 @@ start:
|
|
(match p
|
|
(match p
|
|
[(Program info body) ___]))
|
|
[(Program info body) ___]))
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
|
|
+\end{tcolorbox}
|
|
\caption{Skeleton for the \code{explicate\_control} pass.}
|
|
\caption{Skeleton for the \code{explicate\_control} pass.}
|
|
\label{fig:explicate-control-Lvar}
|
|
\label{fig:explicate-control-Lvar}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -4053,6 +4049,7 @@ hand, is used only after this point, so \code{x} and \code{z} could
|
|
share the same register.
|
|
share the same register.
|
|
|
|
|
|
\begin{figure}
|
|
\begin{figure}
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\begin{minipage}{0.45\textwidth}
|
|
\begin{minipage}{0.45\textwidth}
|
|
Example \LangVar{} program:
|
|
Example \LangVar{} program:
|
|
% var_test_28.rkt
|
|
% var_test_28.rkt
|
|
@@ -4080,7 +4077,7 @@ print(z + (- y))
|
|
\begin{minipage}{0.45\textwidth}
|
|
\begin{minipage}{0.45\textwidth}
|
|
After instruction selection:
|
|
After instruction selection:
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{lstlisting}
|
|
locals-types:
|
|
locals-types:
|
|
x : Integer, y : Integer,
|
|
x : Integer, y : Integer,
|
|
z : Integer, t : Integer,
|
|
z : Integer, t : Integer,
|
|
@@ -4101,7 +4098,7 @@ start:
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
{\if\edition\pythonEd
|
|
{\if\edition\pythonEd
|
|
-\begin{lstlisting}[frame=single]
|
|
|
|
|
|
+\begin{lstlisting}
|
|
movq $1, v
|
|
movq $1, v
|
|
movq $42, w
|
|
movq $42, w
|
|
movq v, x
|
|
movq v, x
|
|
@@ -4118,6 +4115,8 @@ callq print_int
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
\end{minipage}
|
|
\end{minipage}
|
|
|
|
+\end{tcolorbox}
|
|
|
|
+
|
|
\caption{A running example for register allocation.}
|
|
\caption{A running example for register allocation.}
|
|
\label{fig:reg-eg}
|
|
\label{fig:reg-eg}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -4287,6 +4286,8 @@ conclusion, we see that \code{rbx} is restored from the stack with a
|
|
\index{subject}{prelude}\index{subject}{conclusion}
|
|
\index{subject}{prelude}\index{subject}{conclusion}
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
|
|
+
|
|
\begin{minipage}{0.45\textwidth}
|
|
\begin{minipage}{0.45\textwidth}
|
|
Example \LangVar{} program:
|
|
Example \LangVar{} program:
|
|
%var_test_14.rkt
|
|
%var_test_14.rkt
|
|
@@ -4358,6 +4359,8 @@ main:
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
\end{minipage}
|
|
\end{minipage}
|
|
|
|
+\end{tcolorbox}
|
|
|
|
+
|
|
\caption{An example with function calls.}
|
|
\caption{An example with function calls.}
|
|
\label{fig:example-calling-conventions}
|
|
\label{fig:example-calling-conventions}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -4497,6 +4500,7 @@ Finally, the live-before for \code{movq \$5, a} is $\emptyset$
|
|
because it writes to variable \code{a}.
|
|
because it writes to variable \code{a}.
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\begin{minipage}{0.45\textwidth}
|
|
\begin{minipage}{0.45\textwidth}
|
|
\begin{lstlisting}[numbers=left,numberstyle=\tiny]
|
|
\begin{lstlisting}[numbers=left,numberstyle=\tiny]
|
|
movq $5, a
|
|
movq $5, a
|
|
@@ -4521,6 +4525,7 @@ L_{\mathsf{before}}(5)= \{\ttm{b},\ttm{c}\},
|
|
L_{\mathsf{after}}(5)= \emptyset
|
|
L_{\mathsf{after}}(5)= \emptyset
|
|
\end{align*}
|
|
\end{align*}
|
|
\end{minipage}
|
|
\end{minipage}
|
|
|
|
+\end{tcolorbox}
|
|
\caption{Example output of liveness analysis on a short example.}
|
|
\caption{Example output of liveness analysis on a short example.}
|
|
\label{fig:liveness-example-0}
|
|
\label{fig:liveness-example-0}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -4533,6 +4538,7 @@ L_{\mathsf{after}}(5)= \emptyset
|
|
\end{exercise}
|
|
\end{exercise}
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\hspace{20pt}
|
|
\hspace{20pt}
|
|
\begin{minipage}{0.45\textwidth}
|
|
\begin{minipage}{0.45\textwidth}
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
@@ -4594,7 +4600,7 @@ L_{\mathsf{after}}(5)= \emptyset
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
\end{minipage}
|
|
\end{minipage}
|
|
-
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The running example annotated with live-after sets.}
|
|
\caption{The running example annotated with live-after sets.}
|
|
\label{fig:live-eg}
|
|
\label{fig:live-eg}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -4752,6 +4758,7 @@ shown in Figure~\ref{fig:interfere}.
|
|
|
|
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\begin{quote}
|
|
\begin{quote}
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\begin{tabular}{ll}
|
|
\begin{tabular}{ll}
|
|
@@ -4787,12 +4794,15 @@ shown in Figure~\ref{fig:interfere}.
|
|
\end{tabular}
|
|
\end{tabular}
|
|
\fi}
|
|
\fi}
|
|
\end{quote}
|
|
\end{quote}
|
|
|
|
+\end{tcolorbox}
|
|
|
|
+
|
|
\caption{Interference results for the running example.}
|
|
\caption{Interference results for the running example.}
|
|
\label{fig:interference-results}
|
|
\label{fig:interference-results}
|
|
\end{figure}
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\large
|
|
\large
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\[
|
|
\[
|
|
@@ -4846,6 +4856,7 @@ shown in Figure~\ref{fig:interfere}.
|
|
\end{tikzpicture}
|
|
\end{tikzpicture}
|
|
\]
|
|
\]
|
|
\fi}
|
|
\fi}
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The interference graph of the example program.}
|
|
\caption{The interference graph of the example program.}
|
|
\label{fig:interfere}
|
|
\label{fig:interfere}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -4925,8 +4936,10 @@ sampling of the vertices (the colored ones) because showing edges for
|
|
all of the vertices would make the graph unreadable.
|
|
all of the vertices would make the graph unreadable.
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\includegraphics[width=0.45\textwidth]{figs/sudoku}
|
|
\includegraphics[width=0.45\textwidth]{figs/sudoku}
|
|
\includegraphics[width=0.5\textwidth]{figs/sudoku-graph-bw}
|
|
\includegraphics[width=0.5\textwidth]{figs/sudoku-graph-bw}
|
|
|
|
+\end{tcolorbox}
|
|
\caption{A Sudoku game board and the corresponding colored graph.}
|
|
\caption{A Sudoku game board and the corresponding colored graph.}
|
|
\label{fig:sudoku-graph}
|
|
\label{fig:sudoku-graph}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -5002,6 +5015,7 @@ particular, we assign $-1$ to \code{rax} and $-2$ to \code{rsp}.
|
|
|
|
|
|
|
|
|
|
\begin{figure}[btp]
|
|
\begin{figure}[btp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\centering
|
|
\centering
|
|
\begin{lstlisting}[basicstyle=\rmfamily,deletekeywords={for,from,with,is,not,in,find},morekeywords={while},columns=fullflexible]
|
|
\begin{lstlisting}[basicstyle=\rmfamily,deletekeywords={for,from,with,is,not,in,find},morekeywords={while},columns=fullflexible]
|
|
Algorithm: DSATUR
|
|
Algorithm: DSATUR
|
|
@@ -5016,7 +5030,8 @@ while |$W \neq \emptyset$| do
|
|
|$\mathrm{color}[u] \gets c$|
|
|
|$\mathrm{color}[u] \gets c$|
|
|
|$W \gets W - \{u\}$|
|
|
|$W \gets W - \{u\}$|
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
- \caption{The saturation-based greedy graph coloring algorithm.}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
|
|
+\caption{The saturation-based greedy graph coloring algorithm.}
|
|
\label{fig:satur-algo}
|
|
\label{fig:satur-algo}
|
|
\end{figure}
|
|
\end{figure}
|
|
|
|
|
|
@@ -5755,6 +5770,7 @@ and \code{pushq} subtracts $8$ from the \code{rsp}.
|
|
|
|
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\begin{tikzpicture}[baseline=(current bounding box.center)]
|
|
\begin{tikzpicture}[baseline=(current bounding box.center)]
|
|
\node (Lvar) at (0,2) {\large \LangVar{}};
|
|
\node (Lvar) at (0,2) {\large \LangVar{}};
|
|
\node (Lvar-2) at (3,2) {\large \LangVar{}};
|
|
\node (Lvar-2) at (3,2) {\large \LangVar{}};
|
|
@@ -5773,12 +5789,14 @@ and \code{pushq} subtracts $8$ from the \code{rsp}.
|
|
\path[->,bend left=15] (Lvar-2) edge [above] node {\ttfamily\footnotesize remove\_complex.} (Lvar-3);
|
|
\path[->,bend left=15] (Lvar-2) edge [above] node {\ttfamily\footnotesize remove\_complex.} (Lvar-3);
|
|
\path[->,bend left=15] (Lvar-3) edge [right] node {\ttfamily\footnotesize explicate\_control} (Cvar-1);
|
|
\path[->,bend left=15] (Lvar-3) edge [right] node {\ttfamily\footnotesize explicate\_control} (Cvar-1);
|
|
\path[->,bend right=15] (Cvar-1) edge [left] node {\ttfamily\footnotesize select\_instr.} (x86-2);
|
|
\path[->,bend right=15] (Cvar-1) edge [left] node {\ttfamily\footnotesize select\_instr.} (x86-2);
|
|
-\path[->,bend left=15] (x86-2) edge [right] node {\ttfamily\footnotesize uncover\_live} (x86-2-1);
|
|
|
|
|
|
+\path[->,bend left=15] (x86-2) edge [left] node {\ttfamily\footnotesize uncover\_live} (x86-2-1);
|
|
\path[->,bend right=15] (x86-2-1) edge [below] node {\ttfamily\footnotesize build\_inter.} (x86-2-2);
|
|
\path[->,bend right=15] (x86-2-1) edge [below] node {\ttfamily\footnotesize build\_inter.} (x86-2-2);
|
|
-\path[->,bend right=15] (x86-2-2) edge [right] node {\ttfamily\footnotesize allocate\_reg.} (x86-3);
|
|
|
|
|
|
+\path[->,bend right=15] (x86-2-2) edge [left] node {\ttfamily\footnotesize allocate\_reg.} (x86-3);
|
|
\path[->,bend left=15] (x86-3) edge [above] node {\ttfamily\footnotesize patch\_instr.} (x86-4);
|
|
\path[->,bend left=15] (x86-3) edge [above] node {\ttfamily\footnotesize patch\_instr.} (x86-4);
|
|
-\path[->,bend left=15] (x86-4) edge [right] node {\ttfamily\footnotesize prelude\_and\_concl.} (x86-5);
|
|
|
|
|
|
+\path[->,bend left=15] (x86-4) edge [left] node {\ttfamily\footnotesize prelude\_and\_concl.} (x86-5);
|
|
\end{tikzpicture}
|
|
\end{tikzpicture}
|
|
|
|
+\end{tcolorbox}
|
|
|
|
+
|
|
\caption{Diagram of the passes for \LangVar{} with register allocation.}
|
|
\caption{Diagram of the passes for \LangVar{} with register allocation.}
|
|
\label{fig:reg-alloc-passes}
|
|
\label{fig:reg-alloc-passes}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -5820,6 +5838,8 @@ done in the prelude. We move the stack pointer up by \code{8} bytes
|
|
|
|
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
|
|
+\begin{minipage}{0.55\textwidth}
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
% var_test_28.rkt
|
|
% var_test_28.rkt
|
|
% (use-minimal-set-of-registers! #t)
|
|
% (use-minimal-set-of-registers! #t)
|
|
% and only rbx rcx
|
|
% and only rbx rcx
|
|
@@ -5882,6 +5902,8 @@ main:
|
|
retq
|
|
retq
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
|
|
+\end{tcolorbox}
|
|
|
|
+\end{minipage}
|
|
\caption{The x86 output from the running example
|
|
\caption{The x86 output from the running example
|
|
(Figure~\ref{fig:reg-eg}), limiting allocation to just \code{rbx}
|
|
(Figure~\ref{fig:reg-eg}), limiting allocation to just \code{rbx}
|
|
and \code{rcx}.}
|
|
and \code{rcx}.}
|
|
@@ -6677,8 +6699,7 @@ respectively. The \LangIf{} language includes all of
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
\centering
|
|
\centering
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\[
|
|
\[
|
|
\begin{array}{l}
|
|
\begin{array}{l}
|
|
@@ -6703,17 +6724,16 @@ respectively. The \LangIf{} language includes all of
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
\fi}
|
|
\fi}
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The concrete syntax of \LangIf{}, extending \LangVar{}
|
|
\caption{The concrete syntax of \LangIf{}, extending \LangVar{}
|
|
(Figure~\ref{fig:Lvar-concrete-syntax}) with Booleans and conditionals.}
|
|
(Figure~\ref{fig:Lvar-concrete-syntax}) with Booleans and conditionals.}
|
|
\label{fig:Lif-concrete-syntax}
|
|
\label{fig:Lif-concrete-syntax}
|
|
\end{figure}
|
|
\end{figure}
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
|
|
+\begin{minipage}{0.66\textwidth}
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\centering
|
|
\centering
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\[
|
|
\[
|
|
\begin{array}{l}
|
|
\begin{array}{l}
|
|
@@ -6738,8 +6758,8 @@ respectively. The \LangIf{} language includes all of
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
\fi}
|
|
\fi}
|
|
|
|
+\end{tcolorbox}
|
|
\end{minipage}
|
|
\end{minipage}
|
|
-}
|
|
|
|
\caption{The abstract syntax of \LangIf{}.}
|
|
\caption{The abstract syntax of \LangIf{}.}
|
|
\label{fig:Lif-syntax}
|
|
\label{fig:Lif-syntax}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -6770,6 +6790,7 @@ evaluated if $e_1$ evaluates to \TRUE{}.
|
|
behavior.}
|
|
behavior.}
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\begin{lstlisting}
|
|
\begin{lstlisting}
|
|
(define interp-Lif-class
|
|
(define interp-Lif-class
|
|
@@ -6848,6 +6869,7 @@ class InterpLif(InterpLvar):
|
|
...
|
|
...
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
|
|
+\end{tcolorbox}
|
|
\caption{Interpreter for the \LangIf{} language. \racket{(See
|
|
\caption{Interpreter for the \LangIf{} language. \racket{(See
|
|
Figure~\ref{fig:interp-op-Lif} for \code{interp-op}.)}
|
|
Figure~\ref{fig:interp-op-Lif} for \code{interp-op}.)}
|
|
\python{(See Figure~\ref{fig:interp-cmp-Lif} for \code{interp\_cmp}.)}}
|
|
\python{(See Figure~\ref{fig:interp-cmp-Lif} for \code{interp\_cmp}.)}}
|
|
@@ -6856,6 +6878,7 @@ class InterpLif(InterpLvar):
|
|
|
|
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\begin{lstlisting}
|
|
\begin{lstlisting}
|
|
(define/public (interp_op op)
|
|
(define/public (interp_op op)
|
|
(match op
|
|
(match op
|
|
@@ -6882,6 +6905,8 @@ class InterpLif(InterpLvar):
|
|
(>= v1 v2)]))]
|
|
(>= v1 v2)]))]
|
|
[else (error 'interp_op "unknown operator")]))
|
|
[else (error 'interp_op "unknown operator")]))
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
|
|
+\end{tcolorbox}
|
|
|
|
+
|
|
\caption{Interpreter for the primitive operators in the \LangIf{} language.}
|
|
\caption{Interpreter for the primitive operators in the \LangIf{} language.}
|
|
\label{fig:interp-op-Lif}
|
|
\label{fig:interp-op-Lif}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -6889,6 +6914,7 @@ class InterpLif(InterpLvar):
|
|
|
|
|
|
{\if\edition\pythonEd
|
|
{\if\edition\pythonEd
|
|
\begin{figure}
|
|
\begin{figure}
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\begin{lstlisting}
|
|
\begin{lstlisting}
|
|
class InterpLif(InterpLvar):
|
|
class InterpLif(InterpLvar):
|
|
...
|
|
...
|
|
@@ -6907,6 +6933,8 @@ class InterpLif(InterpLvar):
|
|
case NotEq():
|
|
case NotEq():
|
|
return lambda x, y: x != y
|
|
return lambda x, y: x != y
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
|
|
+\end{tcolorbox}
|
|
|
|
+
|
|
\caption{Interpreter for the comparison operators in the \LangIf{} language.}
|
|
\caption{Interpreter for the comparison operators in the \LangIf{} language.}
|
|
\label{fig:interp-cmp-Lif}
|
|
\label{fig:interp-cmp-Lif}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -7028,6 +7056,7 @@ Figure~\ref{fig:type-check-Lvar}. The type of an integer constant is
|
|
an error if the two types are not equal.}
|
|
an error if the two types are not equal.}
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
|
|
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
|
|
(define type-check-Lvar-class
|
|
(define type-check-Lvar-class
|
|
@@ -7133,11 +7162,13 @@ class TypeCheckLvar:
|
|
self.type_check_stmts(body, {})
|
|
self.type_check_stmts(body, {})
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
|
|
+\end{tcolorbox}
|
|
\caption{Type checker for the \LangVar{} language.}
|
|
\caption{Type checker for the \LangVar{} language.}
|
|
\label{fig:type-check-Lvar}
|
|
\label{fig:type-check-Lvar}
|
|
\end{figure}
|
|
\end{figure}
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
|
|
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
|
|
(define type-check-Lif-class
|
|
(define type-check-Lif-class
|
|
@@ -7230,6 +7261,7 @@ class TypeCheckLif(TypeCheckLvar):
|
|
return super().type_check_stmts(ss, env)
|
|
return super().type_check_stmts(ss, env)
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
|
|
+\end{tcolorbox}
|
|
\caption{Type checker for the \LangIf{} language.}
|
|
\caption{Type checker for the \LangIf{} language.}
|
|
\label{fig:type-check-Lif}
|
|
\label{fig:type-check-Lif}
|
|
\end{figure}
|
|
\end{figure}
|
|
@@ -7386,8 +7418,7 @@ in Figure~\ref{fig:c1-syntax}.
|
|
}
|
|
}
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\small
|
|
\small
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\[
|
|
\[
|
|
@@ -7410,16 +7441,14 @@ in Figure~\ref{fig:c1-syntax}.
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
\fi}
|
|
\fi}
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The concrete syntax of the \LangCIf{} intermediate language,
|
|
\caption{The concrete syntax of the \LangCIf{} intermediate language,
|
|
an extension of \LangCVar{} (Figure~\ref{fig:c0-concrete-syntax}).}
|
|
an extension of \LangCVar{} (Figure~\ref{fig:c0-concrete-syntax}).}
|
|
\label{fig:c1-concrete-syntax}
|
|
\label{fig:c1-concrete-syntax}
|
|
\end{figure}
|
|
\end{figure}
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\small
|
|
\small
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\[
|
|
\[
|
|
@@ -7442,8 +7471,7 @@ in Figure~\ref{fig:c1-syntax}.
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
\fi}
|
|
\fi}
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The abstract syntax of \LangCIf{}\racket{, an extension of \LangCVar{}
|
|
\caption{The abstract syntax of \LangCIf{}\racket{, an extension of \LangCVar{}
|
|
(Figure~\ref{fig:c0-syntax})}.}
|
|
(Figure~\ref{fig:c0-syntax})}.}
|
|
\label{fig:c1-syntax}
|
|
\label{fig:c1-syntax}
|
|
@@ -7510,8 +7538,7 @@ $\Atm$ to x86.
|
|
|
|
|
|
|
|
|
|
\begin{figure}[tp]
|
|
\begin{figure}[tp]
|
|
-\fbox{
|
|
|
|
-\begin{minipage}{0.96\textwidth}
|
|
|
|
|
|
+\begin{tcolorbox}[colback=white]
|
|
\[
|
|
\[
|
|
\begin{array}{l}
|
|
\begin{array}{l}
|
|
\gray{\GrammarXInt} \\ \hline
|
|
\gray{\GrammarXInt} \\ \hline
|
|
@@ -7522,8 +7549,7 @@ $\Atm$ to x86.
|
|
\end{array}
|
|
\end{array}
|
|
\end{array}
|
|
\end{array}
|
|
\]
|
|
\]
|
|
-\end{minipage}
|
|
|
|
-}
|
|
|
|
|
|
+\end{tcolorbox}
|
|
\caption{The concrete syntax of \LangXIf{} (extends \LangXInt{} of Figure~\ref{fig:x86-int-concrete}).}
|
|
\caption{The concrete syntax of \LangXIf{} (extends \LangXInt{} of Figure~\ref{fig:x86-int-concrete}).}
|
|
\label{fig:x86-1-concrete}
|
|
\label{fig:x86-1-concrete}
|
|
\end{figure}
|
|
\end{figure}
|