progs/while-arrays/compile_bfc.sc
changeset 958 fddf099a82f8
parent 956 ae9782e62bdd
child 974 0cb4bf2469d1
equal deleted inserted replaced
957:34b3aeb65fbe 958:fddf099a82f8
    19 //  scala-cli --dep com.lihaoyi::fastparse:3.0.2  compile_bfc.sc 
    19 //  scala-cli --dep com.lihaoyi::fastparse:3.0.2  compile_bfc.sc 
    20 //
    20 //
    21 // Scala-cli is another REPL for scala. Unfortunately
    21 // Scala-cli is another REPL for scala. Unfortunately
    22 // fastparse used in this file is not yet supported
    22 // fastparse used in this file is not yet supported
    23 // under ammonite.
    23 // under ammonite.
       
    24 
       
    25 // compile_arrays.sc (no peephole optimisations)
       
    26 // compile_arrays2.sc (peephole optimisations applied)
    24 
    27 
    25 //> using file compile_arrays2.sc
    28 //> using file compile_arrays2.sc
    26 import compile_arrays2._
    29 import compile_arrays2._
    27 
    30 
    28 def time_needed[T](i: Int, code: => T) = {
    31 def time_needed[T](i: Int, code: => T) = {
    61 // modified main compilation function for blocks
    64 // modified main compilation function for blocks
    62 def compile(bl: Block, class_name: String) : String = {
    65 def compile(bl: Block, class_name: String) : String = {
    63   val instructions = compile_block(bl, Map())._1
    66   val instructions = compile_block(bl, Map())._1
    64   (beginning ++ instructions ++ ending).replace("XXX", class_name)
    67   (beginning ++ instructions ++ ending).replace("XXX", class_name)
    65 }
    68 }
    66 
       
    67 // automating the above
       
    68 
       
    69 // pre-2.5.0 ammonite 
       
    70 // import ammonite.ops._
       
    71 
    69 
    72 // post 2.5.0 ammonite
    70 // post 2.5.0 ammonite
    73 import os._
    71 import os._
    74 
    72 
    75 
    73