Dotty Documentation



[-] Constructors

[-] Members

A class loader that loads files from a [[]].

[+] class AmmoniteReader

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.

Utility methods for the Interpreter.

[+] class ConsoleWriter

A Writer that writes onto the Scala Console.

[+] object InteractiveReader

The current Scala REPL know how to do this flexibly.

[+] trait InteractiveReader

Reads lines from an input stream

[+] object Interpreter

This object defines the type of interpreter results

[+] trait Interpreter

The exported functionality of the interpreter

[+] class InterpreterLoop

The interactive shell. It provides a read-eval-print loop around the Interpreter class. After instantiation, clients should call the run method.

[+] object Main

The main entry point of the REPL

[+] object ManifestInfo
[+] class NewLinePrintWriter
[+] class REPL

A compiler which stays resident between runs. Usage:


dotc> "more options and files to compile"


dotc> :reset // reset all options to the ones passed on the command line


dotc> :q // quit

[+] object REPL
[+] class SimpleReader

Reads using standard JDK API