35 \end{tabular}} |
36 \end{tabular}} |
36 |
37 |
37 \normalsize |
38 \normalsize |
38 \begin{center} |
39 \begin{center} |
39 \begin{tabular}{ll} |
40 \begin{tabular}{ll} |
40 Email: & christian.urban at kcl.ac.uk\\ |
41 Email: & christian.urban at kcl.ac.uk\\ |
41 Office: & N7.07 (North Wing, Bush House)\\ |
42 Office Hours: & Thursdays 12 -- 14\\ |
42 Slides: & KEATS (also home work is there)\\ |
43 Location: & N7.07 (North Wing, Bush House)\\ |
|
44 Slides \& Progs: & KEATS (also homework is there)\\ |
43 \end{tabular} |
45 \end{tabular} |
44 \end{center} |
46 \end{center} |
45 |
47 |
46 \end{frame} |
48 \end{frame} |
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
282 \end{frame} |
284 \end{frame} |
283 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
284 |
286 |
285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
286 \begin{frame}[c] |
288 \begin{frame}[c] |
287 \frametitle{Fun Grammar} |
289 \frametitle{Fun-Grammar} |
288 \bl{ |
290 \bl{ |
289 \begin{plstx}[rhs style=] |
291 \begin{plstx}[rhs style=] |
290 : \meta{Exp} ::= \meta{Var} | \meta{Num}{\hspace{3cm}} |
292 : \meta{Exp} ::= \meta{Var} | \meta{Num}{\hspace{4cm}} |
291 | \meta{Exp} + \meta{Exp} | ... | (\meta{Exp}) |
293 | \meta{Exp} + \meta{Exp} | ... | (\meta{Exp}) |
292 | \code{if} \meta{BExp} \code{then} \meta{Exp} \code{else} \meta{Exp} |
294 | \code{if} \meta{BExp} \code{then} \meta{Exp} \code{else} \meta{Exp} |
293 | \code{write} \meta{Exp} {\hspace{3cm}} |
295 | \code{write} \meta{Exp} {\hspace{5cm}} |
294 | \meta{Exp} ; \meta{Exp} |
296 | \meta{Exp} ; \meta{Exp} |
295 | \textit{FunName} (\meta{Exp}, ... , \meta{Exp})\\ |
297 | \textit{FunName} (\meta{Exp}, ... , \meta{Exp})\\ |
296 : \meta{BExp} ::= ...\\ |
298 : \meta{BExp} ::= ...\\ |
297 : \meta{Def} ::= \code{def} \textit{FunName} ($\hspace{0.4mm}x_1$, ... , $x_n$) = \meta{Exp}\\ |
299 : \meta{Def} ::= \code{def} \textit{FunName} ($\hspace{0.4mm}x_1$, ... , $x_n$) = \meta{Exp}\\ |
298 : \meta{Prog} ::= \meta{Def} ; \meta{Prog} |
300 : \meta{Prog} ::= \meta{Def} ; \meta{Prog} |
334 \end{frame} |
336 \end{frame} |
335 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
337 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
336 |
338 |
337 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
339 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
338 \begin{frame}[c, fragile] |
340 \begin{frame}[c, fragile] |
339 \frametitle{Idea} |
341 \frametitle{Ideas} |
340 |
342 |
341 Compile \texttt{exp} such that the result of the expression |
343 Use separate JVM methods for each Fun-function.\bigskip |
|
344 |
|
345 Compile \bl{\texttt{exp}}s such that the result of the expression |
342 is on top of the stack.\bigskip |
346 is on top of the stack.\bigskip |
343 |
347 |
344 \begin{itemize} |
348 \begin{itemize} |
345 \item \texttt{\color{codepurple}{write}}\texttt{(1 + 2)} |
349 \item \texttt{\color{codepurple}{write}}\texttt{(1 + 2)} |
346 \item \texttt{1 + 2; 3 + 4} |
350 \item \texttt{1 + 2; 3 + 4} |
415 invokevirtual java/io/PrintStream/println(I)V |
419 invokevirtual java/io/PrintStream/println(I)V |
416 return |
420 return |
417 .end method |
421 .end method |
418 \end{lstlisting}\bigskip |
422 \end{lstlisting}\bigskip |
419 |
423 |
420 \small We will need for definitions, like\footnotesize\medskip |
424 \small We will need methods for definitions like\footnotesize\medskip |
421 |
425 |
422 \begin{lstlisting}[language=JVMIS, |
426 \begin{lstlisting}[language=JVMIS, |
423 xleftmargin=2mm, |
427 xleftmargin=2mm, |
424 numbers=none] |
428 numbers=none] |
425 def fname (x1, ... , xn) = ... |
429 def fname (x1, ... , xn) = ... |
655 \item \texttt{Exp op Exp} |
659 \item \texttt{Exp op Exp} |
656 \end{itemize}}\medskip |
660 \end{itemize}}\medskip |
657 |
661 |
658 then a call \texttt{f(args)} can be compiled as\medskip\small |
662 then a call \texttt{f(args)} can be compiled as\medskip\small |
659 |
663 |
660 \begin{lstlisting}[basicstyle=\ttfamily, numbers=none] |
664 \begin{lstlisting}[numbers=none] |
661 prepare environment |
665 prepare environment |
662 jump to start of function |
666 jump to start of function |
663 \end{lstlisting} |
667 \end{lstlisting} |
664 |
668 |
665 \end{frame} |
669 \end{frame} |
668 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
672 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
669 \begin{frame}[c, fragile] |
673 \begin{frame}[c, fragile] |
670 \frametitle{Tail Recursive Call} |
674 \frametitle{Tail Recursive Call} |
671 \footnotesize |
675 \footnotesize |
672 |
676 |
673 \begin{textblock}{13}(-0.3,2) |
677 \begin{textblock}{13}(-0.3,3) |
674 \begin{lstlisting}[language=Scala,basicstyle=\ttfamily, numbers=none] |
678 \begin{lstlisting}[language=Scala, numbers=none] |
675 def compile_expT(a: Exp, env: Mem, name: String): Instrs = |
679 def compile_expT(a: Exp, env: Mem, name: String): Instrs = |
676 ... |
680 ... |
677 case Call(n, args) => if (name == n) |
681 case Call(n, args) => if (name == n) |
678 { |
|
679 val stores = args.zipWithIndex.map |
|
680 { case (x, y) => "istore " + y.toString + "\n" } |
|
681 args.flatMap(a => compile_expT(a, env, "")) ++ |
|
682 stores.reverse ++ |
|
683 List ("goto " + n + "_Start\n") |
|
684 } |
|
685 else |
|
686 { |
682 { |
|
683 val stores = |
|
684 args.zipWithIndex.map { case (x, y) => i"istore $y" } |
|
685 |
|
686 args.map(a => compile_expT(a, env, "")).mkString ++ |
|
687 stores.reverse.mkString ++ |
|
688 i"goto ${n}_Start" |
|
689 } else { |
687 val is = "I" * args.length |
690 val is = "I" * args.length |
688 args.flatMap(a => compile_expT(a, env, "")) ++ |
691 args.map(a => compile_expT(a, env, "")).mkString ++ |
689 List ("invokestatic XXX/XXX/" + n + "(" + is + ")I\n") |
692 i"invokestatic XXX/XXX/${n}(${is})I" |
690 } |
693 } |
691 \end{lstlisting} |
694 \end{lstlisting} |
692 \end{textblock} |
695 \end{textblock} |
693 |
696 |
694 \end{frame} |
697 \end{frame} |
741 \end{frame} |
744 \end{frame} |
742 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
745 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
743 |
746 |
744 |
747 |
745 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
748 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
746 |
|
747 \begin{frame}[c] |
749 \begin{frame}[c] |
748 \frametitle{Can This Be Done?} |
750 \frametitle{Can This Be Done?} |
749 |
751 |
750 \begin{itemize} |
752 \begin{itemize} |
751 \item in 2008, verification of a small C-compiler |
753 \item in 2008, verification of a small C-compiler |
784 \end{itemize} |
786 \end{itemize} |
785 |
787 |
786 \end{frame} |
788 \end{frame} |
787 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
789 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
788 |
790 |
|
791 |
|
792 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
793 \begin{frame}[c] |
|
794 |
|
795 \begin{center} |
|
796 \includegraphics[angle=90,scale=0.35]{/Users/cu/vote.pdf} |
|
797 \end{center} |
|
798 |
|
799 \end{frame} |
|
800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
801 |
|
802 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
803 \begin{frame}[c] |
|
804 |
|
805 \begin{center} |
|
806 \includegraphics[scale=0.25]{/Users/cu/dresden.png} |
|
807 \end{center} |
|
808 |
|
809 \begin{textblock}{13}(2,12) |
|
810 \includegraphics[scale=0.08]{/Users/cu/kiss.jpg} |
|
811 \end{textblock} |
|
812 |
|
813 \begin{textblock}{13}(7,12) |
|
814 \includegraphics[scale=0.079]{/Users/cu/pioniere.jpg} |
|
815 \end{textblock} |
|
816 |
|
817 \end{frame} |
|
818 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
819 |
|
820 |
789 \end{document} |
821 \end{document} |
790 |
822 |
791 %%% Local Variables: |
823 %%% Local Variables: |
792 %%% mode: latex |
824 %%% mode: latex |
793 %%% TeX-master: t |
825 %%% TeX-master: t |