package interpreter
The main REPL related classes and values are as follows. In addition to standard compiler classes Global and Settings, there are:
History: an interface for session history. Completion: an interface for tab completion. ILoop (formerly InterpreterLoop): The umbrella class for a session. IMain (formerly Interpreter): Handles the evolving state of the session and handles submitting code to the compiler and handling the output. InteractiveReader: how ILoop obtains input. History: an interface for session history. Completion: an interface for tab completion. Power: a repository for more advanced/experimental features.
ILoop contains { in: InteractiveReader, intp: IMain, settings: Settings, power: Power } InteractiveReader contains { history: History, completion: Completion } IMain contains { global: Global }
- Source
- package.scala
- Alphabetic
- By Inheritance
- interpreter
- ReplStrings
- ReplConfig
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- class AbstractOrMissingHandler [T] extends PartialFunction[Throwable, T]
-
class
CommandLine
extends CompilerCommand
A command line for the interpreter.
-
trait
Completion
extends AnyRef
An implementation-agnostic completion interface which makes no reference to the jline classes.
- trait Delimited extends AnyRef
- trait EchoReader extends SimpleReader
- trait ExprTyper extends AnyRef
- class Formatting extends AnyRef
-
class
ILoop
extends LoopCommands
The Scala interactive shell.
The Scala interactive shell. It provides a read-eval-print loop around the Interpreter class. After instantiation, clients should call the main() method.
If no in0 is specified, then input will come from the console, and the class will attempt to provide input editing feature such as input history.
- Version
1.2
-
class
IMain
extends Imports with PresentationCompilation
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.
-
implicit
class
IMainOps
extends AnyRef
This class serves to trick the compiler into treating a var (intp, in ILoop) as a stable identifier.
-
class
ISettings
extends AnyRef
Settings for the interpreter
Settings for the interpreter
- Version
1.0
- trait Imports extends AnyRef
- type InputStream = java.io.InputStream
-
trait
InteractiveReader
extends AnyRef
Reads lines from an input stream
- type JClass = Class[_]
- type JCollection[T] = Collection[T]
- type JFile = File
- type JList[T] = java.util.List[T]
- type JPrintWriter = PrintWriter
- abstract class Javap extends AnyRef
-
class
JavapClass
extends Javap
Javap command implementation.
- trait Logger extends AnyRef
- trait LoopCommands 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
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.
- type OutputStream = java.io.OutputStream
-
class
Parsed
extends Delimited
One instance of a command buffer.
-
abstract
class
Pasted
extends AnyRef
If it looks like they're pasting in a scala interpreter transcript, remove all the formatting we inserted so we can make some sense of it.
If it looks like they're pasting in a scala interpreter transcript, remove all the formatting we inserted so we can make some sense of it.
Most of the interesting code in here is due to my goal of "paste idempotence" i.e. the transcript resulting from pasting a transcript should itself be pasteable and should achieve the same result.
-
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
- class PresentationCompilerCompleter extends Completion
- class ProcessResult extends AnyRef
- trait ReplConfig extends AnyRef
-
class
TapMaker
[T] extends AnyRef
- Definition Classes
- ReplConfig
-
trait
ReplDir
extends AbstractFile with Clearable
Directory to save .class files to.
-
trait
ReplGlobal
extends Global
A layer on top of Global so I can guarantee some extra functionality for the repl.
A layer on top of Global so I can guarantee some extra functionality for the repl. It doesn't do much yet.
- class ReplOutput extends AnyRef
- class ReplProps extends AnyRef
-
class
ReplReporter
extends ConsoleReporter
Like ReplGlobal, a layer for ensuring extra functionality.
- trait ReplStrings 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 RichClass [T] extends AnyRef
- class Scripted extends AbstractScriptEngine with Compilable
-
class
SimpleReader
extends InteractiveReader
Reads using standard JDK API
-
class
SplashLoop
extends Runnable
Collect one line of user input from the supplied reader.
Collect one line of user input from the supplied reader. Runs on a new thread while the REPL is initializing on the main thread.
The user can enter text or a
:paste
command. -
class
SplashReader
extends InteractiveReader
Reader during splash.
Reader during splash. Handles splash-completion with a stub, otherwise delegates.
- trait StdReplTags extends StdTags
- class StdReplVals extends ReplVals
- trait Tabulator extends AnyRef
-
trait
VariColumnTabulator
extends Tabulator
Adjust the column width and number of columns to minimize the row count.
- class WriterOutputStream extends OutputStream
-
class
AbstractFileClassLoader
extends util.AbstractFileClassLoader
- Annotations
- @deprecated
- Deprecated
(Since version 2.11.0) Use
scala.tools.nsc.util.AbstractFileClassLoader
Value Members
- val IR: Results.type
-
def
any2stringOf(x: Any, maxlen: Int): String
- Definition Classes
- ReplStrings
-
def
isAcross: Boolean
- Definition Classes
- ReplConfig
-
def
isPaged: Boolean
- Definition Classes
- ReplConfig
-
def
isReplDebug: Boolean
- Definition Classes
- ReplConfig
-
def
isReplInfo: Boolean
- Definition Classes
- ReplConfig
-
def
isReplPower: Boolean
- Definition Classes
- ReplConfig
-
def
isReplTrace: Boolean
- Definition Classes
- ReplConfig
- implicit def postfixOps: postfixOps
-
lazy val
replProps: ReplProps
- Definition Classes
- ReplConfig
- def staticTypeTag[T](implicit arg0: ClassTag[T]): reflect.api.JavaUniverse.TypeTag[T]
-
def
string2code(str: String): String
Convert a string into code that can recreate the string.
Convert a string into code that can recreate the string. This requires replacing all special characters by escape codes. It does not add the surrounding " marks.
- Definition Classes
- ReplStrings
-
def
string2codeQuoted(str: String): String
- Definition Classes
- ReplStrings
-
def
unquoted(s: String): String
- Definition Classes
- ReplStrings
-
def
words(s: String): List[String]
- Definition Classes
- ReplStrings
- object AbstractOrMissingHandler
- object Completion
- object Formatting
- object ILoop
-
object
IMain
Utility methods for the Interpreter.
- object InteractiveReader
- object Javap
- object JavapClass
- object NamedParam extends NamedParamCreator
- object NoCompletion extends Completion
- object NoJavap extends Javap
- object Parsed
- object PresentationCompilerCompleter
- object ReplVals
- object Results
- object Scripted
- object SimpleReader
- object SplashLoop
- object SplashReader
- object StdReplTags extends StdTags with StdReplTags
The Scala compiler and reflection APIs.