|
@@ -4048,6 +4048,8 @@ arguments.
|
|
|
|
|
|
\section{Type Checking $R_2$ Programs}
|
|
|
\label{sec:type-check-r2}
|
|
|
+\index{type checking}
|
|
|
+\index{semantic analysis}
|
|
|
|
|
|
It is helpful to think about type checking in two complementary
|
|
|
ways. A type checker predicts the type of value that will be produced
|
|
@@ -5357,7 +5359,8 @@ of the \key{if} is taken. The element at index $0$ of \code{t} is
|
|
|
\label{fig:r3-syntax}
|
|
|
\end{figure}
|
|
|
|
|
|
-
|
|
|
+\index{allocate}
|
|
|
+\index{heap allocate}
|
|
|
Tuples are our first encounter with heap-allocated data, which raises
|
|
|
several interesting issues. First, variable binding performs a
|
|
|
shallow-copy when dealing with tuples, which means that different
|
|
@@ -5841,8 +5844,9 @@ of the \code{vector} form.
|
|
|
The $(\key{collect}\,n)$ form runs the garbage collector, requesting
|
|
|
$n$ bytes. It will become a call to the \code{collect} function in
|
|
|
\code{runtime.c} in \code{select-instructions}. The
|
|
|
-$(\key{allocate}\,n\,T)$ form creates an tuple of $n$ elements. The
|
|
|
-$T$ parameter is the type of the tuple: \code{(Vector $\Type_1 \ldots
|
|
|
+$(\key{allocate}\,n\,T)$ form creates an tuple of $n$ elements.
|
|
|
+\index{allocate}
|
|
|
+The $T$ parameter is the type of the tuple: \code{(Vector $\Type_1 \ldots
|
|
|
\Type_n$)} where $\Type_i$ is the type of the $i$th element in the
|
|
|
tuple. The $(\key{global-value}\,\itm{name})$ form reads the value of
|
|
|
a global variable, such as \code{free\_ptr}.
|
|
@@ -6473,6 +6477,8 @@ for the compilation of $R_3$.
|
|
|
|
|
|
\section{Challenge: Simple Structures}
|
|
|
\label{sec:simple-structures}
|
|
|
+\index{struct}
|
|
|
+\index{structure}
|
|
|
|
|
|
Figure~\ref{fig:r3s-concrete-syntax} defines the concrete syntax for
|
|
|
$R^s_3$, which extends $R^3$ with support for simple structures.
|
|
@@ -7801,6 +7807,8 @@ values.
|
|
|
\end{figure}
|
|
|
|
|
|
\section{Type Checking $R_5$}
|
|
|
+\label{sec:type-check-r5}
|
|
|
+\index{type checking}
|
|
|
|
|
|
Figure~\ref{fig:typecheck-R5} shows how to type check the new
|
|
|
\key{lambda} form. The body of the \key{lambda} is checked in an
|
|
@@ -7829,6 +7837,8 @@ require the body's type to match the declared return type.
|
|
|
|
|
|
|
|
|
\section{Closure Conversion}
|
|
|
+\label{sec:closure-conversion}
|
|
|
+\index{closure conversion}
|
|
|
|
|
|
The compiling of lexically-scoped functions into top-level function
|
|
|
definitions is accomplished in the pass \code{convert-to-closures}
|