progs/fun/funt.sc
changeset 869 81ee93b87258
parent 813 059f970287d1
child 870 739039774cee
equal deleted inserted replaced
868:8fb3b6d3be70 869:81ee93b87258
   159 def compile(prog: List[Decl], class_name: String) : String = {
   159 def compile(prog: List[Decl], class_name: String) : String = {
   160   val instructions = prog.map(compile_decl).mkString
   160   val instructions = prog.map(compile_decl).mkString
   161   (library + instructions).replaceAllLiterally("XXX", class_name)
   161   (library + instructions).replaceAllLiterally("XXX", class_name)
   162 }
   162 }
   163 
   163 
   164 import ammonite.ops._
   164 // pre-2.5.0 ammonite 
       
   165 // import ammonite.ops._
       
   166 
       
   167 // post 2.5.0 ammonite
       
   168 import $ivy.`com.lihaoyi::os-lib:0.8.0` 
   165 
   169 
   166 def compile_to_file(prog: List[Decl], class_name: String) : Unit = 
   170 def compile_to_file(prog: List[Decl], class_name: String) : Unit = 
   167   write.over(pwd / s"$class_name.j", compile(prog, class_name))  
   171   write.over(pwd / s"$class_name.j", compile(prog, class_name))  
   168 
   172 
   169 def compile_and_run(prog: List[Decl], class_name: String) : Unit = {
   173 def compile_and_run(prog: List[Decl], class_name: String) : Unit = {