updated
authorChristian Urban <urbanc@in.tum.de>
Wed, 15 Nov 2017 08:12:03 +0000
changeset 535 095be64c03c1
parent 534 6937caaff1d9
child 536 594f8d2adae9
updated
progs/compile.scala
slides/slides08.pdf
slides/slides08.tex
--- a/progs/compile.scala	Wed Nov 15 00:28:25 2017 +0000
+++ b/progs/compile.scala	Wed Nov 15 08:12:03 2017 +0000
@@ -210,8 +210,6 @@
                Assign("n",Aop("-",Var("n"),Num(1))))), //  n := n - 1 };
        Write("minus1"))                 //  write minus1
 
-
-
 // prints out the JVM-assembly program
 
 println(compile(fib_test, "fib"))
@@ -235,14 +233,13 @@
   fw.close()
 }
 
-def compile_and_run(bl: Block, class_name: String) : Unit = {
+def compile_all(bl: Block, class_name: String) : Unit = {
   compile_tofile(bl, class_name)
   println("compiled ")
   val test = ("java -jar jvm/jasmin-2.4/jasmin.jar " + class_name + ".j").!!
   println("assembled ")
-  ("java " + class_name + "/" + class_name).!!
 }
 
 
-compile_and_run(fib_test, "fib")
+compile_all(fib_test, "fib")
 
Binary file slides/slides08.pdf has changed
--- a/slides/slides08.tex	Wed Nov 15 00:28:25 2017 +0000
+++ b/slides/slides08.tex	Wed Nov 15 08:12:03 2017 +0000
@@ -219,25 +219,45 @@
 
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[t]
+\begin{frame}[t,fragile]
 \frametitle{Compiling AExps}
 
-{\Large\bl{1 + 2}}
+For example \bl{$1 + ((2 * 3) + (4 - 3))$}:\medskip
 
+\begin{columns}[T]
+\begin{column}{.3\textwidth}
 \begin{center}
-\bl{\begin{tabular}{l}
-ldc 1\\
-ldc 2\\
-iadd\\
-\end{tabular}}
+\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
+
 \end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
 \begin{frame}[t]
 \frametitle{\begin{tabular}{c}Compiling AExps\end{tabular}}
 
@@ -253,7 +273,7 @@
 \end{tabular}}
 \end{center}
 
-\end{frame}}
+\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -848,7 +868,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \mode<presentation>{
 \begin{frame}[t]
-\frametitle{\begin{tabular}{c}What Next\end{tabular}}
+\frametitle{\begin{tabular}{c}What is Next\end{tabular}}
 
 \begin{itemize}
 \item register spilling
@@ -866,6 +886,48 @@
 \end{frame}}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+  \frametitle{Coursework: MkEps}
+
+\begin{center}
+\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
+  \bl{$mkeps([c_1 c_2 \ldots c_n])$}  & \bl{$\dn$} & $\bl{undefined}$\\
+  \bl{$mkeps(r^*)$}                   & \bl{$\dn$} & $\bl{Stars\,[]}$\\
+  \bl{$mkeps(r^{\{n\}})$}              & \bl{$\dn$} & $\bl{Stars\,(mkeps(r))^n}$\\
+  \bl{$mkeps(r^{\{n..\}})$}            & \bl{$\dn$} & $\bl{Stars\,(mkeps(r))^n}$\\
+  \bl{$mkeps(r^{\{..n\}})$}            & \bl{$\dn$} & $\bl{Stars\,[]}$\\
+  \bl{$mkeps(r^{\{n..m\}})$}           & \bl{$\dn$} & $\bl{Stars\,(mkeps(r))^n}$\medskip\\
+  
+  \bl{$mkeps(r^+)$}                   & \bl{$\dn$} & \bl{$mkeps(r^{\{1..\}})$}\\
+  \bl{$mkeps(r^?)$}                   & \bl{$\dn$} & \bl{$mkeps(r^{\{..1\}})$}\\
+\end{tabular}
+\end{center}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+  \frametitle{Coursework: Inj}
+
+\begin{center}
+\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
+  \bl{$inj([c_1 c_2 \ldots c_n])\,c\,Empty$}  & \bl{$\dn$} & $\bl{Chr\,c}$\\
+  \bl{$inj(r^*)\,c\;Seq\,v\,(Stars\,vs)$}                   & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\\
+  \bl{$inj(r^{\{n\}})\,c\;Seq\,v\,(Stars\,vs)$}              & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\\
+  \bl{$inj(r^{\{n..\}})\,c\;Seq\,v\,(Stars\,vs)$}            & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\\
+  \bl{$inj(r^{\{..n\}})\,c\;Seq\,v\,(Stars\,vs)$}            & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\\
+  \bl{$inj(r^{\{n..m\}})\,c\;Seq\,v\,(Stars\,vs)$}           & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\medskip\\
+  
+  \bl{$inj(r^+)\,c\,v$}                   & \bl{$\dn$} & \bl{$inj(r^{\{1..\}})\,c\,v$}\\
+  \bl{$inj(r^?)\,c\,v$}                   & \bl{$\dn$} & \bl{$inj(r^{\{..1\}})\,c\,v$}\\
+\end{tabular}
+\end{center}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
 
 \end{document}