Explorar o código

diagrams for python

Jeremy Siek %!s(int64=2) %!d(string=hai) anos
pai
achega
0d4b44776b
Modificáronse 1 ficheiros con 195 adicións e 93 borrados
  1. 195 93
      book.tex

+ 195 - 93
book.tex

@@ -16727,22 +16727,20 @@ $58$ from the tag.}
 {\if\edition\pythonEd
 \begin{tikzpicture}[baseline=(current  bounding  box.center),scale=0.85]
 \node (Lfun) at (0,2)  {\large \LangLam{}};
-\node (Lfun-2) at (3,2)  {\large \LangLam{}};
-\node (Lfun-3) at (6,2)  {\large \LangLam{}};
-\node (F1-0) at (9,2)  {\large \LangLamFunRef{}};
-\node (F1-1) at (12,2)  {\large \LangLamFunRef{}};
-\node (F1-2) at (9,0)  {\large \LangFunRef{}};
-\node (F1-3) at (6,0)  {\large \LangFunRef{}};
-\node (F1-5) at (3,0)  {\large \LangFunRefAlloc{}};
-\node (F1-6) at (0,0)  {\large \LangFunANF{}};
-\node (C3-2) at (0,-2)  {\large \LangCFun{}};
+\node (Lfun-2) at (4,2)  {\large \LangLam{}};
+\node (Lfun-3) at (8,2)  {\large \LangLam{}};
+\node (F1-0) at (12,2)  {\large \LangLamFunRef{}};
+\node (F1-1) at (12,0)  {\large \LangLamFunRef{}};
+\node (F1-2) at (8,0)  {\large \LangFunRef{}};
+\node (F1-3) at (4,0)  {\large \LangFunRef{}};
+\node (F1-5) at (0,0)  {\large \LangFunRefAlloc{}};
+\node (F1-6) at (0,-2)  {\large \LangFunANF{}};
+\node (C3-2) at (0,-4)  {\large \LangCFun{}};
 
-\node (x86-2) at (0,-4)  {\large \LangXIndCallVar{}};
-\node (x86-2-1) at (0,-6)  {\large \LangXIndCallVar{}};
-\node (x86-2-2) at (3,-6)  {\large \LangXIndCallVar{}};
-\node (x86-3) at (3,-4)  {\large \LangXIndCallVar{}};
-\node (x86-4) at (6,-4) {\large \LangXIndCall{}};
-\node (x86-5) at (6,-6) {\large \LangXIndCall{}};
+\node (x86-2) at (0,-6)  {\large \LangXIndCallVar{}};
+\node (x86-3) at (4,-6)  {\large \LangXIndCallVar{}};
+\node (x86-4) at (8,-6) {\large \LangXIndCall{}};
+\node (x86-5) at (12,-6) {\large \LangXIndCall{}};
 
 \path[->,bend left=15] (Lfun) edge [above] node
      {\ttfamily\footnotesize shrink} (Lfun-2);
@@ -16750,29 +16748,25 @@ $58$ from the tag.}
      {\ttfamily\footnotesize uniquify} (Lfun-3);
 \path[->,bend left=15] (Lfun-3) edge [above] node
      {\ttfamily\footnotesize reveal\_functions} (F1-0);
-\path[->,bend left=15] (F1-0) edge [above] node
-     {\ttfamily\footnotesize convert\_assign.} (F1-1);
-\path[->,bend left=15] (F1-1) edge [left] node
-     {\ttfamily\footnotesize convert\_to\_clos.} (F1-2);
+\path[->,bend left=15] (F1-0) edge [left] node
+     {\ttfamily\footnotesize convert\_assignments} (F1-1);
+\path[->,bend left=15] (F1-1) edge [below] node
+     {\ttfamily\footnotesize convert\_to\_closures} (F1-2);
 \path[->,bend left=15] (F1-2) edge [below] node
