--- a/progs/while-arrays/compile_arrays.sc Sat Nov 09 06:31:45 2024 +0000
+++ b/progs/while-arrays/compile_arrays.sc Fri Nov 22 12:42:07 2024 +0000
@@ -7,7 +7,7 @@
//
// amm compile_arrays.sc
-//> using toolkit latest
+//> using toolkit 0.6.0
// the abstract syntax trees for WHILE
@@ -90,9 +90,10 @@
// convenient string interpolations
// for generating instructions and labels
+
extension (sc: StringContext) {
- def i(args: Any*): String = " " ++ sc.s(args:_*) ++ "\n"
- def l(args: Any*): String = sc.s(args:_*) ++ ":\n"
+ def i(args: Any*): String = " " ++ sc.s(args*) ++ "\n"
+ def l(args: Any*): String = sc.s(args*) ++ ":\n"
}
@@ -128,7 +129,7 @@
def compile_stmt(s: Stmt, env: Env) : (String, Env) = s match {
case Skip => ("", env)
case Assign(x, a) => {
- val index = env.getOrElse(x, env.keys.size)
+ val index = env.getOrElse(x, env.keys.size)
(compile_aexp(a, env) ++ i"istore $index \t\t; $x", env + (x -> index))
}
case If(b, bl1, bl2) => {
@@ -218,7 +219,7 @@
// automating the above
-import os._
+import os.*
def compile_to_file(bl: Block, class_name: String) : Unit =
write.over(pwd / s"$class_name.j", compile(bl, class_name))