Packages

  • package root

    The Scala compiler and reflection APIs.

    The Scala compiler and reflection APIs.

    Definition Classes
    root
  • package scala
    Definition Classes
    root
  • package tools
    Definition Classes
    scala
  • package nsc
    Definition Classes
    tools
  • package interpreter
    Definition Classes
    nsc
  • 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.

    Definition Classes
    interpreter
  • ComputedImports
  • PhaseDependentOps
  • PresentationCompileResult
  • ReadEvalPrint
  • ReplTypeOps
  • Request
  • deconstruct
  • exprTyper
  • flatOp
  • naming
  • replOutput
  • typerOp

class Request extends ReplRequest

One line of code submitted by the user for interpretation

Source
IMain.scala
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Request
  2. ReplRequest
  3. AnyRef
  4. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Request(line: String, origTrees: List[Global.Tree], parserSource: BatchSourceFile, firstXmlPos: Global.Position = NoPosition, generousImports: Boolean = false, synthetic: Boolean = false, storeResultInVal: Boolean = true)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from Request toany2stringadd[Request] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Request, B)
    Implicit
    This member is added by an implicit conversion from Request toArrowAssoc[Request] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. lazy val accessPath: String

    Code to import bound names from previous lines - accessPath is code to append to objectName to access anything bound by request.

  7. def applyToResultMember[T](name: Global.Name, f: (Global.Symbol) => T): T
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  10. def compile: Boolean

    Compile the object file.

    Compile the object file. Returns whether the compilation succeeded. If all goes well, the "types" map is computed.

  11. lazy val compilerTypeOf: Map[Global.Name, Global.Type]

    Types of variables defined by this request.

  12. def defHandlers: collection.immutable.List[(memberHandlers)#MemberDefHandler]
  13. def defTypeOf(name: Global.Name)(implicit show: (Global.Name) => String): String
  14. lazy val definedSymbols: Map[Global.Name, Global.Symbol]
  15. def defines: collection.immutable.List[Global.Symbol]
  16. def definesTermNames: List[String]
  17. val definesValueClass: Boolean
  18. def ensuring(cond: (Request) => Boolean, msg: => Any): Request
    Implicit
    This member is added by an implicit conversion from Request toEnsuring[Request] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  19. def ensuring(cond: (Request) => Boolean): Request
    Implicit
    This member is added by an implicit conversion from Request toEnsuring[Request] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  20. def ensuring(cond: Boolean, msg: => Any): Request
    Implicit
    This member is added by an implicit conversion from Request toEnsuring[Request] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  21. def ensuring(cond: Boolean): Request
    Implicit
    This member is added by an implicit conversion from Request toEnsuring[Request] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  22. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  24. def eval: Either[Throwable, AnyRef]
    Definition Classes
    RequestReplRequest
  25. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  26. def fullAccessPath: String

    The path of the value that contains the user code.

  27. def fullPath(vname: String): String

    The path of the given member of the wrapping instance.

  28. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  29. val handlers: List[(memberHandlers)#MemberHandler]

    handlers for each tree in this request

  30. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  31. lazy val headerPreamble: String

    Code to import bound names from previous lines - accessPath is code to append to objectName to access anything bound by request.

  32. def importedSymbols: collection.immutable.List[Global.Symbol]
  33. def imports: collection.immutable.List[Global.Symbol]
  34. lazy val importsPreamble: String

    Code to import bound names from previous lines - accessPath is code to append to objectName to access anything bound by request.

  35. lazy val importsTrailer: String

    Code to import bound names from previous lines - accessPath is code to append to objectName to access anything bound by request.

  36. val isClassBased: Boolean
  37. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  38. val line: String
    Definition Classes
    RequestReplRequest
  39. val lineRep: ReadEvalPrint
  40. def loadAndRun: Either[String, String]

    load and run the code using reflection

  41. def lookupTypeOf(name: Global.Name): String
  42. def mkUnit: Global.CompilationUnit

    generate the source code for the object that computes this request

  43. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  44. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  45. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  46. val parserSource: BatchSourceFile
  47. def postwrap: String

    Like postamble for an import wrapper.

  48. val referencedNames: List[Global.Name]

    list of names used by this expression

  49. lazy val resultSymbol: Global.Symbol
  50. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  51. def termNames: collection.immutable.List[Global.TermName]

    def and val names

  52. def toString(): String
    Definition Classes
    Request → AnyRef → Any
  53. val trees: List[Global.Tree]
  54. def typeNames: collection.immutable.List[Global.TypeName]
  55. lazy val typeOf: Map[Global.Name, String]

    String representations of same.

  56. lazy val typesOfDefinedTerms: Map[Global.Name, Global.Type]
  57. def value: Global.Symbol
  58. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  59. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  60. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  61. def wrapperDef(iw: String): String

Deprecated Value Members

  1. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from Request toStringFormat[Request] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.12.16) Use formatString.format(value) instead of value.formatted(formatString), or use the f"" string interpolator. In Java 15 and later, formatted resolves to the new method in String which has reversed parameters.

  2. def [B](y: B): (Request, B)
    Implicit
    This member is added by an implicit conversion from Request toArrowAssoc[Request] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use -> instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

Inherited from ReplRequest

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd fromRequest to any2stringadd[Request]

Inherited by implicit conversion StringFormat fromRequest to StringFormat[Request]

Inherited by implicit conversion Ensuring fromRequest to Ensuring[Request]

Inherited by implicit conversion ArrowAssoc fromRequest to ArrowAssoc[Request]

Ungrouped