updated
authorChristian Urban <christian.urban@kcl.ac.uk>
Wed, 18 Nov 2020 12:18:33 +0000
changeset 808 ba3edaf7dc49
parent 807 9fa90c73c6f3
child 809 2b9956d29038
updated
progs/while/test-small.j
slides/slides07.pdf
slides/slides07.tex
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/progs/while/test-small.j	Wed Nov 18 12:18:33 2020 +0000
@@ -0,0 +1,20 @@
+.class public test.test
+.super java/lang/Object
+
+.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
+
+.method public static main([Ljava/lang/String;)V
+   .limit locals 200
+   .limit stack 200
+
+   bipush 8
+   invokestatic test/test/write(I)V 
+   return
+.end method
\ No newline at end of file
Binary file slides/slides07.pdf has changed
--- a/slides/slides07.tex	Wed Nov 18 01:54:03 2020 +0000
+++ b/slides/slides07.tex	Wed Nov 18 12:18:33 2020 +0000
@@ -81,11 +81,40 @@
   \draw [->,line width=4mm] (B) -- (C); 
   \draw [->,line width=4mm] (C) -- (1); 
   \end{tikzpicture}
+  \end{center}\pause
+
+  \begin{center}
+\begin{tikzpicture}[scale=1,font=\bf,
+                      node/.style={
+                      rectangle,rounded corners=3mm,
+                      ultra thick,draw=black!50,minimum height=18mm, 
+                      minimum width=20mm,
+                      top color=white,bottom color=black!20}]
+
+  \node (0) at (-3,0) {};  
+  \node (A) at (0,0) [node,text width=1.6cm,text centered] {\small{}our compiler};
+  \node (B) at (3.5,0) [node,text width=1.6cm,text centered] {\small{}Jasmin / Krakatau};
+  \node (C) at (7.5,0) [node] {JVM};
+ 
+  \draw [->,line width=2.5mm] (0) -- node [above,pos=0.35] {*.while} (A); 
+  \draw [->,line width=2.5mm] (A) -- node [above,pos=0.35] {*.j} (B); 
+  \draw [->,line width=2.5mm] (B) -- node [above,pos=0.35] {*.class} (C); 
+  \end{tikzpicture}
   \end{center}
-  
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+\frametitle{Test Program}
+
+\mbox{}\\[-18mm]\mbox{}
+
+{\lstset{language=While}\fontsize{10}{12}\selectfont
+\texttt{\lstinputlisting{../progs/while-tests/loops.while}}}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -122,117 +151,117 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  
  
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[t]
+%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[t]
 
-\begin{center}
-\bl{\begin{tabular}{@{}lcl@{}}
-\\[-12mm]        
-\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@{}}
+% \\[-12mm]        
+% \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}[c]
-\frametitle{\begin{tabular}{c}Fibonacci Numbers\end{tabular}}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c]
+% \frametitle{\begin{tabular}{c}Fibonacci Numbers\end{tabular}}
 
-\mbox{}\\[-18mm]\mbox{}
-??
-%{\lstset{language=While}\fontsize{10}{12}\selectfont
-%\texttt{\lstinputlisting{../progs/fib.while}}}
+% \mbox{}\\[-18mm]\mbox{}
+% ??
+% %{\lstset{language=While}\fontsize{10}{12}\selectfont
+% %\texttt{\lstinputlisting{../progs/fib.while}}}
 
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
-\frametitle{Interpreter}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c]
+% \frametitle{Interpreter}
 
-\begin{center}
-\bl{\begin{tabular}{@{}lcl@{}}
-$\text{eval}(n, E)$ & $\dn$ & $n$\\
-$\text{eval}(x, E)$ & $\dn$ & $E(x)$ \;\;\;\textcolor{black}{lookup \bl{$x$} in \bl{$E$}}\\
-$\text{eval}(a_1 + a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) + \text{eval}(a_2, E)$\\
-$\text{eval}(a_1 - a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) - \text{eval}(a_2, E)$\\
-$\text{eval}(a_1 * a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) * \text{eval}(a_2, E)$\bigskip\\
-$\text{eval}(a_1 = a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) = \text{eval}(a_2, E)$\\
-$\text{eval}(a_1\,!\!= a_2, E)$ & $\dn$ & $\neg(\text{eval}(a_1, E) = \text{eval}(a_2, E))$\\
-$\text{eval}(a_1 < a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) < \text{eval}(a_2, E)$\
-\end{tabular}}
-\end{center}
+% \begin{center}
+% \bl{\begin{tabular}{@{}lcl@{}}
+% $\text{eval}(n, E)$ & $\dn$ & $n$\\
+% $\text{eval}(x, E)$ & $\dn$ & $E(x)$ \;\;\;\textcolor{black}{lookup \bl{$x$} in \bl{$E$}}\\
+% $\text{eval}(a_1 + a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) + \text{eval}(a_2, E)$\\
+% $\text{eval}(a_1 - a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) - \text{eval}(a_2, E)$\\
+% $\text{eval}(a_1 * a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) * \text{eval}(a_2, E)$\bigskip\\
+% $\text{eval}(a_1 = a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) = \text{eval}(a_2, E)$\\
+% $\text{eval}(a_1\,!\!= a_2, E)$ & $\dn$ & $\neg(\text{eval}(a_1, E) = \text{eval}(a_2, E))$\\
+% $\text{eval}(a_1 < a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) < \text{eval}(a_2, E)$\
+% \end{tabular}}
+% \end{center}
 
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
-\frametitle{Interpreter (2)}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c]
+% \frametitle{Interpreter (2)}
 
