Skip to content

Commit

Permalink
Use different filenames for different backends
Browse files Browse the repository at this point in the history
  • Loading branch information
phischu committed Jan 22, 2025
1 parent 5c19040 commit ac339f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions examples/benchmarks/input_output/dyck_one.effekt
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,19 @@ def size(tree: Tree): Int =
}
}

extern def filename(): String =
js { "/tmp/dyck_one_js.txt" }
llvm { "/tmp/dyck_one_llvm.txt" }

def run(n: Int): Int = {
with on[IOError].panic

val filename = "/tmp/dyck_one.txt"

val _ = {
with writeFile(filename)
with writeFile(filename())
emitTree(n)
}

with readFile(filename)
with readFile(filename())
with returning::scanner[Byte, Int]
attempt { readTree().size } { panic("Expected tree.")}
}
Expand Down
10 changes: 6 additions & 4 deletions examples/benchmarks/input_output/word_count_ascii.effekt
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ def countWords(): Output / read[Byte] = {
Output(chars, words, lines)
}

extern def filename(): String =
js { "/tmp/word_count_ascii_js.txt" }
llvm { "/tmp/word_count_ascii_llvm.txt" }

def run(n: Int) = {
with on[IOError].panic;

val filename = "/tmp/word_count_ascii.txt"

val _ = {
with writeFile(filename)
with writeFile(filename())
with repeat(n)
for[Int] { range(32, 127) } { c =>
repeat(10) {
Expand All @@ -76,7 +78,7 @@ def run(n: Int) = {
}

val output = {
with readFile(filename)
with readFile(filename())
countWords()
}

Expand Down

0 comments on commit ac339f7

Please sign in to comment.