class NonLocalReturns
extends MiniPhaseTransform

Implement non-local returns using NonLocalReturnControl exceptions.

Constructors

NonLocalReturns ( )

Members

[+] private val nonLocalReturnKeys : Map [ Symbol, TermSymbol ]

A hashmap from method symbols to non-local return keys

A hashmap from method symbols to non-local return keys

[+] private def ensureConforms ( tree: Tree , pt: Type ) ( implicit ctx: Context ) : Tree
[+] private def nonLocalReturnExceptionType ( argtype: Type ) ( implicit ctx: Context ) : Type

The type of a non-local return expression with given argument type

The type of a non-local return expression with given argument type

[+] private def nonLocalReturnKey ( meth: Symbol ) ( implicit ctx: Context ) : B

Return non-local return key for given method

Return non-local return key for given method

[+] private def nonLocalReturnThrow ( expr: Tree , meth: Symbol ) ( implicit ctx: Context ) : Tree

Generate a non-local return throw with given return expression from given method. I.e. for the method's non-local return key, generate:

throw new NonLoc...

Generate a non-local return throw with given return expression from given method. I.e. for the method's non-local return key, generate:

throw new NonLocalReturnControl(key, expr) todo: maybe clone a pre-existing exception instead? (but what to do about exceptions that miss their targets?)

[+] private def nonLocalReturnTry ( body: Tree , key: TermSymbol , meth: Symbol ) ( implicit ctx: Context ) : Block

Transform (body, key) to:

{ val key = new Object() try { body } catch { case ex: NonLocalReturnControl => if (ex.key().eq(key)) ex.value().asInstanceOf[T] else...

Transform (body, key) to:

{ val key = new Object() try { body } catch { case ex: NonLocalReturnControl => if (ex.key().eq(key)) ex.value().asInstanceOf[T] else throw ex } }

[+] override def phaseName : String

A name given to the Phase that can be used to debug the compiler. For instance, it is possible to print trees after a given phase using:

A name given to the Phase that can be used to debug the compiler. For instance, it is possible to print trees after a given phase using:

$ ./bin/dotc -Xprint:<phaseNameHere> sourceFile.scala
[+] override def runsAfter : Set [ Class [ Nothing <: Phase ] ]

List of names of phases that should precede this phase

List of names of phases that should precede this phase

[+] override def transformDefDef ( tree: DefDef ) ( implicit ctx: Context , info: TransformerInfo ) : Tree
[+] override def transformReturn ( tree: Return ) ( implicit ctx: Context , info: TransformerInfo ) : Tree