
diff -r fa2589ec0fae -r 1e88390e81aa slides/slides09.tex
--- a/slides/slides09.tex	Tue Nov 17 19:12:51 2015 +0000
+++ b/slides/slides09.tex	Wed Nov 18 01:53:01 2015 +0000
@@ -91,15 +91,15 @@
 \bl{
 \begin{plstx}[rhs style=]
 : \meta{Exp} ::= \meta{Var} | \meta{Num}{\hspace{3cm}}
-             |   \meta{Exp} + \meta{Exp} | ... | (\meta{ExP})
+             |   \meta{Exp} + \meta{Exp} | ... | (\meta{Exp})
              |   \code{if} \meta{BExp} \code{then} \meta{Exp} \code{else} \meta{Exp}
              |   \code{write} \meta{Exp} {\hspace{3cm}}
              |   \meta{Exp} ; \meta{Exp}
-             |   \textit{FunName} (\meta{Exp}, ..., \meta{Exp})\\
+             |   \textit{FunName} (\meta{Exp}, ... , \meta{Exp})\\
 : \meta{BExp} ::= ...\\
 : \meta{Decl} ::= \meta{Def} ; \meta{Decl}
              | \meta{Exp}\\
-: \meta{Def} ::= \code{def} \textit{FunName} ($\hspace{0.4mm}x_1$, ..., $x_2$)\\               
+: \meta{Def} ::= \code{def} \textit{FunName} ($\hspace{0.4mm}x_1$, ... , $x_n$) = \meta{Exp}\\               
 \end{plstx}}
 
 
@@ -107,15 +107,12 @@
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
-
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[c, fragile]
-\frametitle{Abstract Syntax Tree}
+\frametitle{Abstract Syntax Trees}
 
 \footnotesize
-\begin{textblock}{13}(0.3,2)
-\begin{lstlisting}[language=Scala,basicstyle=\ttfamily, numbers=none]
+\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
 abstract class Exp
 abstract class BExp 
 abstract class Decl
@@ -134,16 +131,15 @@
 case class Sequ(e1: Exp, e2: Exp) extends Exp
 case class Bop(o: String, a1: Exp, a2: Exp) extends BExp
 \end{lstlisting}
-\end{textblock}
 
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c, fragile]
-\frametitle{Mathematical Functions}
+\begin{frame}[c]
+\frametitle{Arithmetic Functions}
 
-Compilation of some mathematical functions:
+Compilation of some aritmetic functions:
 
 \begin{center}
 \begin{tabular}{lcl}
@@ -159,10 +155,10 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c, fragile]
+\begin{frame}[c]
 \frametitle{Boolean Expressions}
 
