package interpreter
- Alphabetic
- Public
- All
Type Members
- class AbstractOrMissingHandler[T] extends PartialFunction[Throwable, T]
- trait ExprTyper extends AnyRef
- class IMain extends Repl with Imports with PresentationCompilation with Closeable
An interpreter for Scala code.
An interpreter for Scala code.
The main public entry points are compile(), interpret(), and bind(). The compile() method loads a complete Scala file. The interpret() method executes one line of Scala code at the request of the user. The bind() method binds an object to a variable that can then be used by later interpreted code.
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 member(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 members called "$eval" and "$print". 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.
- case class ImportContextPreamble(exclude: Set[String], include: Set[String], preamble: String) extends Product with Serializable
- trait Imports extends AnyRef
- trait MemberHandlers extends AnyRef
- trait NamedParam extends AnyRef
- case class NamedParamClass(name: String, tpe: String, value: Any) extends NamedParam with Product with Serializable
- trait NamedParamCreator extends AnyRef
- trait Naming extends AnyRef
- trait Phased extends AnyRef
Mix this into an object and use it as a phasing Swiss Army knife.
- class Power[ReplValsImpl <: ReplVals] extends AnyRef
A class for methods to be injected into the intp in power mode.
- trait PresentationCompilation extends AnyRef
- trait PresentationCompilationResult extends AnyRef
Created by scala.tools.nsc.interpreter.Repl#presentationCompile
- trait Repl extends ReplCore
Interface to the repl for use by the frontend (shell, the UI).
Interface to the repl for use by the frontend (shell, the UI).
The interface should not depend on symbols and types (the compiler's internal state). At most, expose untyped trees and positions in addition to standard Java types. This decoupling would allow running the shell in a separate thread, or even in a separate process from the compiler. It should also be possible to write a new REPL frontend using this interface, and be compatible across minor compiler releases.
(The first iteration of this interface is only uses Positions and standard JVM types, but we could loosen that.)
- trait ReplCore extends AnyRef
The subset of the Repl used by sbt.
- trait ReplDir extends AbstractFile with Clearable
Directory to save .class files to.
- trait ReplGlobal extends Global
- class ReplOutput extends AnyRef
- trait ReplReporter extends Reporter
- trait ReplRequest extends AnyRef
- abstract class ReplVals extends AnyRef
A class which the repl utilizes to expose predefined objects.
A class which the repl utilizes to expose predefined objects. The base implementation is empty; the standard repl implementation is StdReplVals.
- class ScriptedInterpreter extends IMain with ScriptedRepl
- trait ScriptedRepl extends Repl
The interface used to expose the repl as a Java Script Engine
- trait StdReplTags extends StdTags
- class StdReplVals extends ReplVals
Value Members
- object AbstractOrMissingHandler
- object IMain
Utility methods for the Interpreter.
- object ImportContextPreamble extends java.io.Serializable
- object NamedParam extends NamedParamCreator
- object Naming
This is for name logic which is independent of the compiler (notice there's no Global.) That includes at least generating, metaquoting, mangling, and unmangling.
- object ReplStrings
- object ReplVals
- object Results
- object StdReplTags extends StdTags with StdReplTags
The Scala compiler and reflection APIs.