diff -r df455e0a9f98 -r 10d4d20c4e4b scala/ex_jvm.scala --- a/scala/ex_jvm.scala Thu Mar 14 19:03:05 2013 +0000 +++ b/scala/ex_jvm.scala Thu Mar 14 19:18:39 2013 +0000 @@ -74,19 +74,18 @@ def compile(f: Rec, ns: List[Int]) : Unit = { - val class_name = "Prog" + val class_name = "Prog" // name of the class and program val (aprog, res, max) = compile_rec(f) - val init_code = init_regs(ns.padTo(max, 0)) + val init_code = init_regs(ns.padTo(max, 0)) // initialising registers with input data val main_code = compile_aprog(aprog.p) - val fin_code = print_result(aprog.p.length, res, class_name) - val code = init_code.mkString + main_code.mkString + fin_code + val end_code = print_result(aprog.p.length, res, class_name) + val code = beginning(class_name) + init_code + main_code + end_code + ending - val assembly = beginning(class_name) ++ code ++ ending + val fw = new java.io.FileWriter(class_name + ".j") // temporary file + fw.write(code) + fw.close() - val fw = new java.io.FileWriter(class_name + ".j") - fw.write(assembly) - fw.close() val _ = ("java -jar jvm/jasmin-2.4/jasmin.jar " + class_name + ".j").!! val start = System.nanoTime() val result = ("java " + class_name + "/" + class_name).!! @@ -101,7 +100,7 @@ println("FACTORIAL") -for (i <- 5 to 9) { +for (i <- 7 to 14) { println("Input: " + i) compile(Fact, List(i)) }