Skip to content

Commit 8e4575b

Browse files
committed
add Begin to LAlloc
1 parent f913bbb commit 8e4575b

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

book.tex

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13002,7 +13002,7 @@ \section{Expose Allocation}
1300213002
expressions to temporary variables (see below).
1300313003

1300413004
The output of \code{expose\_allocation} is a language \LangAlloc{}
13005-
that replaces tuple creation with new lower-level forms that we use in the
13005+
that replaces tuple creation with new forms that we use in the
1300613006
translation of tuple creation\index{subject}{Lalloc@\LangAlloc{}}.
1300713007
%
1300813008
{\if\edition\racketEd
@@ -13016,22 +13016,27 @@ \section{Expose Allocation}
1301613016
\fi}
1301713017
{\if\edition\pythonEd\pythonColor
1301813018
\[
13019-
\begin{array}{lcl}
13020-
\Exp &::=& \key{collect}(\itm{int})
13021-
\MID \key{allocate}(\itm{int},\itm{type})
13022-
\MID \key{global\_value}(\itm{name}) \\
13023-
\Stmt &::= & \CASSIGN{\CPUT{\Exp}{\itm{int}}}{\Exp}
13019+
%% \begin{array}{lcl}
13020+
%% \Exp &::=& \key{collect}(\itm{int})
13021+
%% \MID \key{allocate}(\itm{int},\itm{type})
13022+
%% \MID \key{global\_value}(\itm{name}) \\
13023+
%% \Stmt &::= & \CASSIGN{\CPUT{\Exp}{\itm{int}}}{\Exp}
13024+
%% \end{array}
13025+
\begin{array}{rcl}
13026+
\Exp &::=& \COLLECT{\Int} \MID \ALLOCATE{\Int}{\Type} \\
13027+
&\MID& \GLOBALVALUE{\Var} \MID \BEGIN{\Stmt^{*}}{\Exp}\\
13028+
\Stmt{} &::=& \ASSIGN{\PUT{\Exp}{\itm{int}}}{\Exp}
1302413029
\end{array}
1302513030
\]
1302613031
\fi}
1302713032
%
13028-
The \CCOLLECT{$n$} form runs the garbage collector, requesting that
13033+
The \COLLECT{$n$} form runs the garbage collector, requesting that
1302913034
there be $n$ bytes ready to be allocated. During instruction
13030-
selection\index{subject}{instruction selection}, the \CCOLLECT{$n$}
13035+
selection\index{subject}{instruction selection}, the \COLLECT{$n$}
1303113036
form will become a call to the \code{collect} function in
1303213037
\code{runtime.c}.
1303313038
%
13034-
The \CALLOCATE{$n$}{$\itm{type}$} form obtains memory for $n$ elements (and
13039+
The \ALLOCATE{$n$}{$\itm{type}$} form obtains memory for $n$ elements (and
1303513040
space at the front for the 64-bit tag), but the elements are not
1303613041
initialized. \index{subject}{allocate} The $\itm{type}$ parameter is the type
1303713042
of the tuple:
@@ -13040,11 +13045,14 @@ \section{Expose Allocation}
1304013045
%
1304113046
where $\Type_i$ is the type of the $i$th element.
1304213047
%
13043-
The \CGLOBALVALUE{\itm{name}} form reads the value of a global
13048+
The \GLOBALVALUE{\itm{name}} form reads the value of a global
1304413049
variable, such as \code{free\_ptr}.
13050+
%
13051+
\python{We have already seen the \BEGIN{\itm{stmt}$^{*}$}{\itm{exp}} form
13052+
in section~\ref{sec:remove-complex-opera-Lif}.}
1304513053

1304613054
\racket{
13047-
The type information that you need for \CALLOCATE{$n$}{$\itm{type}$}
13055+
The type information that you need for \ALLOCATE{$n$}{$\itm{type}$}
1304813056
can be obtained by running the
1304913057
\code{type-check-Lvec-has-type} type checker immediately before the
1305013058
\code{expose\_allocation} pass. This version of the type checker

0 commit comments

Comments
 (0)