Dotty Documentation

0.14.0-bin-SNAPSHOT

class Lifter
extends Object

The core lambda lift functionality.

[-] Constructors

Lifter ( thisPhase: MiniPhase & DenotTransformer )
Lifter ( implicit ctx: Context )

[-] Members

[+] private class CollectDependencies
[+] private type SymSet = TreeSet [ Symbol ]
[+] private val called : LinkedHashMap [ Symbol, SymSet ]

A hashtable storing calls between functions

[+] private val calledFromInner : HashSet [ Symbol ]

Symbols that are called from an inner class.

[+] private var changedFreeVars : Boolean

A flag to indicate whether new free variables have been found

[+] private var changedLiftedOwner : Boolean

A flag to indicate whether lifted owners have changed

[+] private implicit val ctx : Context
[+] val free : LinkedHashMap [ Symbol, SymSet ]

A map storing free variables of functions and classes

[+] val liftedDefs : HashMap [ Symbol, ListBuffer [ Tree ] ]

Buffers for lifted out classes and methods, indexed by owner

[+] private val liftedOwner : LinkedHashMap [ Symbol, Symbol ]

A map from local methods and classes to the owners to which they will be lifted as members. For methods and classes that do not have any dependencies this will be the enclosing package. symbols with packages as lifted owners will subsequently represented as static members of their toplevel class, unless their enclosing class was already static. Note: During tree transform (which runs at phase LambdaLift + 1), liftedOwner is also used to decide whether a method had a term owner before.

[+] private val ord : Ordering [ Symbol ]
[+] private val outerParam : HashMap [ Symbol, Symbol ]

The outer parameter of a constructor

[+] private val proxyMap : LinkedHashMap [ Symbol, Map [ Symbol, Symbol ] ]

A map storing the free variable proxies of functions and classes. For every function and class, this is a map from the free variables of that function or class to the proxy symbols accessing them.

[+] private val thisPhase : MiniPhase & DenotTransformer
[+] def addFreeArgs ( sym: Symbol , args: List [ Tree ] ) ( implicit ctx: Context ) : List [ Tree ]
[+] def addFreeParams ( tree: Tree , proxies: List [ Symbol ] ) ( implicit ctx: Context ) : Tree
[+] private def computeFreeVars ( ) ( implicit ctx: Context ) : Unit

Compute final free variables map `fvs by closing over caller dependencies.

[+] private def computeLiftedOwners ( ) ( implicit ctx: Context ) : Unit

Compute final liftedOwner map by closing over caller dependencies

[+] def currentEnclosure ( implicit ctx: Context ) : Symbol
[+] def freeVars ( sym: Symbol ) : List [ Symbol ]
[+] private def generateProxies ( ) ( implicit ctx: Context ) : Unit
[+] private def inCurrentOwner ( sym: Symbol ) ( implicit ctx: Context ) : Boolean
[+] def isLocal ( sym: Symbol ) ( implicit ctx: Context ) : Boolean

A symbol is local if it is owned by a term or a local trait, or if it is a constructor of a local symbol.

[+] def liftDef ( tree: MemberDef ) ( implicit ctx: Context ) : Tree
[+] private def liftLocals ( ) ( implicit ctx: Context ) : Unit
[+] private def liftedInfo ( local: Symbol ) ( implicit ctx: Context ) : Type
[+] private def markCalled ( callee: Symbol , caller: Symbol ) ( implicit ctx: Context ) : Unit
[+] private def markFree ( sym: Symbol , enclosure: Symbol ) ( implicit ctx: Context ) : Symbol

Mark symbol sym as being free in enclosure, unless sym is defined in enclosure or there is an intermediate class properly containing enclosure in which sym is also free. Also, update liftedOwner of enclosure so that enclosure can access sym, or its proxy in an intermediate class. This means:

  1. If there is an intermediate class in which sym is free, enclosure must be contained in that class (in order to access the `sym proxy stored in the class).

  2. If there is no intermediate class, enclosure must be contained in the class enclosing sym.
[+] def memberRef ( sym: Symbol ) ( implicit ctx: Context ) : Tree
[+] def narrowLiftedOwner ( sym: Symbol , owner: Symbol ) ( implicit ctx: Context ) : Unit

Set liftedOwner(sym) to owner if owner is more deeply nested than the previous value of liftedowner(sym).

[+] def needsLifting ( sym: Symbol ) : Boolean
[+] private def newName ( sym: Symbol ) ( implicit ctx: Context ) : Name
[+] private def newSymSet : TreeSet [ Symbol ]
[+] def proxies ( sym: Symbol ) : List [ Symbol ]
[+] private def proxy ( sym: Symbol ) ( implicit ctx: Context ) : Symbol
[+] def proxyOf ( sym: Symbol , fv: Symbol ) : Symbol
[+] def proxyRef ( sym: Symbol ) ( implicit ctx: Context ) : Tree
[+] private def symSet ( f: LinkedHashMap [ Symbol, SymSet ] , sym: Symbol ) : SymSet