-     {\ttfamily\footnotesize limit\_fun.} (F1-3);
+     {\ttfamily\footnotesize limit\_functions} (F1-3);
 \path[->,bend right=15] (F1-3) edge [above] node
-     {\ttfamily\footnotesize expose\_alloc.} (F1-5);
-\path[->,bend right=15] (F1-5) edge [above] node
-     {\ttfamily\footnotesize remove\_complex.} (F1-6);
-\path[->,bend right=15] (F1-6) edge [right] node
+     {\ttfamily\footnotesize expose\_allocation} (F1-5);
+\path[->,bend right=15] (F1-5) edge [right] node
+     {\ttfamily\footnotesize remove\_complex\_operands} (F1-6);
+\path[->,bend left=15] (F1-6) edge [right] node
      {\ttfamily\footnotesize explicate\_control} (C3-2);
-\path[->,bend left=15] (C3-2) edge [right] node
-     {\ttfamily\footnotesize select\_instr.} (x86-2);
-\path[->,bend right=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);
-\path[->,bend left=15] (x86-3) edge [above] node
-     {\ttfamily\footnotesize patch\_instr.} (x86-4);
-\path[->,bend left=15] (x86-4) edge [right] node
+\path[->,bend right=15] (C3-2) edge [right] node
+     {\ttfamily\footnotesize select\_instructions} (x86-2);
+\path[->,bend right=15] (x86-2) edge [below] node
+     {\ttfamily\footnotesize assign\_homes} (x86-3);
+\path[->,bend right=15] (x86-3) edge [below] node
+     {\ttfamily\footnotesize patch\_instructions} (x86-4);
+\path[->,bend left=15] (x86-4) edge [above] node
      {\ttfamily\footnotesize prelude\_and\_conclusion} (x86-5);
 \end{tikzpicture}
 \fi}
@@ -18846,8 +18840,9 @@ completion without error.
 
 
 \begin{figure}[p]
