Skip to content

Commit f10a2ad

Browse files
committed
Unify preludes across backends
1 parent ea19f7a commit f10a2ad

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

effekt/jvm/src/main/scala/effekt/Runner.scala

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ trait Runner[Executable] {
4343
* if module A depends on module B, then B should come before A.
4444
* - Furthermore, each module mentioned here must import the `effekt` module as its first import.
4545
*/
46-
def prelude: List[String] = List("effekt")
46+
def prelude: List[String] = List("effekt", "option", "list", "result", "exception", "array", "string", "ref", "bytearray", "stringbuffer", "splice")
4747

4848
/**
4949
* Creates a OS-specific script file that will execute the command when executed,
@@ -157,8 +157,6 @@ object JSNodeRunner extends Runner[String] {
157157

158158
override def includes(path: File): List[File] = List(path / ".." / "js")
159159

160-
override def prelude: List[String] = List("effekt", "option", "list", "result", "exception", "array", "string", "ref", "bytearray", "stringbuffer", "splice")
161-
162160
def checkSetup(): Either[String, Unit] =
163161
if canRunExecutable("node", "--version") then Right(())
164162
else Left("Cannot find nodejs. This is required to use the JavaScript backend.")
@@ -190,16 +188,13 @@ object JSNodeRunner extends Runner[String] {
190188
}
191189
}
192190
object JSWebRunner extends Runner[String] {
193-
import scala.sys.process.Process
194191

195192
val extension = "js"
196193

197194
def standardLibraryPath(root: File): File = root / "libraries" / "common"
198195

199196
override def includes(path: File): List[File] = List(path / ".." / "js")
200197

201-
override def prelude: List[String] = List("effekt", "option", "list", "result", "exception", "array", "string", "ref", "bytearray", "stringbuffer", "splice")
202-
203198
def checkSetup(): Either[String, Unit] =
204199
Left("Running js-web code directly is not supported. Use `--compile` to generate a js file / `--build` to generate a html file.")
205200

@@ -208,7 +203,6 @@ object JSWebRunner extends Runner[String] {
208203
* and then errors out, printing it's path.
209204
*/
210205
def build(path: String)(using C: Context): String =
211-
import java.nio.file.Path
212206
val out = C.config.outputPath().getAbsolutePath
213207
val jsFilePath = (out / path).unixPath
214208
val jsFileName = path.unixPath.split("/").last
@@ -237,9 +231,7 @@ object JSWebRunner extends Runner[String] {
237231
trait ChezRunner extends Runner[String] {
238232
val extension = "ss"
239233

240-
def standardLibraryPath(root: File): File = root / "libraries" / "common"
241-
242-
override def prelude: List[String] = List("effekt", "option", "list", "result", "exception", "array", "string", "bytearray", "stringbuffer", "splice", "ref")
234+
def standardLibraryPath(root: File): File = root / "libraries" / "common"
243235

244236
def checkSetup(): Either[String, Unit] =
245237
if canRunExecutable("scheme", "--help") then Right(())
@@ -270,17 +262,13 @@ object ChezCallCCRunner extends ChezRunner {
270262
}
271263

272264
object LLVMRunner extends Runner[String] {
273-
import scala.sys.process.Process
274265

275266
val extension = "ll"
276267

277268
def standardLibraryPath(root: File): File = root / "libraries" / "common"
278269

279270
override def includes(path: File): List[File] = List(path / ".." / "llvm")
280271

281-
override def prelude: List[String] = List("effekt", "option", "list", "result", "exception", "string", "bytearray", "stringbuffer", "splice") // "array", "ref")
282-
283-
284272
lazy val gccCmd = discoverExecutable(List("cc", "clang", "gcc"), List("--version"))
285273
lazy val llcCmd = discoverExecutable(List("llc", "llc-15", "llc-16"), List("--version"))
286274
lazy val optCmd = discoverExecutable(List("opt", "opt-15", "opt-16"), List("--version"))

0 commit comments

Comments
 (0)