1071 \end{itemize} |
1071 \end{itemize} |
1072 |
1072 |
1073 \end{frame} |
1073 \end{frame} |
1074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1075 |
1075 |
|
1076 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1077 \mode<presentation>{ |
|
1078 \begin{frame}[c] |
|
1079 \frametitle{\begin{tabular}{c}An Interpreter\end{tabular}} |
|
1080 |
|
1081 \begin{center} |
|
1082 \bl{\begin{tabular}{l} |
|
1083 $\{$\\ |
|
1084 \;\;$x := 5 \text{;}$\\ |
|
1085 \;\;$y := x * 3\text{;}$\\ |
|
1086 \;\;$y := x * 4\text{;}$\\ |
|
1087 \;\;$x := u * 3$\\ |
|
1088 $\}$ |
|
1089 \end{tabular}} |
|
1090 \end{center} |
|
1091 |
|
1092 \begin{itemize} |
|
1093 \item the interpreter has to record the value of \bl{$x$} before assigning a value to \bl{$y$}\pause |
|
1094 \item \bl{\text{eval}(stmt, env)} |
|
1095 \end{itemize} |
|
1096 |
|
1097 |
|
1098 \end{frame}} |
|
1099 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1100 |
|
1101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1102 \mode<presentation>{ |
|
1103 \begin{frame}[c] |
|
1104 \frametitle{\begin{tabular}{c}Interpreter\end{tabular}} |
|
1105 |
|
1106 \begin{center} |
|
1107 \bl{\begin{tabular}{@{}lcl@{}} |
|
1108 $\text{eval}(n, E)$ & $\dn$ & $n$\\ |
|
1109 $\text{eval}(x, E)$ & $\dn$ & $E(x)$ \;\;\;\textcolor{black}{lookup \bl{$x$} in \bl{$E$}}\\ |
|
1110 $\text{eval}(a_1 + a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) + \text{eval}(a_2, E)$\\ |
|
1111 $\text{eval}(a_1 - a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) - \text{eval}(a_2, E)$\\ |
|
1112 $\text{eval}(a_1 * a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) * \text{eval}(a_2, E)$\bigskip\\ |
|
1113 $\text{eval}(a_1 = a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) = \text{eval}(a_2, E)$\\ |
|
1114 $\text{eval}(a_1\,!\!= a_2, E)$ & $\dn$ & $\neg(\text{eval}(a_1, E) = \text{eval}(a_2, E))$\\ |
|
1115 $\text{eval}(a_1 < a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) < \text{eval}(a_2, E)$\ |
|
1116 \end{tabular}} |
|
1117 \end{center} |
|
1118 |
|
1119 \end{frame}} |
|
1120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1122 \mode<presentation>{ |
|
1123 \begin{frame}[c] |
|
1124 \frametitle{\begin{tabular}{c}Interpreter (2)\end{tabular}} |
|
1125 |
|
1126 \begin{center} |
|
1127 \bl{\begin{tabular}{@{}lcl@{}} |
|
1128 $\text{eval}(\text{skip}, E)$ & $\dn$ & $E$\\ |
|
1129 $\text{eval}(x:=a, E)$ & $\dn$ & \bl{$E(x \mapsto \text{eval}(a, E))$}\\ |
|
1130 \multicolumn{3}{@{}l@{}}{$\text{eval}(\text{if}\;b\;\text{then}\;cs_1\;\text{else}\;cs_2 , E) \dn$}\\ |
|
1131 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)\;\text{then}\; |
|
1132 \text{eval}(cs_1,E)$}\\ |
|
1133 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\phantom{\text{if}\;\text{eval}(b,E)\;}\text{else}\;\text{eval}(cs_2,E)$}\\ |
|
1134 \multicolumn{3}{@{}l@{}}{$\text{eval}(\text{while}\;b\;\text{do}\;cs, E) \dn$}\\ |
|
1135 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)$}\\ |
|
1136 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{then}\; |
|
1137 \text{eval}(\text{while}\;b\;\text{do}\;cs, \text{eval}(cs,E))$}\\ |
|
1138 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\ |
|
1139 $\text{eval}(\text{write}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\ |
|
1140 \end{tabular}} |
|
1141 \end{center} |
|
1142 |
|
1143 \end{frame}} |
|
1144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1145 |
|
1146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1147 \begin{frame}[c] |
|
1148 \frametitle{\begin{tabular}{c}Test Program\end{tabular}} |
|
1149 |
|
1150 \mbox{}\\[-18mm]\mbox{} |
|
1151 |
|
1152 {\lstset{language=While}%%\fontsize{10}{12}\selectfont |
|
1153 \texttt{\lstinputlisting{../progs/loops.while}}} |
|
1154 |
|
1155 \end{frame} |
|
1156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1157 |
|
1158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1159 \mode<presentation>{ |
|
1160 \begin{frame}[t] |
|
1161 \frametitle{\begin{tabular}{c}Interpreted Code\end{tabular}} |
|
1162 |
|
1163 \begin{center} |
|
1164 \begin{tikzpicture} |
|
1165 \begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small] |
|
1166 \addplot+[smooth] file {interpreted.data}; |
|
1167 \end{axis} |
|
1168 \end{tikzpicture} |
|
1169 \end{center} |
|
1170 |
|
1171 \end{frame}} |
|
1172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1173 |
|
1174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1175 \mode<presentation>{ |
|
1176 \begin{frame}[c] |
|
1177 \frametitle{\begin{tabular}{c}Java Virtual Machine\end{tabular}} |
|
1178 |
|
1179 \begin{itemize} |
|
1180 \item introduced in 1995 |
|
1181 \item is a stack-based VM (like Postscript, CLR of .Net) |
|
1182 \item contains a JIT compiler |
|
1183 \item many languages take advantage of JVM's infrastructure (JRE) |
|
1184 \item is garbage collected $\Rightarrow$ no buffer overflows |
|
1185 \item some languages compile to the JVM: Scala, Clojure\ldots |
|
1186 \end{itemize} |
|
1187 |
|
1188 \end{frame}} |
|
1189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1076 |
1190 |
1077 |
1191 |
1078 \end{document} |
1192 \end{document} |
1079 |
1193 |
1080 %%% Local Variables: |
1194 %%% Local Variables: |