-  \begin{tcolorbox}[colback=white]
-    \begin{tikzpicture}[baseline=(current  bounding  box.center),scale=0.85]
+\begin{tcolorbox}[colback=white]
+{\if\edition\racketEd    
+\begin{tikzpicture}[baseline=(current  bounding  box.center),scale=0.85]
 \node (Lfun) at (0,4)  {\large \LangDyn{}};
 \node (Lfun-2) at (4,4)  {\large \LangDyn{}};
 \node (Lfun-3) at (8,4)  {\large \LangDyn{}};
@@ -18908,6 +18903,60 @@ completion without error.
 \path[->,bend left=15] (x86-4) edge [right] node
      {\ttfamily\footnotesize prelude\_and\_conclusion} (x86-5);
 \end{tikzpicture}
+\fi}
+{\if\edition\pythonEd
+\begin{tikzpicture}[baseline=(current  bounding  box.center),scale=0.85]
+\node (Lfun) at (0,4)  {\large \LangDyn{}};
+\node (Lfun-2) at (4,4)  {\large \LangDyn{}};
+\node (Lfun-3) at (8,4)  {\large \LangDyn{}};
+\node (Lfun-4) at (12,4)  {\large \LangDynFunRef{}};
+\node (Lfun-5) at (12,2)  {\large \LangAnyFunRef{}};
+\node (Lfun-6) at (8,2)  {\large \LangAnyFunRef{}};
+\node (Lfun-7) at (4,2)  {\large \LangAnyFunRef{}};
+
+\node (F1-2) at (0,2)  {\large \LangAnyFunRef{}};
+\node (F1-3) at (0,0)  {\large \LangAnyFunRef{}};
+\node (F1-5) at (4,0)  {\large \LangAnyAlloc{}};
+\node (F1-6) at (8,0)  {\large \LangAnyAlloc{}};
+\node (C3-2) at (0,-2)  {\large \LangCAny{}};
+
+\node (x86-2) at (0,-4)  {\large \LangXIndCallVar{}};
+\node (x86-3) at (4,-4)  {\large \LangXIndCallVar{}};
+\node (x86-4) at (8,-4) {\large \LangXIndCall{}};
+\node (x86-5) at (12,-4) {\large \LangXIndCall{}};
+
+\path[->,bend left=15] (Lfun) edge [above] node
+     {\ttfamily\footnotesize shrink} (Lfun-2);
+\path[->,bend left=15] (Lfun-2) edge [above] node
+     {\ttfamily\footnotesize uniquify} (Lfun-3);
+\path[->,bend left=15] (Lfun-3) edge [above] node
+     {\ttfamily\footnotesize reveal\_functions} (Lfun-4);
+\path[->,bend left=15] (Lfun-4) edge [left] node
+     {\ttfamily\footnotesize cast\_insert} (Lfun-5);
+\path[->,bend left=15] (Lfun-5) edge [below] node
+     {\ttfamily\footnotesize reveal\_casts} (Lfun-6);
+\path[->,bend right=15] (Lfun-6) edge [above] node
+     {\ttfamily\footnotesize convert\_assignments} (Lfun-7);
+\path[->,bend right=15] (Lfun-7) edge [above] node
+     {\ttfamily\footnotesize convert\_to\_closures} (F1-2);
+\path[->,bend right=15] (F1-2) edge [right] node
+     {\ttfamily\footnotesize limit\_functions} (F1-3);
+\path[->,bend right=15] (F1-3) edge [below] node
+     {\ttfamily\footnotesize expose\_allocation} (F1-5);
+\path[->,bend left=15] (F1-5) edge [above] node
+     {\ttfamily\footnotesize remove\_complex\_operands} (F1-6);
+\path[->,bend left=15] (F1-6) edge [below] node
+     {\ttfamily\footnotesize explicate\_control} (C3-2);
+\path[->,bend right=15] (C3-2) edge [right] node
+     {\ttfamily\footnotesize select\_instructions} (x86-2);
+\path[->,bend right=15] (x86-2) edge [below] node
+     {\ttfamily\footnotesize assign\_homes} (x86-3);
+\path[->,bend right=15] (x86-3) edge [below] node
+     {\ttfamily\footnotesize patch\_instructions} (x86-4);
+\path[->,bend left=15] (x86-4) edge [above] node
+     {\ttfamily\footnotesize prelude\_and\_conclusion} (x86-5);
+\end{tikzpicture}
+\fi}
   \end{tcolorbox}
 
   \caption{Diagram of the passes for \LangDyn{}, a dynamically typed language.}
@@ -20830,7 +20879,8 @@ and \code{proxy\_vec\_length} functions.
 \end{exercise}
 
 \begin{figure}[p]