-Compilation of boolean expressions:
+Compilation of Boolean expressions:
 
 \begin{center}
 \begin{tikzpicture}[node distance=2mm and 4mm,
@@ -200,57 +196,37 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[t, fragile]
+\begin{frame}[c, fragile]
 \frametitle{Sequences}
 
-Compiling \texttt{arg1 ; arg2}:
+Compiling \texttt{arg1 ; arg2}:\bigskip
 
 
-\begin{textblock}{7}(2,5)\footnotesize
-\begin{minipage}{6cm}
-\begin{lstlisting}[language=JVMIS,basicstyle=\ttfamily, numbers=none]
+\begin{lstlisting}[language=JVMIS, numbers=none]
 ...arg1...
 pop
 ...arg1...
 \end{lstlisting}
-\end{minipage}
-\end{textblock}
-
   
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[t, fragile]
+\begin{frame}[c, fragile]
 \frametitle{Write}
 
-Compiling \texttt{write(arg)}:
+Compiling call to \texttt{write(arg)}:\bigskip
 
 
-\begin{textblock}{7}(2,4)\footnotesize
-\begin{minipage}{6cm}
-\begin{lstlisting}[language=JVMIS,basicstyle=\ttfamily, numbers=none]
+\begin{lstlisting}[language=JVMIS, numbers=none]
 ...arg...
 dup
 invokestatic XXX/XXX/write(I)V
-\end{lstlisting}
-\end{minipage}
-\end{textblock}
-
-
+\end{lstlisting}\bigskip
 
-\begin{textblock}{7}(2,8)\footnotesize
-\begin{minipage}{6cm}
-\begin{lstlisting}[language=Scala,basicstyle=\ttfamily, numbers=none]
-case Write(a1) => {
-    compile_exp(a1, env) ++
-    List("dup\n",
-         "invokestatic XXX/XXX/write(I)V\n")
-  }
-\end{lstlisting}
-\end{minipage}
-\end{textblock}
-  
+\small
+needs a helper function
+
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
@@ -258,37 +234,33 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[c, fragile]
-\frametitle{Functions}
+\frametitle{Function Definitions}
 
-\begin{textblock}{7}(1,2)\footnotesize
-\begin{minipage}{6cm}
-\begin{lstlisting}[language=JVMIS,basicstyle=\ttfamily, numbers=none]
+\footnotesize
+\begin{lstlisting}[language=JVMIS, 
+                   xleftmargin=2mm, 
+                   numbers=none]
 .method public static write(I)V 
-   .limit locals 5 
-   .limit stack 5 
+   .limit locals 1
+   .limit stack 2
+   getstatic java/lang/System/out Ljava/io/PrintStream; 
    iload 0 
-   getstatic java/lang/System/out Ljava/io/PrintStream; 
-   swap 
    invokevirtual java/io/PrintStream/println(I)V 
    return 
 .end method
-\end{lstlisting}
-\end{minipage}
-\end{textblock}
+\end{lstlisting}\bigskip
 
+\small We will need for definitions\footnotesize\medskip
 
-\begin{textblock}{10}(1,9.8)
-\small We will need for definitions\\[-8mm]\mbox{}\footnotesize
-\begin{center}
-\begin{lstlisting}[language=JVMIS,basicstyle=\ttfamily, numbers=none]
+\begin{lstlisting}[language=JVMIS, 
+                   xleftmargin=2mm, 
+                   numbers=none]
 .method public static f (I...I)I
   .limit locals ??
   .limit stack ?? 
   ??
 .end method
 \end{lstlisting}
-\end{center}
-\end{textblock}
 
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
@@ -302,19 +274,19 @@
 def max_stack_exp(e: Exp): Int = e match {
   case Call(_, args) => args.map(max_stack_exp).sum
   case If(a, e1, e2) => max_stack_bexp(a) + 
-  	(List(max_stack_exp(e1), max_stack_exp(e1)).max)
+    (List(max_stack_exp(e1), max_stack_exp(e1)).max)
   case Write(e) => max_stack_exp(e) + 1
   case Var(_) => 1
   case Num(_) => 1
   case Aop(_, a1, a2) => 
-  	max_stack_exp(a1) + max_stack_exp(a2)
+    max_stack_exp(a1) + max_stack_exp(a2)
   case Sequ(e1, e2) => 
-  	List(max_stack_exp(e1), max_stack_exp(e2)).max
+    List(max_stack_exp(e1), max_stack_exp(e2)).max
 }
 
 def max_stack_bexp(e: BExp): Int = e match {
   case Bop(_, a1, a2) => 
-  	max_stack_exp(a1) + max_stack_exp(a2)
+    max_stack_exp(a1) + max_stack_exp(a2)
 }
 \end{lstlisting}
 \end{center}
@@ -324,7 +296,7 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[fragile]
-\frametitle{Successor}
+\frametitle{Successor Function}
 
 \begin{textblock}{7}(1,2.5)\footnotesize
 \begin{minipage}{6cm}
@@ -357,9 +329,9 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[fragile]
-\frametitle{Addition}
+\frametitle{Addition Function}
 
-\begin{textblock}{7}(1,1.5)\footnotesize
+\begin{textblock}{7}(1,1.9)\footnotesize
 \begin{minipage}{6cm}
 \begin{lstlisting}[language=JVMIS,basicstyle=\ttfamily, numbers=none]
 .method public static add(II)I 
@@ -367,24 +339,24 @@
 .limit stack 6
   iload 0
   ldc 0
-  if_icmpne If_else_2
+  if_icmpne If_else
   iload 1
-  goto If_end_3
-If_else_2:
+  goto If_end
+If_else:
   iload 0
   ldc 1
   isub
   iload 1
-  invokestatic defs/defs/add(II)I
-  invokestatic defs/defs/suc(I)I
-If_end_3:
+  invokestatic XXX/XXX/add(II)I
+  invokestatic XXX/XXX/suc(I)I
+If_end:
   ireturn
 .end method
 \end{lstlisting}
 \end{minipage}
 \end{textblock}
 
-\begin{textblock}{7}(6,6.2)
+\begin{textblock}{7}(6,6.6)
 \begin{bubble}[7cm]\small
 \begin{lstlisting}[language=Lisp,
                    basicstyle=\ttfamily, 




