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