slides/slides07.tex
author Christian Urban <christian.urban@kcl.ac.uk>
Thu, 24 Nov 2022 19:05:34 +0000
changeset 898 45a48c47dcca
parent 871 94b84d880c2b
child 940 46eee459a999
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
     1
% !TEX program = xelatex
744
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
     2
\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer}
302
0fa7b4221745 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
     3
\usepackage{../slides}
215
828303e8e4af updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 188
diff changeset
     4
\usepackage{../langs}
828303e8e4af updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 188
diff changeset
     5
\usepackage{../data}
871
94b84d880c2b updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 852
diff changeset
     6
\usepackage{../graphicss}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
     7
\usepackage{../grammar}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
     8
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
% beamer stuff 
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 387
diff changeset
    10
\renewcommand{\slidecaption}{CFL 07, King's College London}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
\newcommand{\bl}[1]{\textcolor{blue}{#1}}       
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
\begin{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
302
0fa7b4221745 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    16
\begin{frame}[t]
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
\frametitle{%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
  \begin{tabular}{@ {}c@ {}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
  \\[-3mm]
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 387
diff changeset
    20
  \LARGE Compilers and \\[-2mm] 
898
45a48c47dcca updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    21
  \LARGE Formal Languages\\[-5mm] 
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
  \end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
898
45a48c47dcca updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    24
  
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
  \normalsize
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
  \begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
  \begin{tabular}{ll}
898
45a48c47dcca updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    28
  Email:  & christian.urban at kcl.ac.uk\\
45a48c47dcca updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    29
  Office Hour: & Fridays 11 -- 12\\
45a48c47dcca updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    30
  Location: & N7.07 (North Wing, Bush House)\\
45a48c47dcca updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    31
  Slides \& Progs: & KEATS\\
45a48c47dcca updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 871
diff changeset
    32
  Pollev: & \texttt{\alert{https://pollev.com/cfltutoratki576}}\\  
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
  \end{tabular}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
  \end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
744
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    36
  \begin{center}
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    37
    \begin{tikzpicture}
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    38
      \node[drop shadow,fill=white,inner sep=0pt] 
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    39
      {\footnotesize\rowcolors{1}{capri!10}{white}
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    40
        \begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    41
          1 Introduction, Languages          & 6 While-Language \\
852
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    42
          2 Regular Expressions, Derivatives & 7 Compilation, JVM \\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    43
          3 Automata, Regular Languages      & \cellcolor{blue!50} 8 Compiling Functional Languages \\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    44
          4 Lexing, Tokenising               & 9 Optimisations \\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    45
          5 Grammars, Parsing                & 10 LLVM \\ \hline
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    46
        \end{tabular}%
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    47
      };
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    48
    \end{tikzpicture}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    49
  \end{center}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    50
\end{frame}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    51
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    52
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    53
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    54
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    55
\begin{frame}[t]
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    56
\frametitle{%
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    57
  \begin{tabular}{@ {}c@ {}}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    58
  \\[-3mm]
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    59
  \LARGE Compilers and \\[-2mm] 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    60
  \LARGE Formal Languages\\[3mm] 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    61
  \end{tabular}}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    62
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    63
  \normalsize
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    64
  \begin{center}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    65
  \begin{tabular}{ll}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    66
    Email:  & christian.urban at kcl.ac.uk\\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    67
    %Office Hours: & Thursdays 12 -- 14\\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    68
    %Location: & N7.07 (North Wing, Bush House)\\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    69
    Slides \& Progs: & KEATS (also homework is there)\\  
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    70
  \end{tabular}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    71
  \end{center}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    72
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    73
  \begin{center}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    74
    \begin{tikzpicture}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    75
      \node[drop shadow,fill=white,inner sep=0pt] 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    76
      {\footnotesize\rowcolors{1}{capri!10}{white}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    77
        \begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
    78
          1 Introduction, Languages          & 6 While-Language \\
744
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    79
          2 Regular Expressions, Derivatives & \cellcolor{blue!50} 7 Compilation, JVM \\
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    80
          3 Automata, Regular Languages      & 8 Compiling Functional Languages \\
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    81
          4 Lexing, Tokenising               & 9 Optimisations \\
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    82
          5 Grammars, Parsing                & 10 LLVM \\ \hline
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    83
        \end{tabular}%
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    84
      };
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    85
    \end{tikzpicture}
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    86
  \end{center}
99c5916d9a8f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 688
diff changeset
    87
302
0fa7b4221745 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    88
\end{frame}
0fa7b4221745 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    89
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
    91
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
807
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
    92
\begin{frame}[t]
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
    93
\frametitle{Bird's Eye View}
807
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
    94
\mbox{}\\[-16mm]\mbox{}
387
8aa406adfde0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 374
diff changeset
    95
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
    96
\begin{center}
807
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
    97
  \begin{tikzpicture}[scale=1,
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
    98
                      node/.style={
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
    99
                      rectangle,rounded corners=3mm,
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   100
                      very thick,draw=black!50,
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   101
                      minimum height=18mm, minimum width=20mm,
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   102
                      top color=white,bottom color=black!20,drop shadow}]
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   103
  \node (0) at (-2.3,0) {}; 
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   104
  
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   105
  \node (A) at (0,0)  [node] {};
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   106
  \node [below right] at (A.north west) {lexer};
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   107
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   108
  \node (B) at (3,0)  [node] {};
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   109
  \node [below right=1mm] at (B.north west) 
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   110
    {\mbox{}\hspace{-1mm}parser};
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   111
807
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   112
  \node (C) at (6,0)  [node] {};
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   113
  \node [below right] at (C.north west) 
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   114
    {\mbox{}\hspace{-1mm}code gen};
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   115
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   116
  \node (1) at (8.4,0) {}; 
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   117
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   118
  \draw [->,line width=4mm] (0) -- (A); 
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   119
  \draw [->,line width=4mm] (A) -- (B); 
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   120
  \draw [->,line width=4mm] (B) -- (C); 
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   121
  \draw [->,line width=4mm] (C) -- (1); 
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   122
  \end{tikzpicture}
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   123
  \end{center}\pause
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   124
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   125
  \begin{center}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   126
\begin{tikzpicture}[scale=1,font=\bf,
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   127
                      node/.style={
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   128
                      rectangle,rounded corners=3mm,
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   129
                      ultra thick,draw=black!50,minimum height=18mm, 
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   130
                      minimum width=20mm,
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   131
                      top color=white,bottom color=black!20}]
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   132
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   133
  \node (0) at (-3,0) {};  
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   134
  \node (A) at (0,0) [node,text width=1.6cm,text centered] {\small{}our compiler};
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   135
  \node (B) at (3.5,0) [node,text width=1.6cm,text centered] {\small{}Jasmin / Krakatau};
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   136
  \node (C) at (7.5,0) [node] {JVM};
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   137
 
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   138
  \draw [->,line width=2.5mm] (0) -- node [above,pos=0.35] {*.while} (A); 
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   139
  \draw [->,line width=2.5mm] (A) -- node [above,pos=0.35] {*.j} (B); 
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   140
  \draw [->,line width=2.5mm] (B) -- node [above,pos=0.35] {*.class} (C); 
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   141
  \end{tikzpicture}
807
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   142
  \end{center}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   143
\end{frame}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   145
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   146
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   147
\begin{frame}[c]
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   148
\frametitle{Test Program}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   149
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   150
\mbox{}\\[-18mm]\mbox{}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   151
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   152
{\lstset{language=While}\fontsize{10}{12}\selectfont
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   153
\texttt{\lstinputlisting{../progs/while-tests/loops.while}}}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   154
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   155
\end{frame}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   156
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   157
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   158
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   159
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   160
\begin{frame}[c]
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   161
\begin{textblock}{10}(0.5,0.5)
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   162
  \LARGE
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   163
  \fontspec{Hoefler Text Black}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   164
  \textcolor{ProcessBlue}{JVM\\ Code}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   165
  \\[12mm]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   166
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   167
  \normalsize
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   168
  Jasmin\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   169
  Krakatau\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   170
  ASM lib
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   171
\end{textblock}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   172
387
8aa406adfde0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 374
diff changeset
   173
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   174
\fontsize{8}{10}\selectfont
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   175
%\footnotesize
807
9fa90c73c6f3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 744
diff changeset
   176
\mbox{}\\[-13mm]\mbox{}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   177
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   178
\begin{columns}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   179
\begin{column}{2cm} 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   180
\lstinputlisting[numbers=none]{../progs/appHa.j}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   181
\end{column}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   182
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   183
\begin{column}{2cm} 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   184
\lstinputlisting[numbers=none]{../progs/appHb.j}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   185
\end{column}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   186
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   187
\end{columns}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   189
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   190
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   191
 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   192
 
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   193
%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   194
% \begin{frame}[t]
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   195
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   196
% \begin{center}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   197
% \bl{\begin{tabular}{@{}lcl@{}}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   198
% \\[-12mm]        
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   199
% \meta{Stmt} & $::=$ &  $\texttt{skip}$\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   200
%               & $|$ & \textit{Id}\;\texttt{:=}\;\meta{AExp}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   201
%               & $|$ & \texttt{if}\; \meta{BExp} \;\texttt{then}\; \meta{Block} \;\texttt{else}\; \meta{Block}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   202
%               & $|$ & \texttt{while}\; \meta{BExp} \;\texttt{do}\; \meta{Block}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   203
%               & $|$ & \texttt{read}\;\textit{Id}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   204
%               & $|$ & \texttt{write}\;\textit{Id}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   205
%               & $|$ & \texttt{write}\;\textit{String}\medskip\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   206
% \meta{Stmts} & $::=$ &  \meta{Stmt} \;\texttt{;}\; \meta{Stmts}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   207
%               & $|$ & \meta{Stmt}\medskip\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   208
% \meta{Block} & $::=$ &  \texttt{\{}\,\meta{Stmts}\,\texttt{\}}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   209
%                 & $|$ & \meta{Stmt}\medskip\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   210
% \meta{AExp} & $::=$ & \ldots\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   211
% \meta{BExp} & $::=$ & \ldots\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   212
% \end{tabular}}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   213
% \end{center}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   214
% \end{frame}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   215
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
   216
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   217
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   218
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   219
% \begin{frame}[c]
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   220
% \frametitle{\begin{tabular}{c}Fibonacci Numbers\end{tabular}}
387
8aa406adfde0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 374
diff changeset
   221
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   222
% \mbox{}\\[-18mm]\mbox{}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   223
% ??
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   224
% %{\lstset{language=While}\fontsize{10}{12}\selectfont
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   225
% %\texttt{\lstinputlisting{../progs/fib.while}}}
387
8aa406adfde0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 374
diff changeset
   226
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   227
% \end{frame}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   228
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
387
8aa406adfde0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 374
diff changeset
   229
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   230
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   231
% \begin{frame}[c]
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   232
% \frametitle{Interpreter}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   233
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   234
% \begin{center}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   235
% \bl{\begin{tabular}{@{}lcl@{}}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   236
% $\text{eval}(n, E)$ & $\dn$ & $n$\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   237
% $\text{eval}(x, E)$ & $\dn$ & $E(x)$ \;\;\;\textcolor{black}{lookup \bl{$x$} in \bl{$E$}}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   238
% $\text{eval}(a_1 + a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) + \text{eval}(a_2, E)$\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   239
% $\text{eval}(a_1 - a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) - \text{eval}(a_2, E)$\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   240
% $\text{eval}(a_1 * a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) * \text{eval}(a_2, E)$\bigskip\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   241
% $\text{eval}(a_1 = a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) = \text{eval}(a_2, E)$\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   242
% $\text{eval}(a_1\,!\!= a_2, E)$ & $\dn$ & $\neg(\text{eval}(a_1, E) = \text{eval}(a_2, E))$\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   243
% $\text{eval}(a_1 < a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) < \text{eval}(a_2, E)$\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   244
% \end{tabular}}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   245
% \end{center}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   246
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   247
% \end{frame}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   248
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   249
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   250
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   251
% \begin{frame}[c]
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   252
% \frametitle{Interpreter (2)}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   253
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   254
% \begin{center}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   255
% \bl{\begin{tabular}{@{}lcl@{}}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   256
% $\text{eval}(\text{skip}, E)$ & $\dn$ & $E$\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   257
% $\text{eval}(x:=a, E)$ & $\dn$ & \bl{$E(x \mapsto \text{eval}(a, E))$}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   258
% \multicolumn{3}{@{}l@{}}{$\text{eval}(\text{if}\;b\;\text{then}\;cs_1\;\text{else}\;cs_2 , E) \dn$}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   259
% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)\;\text{then}\;
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   260
% \text{eval}(cs_1,E)$}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   261
% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\phantom{\text{if}\;\text{eval}(b,E)\;}\text{else}\;\text{eval}(cs_2,E)$}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   262
% \multicolumn{3}{@{}l@{}}{$\text{eval}(\text{while}\;b\;\text{do}\;cs, E) \dn$}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   263
% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)$}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   264
% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{then}\;
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   265
% \text{eval}(\text{while}\;b\;\text{do}\;cs, \text{eval}(cs,E))$}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   266
% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   267
% $\text{eval}(\text{write}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   268
% \end{tabular}}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   269
% \end{center}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   270
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   271
% \end{frame}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   272
% %%%%%%%%%%%%%%%
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   273
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   274
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   275
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   276
% \begin{frame}[c]
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   277
% \frametitle{Test Program}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   278
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   279
% \mbox{}\\[-18mm]\mbox{}
188
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 187
diff changeset
   280
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   281
% {\lstset{language=While}\fontsize{10}{12}\selectfont
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   282
% \texttt{\lstinputlisting{../progs/while-tests/loops.while}}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   283
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   284
% \end{frame}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   285
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   286
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   287
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   288
% \begin{frame}[c]
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   289
% \fontsize{7}{9}\selectfont
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   290
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   291
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   292
% \begin{columns}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   293
% \begin{column}{7cm} 
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   294
% \lstinputlisting[numbers=none]{../progs/appHa.j}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   295
% \end{column}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   296
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   297
% \begin{column}{7cm} 
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   298
% \lstinputlisting[numbers=none]{../progs/appHb.j}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   299
% \end{column}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   300
% \end{columns}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   301
808
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   302
% \end{frame}
ba3edaf7dc49 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 807
diff changeset
   303
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   304
 
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   305
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   306
%\begin{frame}[t]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   307
%\frametitle{Interpreted Code}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   308
%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   309
%\begin{center}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   310
%\begin{tikzpicture}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   311
%\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   312
%\addplot+[smooth] file {interpreted.data};
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   313
%\end{axis}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   314
%\end{tikzpicture}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   315
%\end{center}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   316
%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   317
%\end{frame}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   318
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   319
%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   320
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   321
%\begin{frame}[c]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   322
%\frametitle{Java Virtual Machine}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   323
%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   324
%\begin{itemize}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   325
%\item introduced in 1995
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   326
%\item is a stack-based VM (like Postscript, CLR of .Net)
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   327
%\item contains a JIT compiler
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   328
%\item many languages take advantage of JVM's infrastructure (JRE)
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   329
%\item is garbage collected $\Rightarrow$ no buffer overflows
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   330
%\item some languages compiled to the JVM: Scala, Clojure\ldots
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   331
%\end{itemize}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   332
%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   333
%\end{frame}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   334
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   335
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   336
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   337
\begin{frame}[t,fragile]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   338
\frametitle{Compiling AExps}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   339
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   340
For example \textbf{\bl{1 + ((2 * 3) + (4 - 3))}}:\medskip
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   341
  
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   342
\begin{columns}[T]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   343
\begin{column}{.3\textwidth}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   344
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   345
\bl{\begin{tikzpicture}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   346
\tikzset{level distance=12mm,sibling distance=4mm}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   347
\tikzset{edge from parent/.style={draw,very thick}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   348
\Tree [.$+$ [.$1$ ] [.$+$ [.$*$ $2$ $3$ ] [.$-$ $4$ $3$ ]]]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   349
\end{tikzpicture}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   350
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   351
\end{column}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   352
\begin{column}{.3\textwidth}  
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   353
\begin{lstlisting}[language=JVMIS,numbers=none]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   354
ldc 1 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   355
ldc 2 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   356
ldc 3 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   357
imul 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   358
ldc 4 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   359
ldc 3 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   360
isub 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   361
iadd 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   362
iadd
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   363
\end{lstlisting}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   364
\end{column}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   365
\end{columns}\bigskip
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   366
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   367
\small
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   368
Traverse tree in post-order \bl{$\Rightarrow$} code for 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   369
stack-machine
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   370
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   371
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   372
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   373
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   374
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   375
\begin{frame}[t,fragile]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   376
\frametitle{Compiling AExps}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   377
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   378
\liningnums{\textbf{\Large\bl{(1 + 2) + 3}}}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   379
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   380
\begin{lstlisting}[language=JVMIS,numbers=none,xleftmargin=6cm]  
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   381
ldc 1
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   382
ldc 2
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   383
iadd
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   384
ldc 3
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   385
iadd
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   386
\end{lstlisting}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   387
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   388
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   389
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   390
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   391
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   392
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   393
\begin{frame}[t,fragile]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   394
\frametitle{Compiling AExps}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   395
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   396
\liningnums{\textbf{\Large\bl{1 + (2 + 3)}}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   397
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   398
\begin{lstlisting}[language=JVMIS,numbers=none,xleftmargin=6cm]  
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   399
ldc 1
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   400
ldc 2
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   401
ldc 3
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   402
iadd
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   403
iadd
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   404
\end{lstlisting}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   405
\bigskip\pause
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   406
\vfill
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   407
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   408
\textcolor{codepurple}{\textbf{\texttt{dadd}}},
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   409
\textcolor{codepurple}{\textbf{\texttt{fadd}}},
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   410
\textcolor{codepurple}{\textbf{\texttt{ladd}}}, \ldots
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   411
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   412
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   413
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   414
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   415
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   416
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   417
\begin{frame}[t]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   418
\frametitle{Compiling AExps}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   419
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   420
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   421
\bl{\begin{tabular}{@{}lcl@{}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   422
$\text{compile}(n)$ & $\dn$ & $\text{ldc}\;n$\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   423
$\text{compile}(a_1 + a_2)$ & $\dn$\\ 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   424
\multicolumn{3}{l}{$\qquad\text{compile}(a_1) \;@\;\text{compile}(a_2)\;@\; \text{iadd}$}\smallskip\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   425
$\text{compile}(a_1 - a_2)$ & $\dn$\\ 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   426
\multicolumn{3}{l}{$\qquad\text{compile}(a_1) \;@\; \text{compile}(a_2)\;@\; \text{isub}$}\smallskip\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   427
$\text{compile}(a_1 * a_2)$ & $\dn$\\ 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   428
\multicolumn{3}{l}{$\qquad\text{compile}(a_1) \;@\; \text{compile}(a_2)\;@\; \text{imul}$}\smallskip\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   429
\end{tabular}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   430
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   431
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   432
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   433
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   434
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   435
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   436
\begin{frame}[t,fragile]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   437
\frametitle{\begin{tabular}{c}Compiling AExps\end{tabular}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   438
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   439
\liningnums{\textbf{\Large\bl{1 $+$ 2 $*$ 3 $+$ (4 $-$ 3)}}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   440
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   441
\begin{lstlisting}[language=JVMIS,numbers=none,xleftmargin=6cm]         
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   442
ldc 1
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   443
ldc 2
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   444
ldc 3
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   445
imul
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   446
ldc 4
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   447
ldc 3
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   448
isub
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   449
iadd
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   450
iadd
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   451
\end{lstlisting}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   452
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   453
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   454
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   455
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   456
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   457
\begin{frame}[c]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   458
\frametitle{Variables}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   459
\liningnums{\textbf{\Large\bl{x $:=$ 5 $+$ y $*$ 2}}}\bigskip\pause   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   460
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   461
\begin{itemize}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   462
\item lookup: \bl{$\textcolor{codepurple}{\textbf{\texttt{iload}}}\; index$}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   463
\item store: \bl{$\textcolor{codepurple}{\textbf{\texttt{istore}}}\; index$}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   464
\end{itemize}\bigskip\pause
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   465
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   466
while compilating we have to maintain a map between our identifiers and the
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   467
Java bytecode indices
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   468
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   469
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   470
\bl{$\text{compile}(a, E)$}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   471
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   472
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   473
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   474
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   475
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   476
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   477
\begin{frame}[t]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   478
\frametitle{Compiling AExps}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   479
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   480
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   481
\bl{\begin{tabular}{@{}lcl@{}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   482
$\text{compile}(n, E)$ & $\dn$ & $\text{ldc}\;n$\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   483
$\text{compile}(a_1 + a_2, E)$ & $\dn$\\ 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   484
\multicolumn{3}{l}{$\qquad\text{compile}(a_1, E) \;@\;\text{compile}(a_2, E)\;@\; \text{iadd}$}\smallskip\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   485
$\text{compile}(a_1 - a_2, E)$ & $\dn$\\ 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   486
\multicolumn{3}{l}{$\qquad\text{compile}(a_1, E) \;@\; \text{compile}(a_2, E)\;@\; \text{isub}$}\smallskip\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   487
$\text{compile}(a_1 * a_2, E)$ & $\dn$\\ 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   488
\multicolumn{3}{l}{$\qquad\text{compile}(a_1, E) \;@\; \text{compile}(a_2, E)\;@\; \text{imul}$}\bigskip\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   489
$\text{compile}(x, E)$ & $\dn$ & $\text{iload}\;E(x)$\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   490
\end{tabular}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   491
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   492
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   493
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   494
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   495
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   496
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   497
\begin{frame}[c, fragile]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   498
\frametitle{Mathematical Functions}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   499
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   500
Compilation of some mathematical functions:
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   501
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   502
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   503
\begin{tabular}{lcl}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   504
\texttt{Aop("+", a1, a2)} & $\Rightarrow$ & \texttt{...iadd}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   505
\texttt{Aop("-", a1, a2)} & $\Rightarrow$ & \texttt{...isub}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   506
\texttt{Aop("*", a1, a2)} & $\Rightarrow$ & \texttt{...imul}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   507
\texttt{Aop("/", a1, a2)} & $\Rightarrow$ & \texttt{...idiv}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   508
\texttt{Aop("\%", a1, a2)} & $\Rightarrow$ & \texttt{...irem}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   509
\end{tabular}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   510
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   511
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   512
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   513
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   514
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   515
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   516
\begin{frame}[c]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   517
\frametitle{Compiling Statements}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   518
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   519
We return a list of instructions and an environment for the
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   520
variables
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   521
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   522
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   523
\bl{\begin{tabular}{@{}l@{\hspace{1mm}}c@{\hspace{1mm}}l@{}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   524
$\text{compile}(\text{skip}, E)$ & $\dn$ & $(\textit{Nil}, E)$\bigskip\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   525
$\text{compile}(x := a, E)$ & $\dn$\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   526
\multicolumn{3}{l}{$(\text{compile}(a, E) \;@\;\text{istore}\;index, E(x\mapsto index))$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   527
\end{tabular}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   528
\end{center}\medskip
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   529
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   530
where \bl{$index$} is \bl{$E(x)$} if it is already defined, 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   531
or if it is not, then the largest index not yet seen
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   532
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   533
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   534
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   535
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   536
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   537
\begin{frame}[c,fragile]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   538
\frametitle{Compiling Assignments}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   539
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   540
\liningnums{\textbf{\Large\bl{x $:=$ x $+$ 1}}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   541
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   542
\begin{lstlisting}[language=JVMIS,numbers=none,xleftmargin=6cm]        
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   543
iload /*@\bl{$n_x$}@*/
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   544
ldc 1
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   545
iadd
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   546
istore /*@\bl{$n_x$}@*/
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   547
\end{lstlisting}\medskip
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   548
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   549
where \bl{$n_x$} is the index corresponding to the variable~\bl{$x$}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   550
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   551
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   552
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   553
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   554
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   555
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   556
\begin{frame}[t]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   557
\frametitle{Compiling Ifs}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   558
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   559
{\Large\bl{$\text{if}\;b\;\text{then}\;cs_1\;\text{else}\;cs_2$}}\bigskip\bigskip
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   560
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   561
\onslide<2->{Case }\only<2>{{\bf True}:}\only<3>{{\bf False}:}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   562
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   563
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   564
\begin{tikzpicture}[node distance=2mm and 4mm,
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   565
 block/.style={rectangle, minimum size=1cm, draw=black, line width=1mm},
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   566
 point/.style={rectangle, inner sep=0mm, minimum size=0mm, fill=red},
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   567
 skip loop/.style={red, line width=1mm, to path={-- ++(0,-10mm) -| (\tikztotarget)}}]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   568
\node (A1) [point] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   569
\node (b) [block, right=of A1] {code of \bl{$b$}};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   570
\node (A2) [point, right=of b] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   571
\node (cs1) [block, right=of A2] {code of \bl{$cs_1$}};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   572
\node (A3) [point, right=of cs1] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   573
\node (cs2) [block, right=of A3] {code of \bl{$cs_2$}};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   574
\node (A4) [point, right=of cs2] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   575
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   576
\only<2>{
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   577
\draw (A1) edge [->, red, line width=1mm] (b);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   578
\draw (b) edge [->, red, line width=1mm] (cs1);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   579
\draw (cs1) edge [->, red, line width=1mm] (A3);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   580
\draw (A3) edge [->,skip loop] (A4);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   581
\node [below=of cs2] {\raisebox{-5mm}{\small{}jump}};}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   582
\only<3>{
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   583
\draw (A1) edge [->, red, line width=1mm] (b);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   584
\draw (b) edge [->, red, line width=1mm] (A2);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   585
\draw (A2) edge [skip loop] (A3);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   586
\draw (A3) edge [->, red, line width=1mm] (cs2);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   587
\draw (cs2) edge [->,red, line width=1mm] (A4);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   588
\node [below=of cs1] {\raisebox{-5mm}{\small{}conditional jump}};}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   589
\end{tikzpicture}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   590
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   591
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   592
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   593
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   594
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   595
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   596
\begin{frame}[t,fragile]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   597
\frametitle{Conditional Jumps}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   598
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   599
\begin{minipage}{1.1\textwidth}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   600
\begin{itemize}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   601
\item \textcolor{codepurple}{\textbf{\texttt{if\_icmpeq}}} \bl{$label$}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   602
  if two ints are equal, then jump\medskip
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   603
\item \textcolor{codepurple}{\textbf{\texttt{if\_icmpne}}} \bl{$label$}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   604
  if two ints aren't equal, then jump\medskip
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   605
\item \textcolor{codepurple}{\textbf{\texttt{if\_icmpge}}} \bl{$label$}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   606
  if one int is greater or equal then another, then jump
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   607
\item[]\ldots
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   608
\end{itemize}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   609
\end{minipage}\pause
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   610
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   611
\begin{lstlisting}[language=JVMIS,numbers=none,xleftmargin=2cm]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   612
/*@\bl{$L_1$:}@*/
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   613
  if_icmpeq /*@\bl{$L_2$}@*/
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   614
  iload 1
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   615
  ldc 1
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   616
  iadd
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   617
  if_icmpeq /*@\bl{$L_1$}@*/
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   618
/*@\bl{$L_2$:}@*/
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   619
\end{lstlisting}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   620
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   621
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   622
\begin{textblock}{3.5}(11,12)
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   623
\only<3>{labels must be unique}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   624
\end{textblock}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   625
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   626
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   627
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   628
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   629
\begin{frame}[c,fragile]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   630
\frametitle{Compiling Ifs}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   631
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   632
For example
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   633
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   634
\begin{lstlisting}[mathescape,numbers=none,language=While]
810
ba25eaf6043c updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 808
diff changeset
   635
if 1 == 1 then x := 2 else y := 3
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   636
\end{lstlisting}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   637
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   638
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   639
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   640
\begin{lstlisting}[mathescape,language=JVMIS,numbers=none]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   641
   ldc 1
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   642
   ldc 1
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   643
   if_icmpne L_ifelse $\quad\tikz[remember picture] \node (C) {\mbox{}};$
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   644
   ldc 2
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   645
   istore 0
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   646
   goto L_ifend $\quad\tikz[remember picture] \node (A) {\mbox{}};$
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   647
L_ifelse: $\quad\tikz[remember picture] \node[] (D) {\mbox{}};$
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   648
   ldc 3
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   649
   istore 1
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   650
L_ifend: $\quad\tikz[remember picture] \node[] (B) {\mbox{}};$
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   651
\end{lstlisting}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   652
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   653
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   654
\begin{tikzpicture}[remember picture,overlay]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   655
  \draw[->,very thick] (A) edge [->,to path={-- ++(10mm,0mm) 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   656
           -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (B.east);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   657
  \draw[->,very thick] (C) edge [->,to path={-- ++(10mm,0mm) 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   658
           -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (D.east);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   659
\end{tikzpicture}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   660
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   661
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   662
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   663
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   664
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   665
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   666
\begin{frame}[t]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   667
\frametitle{Compiling BExps}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   668
810
ba25eaf6043c updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 808
diff changeset
   669
{\Large\bl{$a_1 == a_2$}}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   670
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   671
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   672
\bl{\begin{tabular}{lcl}
810
ba25eaf6043c updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 808
diff changeset
   673
$\text{compile}(a_1 == a_2, E, lab)$ & $\dn$\\ 
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   674
\multicolumn{3}{l}{$\quad\text{compile}(a_1, E) \;@\;\text{compile}(a_2, E)\;@\; \text{if\_icmpne}\;lab$}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   675
\end{tabular}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   676
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   677
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   678
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   679
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   680
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   681
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   682
\begin{frame}[c, fragile]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   683
\frametitle{Boolean Expressions}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   684
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   685
Compilation of boolean expressions:
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   686
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   687
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   688
\begin{tikzpicture}[node distance=2mm and 4mm,
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   689
 block/.style={rectangle, minimum size=1cm, draw=black, line width=1mm},
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   690
 point/.style={rectangle, inner sep=0mm, minimum size=0mm, fill=red},
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   691
 skip loop/.style={red, line width=1mm, to path={-- ++(0,-10mm) -| (\tikztotarget)}}]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   692
\node (A1) [point] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   693
\node (b) [block, right=of A1] {code of \bl{$b$}};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   694
\node (A2) [point, right=of b] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   695
\node (cs1) [block, right=of A2] {code of \bl{$cs_1$}};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   696
\node (A3) [point, right=of cs1] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   697
\node (cs2) [block, right=of A3] {code of \bl{$cs_2$}};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   698
\node (A4) [point, right=of cs2] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   699
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   700
\only<1>{
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   701
\draw (A1) edge [->, red, line width=1mm] (b);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   702
\draw (b) edge [->, red, line width=1mm] (A2);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   703
\draw (A2) edge [skip loop] (A3);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   704
\draw (A3) edge [->, red, line width=1mm] (cs2);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   705
\draw (cs2) edge [->,red, line width=1mm] (A4);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   706
\node [below=of cs1] {\raisebox{-5mm}{\small{}conditional jump}};}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   707
\end{tikzpicture}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   708
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   709
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   710
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   711
\begin{tabular}{lcl}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   712
\texttt{Bop("==", a1, a2)} & $\Rightarrow$ & \texttt{...if\_icmpne...}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   713
\texttt{Bop("!=", a1, a2)} & $\Rightarrow$ & \texttt{...if\_icmpeq...}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   714
\texttt{Bop("<", a1, a2)} & $\Rightarrow$ & \texttt{...if\_icmpge...}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   715
\texttt{Bop("<=", a1, a2)} & $\Rightarrow$ & \texttt{...if\_icmpgt...}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   716
\end{tabular}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   717
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   718
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   719
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   720
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   721
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   722
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   723
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   724
\begin{frame}[t]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   725
\frametitle{Compiling Ifs}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   726
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   727
{\Large\bl{if $b$ then $cs_1$ else $cs_2$}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   728
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   729
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   730
\bl{\begin{tabular}{lcl}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   731
$\text{compile}(\text{if}\;b\;\text{then}\; cs_1\;\text{else}\; cs_2, E)$ & $\dn$\\ 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   732
\multicolumn{3}{l}{$\quad l_{ifelse}\;$ \textcolor{black}{(fresh label)}}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   733
\multicolumn{3}{l}{$\quad l_{ifend}\;$ \textcolor{black}{(fresh label)}}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   734
\multicolumn{3}{l}{$\quad (is_1, E') = \text{compile}(cs_1, E)$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   735
\multicolumn{3}{l}{$\quad (is_2, E'') = \text{compile}(cs_2, E')$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   736
\multicolumn{3}{l}{$\quad(\text{compile}(b, E, l_{ifelse})$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   737
\multicolumn{3}{l}{$\quad\phantom{(}@\;is_1$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   738
\multicolumn{3}{l}{$\quad\phantom{(}@\; \text{goto}\;l_{ifend}$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   739
\multicolumn{3}{l}{$\quad\phantom{(}@\;l_{ifelse}:$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   740
\multicolumn{3}{l}{$\quad\phantom{(}@\;is_2$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   741
\multicolumn{3}{l}{$\quad\phantom{(}@\;l_{ifend}:, E'')$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   742
\end{tabular}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   743
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   744
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   745
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   746
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   747
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   748
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   749
\begin{frame}[t]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   750
\frametitle{Compiling Whiles}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   751
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   752
{\Large\bl{$\text{while}\;b\;\text{do}\;cs$}}\bigskip\bigskip
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   753
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   754
\onslide<2->{Case }\only<2>{{\bf True}:}\only<3>{{\bf False}:}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   755
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   756
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   757
\begin{tikzpicture}[node distance=2mm and 4mm,
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   758
 block/.style={rectangle, minimum size=1cm, draw=black, line width=1mm},
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   759
 point/.style={rectangle, inner sep=0mm, minimum size=0mm, fill=red},
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   760
 skip loop/.style={red, line width=1mm, to path={-- ++(0,-10mm) -| (\tikztotarget)}}]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   761
\node (A0) [point, left=of A1] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   762
\node (A1) [point] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   763
\node (b) [block, right=of A1] {code of \bl{$b$}};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   764
\node (A2) [point, right=of b] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   765
\node (cs1) [block, right=of A2] {code of \bl{$cs$}};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   766
\node (A3) [point, right=of cs1] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   767
\node (A4) [point, right=of A3] {};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   768
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   769
\only<2>{
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   770
\draw (A0) edge [->, red, line width=1mm] (b);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   771
\draw (b) edge [->, red, line width=1mm] (cs1);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   772
\draw (cs1) edge [->, red, line width=1mm] (A3);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   773
\draw (A3) edge [->,skip loop] (A1);}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   774
\only<3>{
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   775
\draw (A0) edge [->, red, line width=1mm] (b);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   776
\draw (b) edge [->, red, line width=1mm] (A2);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   777
\draw (A2) edge [skip loop] (A3);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   778
\draw (A3) edge [->, red, line width=1mm] (A4);}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   779
\end{tikzpicture}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   780
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   781
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   782
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   783
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   784
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   785
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   786
\begin{frame}[t]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   787
\frametitle{Compiling Whiles}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   788
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   789
{\Large\bl{while $b$ do $cs$}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   790
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   791
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   792
\bl{\begin{tabular}{lcl}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   793
$\text{compile}(\text{while}\; b\; \text{do} \;cs, E)$ & $\dn$\\ 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   794
\multicolumn{3}{l}{$\quad l_{wbegin}\;$ \textcolor{black}{(fresh label)}}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   795
\multicolumn{3}{l}{$\quad l_{wend}\;$ \textcolor{black}{(fresh label)}}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   796
\multicolumn{3}{l}{$\quad (is, E') = \text{compile}(cs_1, E)$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   797
\multicolumn{3}{l}{$\quad(l_{wbegin}:$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   798
\multicolumn{3}{l}{$\quad\phantom{(}@\;\text{compile}(b, E, l_{wend})$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   799
\multicolumn{3}{l}{$\quad\phantom{(}@\;is$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   800
\multicolumn{3}{l}{$\quad\phantom{(}@\; \text{goto}\;l_{wbegin}$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   801
\multicolumn{3}{l}{$\quad\phantom{(}@\;l_{wend}:, E')$}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   802
\end{tabular}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   803
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   804
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   805
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   806
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   807
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   808
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   809
\begin{frame}[c,fragile]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   810
\frametitle{Compiling Whiles}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   811
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   812
For example
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   813
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   814
\begin{lstlisting}[mathescape,numbers=none,language=While]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   815
while x <= 10 do x := x + 1
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   816
\end{lstlisting}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   817
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   818
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   819
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   820
\begin{lstlisting}[mathescape,language=JVMIS,numbers=none]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   821
L_wbegin: $\quad\tikz[remember picture] \node[] (LB) {\mbox{}};$
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   822
   iload 0
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   823
   ldc 10
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   824
   if_icmpgt L_wend $\quad\tikz[remember picture] \node (LC) {\mbox{}};$
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   825
   iload 0
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   826
   ldc 1
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   827
   iadd
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   828
   istore 0
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   829
   goto L_wbegin $\quad\tikz[remember picture] \node (LA) {\mbox{}};$
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   830
L_wend: $\quad\tikz[remember picture] \node[] (LD) {\mbox{}};$
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   831
\end{lstlisting}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   832
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   833
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   834
\begin{tikzpicture}[remember picture,overlay]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   835
  \draw[->,very thick] (LA) edge [->,to path={-- ++(12mm,0mm) 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   836
           -- ++(0mm,17.3mm) |- (\tikztotarget)},line width=1mm] (LB.east);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   837
  \draw[->,very thick] (LC) edge [->,to path={-- ++(12mm,0mm) 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   838
           -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (LD.east);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   839
\end{tikzpicture}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   840
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   841
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   842
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   843
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   844
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   845
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   846
\begin{frame}[c,fragile]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   847
\frametitle{Compiling Writes}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   848
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   849
\small
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   850
\begin{lstlisting}[language=JVMIS,mathescape,
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   851
                   numbers=none,xleftmargin=-6mm]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   852
.method public static write(I)V 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   853
  .limit locals 1 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   854
  .limit stack 2 
811
86406d70d6f0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 810
diff changeset
   855
  getstatic java/lang/System/out Ljava/io/PrintStream; 
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   856
  iload 0
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   857
  invokevirtual java/io/PrintStream/println(I)V 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   858
  return 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   859
.end method
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   860
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   861
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   862
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   863
iload $E(x)$ 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   864
invokestatic XXX/XXX/write(I)V
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   865
\end{lstlisting}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   866
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   867
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   868
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   869
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   870
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   871
\begin{frame}[c,fragile]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   872
\frametitle{Compiling Main}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   873
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   874
\footnotesize
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   875
\begin{lstlisting}[language=JVMIS,mathescape,
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   876
                   numbers=none,xleftmargin=-6mm]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   877
.class public XXX.XXX
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   878
.super java/lang/Object
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   879
811
86406d70d6f0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 810
diff changeset
   880
...
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   881
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   882
.method public static main([Ljava/lang/String;)V
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   883
    .limit locals 200
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   884
    .limit stack 200
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   885
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   886
      $\textit{\ldots{}here comes the compiled code\ldots}$
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   887
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   888
    return
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   889
.end method
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   890
\end{lstlisting}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   891
811
86406d70d6f0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 810
diff changeset
   892
%.method public <init>()V
86406d70d6f0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 810
diff changeset
   893
%    aload_0
86406d70d6f0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 810
diff changeset
   894
%    invokenonvirtual java/lang/Object/<init>()V
86406d70d6f0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 810
diff changeset
   895
%    return
86406d70d6f0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 810
diff changeset
   896
%.end method
86406d70d6f0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 810
diff changeset
   897
86406d70d6f0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 810
diff changeset
   898
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   899
\end{frame}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   900
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   901
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   902
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   903
\begin{frame}[c]
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   904
\frametitle{Next Compiler Phases}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   905
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   906
\begin{itemize}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   907
\item assembly $\Rightarrow$ byte code (class file)
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   908
\item labels $\Rightarrow$ absolute or relative jumps\bigskip\bigskip
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   909
\item \texttt{javap} is a disassembler for class files
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   910
\item jasmin and krakatau are assemblers for jvm code
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   911
\end{itemize}
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
   912
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   913
\end{frame}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   914
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   915
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   916
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   917
\begin{frame}[t]
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   918
\frametitle{Recall: Interpreted Code}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   919
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   920
\begin{center}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   921
\begin{tikzpicture}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   922
\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   923
\addplot+[smooth] file {interpreted.data};
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   924
\end{axis}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   925
\end{tikzpicture}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   926
\end{center}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   927
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   928
Loop program
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   929
\end{frame}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   930
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   931
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   932
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   933
\begin{frame}[t]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   934
\frametitle{Compiled Code}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   935
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   936
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   937
\begin{tikzpicture}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   938
\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   939
\addplot+[smooth] file {compiled.data};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   940
\end{axis}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   941
\end{tikzpicture}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   942
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   943
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   944
\end{frame}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   945
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   946
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   947
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   948
\begin{frame}[t]
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   949
\frametitle{Compiler vs.~Interpreter}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   950
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   951
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   952
\begin{tikzpicture}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   953
\begin{axis}[axis x line=bottom, axis y line=left, ylabel=secs,
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   954
    xlabel=n,
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   955
    enlargelimits=0.05,
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   956
    ybar interval=0.7, legend style=small]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   957
\addplot file {interpreted2.data};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   958
\addplot file {compiled2.data};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   959
%\legend{interpreted, compiled}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   960
\end{axis}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   961
\end{tikzpicture}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   962
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   963
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   964
\end{frame}
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   965
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   966
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   967
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   968
\begin{frame}[c]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   969
  \frametitle{A ``Compiler'' for BF*** to C}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   970
  
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   971
  \begin{center}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   972
  \begin{tabular}{lcl}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   973
  \bl{\texttt{>}} & $\Rightarrow$ & \texttt{ptr++}\\
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   974
  \bl{\texttt{<}} & $\Rightarrow$ & \texttt{ptr--}\\
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   975
  \bl{\texttt{+}} & $\Rightarrow$ & \texttt{(*ptr)++}\\
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   976
  \bl{\texttt{-}} & $\Rightarrow$ & \texttt{(*ptr)--}\\
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   977
  \bl{\texttt{.}} & $\Rightarrow$ & \texttt{putchar(*ptr)}\\
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   978
  \bl{\texttt{,}} & $\Rightarrow$ & \texttt{*ptr = getchar()}\\
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   979
  \bl{\texttt{[}} & $\Rightarrow$ & \texttt{while(*ptr)\{}\\
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   980
  \bl{\texttt{]}} & $\Rightarrow$ & \texttt{\}}\medskip\\
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   981
                  & $\Rightarrow$ & ignore everything else\\
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   982
  \end{tabular}  
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   983
  \end{center}\bigskip  
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   984
  
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   985
  \texttt{char field[30000]\\ char *ptr = \&field[15000]}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   986
  
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   987
\end{frame}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   988
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   989
    
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   990
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   991
\begin{frame}[c,fragile]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   992
\frametitle{BF***}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   993
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   994
we need some big array, say \texttt{arr} and 7 (8) instructions:\medskip
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   995
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   996
\begin{itemize}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   997
\item \texttt{>} move \texttt{ptr++}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   998
\item \texttt{<} move \texttt{ptr-{}-}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
   999
\item \texttt{+} add \texttt{arr[ptr]++}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1000
\item \texttt{-} subtract \texttt{arr[ptr]-{}-}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1001
\item \texttt{.} print out \texttt{arr[ptr]} as ASCII
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1002
\item \texttt{[} if \texttt{arr[ptr] == 0} jump just after the corresponding \texttt{]}; otherwise \texttt{ptr++}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1003
\item \texttt{]} if \texttt{arr[ptr] != 0} jump just after the corresponding \texttt{[}; otherwise \texttt{ptr++}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1004
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1005
\end{itemize}  
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1006
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1007
\end{frame}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1008
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1009
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1010
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1011
\begin{frame}[c,fragile]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1012
\frametitle{Arrays in While}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1013
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1014
\begin{itemize}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1015
\item \texttt{new arr[15000]}\medskip 
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1016
\item \texttt{x := 3 + arr[3 + y]}\medskip 
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1017
\item \texttt{arr[42 * n] := ...}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1018
\end{itemize}  
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1019
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1020
\end{frame}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1021
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1022
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1023
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1024
\begin{frame}[c,fragile]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1025
\frametitle{New Arrays}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1026
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1027
\begin{lstlisting}[mathescape,numbers=none,language=While]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1028
  new arr[number]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1029
\end{lstlisting}\bigskip\bigskip
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1030
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1031
\begin{lstlisting}[mathescape,numbers=none,language=JVMIS]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1032
  ldc number
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1033
  newarray int
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1034
  astore loc_var
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1035
\end{lstlisting}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1036
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1037
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1038
\end{frame}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1039
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1040
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1041
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1042
\begin{frame}[c,fragile]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1043
\frametitle{Array Update}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1044
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1045
\begin{lstlisting}[mathescape,numbers=none,language=While]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1046
  arr[...] := 
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1047
\end{lstlisting}\bigskip\bigskip
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1048
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1049
\begin{lstlisting}[mathescape,numbers=none,language=JVMIS]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1050
  aload loc_var
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1051
  index_aexp
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1052
  value_aexp
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1053
  iastore
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1054
\end{lstlisting}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1055
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1056
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1057
\end{frame}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1058
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1059
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1060
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1061
\begin{frame}[c,fragile]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1062
\frametitle{Array Lookup in AExp}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1063
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1064
\begin{lstlisting}[mathescape,numbers=none,language=While]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1065
  ...arr[...]... 
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1066
\end{lstlisting}\bigskip\bigskip
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1067
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1068
\begin{lstlisting}[mathescape,numbers=none,language=JVMIS]
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1069
  aload loc_var
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1070
  index_aexp
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1071
  iaload
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1072
\end{lstlisting}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1073
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1074
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1075
\end{frame}
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1076
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1077
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1078
852
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1079
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1080
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1081
\begin{frame}[t, fragile]
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1082
\frametitle{Function Definitions}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1083
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1084
\footnotesize
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1085
\begin{lstlisting}[language=JVMIS, 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1086
                   xleftmargin=2mm, 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1087
                   numbers=none]
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1088
.method public static write(I)V 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1089
   .limit locals 1
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1090
   .limit stack 2
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1091
   getstatic java/lang/System/out Ljava/io/PrintStream; 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1092
   iload 0 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1093
   invokevirtual java/io/PrintStream/println(I)V 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1094
   return 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1095
.end method
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1096
\end{lstlisting}\bigskip
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1097
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1098
\small We will need methods for definitions like\footnotesize\medskip
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1099
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1100
\begin{lstlisting}[language=JVMIS, 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1101
                   xleftmargin=2mm, 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1102
                   numbers=none]
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1103
def fname (x1, ... , xn) = ...                   
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1104
                   
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1105
.method public static fname (I...I)I
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1106
  .limit locals ??
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1107
  .limit stack ?? 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1108
  ??
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1109
.end method
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1110
\end{lstlisting}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1111
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1112
\end{frame}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1113
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1114
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1115
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1116
\begin{frame}[c, fragile]
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1117
\frametitle{Stack Estimation}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1118
\small
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1119
\mbox{}\\[-15mm]
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1120
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1121
\bl{\begin{center}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1122
\begin{tabular}{@{\hspace{-4mm}}l@{\hspace{2mm}}c@{\hspace{2mm}}l@{}}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1123
$\textit{estimate}(n)$ & $\dn$ & $1$\\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1124
$\textit{estimate}(x)$ & $\dn$ & $1$\\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1125
$\textit{estimate}(a_1\;aop\;a_2)$ & $\dn$ &
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1126
$\textit{estimate}(a_1) + \textit{estimate}(a_2)$\\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1127
$\textit{estimate}(\pcode{if}\;b\;\pcode{then}\;e_1\;\pcode{else}\;e_2)$ & $\dn$ & 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1128
$\textit{estimate}(b) +$\\ 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1129
& & $\quad max(\textit{estimate}(e_1), \textit{estimate}(e_2))$\\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1130
$\textit{estimate}(\pcode{write}(e))$ & $\dn$ & 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1131
$\textit{estimate}(e) + 1$\\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1132
$\textit{estimate}(e_1 ; e_2)$ & $\dn$ & 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1133
$max(\textit{estimate}(e_1), \textit{estimate}(e_2))$\\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1134
$\textit{estimate}(f(e_1, ..., e_n))$ & $\dn$ & 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1135
$\sum_{i = 1..n}\;estimate(e_i)$\medskip\\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1136
$\textit{estimate}(a_1\;bop\;a_2)$ & $\dn$ &
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1137
$\textit{estimate}(a_1) + \textit{estimate}(a_2)$\\
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1138
\end{tabular}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1139
\end{center}}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1140
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1141
\end{frame}
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1142
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1143
8706b846a3e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 812
diff changeset
  1144
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 608
diff changeset
  1145
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1146
\mode<presentation>{
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1147
\begin{frame}[c]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1148
\frametitle{Backend}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1149
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1150
\begin{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1151
\begin{tikzpicture}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1152
\node (rexp)  {\bl{\bf Lexer}};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1153
\node (nfa) [right=of rexp] {\bl{\bf Parser}};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1154
\node (dfa) [right=of nfa] {\bl{\begin{tabular}{c}\bf Optimizations\end{tabular}}};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1155
\path[->, red, line width=2mm] (rexp) edge node [above=4mm, black] {\begin{tabular}{c@{\hspace{9mm}}}token\\[-1mm]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1156
sequence\end{tabular}} (nfa);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1157
\node (final) [below=of dfa] {\bl{\begin{tabular}{c}\bf Machine Code/\\\bf Byte Code\end{tabular}}};
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1158
\path[->, red, line width=2mm] (nfa) edge node [above=4mm, black] {\begin{tabular}{c}parse\\[-1mm] tree
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1159
\end{tabular}}(dfa);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1160
\path[->, red, line width=2mm] (dfa) edge (final);
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1161
\end{tikzpicture}\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1162
\end{center}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1163
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1164
\end{frame}}
369
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
  1165
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
43c0ed473720 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 302
diff changeset
  1166
608
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1167
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1168
\mode<presentation>{
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1169
\begin{frame}[t]
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1170
\frametitle{\begin{tabular}{c}What is Next\end{tabular}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1171
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1172
\begin{itemize}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1173
\item register spilling
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1174
\item dead code removal
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1175
\item loop optimisations
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1176
\item instruction selection
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1177
\item type checking
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1178
\item concurrency
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1179
\item fuzzy testing
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1180
\item verification\bigskip\\
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1181
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1182
\item GCC, LLVM, tracing JITs
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1183
\end{itemize}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1184
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1185
\end{frame}}
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1186
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
3db4970ad0aa updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
  1187
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 173
diff changeset
  1188
812
2f9a0dcf61ae updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 811
diff changeset
  1189
2f9a0dcf61ae updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 811
diff changeset
  1190
\begin{frame}<1-10>
2f9a0dcf61ae updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 811
diff changeset
  1191
\end{frame}  
2f9a0dcf61ae updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 811
diff changeset
  1192
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
  1193
\end{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
  1194
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
  1195
%%% Local Variables:  
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
  1196
%%% mode: latex
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
  1197
%%% TeX-master: t
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
  1198
%%% End: 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
  1199