A class loader that loads files from a scala.tools.nsc.io.AbstractFile
.
An interpreter for Scala code which is based on the dotc
compiler.
A Writer that writes onto the Scala Console.
A Writer that writes onto the Scala Console.
1.0
Reads lines from an input stream
The exported functionality of the interpreter
The interactive shell.
The interactive shell. It provides a read-eval-print loop around
the Interpreter class.
After instantiation, clients should call the run
method.
A compiler which stays resident between runs.
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
Reads using standard JDK API
Utility methods for the Interpreter.
The current Scala REPL know how to do this flexibly.
This object defines the type of interpreter results
The main entry point of the REPL
An interpreter for Scala code which is based on the
dotc
compiler.The overall approach is based on compiling the requested code and then using a Java classloader and Java reflection to run the code and access its results.
In more detail, a single compiler instance is used to accumulate all successfully compiled or interpreted Scala code. To "interpret" a line of code, the compiler generates a fresh object that includes the line of code and which has public definition(s) to export all variables defined by that code. To extract the result of an interpreted line to show the user, a second "result object" is created which imports the variables exported by the above object and then exports a single definition named "result". To accommodate user expressions that read from variables or methods defined in previous statements, "import" statements are used.
This interpreter shares the strengths and weaknesses of using the full compiler-to-Java. The main strength is that interpreted code behaves exactly as does compiled code, including running at full speed. The main weakness is that redefining classes and methods is not handled properly, because rebinding at the Java level is technically difficult.