slides/slides08.tex
changeset 813 059f970287d1
parent 744 99c5916d9a8f
child 814 1fbaa5f05516
--- a/slides/slides08.tex	Fri Nov 27 13:53:06 2020 +0000
+++ b/slides/slides08.tex	Tue Dec 01 05:41:12 2020 +0000
@@ -62,216 +62,216 @@
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c]
 
-\begin{center}
-\bl{\begin{tabular}{@{}lcl@{}}
-\meta{Stmt} & $::=$ &  $\texttt{skip}$\\
-              & $|$ & \textit{Id}\;\texttt{:=}\;\meta{AExp}\\
-              & $|$ & \texttt{if}\; \meta{BExp} \;\texttt{then}\; \meta{Block} \;\texttt{else}\; \meta{Block}\\
-              & $|$ & \texttt{while}\; \meta{BExp} \;\texttt{do}\; \meta{Block}\\
-              & $|$ & \texttt{read}\;\textit{Id}\\
-              & $|$ & \texttt{write}\;\textit{Id}\\
-              & $|$ & \texttt{write}\;\textit{String}\medskip\\
-\meta{Stmts} & $::=$ &  \meta{Stmt} \;\texttt{;}\; \meta{Stmts}\\
-              & $|$ & \meta{Stmt}\medskip\\
-\meta{Block} & $::=$ &  \texttt{\{}\,\meta{Stmts}\,\texttt{\}}\\
-                & $|$ & \meta{Stmt}\medskip\\
-\meta{AExp} & $::=$ & \ldots\\
-\meta{BExp} & $::=$ & \ldots\\
-\end{tabular}}
-\end{center}
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+% \begin{center}
+% \bl{\begin{tabular}{@{}lcl@{}}
+% \meta{Stmt} & $::=$ &  $\texttt{skip}$\\
+%               & $|$ & \textit{Id}\;\texttt{:=}\;\meta{AExp}\\
+%               & $|$ & \texttt{if}\; \meta{BExp} \;\texttt{then}\; \meta{Block} \;\texttt{else}\; \meta{Block}\\
+%               & $|$ & \texttt{while}\; \meta{BExp} \;\texttt{do}\; \meta{Block}\\
+%               & $|$ & \texttt{read}\;\textit{Id}\\
+%               & $|$ & \texttt{write}\;\textit{Id}\\
+%               & $|$ & \texttt{write}\;\textit{String}\medskip\\
+% \meta{Stmts} & $::=$ &  \meta{Stmt} \;\texttt{;}\; \meta{Stmts}\\
+%               & $|$ & \meta{Stmt}\medskip\\
+% \meta{Block} & $::=$ &  \texttt{\{}\,\meta{Stmts}\,\texttt{\}}\\
+%                 & $|$ & \meta{Stmt}\medskip\\
+% \meta{AExp} & $::=$ & \ldots\\
+% \meta{BExp} & $::=$ & \ldots\\
+% \end{tabular}}
+% \end{center}
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[t,fragile]
-\frametitle{Compiling AExps}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[t,fragile]
+% \frametitle{Compiling AExps}
 
-For example \bl{$1 + ((2 * 3) + (4 - 3))$}:\medskip
+% For example \bl{$1 + ((2 * 3) + (4 - 3))$}:\medskip
 
-\begin{columns}[T]
-\begin{column}{.3\textwidth}
-\begin{center}
-\bl{\begin{tikzpicture}
-\tikzset{level distance=12mm,sibling distance=4mm}
-\tikzset{edge from parent/.style={draw,very thick}}
-\Tree [.$+$ [.$1$ ] [.$+$ [.$*$ $2$ $3$ ] [.$-$ $4$ $3$ ]]]
-\end{tikzpicture}}
-\end{center}
-\end{column}
-\begin{column}{.3\textwidth}
-\begin{lstlisting}[language=JVMIS,numbers=none]
-ldc 1 
-ldc 2 
-ldc 3 
-imul 
-ldc 4 
-ldc 3 
-isub 
-iadd 
-iadd
-\end{lstlisting}
-\end{column}
-\end{columns}\bigskip
+% \begin{columns}[T]
+% \begin{column}{.3\textwidth}
+% \begin{center}
+% \bl{\begin{tikzpicture}
+% \tikzset{level distance=12mm,sibling distance=4mm}
+% \tikzset{edge from parent/.style={draw,very thick}}
+% \Tree [.$+$ [.$1$ ] [.$+$ [.$*$ $2$ $3$ ] [.$-$ $4$ $3$ ]]]
+% \end{tikzpicture}}
+% \end{center}
+% \end{column}
+% \begin{column}{.3\textwidth}
+% \begin{lstlisting}[language=JVMIS,numbers=none]
+% ldc 1 
+% ldc 2 
+% ldc 3 
+% imul 
+% ldc 4 
+% ldc 3 
+% isub 
+% iadd 
+% iadd
+% \end{lstlisting}
+% \end{column}
+% \end{columns}\bigskip
 
