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