--- 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;