-\small
-Traverse tree in post-order \bl{$\Rightarrow$} code for 
-stack-machine
+% \small
+% Traverse tree in post-order \bl{$\Rightarrow$} code for 
+% stack-machine
 
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c,fragile]
-\frametitle{Compiling AExps}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c,fragile]
+% \frametitle{Compiling AExps}
 
-\bl{
-\begin{center}
-\begin{tabular}{lcl}
-$\textit{compile}(n, E)$ & $\dn$ & $\pcode{ldc}\;n$\smallskip\\
-$\textit{compile}(a_1 + a_2, E)$ & $\dn$ \\
-\multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\;\textit{compile}(a_2, E)\;@\; \pcode{iadd}$}\smallskip\\
-$\textit{compile}(a_1 - a_2, E)$ & $\dn$ \\
-\multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\; \textit{compile}(a_2, E)\;@\; \pcode{isub}$}\smallskip\\
-$\textit{compile}(a_1 * a_2, E)$ & $\dn$ \\
-\multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\; \textit{compile}(a_2, E)\;@\; \pcode{imul}$}\smallskip\\
-$\textit{compile}(a_1 \backslash a_2, E)$ & $\dn$\\ 
-\multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\; \textit{compile}(a_2, E)\;@\; \pcode{idiv}$}\smallskip\\
-$\textit{compile}(x, E)$ & $\dn$ & $\pcode{iload}\;E(x)$\\
-\end{tabular}
-\end{center}}
+% \bl{
+% \begin{center}
+% \begin{tabular}{lcl}
+% $\textit{compile}(n, E)$ & $\dn$ & $\pcode{ldc}\;n$\smallskip\\
+% $\textit{compile}(a_1 + a_2, E)$ & $\dn$ \\
+% \multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\;\textit{compile}(a_2, E)\;@\; \pcode{iadd}$}\smallskip\\
+% $\textit{compile}(a_1 - a_2, E)$ & $\dn$ \\
+% \multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\; \textit{compile}(a_2, E)\;@\; \pcode{isub}$}\smallskip\\
+% $\textit{compile}(a_1 * a_2, E)$ & $\dn$ \\
+% \multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\; \textit{compile}(a_2, E)\;@\; \pcode{imul}$}\smallskip\\
+% $\textit{compile}(a_1 \backslash a_2, E)$ & $\dn$\\ 
+% \multicolumn{3}{c}{$\qquad\textit{compile}(a_1, E) \;@\; \textit{compile}(a_2, E)\;@\; \pcode{idiv}$}\smallskip\\
+% $\textit{compile}(x, E)$ & $\dn$ & $\pcode{iload}\;E(x)$\\
+% \end{tabular}
+% \end{center}}
 
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c,fragile]
-\frametitle{Compiling Ifs}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c,fragile]
+% \frametitle{Compiling Ifs}
 
-For example
+% For example
 
-\begin{lstlisting}[mathescape,numbers=none,language=While]
-if 1 = 1 then x := 2 else y := 3
-\end{lstlisting}
+% \begin{lstlisting}[mathescape,numbers=none,language=While]
+% if 1 = 1 then x := 2 else y := 3
+% \end{lstlisting}
 
 
-\begin{center}
-\begin{lstlisting}[mathescape,language=JVMIS,numbers=none]
-   ldc 1
-   ldc 1
-   if_icmpne L_ifelse $\quad\tikz[remember picture] \node (C) {\mbox{}};$
-   ldc 2
-   istore 0
-   goto L_ifend $\quad\tikz[remember picture] \node (A) {\mbox{}};$
-L_ifelse: $\quad\tikz[remember picture] \node[] (D) {\mbox{}};$
-   ldc 3
-   istore 1
-L_ifend: $\quad\tikz[remember picture] \node[] (B) {\mbox{}};$
-\end{lstlisting}
-\end{center}
+% \begin{center}
+% \begin{lstlisting}[mathescape,language=JVMIS,numbers=none]
+%    ldc 1
+%    ldc 1
+%    if_icmpne L_ifelse $\quad\tikz[remember picture] \node (C) {\mbox{}};$
+%    ldc 2
+%    istore 0
+%    goto L_ifend $\quad\tikz[remember picture] \node (A) {\mbox{}};$
+% L_ifelse: $\quad\tikz[remember picture] \node[] (D) {\mbox{}};$
+%    ldc 3
+%    istore 1
+% L_ifend: $\quad\tikz[remember picture] \node[] (B) {\mbox{}};$
+% \end{lstlisting}
+% \end{center}
 
