blob: a0255efa67e6dc48f8edca7355a24bbf57d98e33 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package dotty.tools
package dotc
import core.Phases
import core.Contexts.Context
import reporting.Reporter
import java.io.EOFException
import scala.annotation.tailrec
import io.VirtualDirectory
import java.io.{BufferedReader, File, FileReader, PrintWriter}
import repl._
/** A compiler which stays resident between runs.
* Usage:
*
* > scala dotty.tools.dotc.Resident <options> <initial files>
*
* dotc> "more options and files to compile"
*
* ...
*
* dotc> :reset // reset all options to the ones passed on the command line
*
* ...
*
* dotc> :q // quit
*/
class REPL extends Driver {
def input(implicit ctx: Context): InteractiveReader = {
val emacsShell = System.getProperty("env.emacs", "") != ""
//println("emacsShell="+emacsShell) //debug
if (ctx.settings.Xnojline.value || emacsShell) new SimpleReader()
else InteractiveReader.createDefault()
}
def output: PrintWriter = new NewLinePrintWriter(new ConsoleWriter, true)
override def newCompiler(): Compiler = new repl.Interpreter(output)
override def sourcesRequired = false
override def doCompile(compiler: Compiler, fileNames: List[String])(implicit ctx: Context): Reporter = {
new InterpreterLoop(compiler, input, output).run()
ctx.reporter
}
}
|