updated
authorChristian Urban <urbanc@in.tum.de>
Sat, 14 Dec 2019 17:57:43 +0000
changeset 705 bfc8703b1527
parent 704 6d9c960a2b26
child 706 b560f78781b9
updated
handouts/ho07.pdf
handouts/ho07.tex
hws/hw09.pdf
hws/hw09.tex
progs/fun_llvm.scala
Binary file handouts/ho07.pdf has changed
--- a/handouts/ho07.tex	Sat Dec 07 00:57:23 2019 +0000
+++ b/handouts/ho07.tex	Sat Dec 14 17:57:43 2019 +0000
@@ -6,13 +6,14 @@
 \usepackage{../graphics}
 
 
+%% add safety check on references...whether it is above 0 and below the 
+%% index
+
 \begin{document}
 \fnote{\copyright{} Christian Urban, King's College London, 2017, 2018, 2019}
 
 \section*{Handout 7 (Compilation)}
 
-
-
 The purpose of a compiler is to transform a program a human can read and
 write into code the machine can run as fast as possible. The fastest
 code would be machine code the CPU can run directly, but it is often
Binary file hws/hw09.pdf has changed
--- a/hws/hw09.tex	Sat Dec 07 00:57:23 2019 +0000
+++ b/hws/hw09.tex	Sat Dec 14 17:57:43 2019 +0000
@@ -60,7 +60,8 @@
 }
 \end{lstlisting}
 
-  
+\item What is the difference between a parse tree and an abstract
+  syntax tree? Give some simple examples for each of them.
 
 
 
--- a/progs/fun_llvm.scala	Sat Dec 07 00:57:23 2019 +0000
+++ b/progs/fun_llvm.scala	Sat Dec 14 17:57:43 2019 +0000
@@ -138,7 +138,7 @@
 val e7 = Call("foo", List(Num(3)))
 CPSi(e7)
 
-val e8 = Call("foo", List(Num(3), Num(4), Aop("+", Num(5), Num(6))))
+val e8 = Call("foo", List(Aop("*", Num(3), Num(1)), Num(4), Aop("+", Num(5), Num(6))))
 CPSi(e8)
 
 val e9 = Sequence(Aop("*", Var("a"), Num(3)), Aop("+", Var("b"), Num(6)))
@@ -239,6 +239,16 @@
   (end - start)/(i * 1.0e9)
 }
 
+// for Scala 2.12
+/*
+def deserialise[T](file: String) : Try[T] = {
+    val in = new ObjectInputStream(new FileInputStream(new File(file)))
+    val obj = Try(in.readObject().asInstanceOf[T])
+    in.close()
+    obj
+}
+*/
+
 def deserialise[T](fname: String) : Try[T] = {
   import scala.util.Using
   Using(new ObjectInputStream(new FileInputStream(fname))) {