-\begin{tikzpicture}[remember picture,overlay]
-  \draw[->,very thick] (A) edge [->,to path={-- ++(10mm,0mm) 
-           -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (B.east);
-  \draw[->,very thick] (C) edge [->,to path={-- ++(10mm,0mm) 
-           -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (D.east);
-\end{tikzpicture}
+% \begin{tikzpicture}[remember picture,overlay]
+%   \draw[->,very thick] (A) edge [->,to path={-- ++(10mm,0mm) 
+%            -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (B.east);
+%   \draw[->,very thick] (C) edge [->,to path={-- ++(10mm,0mm) 
+%            -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (D.east);
+% \end{tikzpicture}
 
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c,fragile]
-\frametitle{Compiling Whiles}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c,fragile]
+% \frametitle{Compiling Whiles}
 
-For example
+% For example
 
-\begin{lstlisting}[mathescape,numbers=none,language=While]
-while x <= 10 do x := x + 1
-\end{lstlisting}
+% \begin{lstlisting}[mathescape,numbers=none,language=While]
+% while x <= 10 do x := x + 1
+% \end{lstlisting}
 
 
-\begin{center}
-\begin{lstlisting}[mathescape,language=JVMIS,numbers=none]
-L_wbegin: $\quad\tikz[remember picture] \node[] (LB) {\mbox{}};$
-   iload 0
-   ldc 10
-   if_icmpgt L_wend $\quad\tikz[remember picture] \node (LC) {\mbox{}};$
-   iload 0
-   ldc 1
-   iadd
-   istore 0
-   goto L_wbegin $\quad\tikz[remember picture] \node (LA) {\mbox{}};$
-L_wend: $\quad\tikz[remember picture] \node[] (LD) {\mbox{}};$
-\end{lstlisting}
-\end{center}
+% \begin{center}
+% \begin{lstlisting}[mathescape,language=JVMIS,numbers=none]
+% L_wbegin: $\quad\tikz[remember picture] \node[] (LB) {\mbox{}};$
+%    iload 0
+%    ldc 10
+%    if_icmpgt L_wend $\quad\tikz[remember picture] \node (LC) {\mbox{}};$
+%    iload 0
+%    ldc 1
+%    iadd
+%    istore 0
+%    goto L_wbegin $\quad\tikz[remember picture] \node (LA) {\mbox{}};$
+% L_wend: $\quad\tikz[remember picture] \node[] (LD) {\mbox{}};$
+% \end{lstlisting}
+% \end{center}
 
-\begin{tikzpicture}[remember picture,overlay]
-  \draw[->,very thick] (LA) edge [->,to path={-- ++(12mm,0mm) 
-           -- ++(0mm,17.3mm) |- (\tikztotarget)},line width=1mm] (LB.east);
-  \draw[->,very thick] (LC) edge [->,to path={-- ++(12mm,0mm) 
-           -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (LD.east);
-\end{tikzpicture}
+% \begin{tikzpicture}[remember picture,overlay]
+%   \draw[->,very thick] (LA) edge [->,to path={-- ++(12mm,0mm) 
+%            -- ++(0mm,17.3mm) |- (\tikztotarget)},line width=1mm] (LB.east);
+%   \draw[->,very thick] (LC) edge [->,to path={-- ++(12mm,0mm) 
+%            -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (LD.east);
+% \end{tikzpicture}
 
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c,fragile]
-\frametitle{Compiling Writes}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c,fragile]
+% \frametitle{Compiling Writes}
 
-\small
-\begin{lstlisting}[language=JVMIS,mathescape,
-                   numbers=none,xleftmargin=-6mm]
-.method public static write(I)V 
-  .limit locals 1 
-  .limit stack 2 
-  getstatic java/lang/System/out 
-                            Ljava/io/PrintStream; 
-  iload 0
-  invokevirtual java/io/PrintStream/println(I)V 
-  return 
-.end method
+% \small
+% \begin{lstlisting}[language=JVMIS,mathescape,
+%                    numbers=none,xleftmargin=-6mm]
+% .method public static write(I)V 
+%   .limit locals 1 
+%   .limit stack 2 
+%   getstatic java/lang/System/out 
+%                             Ljava/io/PrintStream; 
+%   iload 0
+%   invokevirtual java/io/PrintStream/println(I)V 
+%   return 
+% .end method
 
 
 
-iload $E(x)$ 
-invokestatic XXX/XXX/write(I)V
-\end{lstlisting}
+% iload $E(x)$ 
+% invokestatic XXX/XXX/write(I)V
+% \end{lstlisting}
 
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c,fragile]
-\frametitle{Compiling Main}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c,fragile]
+% \frametitle{Compiling Main}
 
-\footnotesize
-\begin{lstlisting}[language=JVMIS,mathescape,
-                   numbers=none,xleftmargin=-6mm]
-.class public XXX.XXX
-.super java/lang/Object
+% \footnotesize
+% \begin{lstlisting}[language=JVMIS,mathescape,
+%                    numbers=none,xleftmargin=-6mm]
+% .class public XXX.XXX
+% .super java/lang/Object
 
-.method public <init>()V
-    aload_0
-    invokenonvirtual java/lang/Object/<init>()V
-    return
-.end method
+% .method public <init>()V
+%     aload_0
+%     invokenonvirtual java/lang/Object/<init>()V
+%     return
+% .end method
 
-.method public static main([Ljava/lang/String;)V
-    .limit locals 200
-    .limit stack 200
+% .method public static main([Ljava/lang/String;)V
+%     .limit locals 200
+%     .limit stack 200
 
-      $\textit{\ldots{}here comes the compiled code\ldots}$
+%       $\textit{\ldots{}here comes the compiled code\ldots}$
 
-    return
-.end method
-\end{lstlisting}
+%     return
+% .end method
+% \end{lstlisting}
 
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%