-\begin{tcolorbox}[colback=white]  
+\begin{tcolorbox}[colback=white]
+{\if\edition\racketEd    
 \begin{tikzpicture}[baseline=(current  bounding  box.center),scale=0.85]
 \node (Lgradual) at (0,4)  {\large \LangGrad{}};
 \node (Lgradual2) at (4,4)  {\large \LangGrad{}};
@@ -20899,6 +20949,67 @@ and \code{proxy\_vec\_length} functions.
      {\ttfamily\footnotesize patch\_instructions} (x86-4);
 \path[->,bend left=15] (x86-4) edge [right] node {\ttfamily\footnotesize prelude\_and\_conclusion} (x86-5);
 \end{tikzpicture}
+\fi}
+{\if\edition\pythonEd
+\begin{tikzpicture}[baseline=(current  bounding  box.center),scale=0.80]
+\node (Lgradual) at (0,4)  {\large \LangGrad{}};
+\node (Lgradual2) at (4,4)  {\large \LangGrad{}};
+\node (Lgradual3) at (8,4)  {\large \LangCast{}};
+\node (Lgradual4) at (12,4)  {\large \LangProxy{}};
+\node (Lgradualr) at (12,2)  {\large \LangPVec{}};
+\node (Lgradualp) at (8,2)  {\large \LangPVec{}};
+\node (Llambdapp) at (4,2)  {\large \LangPVec{}};
+\node (Llambdaproxy-4) at (0,2)  {\large \LangPVecFunRef{}};
+\node (Llambdaproxy-5) at (0,0)  {\large \LangPVecFunRef{}};
+\node (F1-1) at (4,0)  {\large \LangPVecFunRef{}};
+\node (F1-2) at (8,0)  {\large \LangPVecFunRef{}};
+\node (F1-3) at (12,0)  {\large \LangPVecFunRef{}};
+\node (F1-5) at (8,-2)  {\large \LangPVecAlloc{}};
+\node (F1-6) at (4,-2)  {\large \LangPVecAlloc{}};
+\node (C3-2) at (0,-2)  {\large \LangCLoopPVec{}};
+
+\node (x86-2) at (0,-4)  {\large \LangXIndCallVar{}};
+\node (x86-3) at (4,-4)  {\large \LangXIndCallVar{}};
+\node (x86-4) at (8,-4) {\large \LangXIndCall{}};
+\node (x86-5) at (12,-4) {\large \LangXIndCall{}};
+
+\path[->,bend left=15] (Lgradual) edge [above] node
+     {\ttfamily\footnotesize shrink} (Lgradual2);
+\path[->,bend left=15] (Lgradual2) edge [above] node
+     {\ttfamily\footnotesize uniquify} (Lgradual3);
+\path[->,bend left=15] (Lgradual3) edge [above] node
+     {\ttfamily\footnotesize reveal\_functions} (Lgradual4);
+\path[->,bend left=15] (Lgradual4) edge [left] node
+     {\ttfamily\footnotesize resolve} (Lgradualr);
+\path[->,bend left=15] (Lgradualr) edge [below] node
+     {\ttfamily\footnotesize cast\_insert} (Lgradualp);
+\path[->,bend right=15] (Lgradualp) edge [above] node
+     {\ttfamily\footnotesize lower\_casts} (Llambdapp);
+\path[->,bend right=15] (Llambdapp) edge [above] node
+     {\ttfamily\footnotesize differentiate\_proxies} (Llambdaproxy-4);
+\path[->,bend right=15] (Llambdaproxy-4) edge [right] node
+     {\ttfamily\footnotesize reveal\_casts} (Llambdaproxy-5);
+\path[->,bend right=15] (Llambdaproxy-5) edge [below] node
+     {\ttfamily\footnotesize convert\_assignments} (F1-1);
+\path[->,bend left=15] (F1-1) edge [above] node
+     {\ttfamily\footnotesize convert\_to\_closures} (F1-2);
+\path[->,bend left=15] (F1-2) edge [above] node
+     {\ttfamily\footnotesize limit\_functions} (F1-3);
+\path[->,bend left=15] (F1-3) edge [right] node
+     {\ttfamily\footnotesize expose\_allocation} (F1-5);
+\path[->,bend right=15] (F1-5) edge [above] node
+     {\ttfamily\footnotesize remove\_complex\_operands} (F1-6);
+\path[->,bend right=15] (F1-6) edge [above] node
+     {\ttfamily\footnotesize explicate\_control} (C3-2);
+\path[->,bend right=15] (C3-2) edge [right] node
+     {\ttfamily\footnotesize select\_instructions} (x86-2);
+\path[->,bend right=15] (x86-2) edge [below] node
+     {\ttfamily\footnotesize assign\_homes} (x86-3);
+\path[->,bend right=15] (x86-3) edge [below] node
+     {\ttfamily\footnotesize patch\_instructions} (x86-4);
+\path[->,bend left=15] (x86-4) edge [above] node {\ttfamily\footnotesize prelude\_and\_conclusion} (x86-5);
+\end{tikzpicture}
+\fi}
 \end{tcolorbox}
 
 \caption{Diagram of the passes for \LangGrad{} (gradual typing).}
