|
@@ -6971,6 +6971,7 @@ for $R_6$.
|
|
|
\label{fig:interp-R6}
|
|
|
\end{figure}
|
|
|
|
|
|
+\clearpage
|
|
|
|
|
|
\section{The $R_7$ Language: Untyped Racket}
|
|
|
\label{sec:r7-lang}
|
|
@@ -6989,8 +6990,10 @@ for $R_6$.
|
|
|
&\mid& (\itm{cmp}\;\Exp\;\Exp) \mid \IF{\Exp}{\Exp}{\Exp} \\
|
|
|
&\mid& (\key{vector}\;\Exp^{+}) \mid
|
|
|
(\key{vector-ref}\;\Exp\;\Exp) \\
|
|
|
- &\mid& (\key{vector-set!}\;\Exp\;\Exp\;\Exp) \mid (\key{void}) \\
|
|
|
- &\mid& (\Exp \; \Exp^{*}) \mid (\key{lambda}\; (\Var^{*}) \; \Exp) \\
|
|
|
+ &\mid& (\key{vector-set!}\;\Exp\;\Exp\;\Exp) \mid (\key{void}) \\
|
|
|
+ &\mid& (\Exp \; \Exp^{*}) \mid (\key{lambda}\; (\Var^{*}) \; \Exp) \\
|
|
|
+ & \mid & (\key{boolean?}\;\Exp) \mid (\key{integer?}\;\Exp)\\
|
|
|
+ & \mid & (\key{vector?}\;\Exp) \mid (\key{procedure?}\;\Exp) \mid (\key{void?}\;\Exp) \\
|
|
|
\Def &::=& (\key{define}\; (\Var \; \Var^{*}) \; \Exp) \\
|
|
|
R_7 &::=& (\key{program} \; \Def^{*}\; \Exp)
|
|
|
\end{array}
|
|
@@ -7061,7 +7064,7 @@ Figure~\ref{fig:interp-R7}.
|
|
|
((interp-r7 new-env) body)]
|
|
|
[else (error "interp-r7, expected function, not" f-val)])])))
|
|
|
\end{lstlisting}
|
|
|
-\caption{Interpreter for the $R_7$ language.}
|
|
|
+\caption{Interpreter for the $R_7$ language. UPDATE ME -Jeremy}
|
|
|
\label{fig:interp-R7}
|
|
|
\end{figure}
|
|
|
|
|
@@ -7073,7 +7076,7 @@ Figure~\ref{fig:interp-R7}.
|
|
|
%% Most of the compiler passes only require straightforward changes. The
|
|
|
%% interesting part is in instruction selection.
|
|
|
|
|
|
-\section{Shrink}
|
|
|
+\section{Shrinking $R_6$}
|
|
|
\label{sec:shrink-r6}
|
|
|
|
|
|
In the \code{shrink} pass we recommend compiling \code{project} into
|
|
@@ -7081,10 +7084,11 @@ an explicit \code{if} expression that uses three new operations:
|
|
|
\code{tag-of-any}, \code{value-of-any}, and \code{exit}. The
|
|
|
\code{tag-of-any} operation retrieves the type tag from a tagged value
|
|
|
of type \code{Any}. The \code{value-of-any} retrieves the underlying
|
|
|
-value from a tagged value.
|
|
|
-
|
|
|
-\code{exit}...
|
|
|
-
|
|
|
+value from a tagged value. Finally, the \code{exit} operation ends the
|
|
|
+execution of the program by invoking the operating system's
|
|
|
+\code{exit} function. So the translation for \code{project} is as
|
|
|
+follows. (We have ommitted the \code{has-type} AST nodes to make this
|
|
|
+output more readable.)
|
|
|
|
|
|
\begin{tabular}{lll}
|
|
|
\begin{minipage}{0.3\textwidth}
|
|
@@ -7105,9 +7109,10 @@ $\Rightarrow$
|
|
|
\end{minipage}
|
|
|
\end{tabular} \\
|
|
|
|
|
|
+Similarly, we recommend translating the type predicates
|
|
|
+(\code{boolean?}, etc.) into uses of \code{tag-of-any} and \code{eq?}.
|
|
|
|
|
|
-
|
|
|
-\section{Instruction Selection}
|
|
|
+\section{Instruction Selection for $R_6$}
|
|
|
\label{sec:select-r6}
|
|
|
|
|
|
\paragraph{Inject}
|