tuned
authorChristian Urban <christian dot urban at kcl dot ac dot uk>
Thu, 14 Mar 2013 19:03:05 +0000
changeset 226 df455e0a9f98
parent 225 0974c59e7029
child 227 10d4d20c4e4b
tuned
scala/README
scala/ex.scala
scala/ex_jvm.scala
--- a/scala/README	Thu Mar 14 18:46:34 2013 +0000
+++ b/scala/README	Thu Mar 14 19:03:05 2013 +0000
@@ -33,4 +33,11 @@
 requires the jasmin assembler for Java
 avilable from
 
-   http://jasmin.sourceforge.net
\ No newline at end of file
+  http://jasmin.sourceforge.net
+
+Calling
+
+  scala -cp $PWD ex_jvm.scala
+
+generates a Prog.j intermediate file.
+This will be assembled using jasmin.
\ No newline at end of file
--- a/scala/ex.scala	Thu Mar 14 18:46:34 2013 +0000
+++ b/scala/ex.scala	Thu Mar 14 19:03:05 2013 +0000
@@ -95,7 +95,7 @@
   val res = (abc_f.run(abc_map))(arity)
   val end = System.nanoTime()
   val time = (end - start)/1.0e9
-  ("Result: " + res + "  length: " + abc_f.p.length + " time: " + "%.5f".format(time) + "\n Prog:" + abc_f)
+  ("Result: " + res + "  length: " + abc_f.p.length + " time: " + "%.5f".format(time))
 }
 
 println("S(3)          " + test_comp2(S, 3))
--- a/scala/ex_jvm.scala	Thu Mar 14 18:46:34 2013 +0000
+++ b/scala/ex_jvm.scala	Thu Mar 14 19:03:05 2013 +0000
@@ -74,7 +74,7 @@
 
 
 def compile(f: Rec, ns: List[Int]) : Unit = {
-  val class_name = "LOOP"
+  val class_name = "Prog"
   val (aprog, res, max) = compile_rec(f)
 
   val init_code = init_regs(ns.padTo(max, 0))
@@ -94,12 +94,19 @@
   println("Result: " + result + "  Time: " + (end - start) / 1.0e9)
 }
 
+print("Add(69, 30)   "); compile(Add, List(69, 30))
+print("Mult(13, 9)   "); compile(recs.Mult, List(13, 9))
+print("Power(3, 4)   "); compile(Power, List(3, 4))
+print("Strt:  ");  compile(Strt(2), List(2,3))
 
-//compile(S, List(3))
-//compile(Fact, List(11))
-//compile(Fact, List(12))
-//compile(Fact, List(13))
-//compile(Fact, List(14))
+println("FACTORIAL")
+
+for (i <- 5 to 9) {
+  println("Input:  " + i)
+  compile(Fact, List(i))
+}
+
+println("PRIME TEST")
 
 for (i <- 10 to 20) {
   println("Input:  " + i)