Dotty Documentation

0.6.0-bin-SNAPSHOT

class ReplCompiler
extends Compiler

This subclass of Compiler replaces the appropriate phases in order to facilitate the REPL

Specifically it replaces the front end with REPLFrontEnd, and adds a custom subclass of GenBCode. The custom GenBCode, REPLGenBCode, works in conjunction with a specialized class loader in order to load virtual classfiles.

[-] Constructors

ReplCompiler ( directory: AbstractFile )

[-] Members

[+] private case class Definitions
[+] private object Definitions
[+] private class REPLGenBCode

A GenBCode phase that outputs to a virtual directory

[+] val directory : AbstractFile
[+] private var objectNames : Map [ Int, TermName ]
[+] def compile ( parsed: Parsed ) ( implicit state: State ) : Result [ ( CompilationUnit, State ) ]
[+] private def createUnit ( defs: Definitions , sourceCode: String ) : CompilationUnit
[+] private def definitions ( trees: List [ Tree ] , state: State ) : Definitions
[+] def newRun ( initCtx: Context , objectIndex: Int ) : Run
[+] private def objectName ( state: State ) : TermName
[+] override def phases : List [ List [ Phase ] ]

Meta-ordering constraint:

DenotTransformers that change the signature of their denotation's info must go after erasure. The reason is that denotations are permanently referred to by TermRefs which contain a signature. If the signature of a symbol would change, all refs to it would become outdated - they could not be dereferenced in the new phase.

After erasure, signature changing denot-transformers are OK because erasure will make sure that only term refs with fixed SymDenotations survive beyond it. This is possible because:

  • splitter has run, so every ident or select refers to a unique symbol
  • after erasure, asSeenFrom is the identity, so every reference has a plain SymDenotation, as opposed to a UniqueRefDenotation.
[+] private def runCompilationUnit ( unit: CompilationUnit , state: State ) : Result [ ( CompilationUnit, State ) ]
[+] def typeCheck ( expr: String , errorsAllowed: Boolean ) ( implicit state: State ) : Result [ ValDef ]
[+] def typeOf ( expr: String ) ( implicit state: State ) : Result [ String ]
[+] private def wrapped ( defs: Definitions ) : PackageDef

Wrap trees in an object and add imports from the previous compilations

The resulting structure is something like:

package <none> {
  object rs$line$nextId {
    import rs$line${i <- 0 until nextId}._
    import dotty.Show._

    <trees>
  }
}