-\begin{center}
-\bl{\begin{tabular}{@{}lcl@{}}
-$\text{eval}(\text{skip}, E)$ & $\dn$ & $E$\\
-$\text{eval}(x:=a, E)$ & $\dn$ & \bl{$E(x \mapsto \text{eval}(a, E))$}\\
-\multicolumn{3}{@{}l@{}}{$\text{eval}(\text{if}\;b\;\text{then}\;cs_1\;\text{else}\;cs_2 , E) \dn$}\\
-\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)\;\text{then}\;
-\text{eval}(cs_1,E)$}\\
-\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\phantom{\text{if}\;\text{eval}(b,E)\;}\text{else}\;\text{eval}(cs_2,E)$}\\
-\multicolumn{3}{@{}l@{}}{$\text{eval}(\text{while}\;b\;\text{do}\;cs, E) \dn$}\\
-\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)$}\\
-\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{then}\;
-\text{eval}(\text{while}\;b\;\text{do}\;cs, \text{eval}(cs,E))$}\\
-\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\
-$\text{eval}(\text{write}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\
-\end{tabular}}
-\end{center}
+% \begin{center}
+% \bl{\begin{tabular}{@{}lcl@{}}
+% $\text{eval}(\text{skip}, E)$ & $\dn$ & $E$\\
+% $\text{eval}(x:=a, E)$ & $\dn$ & \bl{$E(x \mapsto \text{eval}(a, E))$}\\
+% \multicolumn{3}{@{}l@{}}{$\text{eval}(\text{if}\;b\;\text{then}\;cs_1\;\text{else}\;cs_2 , E) \dn$}\\
+% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)\;\text{then}\;
+% \text{eval}(cs_1,E)$}\\
+% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\phantom{\text{if}\;\text{eval}(b,E)\;}\text{else}\;\text{eval}(cs_2,E)$}\\
+% \multicolumn{3}{@{}l@{}}{$\text{eval}(\text{while}\;b\;\text{do}\;cs, E) \dn$}\\
+% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)$}\\
+% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{then}\;
+% \text{eval}(\text{while}\;b\;\text{do}\;cs, \text{eval}(cs,E))$}\\
+% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\
+% $\text{eval}(\text{write}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\
+% \end{tabular}}
+% \end{center}
 
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+% \end{frame}
+% %%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
-\frametitle{Test Program}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c]
+% \frametitle{Test Program}
 
-\mbox{}\\[-18mm]\mbox{}
+% \mbox{}\\[-18mm]\mbox{}
 
-??
-%{\lstset{language=While}\fontsize{10}{12}\selectfont
-%\texttt{\lstinputlisting{../progs/loops.while}}}
+% {\lstset{language=While}\fontsize{10}{12}\selectfont
+% \texttt{\lstinputlisting{../progs/while-tests/loops.while}}}
 
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
-\fontsize{7}{9}\selectfont
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \begin{frame}[c]
+% \fontsize{7}{9}\selectfont
 
 
-\begin{columns}
-\begin{column}{7cm} 
-\lstinputlisting[numbers=none]{../progs/appHa.j}
-\end{column}
+% \begin{columns}
+% \begin{column}{7cm} 
+% \lstinputlisting[numbers=none]{../progs/appHa.j}
+% \end{column}
 
-\begin{column}{7cm} 
-\lstinputlisting[numbers=none]{../progs/appHb.j}
-\end{column}
-\end{columns}
+% \begin{column}{7cm} 
+% \lstinputlisting[numbers=none]{../progs/appHb.j}
+% \end{column}
+% \end{columns}
 
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+% \end{frame}
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %\begin{frame}[t]