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