org.apache.spark.repl

SparkIMain

class SparkIMain extends SparkImports with Logging

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 accomodate 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.

Self Type
SparkIMain
Linear Supertypes
Logging, SparkImports, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. SparkIMain
  2. Logging
  3. SparkImports
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new SparkIMain()

  2. new SparkIMain(settings: Settings)

    construct an interpreter that reports to Console

  3. new SparkIMain(initialSettings: Settings, out: JPrintWriter)

Type Members

  1. class ReadEvalPrint extends AnyRef

    Here is where we:

  2. implicit class ReplTypeOps extends AnyRef

  3. class Request extends AnyRef

    One line of code submitted by the user for interpretation

  4. case class SparkComputedImports(prepend: String, append: String, access: String) extends Product with Serializable

    Compute imports that allow definitions from previous requests to be visible in a new request.

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. object FixedSessionNames

    Captures the session names (which are set by system properties) once, instead of for each line.

  7. val SPARK_DEBUG_REPL: Boolean

  8. def addImports(ids: String*): Result

  9. def aliasForType(path: String): Option[String]

    Parse the ScalaSig to find type aliases

  10. def allDefHandlers: List[(memberHandlers)#MemberDefHandler]

  11. def allDefSymbols: List[scala.tools.nsc.Global.Symbol]

  12. def allDefinedNames: List[scala.tools.nsc.Global.Name]

  13. def allHandlers: List[(memberHandlers)#MemberHandler]

  14. def allImplicits: List[scala.tools.nsc.Global.Name { ... /* 5 definitions in type refinement */ }]

  15. def allImportedNames: List[scala.tools.nsc.Global.Name]

    Definition Classes
    SparkImports
  16. def allSeenTypes: List[String]

  17. def apply[T](implicit arg0: ClassTag[T]): scala.tools.nsc.Global.Symbol

  18. def apply(name: String): scala.tools.nsc.Global.Symbol

    Translate a repl-defined identifier into a Symbol.

  19. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  20. def beQuietDuring[T](body: ⇒ T): T

    Temporarily be quiet

  21. def beSilentDuring[T](operation: ⇒ T): T

  22. def bind[T](name: String, value: T)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T], arg1: ClassTag[T]): Result

  23. def bind(p: NamedParam): Result

  24. def bind(name: String, boundType: String, value: Any, modifiers: List[String] = Nil): Result

    Bind a specified name to a specified value.

    Bind a specified name to a specified value. The name may later be used by expressions passed to interpret.

    name

    the variable name to bind

    boundType

    the type of the variable, as a string

    value

    the object value to bind to it

    returns

    an indication of whether the binding succeeded

  25. def bindSyntheticValue(x: Any): Result

  26. def bindValue(name: String, x: Any): Result

  27. def bindValue(x: Any): Result

  28. def classLoader: AbstractFileClassLoader

  29. def classOfTerm(id: String): Option[JClass]

  30. val classServer: HttpServer

  31. val classServerPort: Int

    Jetty server that will serve our classes to worker nodes

  32. def classSymbols: List[scala.tools.nsc.Global.ClassSymbol]

  33. def cleanMemberDecl(owner: scala.tools.nsc.Global.Symbol, member: scala.tools.nsc.Global.Name): scala.tools.nsc.Global.Type

  34. def clearExecutionWrapper(): Unit

  35. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. def close(): Unit

    This instance is no longer needed, so release any resources it is using.

    This instance is no longer needed, so release any resources it is using. The reporter's output gets flushed.

  37. def compileSources(sources: SourceFile*): Boolean

    Compile an nsc SourceFile.

    Compile an nsc SourceFile. Returns true if there are no compilation errors, or false otherwise.

  38. def compileSourcesKeepingRun(sources: SourceFile*): (Boolean, Run)

  39. def compileString(code: String): Boolean

    Compile a string.

    Compile a string. Returns true if there are no compilation errors, or false otherwise.

  40. def compilerClasspath: Seq[URL]

  41. val conf: SparkConf

  42. def debugging[T](msg: String)(res: T): T

  43. object deconstruct extends StructuredTypeStrings

  44. def definedSymbolList: List[scala.tools.nsc.Global.Symbol]

  45. def definedSymbols: Set[scala.tools.nsc.Global.Symbol]

  46. def definedTerms: List[scala.tools.nsc.Global.TermName]

  47. def definedTypes: List[scala.tools.nsc.Global.TypeName]

  48. def definitionForName(name: scala.tools.nsc.Global.Name): Option[(memberHandlers)#MemberHandler]

  49. def directBind[T](name: String, value: T)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T], arg1: ClassTag[T]): Result

  50. def directBind(p: NamedParam): Result

  51. def directBind(name: String, boundType: String, value: Any): Result

  52. final def ensureClassLoader(): Unit

  53. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  54. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  55. def executionWrapper: String

  56. object exprTyper extends SparkExprTyper

  57. def fallback: Boolean

    Definition Classes
    SparkImports
  58. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  59. def flatName(id: String): String

  60. lazy val formatting: Formatting

  61. def generatedName(simpleName: String): Option[String]

    Given a simple repl-defined name, returns the real name of the class representing it, e.

    Given a simple repl-defined name, returns the real name of the class representing it, e.g. for "Bippy" it may return

    $line19.$read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$Bippy
  62. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  63. def getInterpreterClassLoader(): AbstractFileClassLoader

  64. lazy val global: Global

    the public, go through the future compiler

  65. def handleTermRedefinition(name: scala.tools.nsc.Global.TermName, old: Request, req: Request): Unit

  66. def handleTypeRedefinition(name: scala.tools.nsc.Global.TypeName, old: Request, req: Request): Unit

    Stubs for work in progress.

  67. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  68. def implicitSymbols: List[scala.tools.nsc.Global.Symbol]

    Definition Classes
    SparkImports
  69. def implicitSymbolsBySource: List[(scala.tools.nsc.Global.Symbol, List[scala.tools.nsc.Global.Symbol])]

    Definition Classes
    SparkImports
  70. def importHandlers: List[(memberHandlers)#ImportHandler]

  71. def importedSymbols: List[scala.tools.nsc.Global.Symbol]

    Definition Classes
    SparkImports
  72. def importedSymbolsBySource: List[(scala.tools.nsc.Global.Symbol, List[scala.tools.nsc.Global.Symbol])]

    Tuples of (source, imported symbols) in the order they were imported.

    Tuples of (source, imported symbols) in the order they were imported.

    Definition Classes
    SparkImports
  73. def importedTermNamed(name: String): scala.tools.nsc.Global.Symbol

    Definition Classes
    SparkImports
  74. def importedTermSymbols: List[scala.tools.nsc.Global.TermSymbol]

    Definition Classes
    SparkImports
  75. def importedTerms: List[scala.tools.nsc.Global.TermName]

    Definition Classes
    SparkImports
  76. def importedTypeSymbols: List[scala.tools.nsc.Global.TypeSymbol]

    Definition Classes
    SparkImports
  77. def importedTypes: List[scala.tools.nsc.Global.TypeName]

    Definition Classes
    SparkImports
  78. def importsCode(wanted: Set[scala.tools.nsc.Global.Name], definedClass: Boolean): SparkComputedImports

    Attributes
    protected
    Definition Classes
    SparkImports
  79. def initialize(postInitSignal: ⇒ Unit): Unit

  80. def initializeSynchronous(): Unit

  81. def interpret(line: String, synthetic: Boolean): Result

  82. def interpret(line: String): Result

    Interpret one line of input.

    Interpret one line of input. All feedback, including parse errors and evaluation results, are printed via the supplied compiler's reporter. Values defined are available for future interpreted strings.

    The return value is whether the line was interpreter successfully, e.g. that there were no parse errors.

  83. def interpretSynthetic(line: String): Result

  84. def isInitializeComplete: Boolean

  85. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  86. def isNoImports: Boolean

    Definition Classes
    SparkImports
  87. def isNoPredef: Boolean

    Definition Classes
    SparkImports
  88. def isParseable(line: String): Boolean

  89. def isTraceEnabled(): Boolean

    Attributes
    protected
    Definition Classes
    Logging
  90. lazy val isettings: SparkISettings

    interpreter settings

  91. def languageSymbols: List[scala.tools.nsc.Global.Symbol]

    Definition Classes
    SparkImports
  92. def languageWildcardHandlers: List[(memberHandlers)#ImportHandler]

    Definition Classes
    SparkImports
  93. def languageWildcardSyms: List[scala.tools.nsc.Global.Symbol]

    Symbols whose contents are language-defined to be imported.

    Symbols whose contents are language-defined to be imported.

    Definition Classes
    SparkImports
  94. def languageWildcards: List[scala.tools.nsc.Global.Type]

    Definition Classes
    SparkImports
  95. def lastRequest: Request

  96. def lastWarnings: List[(scala.tools.nsc.Global.Position, String)]

  97. def log: Logger

    Attributes
    protected
    Definition Classes
    Logging
  98. def logDebug(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  99. def logDebug(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  100. def logError(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  101. def logError(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  102. def logInfo(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  103. def logInfo(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  104. def logName: String

    Attributes
    protected
    Definition Classes
    Logging
  105. def logTrace(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  106. def logTrace(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  107. def logWarning(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  108. def logWarning(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  109. lazy val memberHandlers: SparkMemberHandlers { val intp: SparkIMain.this.type }

  110. def methodSymbols: List[scala.tools.nsc.Global.MethodSymbol]

  111. def mostRecentLine: String

  112. def mostRecentVar: String

    Returns the name of the most recent interpreter result.

    Returns the name of the most recent interpreter result. Mostly this exists so you can conveniently invoke methods on the previous result.

  113. def namedDefinedTerms: List[scala.tools.nsc.Global.TermName]

  114. object naming extends Naming

  115. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  116. def newCompiler(settings: Settings, reporter: Reporter): ReplGlobal

    Instantiate a compiler.

    Instantiate a compiler. Overridable.

    Attributes
    protected
  117. def normalizeNonPublic(tp: scala.tools.nsc.Global.Type): scala.tools.nsc.Global.Type

  118. final def notify(): Unit

    Definition Classes
    AnyRef
  119. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  120. def onlyTerms(xs: List[scala.tools.nsc.Global.Name]): List[scala.tools.nsc.Global.TermName]

    Attributes
    protected
  121. def onlyTypes(xs: List[scala.tools.nsc.Global.Name]): List[scala.tools.nsc.Global.TypeName]

    Attributes
    protected
  122. def optFlatName(id: String): Option[String]

  123. val out: JPrintWriter

  124. lazy val outputDir: File

    Local directory to save .

    Local directory to save .class files too

  125. def parentClassLoader: ClassLoader

    Parent classloader.

    Parent classloader. Overridable.

    Attributes
    protected
  126. def parse(line: String): Option[List[scala.tools.nsc.Global.Tree]]

  127. def pathToName(name: scala.tools.nsc.Global.Name): String

  128. def pathToTerm(id: String): String

  129. def pathToType(id: String): String

  130. def prevRequestList: List[Request]

  131. var printResults: Boolean

  132. def quietBind(p: NamedParam): Result

  133. def quietImport(ids: String*): Result

  134. def quietRun[T](code: String): Result

  135. def rebind(p: NamedParam): Result

  136. def recordRequest(req: Request): Unit

  137. lazy val repllog: Logger

  138. def replwarn(msg: ⇒ String): Unit

  139. lazy val reporter: ConsoleReporter

  140. def requestForIdent(line: String): Option[Request]

  141. def requestForName(name: scala.tools.nsc.Global.Name): Option[Request]

  142. def requestForReqId(id: Int): Option[Request]

  143. def requestHistoryForName(name: scala.tools.nsc.Global.Name): List[Request]

  144. def reset(): Unit

    Reset this interpreter, forgetting all user-specified requests.

  145. def resetClassLoader(): Unit

  146. def runtimeClassAndTypeOfTerm(id: String): Option[(JClass, scala.tools.nsc.Global.Type)]

  147. def runtimeTypeOfTerm(id: String): scala.tools.nsc.Global.Type

  148. def sessionImportedSymbols: List[scala.tools.nsc.Global.Symbol]

    Definition Classes
    SparkImports
  149. def sessionWildcards: List[scala.tools.nsc.Global.Type]

    Types which have been wildcard imported, such as: val x = "abc" ; import x.

    Types which have been wildcard imported, such as: val x = "abc" ; import x._ // type java.lang.String import java.lang.String._ // object java.lang.String

    Used by tab completion.

    XXX right now this gets import x._ and import java.lang.String._, but doesn't figure out import String._. There's a lot of ad hoc scope twiddling which should be swept away in favor of digging into the compiler scopes.

    Definition Classes
    SparkImports
  150. def setContextClassLoader(): Unit

  151. def setExecutionWrapper(code: String): Unit

  152. def settings: Settings

  153. def showCodeIfDebugging(code: String): Unit

  154. def symbolDefString(sym: scala.tools.nsc.Global.Symbol): String

  155. def symbolOfLine(code: String): scala.tools.nsc.Global.Symbol

  156. def symbolOfTerm(id: String): scala.tools.nsc.Global.Symbol

  157. def symbolOfType(id: String): scala.tools.nsc.Global.Symbol

  158. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  159. def terms[T](implicit arg0: ClassTag[T]): scala.tools.nsc.Global.Symbol

  160. def terms(name: String): scala.tools.nsc.Global.Symbol

  161. def toString(): String

    Definition Classes
    AnyRef → Any
  162. var totalSilence: Boolean

  163. def treesForRequestId(id: Int): List[scala.tools.nsc.Global.Tree]

  164. def typeOfExpression(expr: String, silent: Boolean = true): scala.tools.nsc.Global.Type

  165. def typeOfTerm(id: String): scala.tools.nsc.Global.Type

  166. def types[T](implicit arg0: ClassTag[T]): scala.tools.nsc.Global.Symbol

  167. def types(name: String): scala.tools.nsc.Global.Symbol

  168. def unqualifiedIds: List[String]

    Another entry point for tab-completion, ids in scope

  169. def valueOfTerm(id: String): Option[AnyRef]

  170. val virtualDirectory: PlainFile

  171. def visibleTermNames: List[scala.tools.nsc.Global.Name]

  172. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  173. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  174. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  175. def wildcardTypes: List[scala.tools.nsc.Global.Type]

    Definition Classes
    SparkImports
  176. def withoutUnwrapping(op: ⇒ Unit): Unit

  177. def withoutWarnings[T](body: ⇒ T): T

Deprecated Value Members

  1. lazy val compiler: global.type

    Annotations
    @deprecated
    Deprecated

    (Since version 2.9.0) Use global for access to the compiler instance.

Inherited from Logging

Inherited from SparkImports

Inherited from AnyRef

Inherited from Any

Ungrouped