progs/bf/bfc0.sc
changeset 991 5d01eccc2036
parent 825 dca072e2bb7d
equal deleted inserted replaced
990:ef63ae3586b8 991:5d01eccc2036
    45 
    45 
    46 // running the c-compiler over the transpiled
    46 // running the c-compiler over the transpiled
    47 // BF program and running the resulting binary
    47 // BF program and running the resulting binary
    48 
    48 
    49 def compile_and_run(prog: String) = {
    49 def compile_and_run(prog: String) = {
    50   val tn = "tmp"
    50   val hash = java.util.UUID.randomUUID().toString.take(4)
       
    51   val tn = s"tmp_$hash"
    51   compile_to_file(s"${tn}.c", prog)
    52   compile_to_file(s"${tn}.c", prog)
    52   os.proc("gcc", "-O0", "-o", tn, s"${tn}.c").call() // call gcc
    53   os.proc("gcc", "-O0", "-o", tn, s"${tn}.c").call() // call gcc
    53   os.proc("./tmp").call(stdout = os.Inherit)         // run binary
    54   os.proc(os.pwd / s"${tn}").call(stdout = os.Inherit)         // run binary
    54 }
    55 }
    55 
    56 
    56 // Running Testcases
    57 // Running Testcases
    57 //===================
    58 //===================
    58 
    59