@@ -22042,69 +22153,60 @@ annotations and the body.
 \fi
 \if\edition\pythonEd
 \begin{tikzpicture}[baseline=(current  bounding  box.center),scale=0.85]
-\node (Lgradual) at (12,4)  {\large \LangPoly{}};
-\node (Lgradual2) at (9,4)  {\large \LangPoly{}};
-\node (Lgradual3) at (6,4)  {\large \LangPoly{}};
-\node (Lgradual4) at (3,4)  {\large \LangPoly{}};
-\node (Lgradualr) at (0,4)  {\large \LangInst{}};
-\node (Llambdapp) at (0,2)  {\large \LangCast{}};
-\node (Llambdaproxy-4) at (3,2)  {\large \LangPVec{}};
-\node (Llambdaproxy-5) at (6,2)  {\large \LangPVec{}};
-\node (F1-1) at (9,2)  {\large \LangPVec{}};
-\node (F1-2) at (12,0)  {\large \LangPVec{}};
-\node (F1-3) at (9,0)  {\large \LangPVec{}};
-\node (F1-4) at (6,0)  {\large \LangPVecAlloc{}};
-\node (F1-5) at (3,0)  {\large \LangPVecAlloc{}};
-\node (F1-6) at (0,0)  {\large \LangPVecAlloc{}};
-\node (C3-2) at (3,-2)  {\large \LangCLoopPVec{}};
-
-\node (x86-2) at (3,-4)  {\large \LangXIndCallVar{}};
-\node (x86-2-1) at (3,-6)  {\large \LangXIndCallVar{}};
-\node (x86-2-2) at (6,-6)  {\large \LangXIndCallVar{}};
-\node (x86-3) at (6,-4)  {\large \LangXIndCallVar{}};
-\node (x86-4) at (9,-4) {\large \LangXIndCall{}};
-\node (x86-5) at (9,-6) {\large \LangXIndCall{}};
-
-
-\path[->,bend right=15] (Lgradual) edge [above] node
+\node (Lgradual) at (0,4)  {\large \LangPoly{}};
+\node (Lgradual2) at (4,4)  {\large \LangPoly{}};
+\node (Lgradual3) at (8,4)  {\large \LangPoly{}};
+\node (Lgradual4) at (12,4)  {\large \LangPoly{}};
+\node (Lgradualr) at (12,2)  {\large \LangInst{}};
+\node (Llambdapp) at (8,2)  {\large \LangCast{}};
+\node (Llambdaproxy-4) at (4,2)  {\large \LangPVec{}};
+\node (Llambdaproxy-5) at (0,2)  {\large \LangPVec{}};
+\node (F1-1) at (0,0)  {\large \LangPVec{}};
+\node (F1-2) at (4,0)  {\large \LangPVec{}};
+\node (F1-3) at (8,0)  {\large \LangPVec{}};
+\node (F1-5) at (12,0)  {\large \LangPVecAlloc{}};
+\node (F1-6) at (12,-2)  {\large \LangPVecAlloc{}};
+\node (C3-2) at (0,-2)  {\large \LangCLoopPVec{}};
+
+\node (x86-2) at (0,-4)  {\large \LangXIndCallVar{}};
+\node (x86-3) at (4,-4)  {\large \LangXIndCallVar{}};
+\node (x86-4) at (8,-4) {\large \LangXIndCall{}};
+\node (x86-5) at (12,-4) {\large \LangXIndCall{}};
+
+\path[->,bend left=15] (Lgradual) edge [above] node
      {\ttfamily\footnotesize shrink} (Lgradual2);
-\path[->,bend right=15] (Lgradual2) edge [above] node
+\path[->,bend left=15] (Lgradual2) edge [above] node
      {\ttfamily\footnotesize uniquify} (Lgradual3);
