equal
  deleted
  inserted
  replaced
  
    
    
    86 type Env = Map[String, Int]  | 
    86 type Env = Map[String, Int]  | 
    87   | 
    87   | 
    88 // convenient string interpolations   | 
    88 // convenient string interpolations   | 
    89 // for generating instructions and labels  | 
    89 // for generating instructions and labels  | 
    90   | 
    90   | 
    91 implicit def sring_inters(sc: StringContext) = new { | 
    91 extension (sc: StringContext) { | 
    92     def i(args: Any*): String = "   " ++ sc.s(args:_*) ++ "\n"  | 
    92     def i(args: Any*): String = "   " ++ sc.s(args:_*) ++ "\n"  | 
    93     def l(args: Any*): String = sc.s(args:_*) ++ ":\n"  | 
    93     def l(args: Any*): String = sc.s(args:_*) ++ ":\n"  | 
    94 }  | 
    94 }  | 
         | 
    95   | 
    95   | 
    96   | 
    96 def compile_op(op: String) = op match { | 
    97 def compile_op(op: String) = op match { | 
    97   case "+" => i"iadd"  | 
    98   case "+" => i"iadd"  | 
    98   case "-" => i"isub"  | 
    99   case "-" => i"isub"  | 
    99   case "*" => i"imul"  | 
   100   case "*" => i"imul"  | 
   213 //  | 
   214 //  | 
   214 //    java arr/arr  | 
   215 //    java arr/arr  | 
   215   | 
   216   | 
   216 // automating the above  | 
   217 // automating the above  | 
   217   | 
   218   | 
   218 // pre-2.5.0 ammonite   | 
         | 
   219 // import ammonite.ops._  | 
         | 
   220   | 
         | 
   221 // post 2.5.0 ammonite  | 
         | 
   222 import os._  | 
   219 import os._  | 
   223   | 
         | 
   224   | 
         | 
   225   | 
   220   | 
   226 def compile_to_file(bl: Block, class_name: String) : Unit =   | 
   221 def compile_to_file(bl: Block, class_name: String) : Unit =   | 
   227   write.over(pwd / s"$class_name.j", compile(bl, class_name))    | 
   222   write.over(pwd / s"$class_name.j", compile(bl, class_name))    | 
   228   | 
   223   | 
   229 def compile_and_run(bl: Block, class_name: String) : Unit = { | 
   224 def compile_and_run(bl: Block, class_name: String) : Unit = { | 
   244 }  | 
   239 }  | 
   245   | 
   240   | 
   246   | 
   241   | 
   247   | 
   242   | 
   248   | 
   243   | 
   249 // runs with amm2 and amm3  | 
   244   | 
   250   | 
         |