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