Selaa lähdekoodia

more colorbox

Jeremy Siek 3 vuotta sitten
vanhempi
commit
c5b1bc63f7
1 muutettua tiedostoa jossa 66 lisäystä ja 44 poistoa
  1. 66 44
      book.tex

+ 66 - 44
book.tex

@@ -7568,12 +7568,11 @@ $\Atm$ to x86.
 \end{array}
 }
 
-  \begin{figure}[tp]
-\fbox{
-\begin{minipage}{0.96\textwidth}
+\begin{figure}[tp]
+\begin{tcolorbox}[colback=white]
 \small    
 {\if\edition\racketEd    
-\[
+\[\arraycolsep=3pt
 \begin{array}{l}
   \gray{\ASTXIntRacket} \\ \hline
   \ASTXIfRacket \\
@@ -7609,8 +7608,7 @@ $\Atm$ to x86.
 \end{array}
 \]
 \fi}
-\end{minipage}
-}
+\end{tcolorbox}
 \caption{The abstract syntax of \LangXIf{} (extends \LangXInt{} of Figure~\ref{fig:x86-int-ast}).}
 \label{fig:x86-1}
 \end{figure}
@@ -7781,8 +7779,7 @@ upcoming \code{explicate\_control} pass.
 
 \begin{figure}[tp]
 \centering
-\fbox{
-\begin{minipage}{0.96\textwidth}
+\begin{tcolorbox}[colback=white]
 {\if\edition\racketEd    
 \[
 \begin{array}{l}
@@ -7805,8 +7802,7 @@ upcoming \code{explicate\_control} pass.
 \end{array}
 \]
 \fi}
-\end{minipage}
-}
+\end{tcolorbox}
 \caption{\LangIfANF{} is \LangIf{} in monadic normal form
   (extends \LangVarANF in Figure~\ref{fig:Lvar-anf-syntax}).}
 \label{fig:Lif-anf-syntax}
@@ -7967,6 +7963,7 @@ duplicated any code, but instead used labels and \code{goto} to enable
 sharing of code.
 
 \begin{figure}[tbp]
+\begin{tcolorbox}[colback=white]
 {\if\edition\racketEd        
 \begin{tabular}{lll}
 \begin{minipage}{0.4\textwidth}
@@ -8068,14 +8065,13 @@ block_1:
 \end{minipage}
 \end{tabular} 
 \fi}
+\end{tcolorbox}
 \caption{Translation from \LangIf{} to \LangCIf{}
   via the \code{explicate\_control}.}
 \label{fig:explicate-control-s1-38}
 \end{figure}
 
 
-
-
 {\if\edition\racketEd        
 %
 Recall that in Section~\ref{sec:explicate-control-Lvar} we implement
@@ -8159,6 +8155,7 @@ generate an assignment statement, with the given left and right-hand
 sides, concatenated with its continuation.
 
 \begin{figure}[tbp]
+\begin{tcolorbox}[colback=white]
 \begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
 def explicate_effect(e, cont, basic_blocks):
     match e:
@@ -8220,6 +8217,7 @@ def explicate_control(p):
             basic_blocks[label_name('start')] = new_body
             return CProgram(basic_blocks)
 \end{lstlisting}
+\end{tcolorbox}
 \caption{Skeleton for the \code{explicate\_control} pass.}
 \label{fig:explicate-control-Lif}
 \end{figure}
@@ -8315,7 +8313,8 @@ then there is no need to generate a new label and entry in
 \subsection{Explicate Predicate}
   
 \begin{figure}[tbp]
-\begin{lstlisting}
+  \begin{tcolorbox}[colback=white]
+    \begin{lstlisting}
 (define (explicate_pred cnd thn els)
   (match cnd
     [(Var x) ___]
@@ -8328,7 +8327,9 @@ then there is no need to generate a new label and entry in
     [(If cnd^ thn^ els^) ___]
     [else (error "explicate_pred unhandled case" cnd)]))
 \end{lstlisting}
-\caption{Skeleton for the \key{explicate\_pred} auxiliary function.}
+  \end{tcolorbox}
+
+  \caption{Skeleton for the \key{explicate\_pred} auxiliary function.}
 \label{fig:explicate-pred}
 \end{figure}
 \fi}
@@ -8961,7 +8962,8 @@ Figure~\ref{fig:if-example-x86} shows a simple example program in
 x86 assembly.
 
 \begin{figure}[tbp]
-{\if\edition\racketEd
+  \begin{tcolorbox}[colback=white]
+    {\if\edition\racketEd
 \begin{tabular}{lll}
 \begin{minipage}{0.4\textwidth}
 % cond_test_20.rkt, eq_input.py
@@ -9118,7 +9120,9 @@ conclusion:
 \end{minipage}
 \end{tabular}
 \fi}
-\caption{Example compilation of an \key{if} expression to x86, showing
+\end{tcolorbox}
+
+  \caption{Example compilation of an \key{if} expression to x86, showing
   the results of \code{explicate\_control},
   \code{select\_instructions}, and the final x86 assembly code.  }
 \label{fig:if-example-x86}
@@ -9126,13 +9130,14 @@ conclusion:
 
 
 \begin{figure}[tbp]
+\begin{tcolorbox}[colback=white]  
 {\if\edition\racketEd
 \begin{tikzpicture}[baseline=(current  bounding  box.center)]
 \node (Lif) at (0,2)  {\large \LangIf{}};
 \node (Lif-2) at (3,2)  {\large \LangIf{}};
 \node (Lif-3) at (6,2)  {\large \LangIf{}};
 \node (Lif-4) at (9,2)  {\large \LangIf{}};
-\node (Lif-5) at (12,2)  {\large \LangIfANF{}};
+\node (Lif-5) at (9,0)  {\large \LangIfANF{}};
 \node (C1-1) at (3,0)  {\large \LangCIf{}};
 
 \node (x86-2) at (3,-2)  {\large \LangXIfVar{}};
@@ -9145,9 +9150,9 @@ conclusion:
 \path[->,bend left=15] (Lif) edge [above] node {\ttfamily\footnotesize type\_check} (Lif-2);
 \path[->,bend left=15] (Lif-2) edge [above] node {\ttfamily\footnotesize shrink} (Lif-3);
 \path[->,bend left=15] (Lif-3) edge [above] node {\ttfamily\footnotesize uniquify} (Lif-4);
-\path[->,bend left=15] (Lif-4) edge [above] node {\ttfamily\footnotesize remove\_complex.} (Lif-5);
-\path[->,bend left=15] (Lif-5) edge [left] node {\ttfamily\footnotesize explicate\_control} (C1-1);
-\path[->,bend right=15] (C1-1) edge [left] node {\ttfamily\footnotesize select\_instructions} (x86-2);
+\path[->,bend left=15] (Lif-4) edge [right] node {\ttfamily\footnotesize remove\_complex.} (Lif-5);
+\path[->,bend right=15] (Lif-5) edge [above] node {\ttfamily\footnotesize explicate\_control} (C1-1);
+\path[->,bend right=15] (C1-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 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);
@@ -9176,6 +9181,8 @@ conclusion:
 \path[->,bend right=15] (x86-3) edge [below] node {\ttfamily\footnotesize prelude\_and\_concl. } (x86-4);
 \end{tikzpicture}
 \fi}
+\end{tcolorbox}
+
 \caption{Diagram of the passes for \LangIf{}, a language with conditionals.}
  \label{fig:Lif-passes}
 \end{figure}
@@ -9355,7 +9362,8 @@ see, the number of basic blocks has been reduced from 4 blocks (see
 Figure~\ref{fig:explicate-control-s1-38}) down to 2 blocks.
 
 \begin{figure}[tbp]
-{\if\edition\racketEd        
+  \begin{tcolorbox}[colback=white]
+    {\if\edition\racketEd        
 \begin{tabular}{lll}
 \begin{minipage}{0.4\textwidth}
 % cond_test_82.rkt
@@ -9432,7 +9440,9 @@ block_1:
 \end{minipage}
 \end{tabular} 
 \fi}
-\caption{Translation from \LangIf{} to \LangCIf{}
+  \end{tcolorbox}
+
+  \caption{Translation from \LangIf{} to \LangCIf{}
   via the improved \code{explicate\_control}.}
 \label{fig:explicate-control-challenge}
 \end{figure}
@@ -9566,6 +9576,7 @@ Figure~\ref{fig:remove-jumps} shows the output of
 optimization on the right.
 
 \begin{figure}[tbp]
+\begin{tcolorbox}[colback=white]
 {\if\edition\racketEd        
 \begin{tabular}{lll}
 \begin{minipage}{0.5\textwidth}
@@ -9642,6 +9653,8 @@ block_2:
 \end{minipage}
 \end{tabular}
 \fi}
+\end{tcolorbox}
+
 \caption{Merging basic blocks by removing unnecessary jumps.}
 \label{fig:remove-jumps}
 \end{figure}
@@ -9797,8 +9810,7 @@ the condition remains true.
 
 \begin{figure}[tp]
 \centering
-\fbox{
-  \begin{minipage}{0.96\textwidth}
+\begin{tcolorbox}[colback=white]
     \small
 {\if\edition\racketEd    
 \[
@@ -9826,16 +9838,15 @@ the condition remains true.
 \end{array}
 \]
 \fi}
-\end{minipage}
-}
+\end{tcolorbox}
+
 \caption{The concrete syntax of \LangLoop{}, extending \LangIf{} (Figure~\ref{fig:Lif-concrete-syntax}).}
 \label{fig:Lwhile-concrete-syntax}
 \end{figure}
 
 \begin{figure}[tp]
 \centering
-\fbox{
-  \begin{minipage}{0.96\textwidth}
+\begin{tcolorbox}[colback=white]
     \small
 {\if\edition\racketEd    
 \[
@@ -9863,8 +9874,8 @@ the condition remains true.
 \end{array}
 \]
 \fi}
-\end{minipage}
-}
+\end{tcolorbox}
+
 \caption{The abstract syntax of \LangLoop{}, extending \LangIf{} (Figure~\ref{fig:Lif-syntax}).}
 \label{fig:Lwhile-syntax}
 \end{figure}
@@ -9912,6 +9923,7 @@ function, where we repeatedly interpret the \code{body} so long as the
 
 
 \begin{figure}[tbp]
+\begin{tcolorbox}[colback=white]  
 {\if\edition\racketEd    
 \begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
 (define interp-Lwhile-class
@@ -9958,6 +9970,8 @@ class InterpLwhile(InterpLif):
         return super().interp_stmts(ss, env)
 \end{lstlisting}
 \fi}
+\end{tcolorbox}
+
 \caption{Interpreter for \LangLoop{}.}
 \label{fig:interp-Lwhile}
 \end{figure}
@@ -9984,6 +9998,7 @@ well typed.
 \fi}
 
 \begin{figure}[tbp]
+\begin{tcolorbox}[colback=white]  
 {\if\edition\racketEd    
 \begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
 (define type-check-Lwhile-class
@@ -10034,6 +10049,8 @@ class TypeCheckLwhile(TypeCheckLif):
         return super().type_check_stmts(ss, env)
 \end{lstlisting}
 \fi}
+\end{tcolorbox}
+
 \caption{Type checker for the \LangLoop{} language.}
 \label{fig:type-check-Lwhile}
 \end{figure}
@@ -10313,6 +10330,7 @@ updated and its successor nodes are pushed onto the work list.
 
 
 \begin{figure}[tb]
+\begin{tcolorbox}[colback=white]  
 {\if\edition\racketEd    
 \begin{lstlisting}
 (define (analyze_dataflow G transfer bottom join)
@@ -10351,6 +10369,8 @@ def analyze_dataflow(G, transfer, bottom, join):
             worklist.extend(G.adjacent(node))
 \end{lstlisting}
 \fi}
+\end{tcolorbox}
+
 \caption{Generic work list algorithm for dataflow analysis}
   \label{fig:generic-dataflow}
 \end{figure}
@@ -10551,9 +10571,8 @@ Figure~\ref{fig:Lwhile-anf-syntax} defines the output language
 }
 
 \begin{figure}[tp]
-\centering
-\fbox{
-\begin{minipage}{0.96\textwidth}
+  \centering
+\begin{tcolorbox}[colback=white]  
 \small
 {\if\edition\racketEd    
 \[
@@ -10590,8 +10609,8 @@ Figure~\ref{fig:Lwhile-anf-syntax} defines the output language
 %% \end{array}
 \]
 \fi}
-\end{minipage}
-}
+\end{tcolorbox}
+
 \caption{\LangLoopANF{} is \LangLoop{} in monadic normal form.}
 \label{fig:Lwhile-anf-syntax}
 \end{figure}
@@ -10680,8 +10699,7 @@ chapter is that the control-flow graphs of the later may contain
 cycles.
 
 \begin{figure}[tp]
-\fbox{
-\begin{minipage}{0.96\textwidth}
+\begin{tcolorbox}[colback=white]    
 \small
 \[
 \begin{array}{l}
@@ -10693,8 +10711,8 @@ cycles.
 \end{array}
 \end{array}
 \]
-\end{minipage}
-}
+\end{tcolorbox}
+
 \caption{The abstract syntax of \LangCLoop{}, extending \LangCIf{} (Figure~\ref{fig:c1-syntax}).}
 \label{fig:c7-syntax}
 \end{figure}
@@ -10804,6 +10822,7 @@ The \code{analyze\_dataflow} function has four parameters.
 
 
 \begin{figure}[p]
+\begin{tcolorbox}[colback=white]      
 \begin{tikzpicture}[baseline=(current  bounding  box.center)]
 \node (Lfun) at (0,2)  {\large \LangLoop{}};
 \node (Lfun-2) at (3,2)  {\large \LangLoop{}};
@@ -10814,7 +10833,7 @@ The \code{analyze\_dataflow} function has four parameters.
 %\node (F1-3) at (6,0)  {\large \LangLoopFunRef{}};
 \node (F1-4) at (6,2)  {\large \LangLoop{}};
 \node (F1-5) at (9,2)  {\large \LangLoop{}};
-\node (F1-6) at (12,2)  {\large \LangLoopANF{}};
+\node (F1-6) at (9,0)  {\large \LangLoopANF{}};
 \node (C3-2) at (3,0)  {\large \racket{\LangCLoop{}}\python{\LangCIf{}}};
 
 \node (x86-2) at (3,-2)  {\large \LangXIfVar{}};
@@ -10843,9 +10862,9 @@ The \code{analyze\_dataflow} function has four parameters.
 %%      {\ttfamily\footnotesize expose-alloc.} (F1-4);
 \path[->,bend left=15] (F1-4) edge [above] node
      {\ttfamily\footnotesize uncover\_get!} (F1-5);
-\path[->,bend left=15] (F1-5) edge [above] node
+\path[->,bend left=15] (F1-5) edge [right] node
      {\ttfamily\footnotesize remove\_complex.} (F1-6);
-\path[->,bend left=15] (F1-6) edge [right] node
+\path[->,bend right=15] (F1-6) edge [above] node
      {\ttfamily\footnotesize explicate\_control} (C3-2);
 \path[->,bend left=15] (C3-2) edge [left] node
      {\ttfamily\footnotesize select\_instr.} (x86-2);
@@ -10857,9 +10876,12 @@ The \code{analyze\_dataflow} function has four parameters.
      {\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-4) edge [right] node {\ttfamily\footnotesize prelude\_and\_concl.} (x86-5);
+\path[->,bend left=15] (x86-4) edge [right] node
+     {\ttfamily\footnotesize pre.\_and\_concl.} (x86-5);
 \end{tikzpicture}
-  \caption{Diagram of the passes for \LangLoop{}.}
+\end{tcolorbox}
+
+\caption{Diagram of the passes for \LangLoop{}.}
 \label{fig:Lwhile-passes}
 \end{figure}