-\path[->,bend right=15] (Lgradual3) edge [above] node
+\path[->,bend left=15] (Lgradual3) edge [above] node
      {\ttfamily\footnotesize reveal\_functions} (Lgradual4);
-\path[->,bend right=15] (Lgradual4) edge [above] node
+\path[->,bend left=15] (Lgradual4) edge [left] node
      {\ttfamily\footnotesize resolve} (Lgradualr);
-\path[->,bend right=15] (Lgradualr) edge [right] node
+\path[->,bend left=15] (Lgradualr) edge [below] node
      {\ttfamily\footnotesize erase\_types} (Llambdapp);
-\path[->,bend right=15] (Llambdapp) edge [below] node
-     {\ttfamily\footnotesize differentiate.} (Llambdaproxy-4);
-\path[->,bend left=15] (Llambdaproxy-4) edge [above] node
+\path[->,bend right=15] (Llambdapp) edge [above] node
+     {\ttfamily\footnotesize differentiate\_proxies} (Llambdaproxy-4);
+\path[->,bend right=15] (Llambdaproxy-4) edge [above] node
      {\ttfamily\footnotesize reveal\_casts} (Llambdaproxy-5);
-\path[->,bend left=15] (Llambdaproxy-5) edge [above] node
+\path[->,bend right=15] (Llambdaproxy-5) edge [right] node
      {\ttfamily\footnotesize convert\_assignments} (F1-1);
-\path[->,bend left=15] (F1-1) edge [left] node
-     {\ttfamily\footnotesize convert\_to\_clos.} (F1-2);
-\path[->,bend left=15] (F1-2) edge [below] node
-     {\ttfamily\footnotesize limit\_fun.} (F1-3);
-\path[->,bend right=15] (F1-3) edge [above] node
-     {\ttfamily\footnotesize expose\_alloc.} (F1-4);
-\path[->,bend right=15] (F1-4) edge [above] node
-     {\ttfamily\footnotesize uncover\_get!} (F1-5);
-\path[->,bend right=15] (F1-5) edge [above] node
-     {\ttfamily\footnotesize remove\_complex.} (F1-6);
-\path[->,bend right=15] (F1-6) edge [right] node
+\path[->,bend right=15] (F1-1) edge [below] node
+     {\ttfamily\footnotesize convert\_to\_closures} (F1-2);
+\path[->,bend right=15] (F1-2) edge [below] node
+     {\ttfamily\footnotesize limit\_functions} (F1-3);
+\path[->,bend left=15] (F1-3) edge [above] node
+     {\ttfamily\footnotesize expose\_allocation} (F1-5);
+\path[->,bend left=15] (F1-5) edge [left] node
+     {\ttfamily\footnotesize remove\_complex\_operands} (F1-6);
+\path[->,bend left=5] (F1-6) edge [below] node
      {\ttfamily\footnotesize explicate\_control} (C3-2);
-\path[->,bend left=15] (C3-2) edge [left] node
-     {\ttfamily\footnotesize select\_instr.} (x86-2);
-\path[->,bend right=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-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-4) edge [right] node {\ttfamily\footnotesize prelude\_and\_conc.} (x86-5);
+\path[->,bend right=15] (C3-2) edge [right] node
+     {\ttfamily\footnotesize select\_instructions} (x86-2);
+\path[->,bend right=15] (x86-2) edge [below] node
+     {\ttfamily\footnotesize assign\_homes} (x86-3);
+\path[->,bend right=15] (x86-3) edge [below] node
+     {\ttfamily\footnotesize patch\_instructions} (x86-4);
+\path[->,bend left=15] (x86-4) edge [above] node
+     {\ttfamily\footnotesize prelude\_and\_conclusion} (x86-5);
 \end{tikzpicture}
 \fi
 \end{tcolorbox}