slides/slides07.tex
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sun, 15 Nov 2015 21:31:31 +0000
changeset 369 43c0ed473720
parent 302 0fa7b4221745
child 370 a65767fe5d71
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
\documentclass[dvipsnames,14pt,t]{beamer}
302
0fa7b4221745 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
     2
\usepackage{../slides}
215
828303e8e4af updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 188
diff changeset
     3
\usepackage{../langs}
828303e8e4af updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 188
diff changeset
     4
\usepackage{../data}
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
     5
\usepackage{../graphics}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
     6
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
% beamer stuff 
302
0fa7b4221745 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
     8
\renewcommand{\slidecaption}{AFL 07, King's College London}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
\newcommand{\bl}[1]{\textcolor{blue}{#1}}       
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
\begin{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
302
0fa7b4221745 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    14
\begin{frame}[t]
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
\frametitle{%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
  \begin{tabular}{@ {}c@ {}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
  \\[-3mm]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
  \LARGE Automata and \\[-2mm] 
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    19
  \LARGE Formal Languages (8)\\[3mm] 
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
  \end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
  \normalsize
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
  \begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
  \begin{tabular}{ll}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
  Email:  & christian.urban at kcl.ac.uk\\
173
7cfb7a6f7c99 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    26
  Office: & S1.27 (1st floor Strand Building)\\
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
  Slides: & KEATS (also home work is there)\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
  \end{tabular}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  \end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
302
0fa7b4221745 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    31
\end{frame}
0fa7b4221745 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    32
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
\begin{frame}[c]
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    36
\frametitle{Bird's Eye View}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
\begin{center}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    39
\begin{tikzpicture}
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    40
\node (rexp)  {\bl{\bf Lexer}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    41
\node (nfa) [right=of rexp] {\bl{\bf Parser}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    42
\node (dfa) [right=of nfa] 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    43
 {\bl{\begin{tabular}{c}\bf Machine Code/\\\bf Java Byte Code\end{tabular}}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    44
\path[->, red, line width=2mm] (rexp) edge node [above=4mm, black] {\begin{tabular}{c@{\hspace{9mm}}}token\\[-1mm]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    45
sequence\end{tabular}} (nfa);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    46
\path[->, red, line width=2mm] (nfa) edge node [above=4mm, black] {\begin{tabular}{c}parse\\[-1mm] tree\end{tabular}}(dfa);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    47
\end{tikzpicture}\\
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    48
\end{center}
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    49
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    50
\end{frame}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    51
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    52
 
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    53
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
185
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
    54
\begin{frame}[c]
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    55
\begin{textblock}{10}(0.5,0.5)
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    56
  \LARGE
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    57
  \fontspec{Hoefler Text Black}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    58
  \textcolor{ProcessBlue}{JVM\\ Code}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    59
\end{textblock}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    60
\fontsize{8}{10}\selectfont
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    61
%\footnotesize
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    62
\mbox{}\\[-8mm]\mbox{}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
    63
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    64
\begin{columns}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    65
\begin{column}{2cm} 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    66
\lstinputlisting[numbers=none]{../progs/appHa.j}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    67
\end{column}
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    68
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    69
\begin{column}{2cm} 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    70
\lstinputlisting[numbers=none]{../progs/appHb.j}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    71
\end{column}
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    72
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    73
\end{columns}
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    74
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    75
\end{frame}
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    76
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    77
 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    78
 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
    79
 
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    80
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    81
\mode<presentation>{
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    82
\begin{frame}[c]
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
    83
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    84
\begin{center}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
    85
\bl{\begin{tabular}{@{}lcl@{}}
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    86
\textit{Stmt} & $\rightarrow$ &  $\texttt{skip}$\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    87
              & $|$ & \textit{Id}\;\texttt{:=}\;\textit{AExp}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    88
              & $|$ & \texttt{if}\; \textit{BExp} \;\texttt{then}\; \textit{Block} \;\texttt{else}\; \textit{Block}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    89
              & $|$ & \texttt{while}\; \textit{BExp} \;\texttt{do}\; \textit{Block}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    90
              & $|$ & \texttt{read}\;\textit{Id}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    91
              & $|$ & \texttt{write}\;\textit{Id}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    92
              & $|$ & \texttt{write}\;\textit{String}\medskip\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    93
\textit{Stmts} & $\rightarrow$ &  \textit{Stmt} \;\texttt{;}\; \textit{Stmts}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    94
              & $|$ & \textit{Stmt}\medskip\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    95
\textit{Block} & $\rightarrow$ &  \texttt{\{}\,\textit{Stmts}\,\texttt{\}}\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    96
                & $|$ & \textit{Stmt}\medskip\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    97
\textit{AExp} & $\rightarrow$ & \ldots\\
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
    98
\textit{BExp} & $\rightarrow$ & \ldots\\
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
    99
\end{tabular}}
187
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   100
\end{center}
9471a0325773 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 186
diff changeset
   101
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   102
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   103
\end{frame}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   104
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   105
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   106
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   107
\begin{frame}[c]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   108
\frametitle{\begin{tabular}{c}Fibonacci Numbers\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   109
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   110
\mbox{}\\[-18mm]\mbox{}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   111
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   112
{\lstset{language=While}\fontsize{10}{12}\selectfont
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   113
\texttt{\lstinputlisting{../progs/fib.while}}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   114
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   115
\end{frame}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   116
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   117
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   118
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   119
\begin{frame}[c]
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   120
\frametitle{Interpreter}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   121
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
\begin{center}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   123
\bl{\begin{tabular}{@{}lcl@{}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   124
$\text{eval}(n, E)$ & $\dn$ & $n$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   125
$\text{eval}(x, E)$ & $\dn$ & $E(x)$ \;\;\;\textcolor{black}{lookup \bl{$x$} in \bl{$E$}}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   126
$\text{eval}(a_1 + a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) + \text{eval}(a_2, E)$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   127
$\text{eval}(a_1 - a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) - \text{eval}(a_2, E)$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   128
$\text{eval}(a_1 * a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) * \text{eval}(a_2, E)$\bigskip\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   129
$\text{eval}(a_1 = a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) = \text{eval}(a_2, E)$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   130
$\text{eval}(a_1\,!\!= a_2, E)$ & $\dn$ & $\neg(\text{eval}(a_1, E) = \text{eval}(a_2, E))$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   131
$\text{eval}(a_1 < a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) < \text{eval}(a_2, E)$\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   132
\end{tabular}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   135
\end{frame}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   137
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
\begin{frame}[c]
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   140
\frametitle{Interpreter (2)}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
\begin{center}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   143
\bl{\begin{tabular}{@{}lcl@{}}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   144
$\text{eval}(\text{skip}, E)$ & $\dn$ & $E$\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   145
$\text{eval}(x:=a, E)$ & $\dn$ & \bl{$E(x \mapsto \text{eval}(a, E))$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   146
\multicolumn{3}{@{}l@{}}{$\text{eval}(\text{if}\;b\;\text{then}\;cs_1\;\text{else}\;cs_2 , E) \dn$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   147
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)\;\text{then}\;
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   148
\text{eval}(cs_1,E)$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   149
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\phantom{\text{if}\;\text{eval}(b,E)\;}\text{else}\;\text{eval}(cs_2,E)$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   150
\multicolumn{3}{@{}l@{}}{$\text{eval}(\text{while}\;b\;\text{do}\;cs, E) \dn$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   151
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   152
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{then}\;
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   153
\text{eval}(\text{while}\;b\;\text{do}\;cs, \text{eval}(cs,E))$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   154
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   155
$\text{eval}(\text{write}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   159
\end{frame}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   160
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   161
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   162
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   163
\begin{frame}[c]
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   164
\frametitle{Test Program}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   165
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   166
\mbox{}\\[-18mm]\mbox{}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   167
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   168
{\lstset{language=While}\fontsize{10}{12}\selectfont
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   169
\texttt{\lstinputlisting{../progs/loops.while}}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   171
\end{frame}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   175
\begin{frame}[c]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   176
\fontsize{7}{9}\selectfont
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   177
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   178
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   179
\begin{columns}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   180
\begin{column}{7cm} 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   181
\lstinputlisting[numbers=none]{../progs/appHa.j}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   182
\end{column}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   183
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   184
\begin{column}{7cm} 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   185
\lstinputlisting[numbers=none]{../progs/appHb.j}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   186
\end{column}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   187
\end{columns}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   188
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   189
\end{frame}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   190
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   191
 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   192
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   193
\begin{frame}[t]
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   194
\frametitle{Interpreted Code}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
\begin{center}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   197
\begin{tikzpicture}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   198
\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   199
\addplot+[smooth] file {interpreted.data};
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   200
\end{axis}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   201
\end{tikzpicture}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   202
\end{center}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   204
\end{frame}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   205
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   207
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   208
\begin{frame}[c]
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   209
\frametitle{Java Virtual Machine}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   210
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   211
\begin{itemize}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   212
\item introduced in 1995
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   213
\item is a stack-based VM (like Postscript, CLR of .Net)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   214
\item contains a JIT compiler
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   215
\item many languages take advantage of JVM's infrastructure (JRE)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   216
\item is garbage collected $\Rightarrow$ no buffer overflows
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   217
\item some languages compiled to the JVM: Scala, Clojure\ldots
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   218
\end{itemize}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   219
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   220
\end{frame}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   221
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   222
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   223
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   224
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   225
\frametitle{Compiling AExps}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   226
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   227
{\Large\bl{1 + 2}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   228
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   229
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   230
\bl{\begin{tabular}{l}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   231
ldc 1\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   232
ldc 2\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   233
iadd\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   234
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   235
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   236
\end{frame}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   237
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   238
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   239
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   240
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   241
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   242
\frametitle{\begin{tabular}{c}Compiling AExps\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   243
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   244
{\Large\bl{1 + 2 + 3}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   245
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   246
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   247
\bl{\begin{tabular}{l}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   248
ldc 1\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   249
ldc 2\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   250
iadd\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   251
ldc 3\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   252
iadd\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   253
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   254
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   255
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   256
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   257
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   258
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   259
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   260
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   261
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   262
\frametitle{\begin{tabular}{c}Compiling AExps\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   263
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   264
{\Large\bl{1 + (2 + 3)}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   265
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   266
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   267
\bl{\begin{tabular}{l}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   268
ldc 1\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   269
ldc 2\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   270
ldc 3\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   271
iadd\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   272
iadd\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   273
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   274
\end{center}\bigskip\pause
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   275
\vfill
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   276
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   277
\bl{dadd, fadd, ladd, \ldots}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   278
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   279
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   280
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   281
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   282
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   283
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   284
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   285
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   286
\frametitle{\begin{tabular}{c}Compiling AExps\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   287
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   288
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   289
\bl{\begin{tabular}{@{}lcl@{}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   290
$\text{compile}(n)$ & $\dn$ & $\text{ldc}\;n$\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   291
$\text{compile}(a_1 + a_2)$ & $\dn$\\ 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   292
\multicolumn{3}{l}{$\qquad\text{compile}(a_1) \;@\;\text{compile}(a_2)\;@\; \text{iadd}$}\smallskip\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   293
$\text{compile}(a_1 - a_2)$ & $\dn$\\ 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   294
\multicolumn{3}{l}{$\qquad\text{compile}(a_1) \;@\; \text{compile}(a_2)\;@\; \text{isub}$}\smallskip\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   295
$\text{compile}(a_1 * a_2)$ & $\dn$\\ 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   296
\multicolumn{3}{l}{$\qquad\text{compile}(a_1) \;@\; \text{compile}(a_2)\;@\; \text{imul}$}\smallskip\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   297
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   298
\end{center}\pause
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   299
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   300
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   301
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   302
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   303
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   304
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   305
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   306
\frametitle{\begin{tabular}{c}Compiling AExps\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   307
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   308
{\Large\bl{1 + 2 * 3 + (4 - 3)}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   309
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   310
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   311
\bl{\begin{tabular}{l}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   312
ldc 1\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   313
ldc 2\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   314
ldc 3\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   315
imul\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   316
ldc 4\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   317
ldc 3\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   318
isub\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   319
iadd\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   320
iadd\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   321
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   322
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   323
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   324
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   325
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   326
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   327
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   328
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   329
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   330
\frametitle{\begin{tabular}{c}Variables\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   331
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   332
{\Large\bl{$x := 5 + y * 2$}}\bigskip\pause   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   333
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   334
\begin{itemize}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   335
\item lookup: \bl{$\text{iload}\; index$}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   336
\item store: \bl{$\text{istore}\; index$}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   337
\end{itemize}\bigskip\pause
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   338
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   339
while compilating we have to maintain a map between our identifiers and the
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   340
Java bytecode indices
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   341
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   342
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   343
\bl{$\text{compile}(a, E)$}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   344
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   345
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   346
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   347
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   348
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   349
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   350
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   351
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   352
\frametitle{\begin{tabular}{c}Compiling AExps\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   353
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   354
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   355
\bl{\begin{tabular}{@{}lcl@{}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   356
$\text{compile}(n, E)$ & $\dn$ & $\text{ldc}\;n$\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   357
$\text{compile}(a_1 + a_2, E)$ & $\dn$\\ 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   358
\multicolumn{3}{l}{$\qquad\text{compile}(a_1, E) \;@\;\text{compile}(a_2. E)\;@\; \text{iadd}$}\smallskip\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   359
$\text{compile}(a_1 - a_2, E)$ & $\dn$\\ 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   360
\multicolumn{3}{l}{$\qquad\text{compile}(a_1, E) \;@\; \text{compile}(a_2, E)\;@\; \text{isub}$}\smallskip\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   361
$\text{compile}(a_1 * a_2, E)$ & $\dn$\\ 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   362
\multicolumn{3}{l}{$\qquad\text{compile}(a_1, E) \;@\; \text{compile}(a_2, E)\;@\; \text{imul}$}\bigskip\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   363
$\text{compile}(x, E)$ & $\dn$ & $\text{iload}\;E(x)$\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   364
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   365
\end{center}\pause
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   366
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   367
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   368
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   370
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   371
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   372
\frametitle{Compiling Statements}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   373
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   374
We return a list of instructions and an environment for the
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   375
variables
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   376
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   377
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   378
\bl{\begin{tabular}{@{}l@{\hspace{1mm}}c@{\hspace{1mm}}l@{}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   379
$\text{compile}(\text{skip}, E)$ & $\dn$ & $(\textit{Nil}, E)$\bigskip\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   380
$\text{compile}(x := a, E)$ & $\dn$\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   381
\multicolumn{3}{l}{$(\text{compile}(a, E) \;@\;\text{istore}\;index, E(x\mapsto index))$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   382
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   383
\end{center}\medskip
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   384
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   385
where \bl{$index$} is \bl{$E(x)$} if it is already defined, 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   386
or if it is not then the largest index not yet seen
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   387
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   388
\end{frame}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   389
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   390
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   391
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   392
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   393
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   394
\frametitle{\begin{tabular}{c}Compiling AExps\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   395
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   396
{\Large\bl{$x := x + 1$}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   397
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   398
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   399
\bl{\begin{tabular}{l}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   400
iload $n_x$\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   401
ldc 1\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   402
iadd\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   403
istore $n_x$\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   404
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   405
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   406
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   407
where \bl{$n_x$} is the index corresponding to the variable \bl{$x$}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   408
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   409
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   410
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   411
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   412
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   413
\begin{frame}[c, fragile]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   414
\frametitle{Mathematical Functions}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   415
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   416
Compilation of some mathematical functions:
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   417
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   418
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   419
\begin{tabular}{lcl}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   420
\texttt{Aop("+", a1, a2)} & $\Rightarrow$ & \texttt{...iadd}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   421
\texttt{Aop("-", a1, a2)} & $\Rightarrow$ & \texttt{...isub}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   422
\texttt{Aop("*", a1, a2)} & $\Rightarrow$ & \texttt{...imul}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   423
\texttt{Aop("/", a1, a2)} & $\Rightarrow$ & \texttt{...idiv}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   424
\texttt{Aop("\%", a1, a2)} & $\Rightarrow$ & \texttt{...irem}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   425
\end{tabular}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   426
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   427
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   428
\end{frame}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   429
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   430
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   431
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   432
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   433
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   434
\frametitle{\begin{tabular}{c}Compiling Ifs\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   435
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   436
{\Large\bl{$\text{if}\;b\;\text{then}\;cs_1\;\text{else}\;cs_2$}}\bigskip\bigskip
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   437
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   438
\onslide<2->{Case }\only<2>{{\bf True}:}\only<3>{{\bf False}:}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   439
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   440
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   441
\begin{tikzpicture}[node distance=2mm and 4mm,
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   442
 block/.style={rectangle, minimum size=1cm, draw=black, line width=1mm},
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   443
 point/.style={rectangle, inner sep=0mm, minimum size=0mm, fill=red},
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   444
 skip loop/.style={red, line width=1mm, to path={-- ++(0,-10mm) -| (\tikztotarget)}}]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   445
\node (A1) [point] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   446
\node (b) [block, right=of A1] {code of \bl{$b$}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   447
\node (A2) [point, right=of b] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   448
\node (cs1) [block, right=of A2] {code of \bl{$cs_1$}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   449
\node (A3) [point, right=of cs1] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   450
\node (cs2) [block, right=of A3] {code of \bl{$cs_2$}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   451
\node (A4) [point, right=of cs2] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   452
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   453
\only<2>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   454
\draw (A1) edge [->, red, line width=1mm] (b);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   455
\draw (b) edge [->, red, line width=1mm] (cs1);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   456
\draw (cs1) edge [->, red, line width=1mm] (A3);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   457
\draw (A3) edge [->,skip loop] (A4);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   458
\node [below=of cs2] {\raisebox{-5mm}{\small{}jump}};}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   459
\only<3>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   460
\draw (A1) edge [->, red, line width=1mm] (b);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   461
\draw (b) edge [->, red, line width=1mm] (A2);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   462
\draw (A2) edge [skip loop] (A3);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   463
\draw (A3) edge [->, red, line width=1mm] (cs2);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   464
\draw (cs2) edge [->,red, line width=1mm] (A4);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   465
\node [below=of cs1] {\raisebox{-5mm}{\small{}conditional jump}};}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   466
\end{tikzpicture}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   467
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   468
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   469
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   470
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   471
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   472
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   473
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   474
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   475
\frametitle{Conditional Jumps}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   476
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   477
\begin{minipage}{1.1\textwidth}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   478
\begin{itemize}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   479
\item \bl{if\_icmpeq $label$} if two ints are equal, then jump\medskip
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   480
\item \bl{if\_icmpne $label$} if two ints aren't equal, then jump\medskip
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   481
\item \bl{if\_icmpge $label$} if one int is greater or equal then another, then jump
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   482
\item[]\ldots
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   483
\end{itemize}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   484
\end{minipage}\pause
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   485
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   486
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   487
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   488
\bl{\begin{tabular}{l}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   489
$L_1$:\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   490
\hspace{5mm}if\_icmpeq\;$L_2$\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   491
\hspace{5mm}iload 1\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   492
\hspace{5mm}ldc 1\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   493
\hspace{5mm}iadd\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   494
\hspace{5mm}if\_icmpeq\;$L_1$\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   495
$L_2$:
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   496
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   497
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   498
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   499
\begin{textblock}{3.5}(11,12)
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   500
\only<3>{labels must be unique}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   501
\end{textblock}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   502
\end{frame}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   503
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   504
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   505
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   506
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   507
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   508
\frametitle{\begin{tabular}{c}Compiling BExps\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   509
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   510
{\Large\bl{$a_1 = a_2$}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   511
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   512
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   513
\bl{\begin{tabular}{lcl}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   514
$\text{compile}(a_1 = a_2, E, lab)$ & $\dn$\\ 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   515
\multicolumn{3}{l}{$\quad\text{compile}(a_1, E) \;@\;\text{compile}(a_2, E)\;@\; \text{if\_icmpne}\;lab$}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   516
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   517
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   518
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   519
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   520
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   521
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   522
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   523
\begin{frame}[c, fragile]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   524
\frametitle{Boolean Expressions}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   525
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   526
Compilation of boolean expressions:
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   527
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   528
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   529
\begin{tikzpicture}[node distance=2mm and 4mm,
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   530
 block/.style={rectangle, minimum size=1cm, draw=black, line width=1mm},
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   531
 point/.style={rectangle, inner sep=0mm, minimum size=0mm, fill=red},
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   532
 skip loop/.style={red, line width=1mm, to path={-- ++(0,-10mm) -| (\tikztotarget)}}]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   533
\node (A1) [point] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   534
\node (b) [block, right=of A1] {code of \bl{$b$}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   535
\node (A2) [point, right=of b] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   536
\node (cs1) [block, right=of A2] {code of \bl{$cs_1$}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   537
\node (A3) [point, right=of cs1] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   538
\node (cs2) [block, right=of A3] {code of \bl{$cs_2$}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   539
\node (A4) [point, right=of cs2] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   540
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   541
\only<1>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   542
\draw (A1) edge [->, red, line width=1mm] (b);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   543
\draw (b) edge [->, red, line width=1mm] (A2);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   544
\draw (A2) edge [skip loop] (A3);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   545
\draw (A3) edge [->, red, line width=1mm] (cs2);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   546
\draw (cs2) edge [->,red, line width=1mm] (A4);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   547
\node [below=of cs1] {\raisebox{-5mm}{\small{}conditional jump}};}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   548
\end{tikzpicture}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   549
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   550
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   551
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   552
\begin{tabular}{lcl}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   553
\texttt{Bop("==", a1, a2)} & $\Rightarrow$ & \texttt{...if\_icmpne...}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   554
\texttt{Bop("!=", a1, a2)} & $\Rightarrow$ & \texttt{...if\_icmpeq...}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   555
\texttt{Bop("<", a1, a2)} & $\Rightarrow$ & \texttt{...if\_icmpge...}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   556
\texttt{Bop("<=", a1, a2)} & $\Rightarrow$ & \texttt{...if\_icmpgt...}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   557
\end{tabular}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   558
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   559
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   560
\end{frame}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   561
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   562
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   563
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   564
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   565
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   566
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   567
\frametitle{\begin{tabular}{c}Compiling Ifs\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   568
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   569
{\Large\bl{if $b$ then $cs_1$ else $cs_2$}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   570
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   571
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   572
\bl{\begin{tabular}{lcl}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   573
$\text{compile}(\text{if}\;b\;\text{then}\; cs_1\;\text{else}\; cs_2, E)$ & $\dn$\\ 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   574
\multicolumn{3}{l}{$\quad l_{ifelse}\;$ \textcolor{black}{(fresh label)}}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   575
\multicolumn{3}{l}{$\quad l_{ifend}\;$ \textcolor{black}{(fresh label)}}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   576
\multicolumn{3}{l}{$\quad (is_1, E') = \text{compile}(cs_1, E)$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   577
\multicolumn{3}{l}{$\quad (is_2, E'') = \text{compile}(cs_2, E')$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   578
\multicolumn{3}{l}{$\quad(\text{compile}(b, E, l_{ifelse})$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   579
\multicolumn{3}{l}{$\quad\phantom{(}@\;is_1$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   580
\multicolumn{3}{l}{$\quad\phantom{(}@\; \text{goto}\;l_{ifend}$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   581
\multicolumn{3}{l}{$\quad\phantom{(}@\;l_{ifelse}:$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   582
\multicolumn{3}{l}{$\quad\phantom{(}@\;is_2$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   583
\multicolumn{3}{l}{$\quad\phantom{(}@\;l_{ifend}:, E'')$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   584
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   585
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   586
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   587
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   588
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   589
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   590
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   591
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   592
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   593
\frametitle{\begin{tabular}{c}Compiling Whiles\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   594
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   595
{\Large\bl{$\text{while}\;b\;\text{do}\;cs$}}\bigskip\bigskip
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   596
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   597
\onslide<2->{Case }\only<2>{{\bf True}:}\only<3>{{\bf False}:}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   598
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   599
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   600
\begin{tikzpicture}[node distance=2mm and 4mm,
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   601
 block/.style={rectangle, minimum size=1cm, draw=black, line width=1mm},
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   602
 point/.style={rectangle, inner sep=0mm, minimum size=0mm, fill=red},
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   603
 skip loop/.style={red, line width=1mm, to path={-- ++(0,-10mm) -| (\tikztotarget)}}]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   604
\node (A0) [point, left=of A1] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   605
\node (A1) [point] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   606
\node (b) [block, right=of A1] {code of \bl{$b$}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   607
\node (A2) [point, right=of b] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   608
\node (cs1) [block, right=of A2] {code of \bl{$cs$}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   609
\node (A3) [point, right=of cs1] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   610
\node (A4) [point, right=of A3] {};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   611
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   612
\only<2>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   613
\draw (A0) edge [->, red, line width=1mm] (b);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   614
\draw (b) edge [->, red, line width=1mm] (cs1);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   615
\draw (cs1) edge [->, red, line width=1mm] (A3);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   616
\draw (A3) edge [->,skip loop] (A1);}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   617
\only<3>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   618
\draw (A0) edge [->, red, line width=1mm] (b);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   619
\draw (b) edge [->, red, line width=1mm] (A2);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   620
\draw (A2) edge [skip loop] (A3);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   621
\draw (A3) edge [->, red, line width=1mm] (A4);}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   622
\end{tikzpicture}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   623
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   624
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   625
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   626
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   627
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   628
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   629
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   630
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   631
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   632
\frametitle{\begin{tabular}{c}Compiling Whiles\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   633
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   634
{\Large\bl{while $b$ do $cs$}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   635
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   636
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   637
\bl{\begin{tabular}{lcl}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   638
$\text{compile}(\text{while}\; b\; \text{do} \;cs, E)$ & $\dn$\\ 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   639
\multicolumn{3}{l}{$\quad l_{wbegin}\;$ \textcolor{black}{(fresh label)}}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   640
\multicolumn{3}{l}{$\quad l_{wend}\;$ \textcolor{black}{(fresh label)}}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   641
\multicolumn{3}{l}{$\quad (is, E') = \text{compile}(cs_1, E)$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   642
\multicolumn{3}{l}{$\quad(l_{wbegin}:$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   643
\multicolumn{3}{l}{$\quad\phantom{(}@\;\text{compile}(b, E, l_{wend})$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   644
\multicolumn{3}{l}{$\quad\phantom{(}@\;is$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   645
\multicolumn{3}{l}{$\quad\phantom{(}@\; \text{goto}\;l_{wbegin}$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   646
\multicolumn{3}{l}{$\quad\phantom{(}@\;l_{wend}:, E')$}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   647
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   648
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   649
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   650
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   651
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   652
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   653
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   654
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   655
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   656
\frametitle{\begin{tabular}{c}Compiling Writes\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   657
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   658
{\Large\bl{write $x$}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   659
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   660
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   661
\small\bl{\begin{tabular}{l}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   662
.method public static write(I)V\hspace{1cm}\textcolor{black}{(library function)}\\ 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   663
\;\;    .limit locals 5 \\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   664
\;\;    .limit stack 5 \\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   665
\;\;    iload 0 \\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   666
\;\;    getstatic java/lang/System/out Ljava/io/PrintStream;\\ 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   667
\;\;    swap \\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   668
\;\;    invokevirtual java/io/PrintStream/println(I)V \\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   669
\;\;    return \\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   670
.end method\bigskip\bigskip\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   671
%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   672
\normalsize
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   673
iload $E(x)$\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   674
invokestatic write(I)V\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   675
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   676
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   677
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   678
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   679
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   680
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   681
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   682
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   683
\begin{frame}[c]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   684
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   685
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   686
\small\bl{\begin{tabular}{l}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   687
.class public XXX.XXX\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   688
.super java/lang/Object\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   689
\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   690
.method public <init>()V\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   691
\;\;     aload\_0\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   692
\;\;     invokenonvirtual java/lang/Object/<init>()V\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   693
 \;\;    return\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   694
.end method\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   695
\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   696
.method public static main([Ljava/lang/String;)V\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   697
\;\;   .limit locals 200\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   698
\;\;     .limit stack 200\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   699
\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   700
   \textcolor{black}{(here comes the compiled code)}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   701
\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   702
\;\;     return\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   703
.end method\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   704
\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   705
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   706
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   707
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   708
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   709
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   710
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   711
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   712
\begin{frame}[c]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   713
\frametitle{\begin{tabular}{c}Next Compiler Phases\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   714
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   715
\begin{itemize}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   716
\item assembly $\Rightarrow$ byte code (class file)
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   717
\item labels $\Rightarrow$ absolute or relative jumps\bigskip\bigskip
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   718
\item \texttt{javap} is a disassembler for class files
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   719
\end{itemize}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   720
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   721
\end{frame}}
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   722
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   723
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   724
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   725
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   726
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   727
\frametitle{\begin{tabular}{c}Compiled Code\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   728
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   729
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   730
\begin{tikzpicture}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   731
\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   732
\addplot+[smooth] file {compiled.data};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   733
\end{axis}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   734
\end{tikzpicture}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   735
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   736
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   737
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   738
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   739
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   740
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   741
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   742
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   743
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   744
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   745
\frametitle{\begin{tabular}{c}Compiler vs.~Interpreter\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   746
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   747
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   748
\begin{tikzpicture}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   749
\begin{axis}[axis x line=bottom, axis y line=left, ylabel=secs,
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   750
    xlabel=n,
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   751
    enlargelimits=0.05,
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   752
    ybar interval=0.7, legend style=small]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   753
\addplot file {interpreted2.data};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   754
\addplot file {compiled2.data};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   755
%\legend{interpreted, compiled}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   756
\end{axis}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   757
\end{tikzpicture}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   758
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   759
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   760
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   761
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   762
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   763
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   764
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   765
\begin{frame}[c]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   766
\frametitle{Backend}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   767
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   768
\begin{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   769
\begin{tikzpicture}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   770
\node (rexp)  {\bl{\bf Lexer}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   771
\node (nfa) [right=of rexp] {\bl{\bf Parser}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   772
\node (dfa) [right=of nfa] {\bl{\begin{tabular}{c}\bf Optimizations\end{tabular}}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   773
\path[->, red, line width=2mm] (rexp) edge node [above=4mm, black] {\begin{tabular}{c@{\hspace{9mm}}}token\\[-1mm]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   774
sequence\end{tabular}} (nfa);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   775
\node (final) [below=of dfa] {\bl{\begin{tabular}{c}\bf Machine Code/\\\bf Byte Code\end{tabular}}};
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   776
\path[->, red, line width=2mm] (nfa) edge node [above=4mm, black] {\begin{tabular}{c}parse\\[-1mm] tree
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   777
\end{tabular}}(dfa);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   778
\path[->, red, line width=2mm] (dfa) edge (final);
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   779
\end{tikzpicture}\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   780
\end{center}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   781
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   782
\end{frame}}
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   783
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   784
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   785
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   786
\mode<presentation>{
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   787
\begin{frame}[t]
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   788
\frametitle{\begin{tabular}{c}What Next\end{tabular}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   789
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   790
\begin{itemize}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   791
\item register spilling
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   792
\item dead code removal
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   793
\item loop optimisations
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   794
\item instruction selection
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   795
\item type checking
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   796
\item concurrency
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   797
\item fuzzy testing
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   798
\item verification\bigskip\\
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   799
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   800
\item GCC, LLVM, tracing JITs
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   801
\end{itemize}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   802
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   803
\end{frame}}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   804
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   805
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   806
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   807
\end{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   808
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   809
%%% Local Variables:  
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   810
%%% mode: latex
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   811
%%% TeX-master: t
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   812
%%% End: 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   813