updated
authorChristian Urban <christian.urban@kcl.ac.uk>
Thu, 26 Nov 2020 02:20:13 +0000
changeset 811 86406d70d6f0
parent 810 ba25eaf6043c
child 812 2f9a0dcf61ae
updated
progs/while/compile.sc
slides/slides07.pdf
slides/slides07.tex
--- a/progs/while/compile.sc	Wed Nov 25 23:53:11 2020 +0000
+++ b/progs/while/compile.sc	Thu Nov 26 02:20:13 2020 +0000
@@ -150,11 +150,11 @@
   case Write(x) => 
     (i"iload ${env(x)} \t\t; $x" ++ 
      i"invokestatic XXX/XXX/write(I)V", env)
-  case Read(x) => {
-    val index = env.getOrElse(x, env.keys.size) 
-    (i"invokestatic XXX/XXX/read()I" ++ 
-     i"istore $index \t\t; $x", env + (x -> index))
-  }
+  //case Read(x) => {
+  //  val index = env.getOrElse(x, env.keys.size) 
+  //  (i"invokestatic XXX/XXX/read()I" ++ 
+  //   i"istore $index \t\t; $x", env + (x -> index))
+  //}
 }
 
 // compilation of a block (i.e. list of instructions)
@@ -179,11 +179,11 @@
 
 // Fibonacci numbers as a bare-bone test-case
 val fib_test = 
-  List(Assign("n", Num(9)),            //  n := 10;                     
+  List(Assign("n", Num(9)),            //  n := 9;                     
        Assign("minus1",Num(0)),         //  minus1 := 0;
        Assign("minus2",Num(1)),         //  minus2 := 1;
        Assign("temp",Num(0)),           //  temp := 0;
-       While(Bop("<",Num(0),Var("n")),  //  while n > 0 do  {
+       While(Bop("<",Num(0),Var("n")),  //  while 0 < n do  {
           List(Assign("temp",Var("minus2")), //  temp := minus2;
                Assign("minus2",Aop("+",Var("minus1"),Var("minus2"))), 
                                         //  minus2 := minus1 + minus2;
Binary file slides/slides07.pdf has changed
--- a/slides/slides07.tex	Wed Nov 25 23:53:11 2020 +0000
+++ b/slides/slides07.tex	Thu Nov 26 02:20:13 2020 +0000
@@ -813,8 +813,7 @@
 .method public static write(I)V 
   .limit locals 1 
   .limit stack 2 
-  getstatic java/lang/System/out 
-                            Ljava/io/PrintStream; 
+  getstatic java/lang/System/out Ljava/io/PrintStream; 
   iload 0
   invokevirtual java/io/PrintStream/println(I)V 
   return 
@@ -839,11 +838,7 @@
 .class public XXX.XXX
 .super java/lang/Object
 
-.method public <init>()V
-    aload_0
-    invokenonvirtual java/lang/Object/<init>()V
-    return
-.end method
+...
 
 .method public static main([Ljava/lang/String;)V
     .limit locals 200
@@ -855,6 +850,13 @@
 .end method
 \end{lstlisting}
 
+%.method public <init>()V
+%    aload_0
+%    invokenonvirtual java/lang/Object/<init>()V
+%    return
+%.end method
+
+
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%