progs/bf/bfc0.sc
changeset 990 8cb2e171d952
parent 825 fb9f63a22114
equal deleted inserted replaced
989:84401da2e277 990:8cb2e171d952
    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