trait TreeMakers
extends CodegenCore

Constructors

Members

case class AlternativesTreeMaker
final object AlternativesTreeMaker
case class BodyTreeMaker
final object BodyTreeMaker
sealed abstract class CondTreeMaker
case class EqualityTestTreeMaker
final object EqualityTestTreeMaker
[+] case class ExtractorTreeMaker

Make a TreeMaker that will result in an extractor call specified by extractor the next TreeMaker (here, we don't know which it'll be) is chained after...

Make a TreeMaker that will result in an extractor call specified by extractor the next TreeMaker (here, we don't know which it'll be) is chained after this one by flatMap'ing a function with binder nextBinder over our extractor's result the function's body is determined by the next TreeMaker (furthermore, the interpretation of flatMap depends on the codegen instance we're using).

The values for the subpatterns, as computed by the extractor call in extractor, are stored in local variables that re-use the symbols in subPatBinders. This makes extractor patterns more debuggable (SI-5739).

[+] final object ExtractorTreeMaker

Make a TreeMaker that will result in an extractor call specified by extractor the next TreeMaker (here, we don't know which it'll be) is chained after...

Make a TreeMaker that will result in an extractor call specified by extractor the next TreeMaker (here, we don't know which it'll be) is chained after this one by flatMap'ing a function with binder nextBinder over our extractor's result the function's body is determined by the next TreeMaker (furthermore, the interpretation of flatMap depends on the codegen instance we're using).

The values for the subpatterns, as computed by the extractor call in extractor, are stored in local variables that re-use the symbols in subPatBinders. This makes extractor patterns more debuggable (SI-5739).

sealed abstract class FunTreeMaker
case class GuardTreeMaker
final object GuardTreeMaker
sealed trait NoNewBinders
sealed trait PreserveSubPatBinders

Tree maker that captures sub pattern values during pattern match.

Tree maker that captures sub pattern values during pattern match.

[+] case class ProductExtractorTreeMaker

An optimized version of ExtractorTreeMaker for Products. For now, this is hard-coded to case classes, and we simply extract the case class fields.

The v...

An optimized version of ExtractorTreeMaker for Products. For now, this is hard-coded to case classes, and we simply extract the case class fields.

The values for the subpatterns, as specified by the case class fields at the time of extraction, are stored in local variables that re-use the symbols in subPatBinders. This makes extractor patterns more debuggable (SI-5739) as well as avoiding mutation after the pattern has been matched (SI-5158, SI-6070)

TODO: make this user-definable as follows When a companion object defines a method def unapply_1(x: T): U_1, but no def unapply or def unapplySeq, the extractor is considered to match any non-null value of type T the pattern is expected to have as many sub-patterns as there are def unapply_I(x: T): U_I methods, and the type of the I'th sub-pattern is U_I. The same exception for Seq patterns applies: if the last extractor is of type Seq[U_N], the pattern must have at least N arguments (exactly N if the last argument is annotated with : _*). The arguments starting at N (and beyond) are taken from the sequence returned by apply_N, and it is checked that the sequence has enough elements to provide values for all expected sub-patterns.

For a case class C, the implementation is assumed to be def unapply_I(x: C) = x._I, and the extractor call is inlined under that assumption.

[+] final object ProductExtractorTreeMaker

An optimized version of ExtractorTreeMaker for Products. For now, this is hard-coded to case classes, and we simply extract the case class fields.

The v...

An optimized version of ExtractorTreeMaker for Products. For now, this is hard-coded to case classes, and we simply extract the case class fields.

The values for the subpatterns, as specified by the case class fields at the time of extraction, are stored in local variables that re-use the symbols in subPatBinders. This makes extractor patterns more debuggable (SI-5739) as well as avoiding mutation after the pattern has been matched (SI-5158, SI-6070)

TODO: make this user-definable as follows When a companion object defines a method def unapply_1(x: T): U_1, but no def unapply or def unapplySeq, the extractor is considered to match any non-null value of type T the pattern is expected to have as many sub-patterns as there are def unapply_I(x: T): U_I methods, and the type of the I'th sub-pattern is U_I. The same exception for Seq patterns applies: if the last extractor is of type Seq[U_N], the pattern must have at least N arguments (exactly N if the last argument is annotated with : _*). The arguments starting at N (and beyond) are taken from the sequence returned by apply_N, and it is checked that the sequence has enough elements to provide values for all expected sub-patterns.

For a case class C, the implementation is assumed to be def unapply_I(x: C) = x._I, and the extractor call is inlined under that assumption.

[+] case class SubstOnlyTreeMaker

In scalac for such block x match { case d => }

d inside was to be substitued by x.

In dotty, SubstOnlyTreeMakers instead generate normal ValDef, and does...

In scalac for such block x match { case d => }

d inside was to be substitued by x.

In dotty, SubstOnlyTreeMakers instead generate normal ValDef, and does not create a new substitution.

This was done for several reasons: 1) it is a lot easyer to Y-check, as d type could be used in . 2) it would simplify debugging of the generated code as this works also for nested patterns, and previously they used unreadable names 3) It showed better(~30%), performance, Rebuilding tree and propagating types was taking substantial time.

[+] final object SubstOnlyTreeMaker

In scalac for such block x match { case d => }

d inside was to be substitued by x.

In dotty, SubstOnlyTreeMakers instead generate normal ValDef, and does...

In scalac for such block x match { case d => }

d inside was to be substitued by x.

In dotty, SubstOnlyTreeMakers instead generate normal ValDef, and does not create a new substitution.

This was done for several reasons: 1) it is a lot easyer to Y-check, as d type could be used in . 2) it would simplify debugging of the generated code as this works also for nested patterns, and previously they used unreadable names 3) It showed better(~30%), performance, Rebuilding tree and propagating types was taking substantial time.

abstract class TreeMaker
case class TrivialTreeMaker
final object TrivialTreeMaker
[+] case class TypeTestTreeMaker

implements the run-time aspects of (§8.2) (typedPattern has already done the necessary type transformations)

Type patterns consist of types, type varia...

    - A singleton type p.type.
      This type pattern matches only the value denoted by the path p
      (that is, a pattern match involved a comparison of the matched value with p using method eq in class AnyRef). // TODO: the actual pattern matcher uses ==, so that's what I'm using for now
      // https://issues.scala-lang.org/browse/SI-4577 "pattern matcher, still disappointing us at equality time"

    - A compound type pattern T1 with ... with Tn where each Ti is a type pat- tern.
      This type pattern matches all values that are matched by each of the type patterns Ti.

    - A parameterized type pattern T[a1,...,an], where the ai are type variable patterns or wildcards _.
      This type pattern matches all values which match T for some arbitrary instantiation of the type variables and wildcards.
      The bounds or alias type of these type variable are determined as described in (§8.3).

    - A parameterized type pattern scala.Array[T1], where T1 is a type pattern. // TODO
      This type pattern matches any non-null instance of type scala.Array[U1], where U1 is a type matched by T1.

implements the run-time aspects of (§8.2) (typedPattern has already done the necessary type transformations)

Type patterns consist of types, type variables, and wildcards. A type pattern T is of one of the following forms: - A reference to a class C, p.C, or T#C. This type pattern matches any non-null instance of the given class. Note that the prefix of the class, if it is given, is relevant for determining class instances. For instance, the pattern p.C matches only instances of classes C which were created with the path p as prefix. The bottom types scala.Nothing and scala.Null cannot be used as type patterns, because they would match nothing in any case.

    - A singleton type p.type.
      This type pattern matches only the value denoted by the path p
      (that is, a pattern match involved a comparison of the matched value with p using method eq in class AnyRef). // TODO: the actual pattern matcher uses ==, so that's what I'm using for now
      // https://issues.scala-lang.org/browse/SI-4577 "pattern matcher, still disappointing us at equality time"

    - A compound type pattern T1 with ... with Tn where each Ti is a type pat- tern.
      This type pattern matches all values that are matched by each of the type patterns Ti.

    - A parameterized type pattern T[a1,...,an], where the ai are type variable patterns or wildcards _.
      This type pattern matches all values which match T for some arbitrary instantiation of the type variables and wildcards.
      The bounds or alias type of these type variable are determined as described in (§8.3).

    - A parameterized type pattern scala.Array[T1], where T1 is a type pattern. // TODO
      This type pattern matches any non-null instance of type scala.Array[U1], where U1 is a type matched by T1.
final object TypeTestTreeMaker
protected val debugInfoEmitVars : Boolean
def analyzeCases ( prevBinder: Symbol , cases: List [ List [ TreeMaker ] ] , pt: Type , suppression: Suppression ) : Unit
def combineCases ( scrut: Tree , scrutSym: Symbol , casesRaw: List [ List [ TreeMaker ] ] , pt: Type , owner: Symbol , matchFailGenOverride: Option [ Symbol => Tree ] ) : Tree
def combineExtractors ( treeMakers: List [ TreeMaker ] ) ( casegen: Casegen ) : Tree
def emitSwitch ( scrut: Tree , scrutSym: Symbol , cases: List [ List [ TreeMaker ] ] , pt: Type , matchFailGenOverride: Option [ Symbol => Tree ] , unchecked: Boolean ) : Option [ Tree ]
def emitTypeSwitch ( bindersAndCases: List [ ( Symbol, List [ TreeMaker ] ) ] , pt: Type ) : Option [ List [ CaseDef ] ]
def optimizeCases ( prevBinder: Symbol , cases: List [ List [ TreeMaker ] ] , pt: Type ) : ( List [ List [ TreeMaker ] ], List [ Tree ] )
def propagateRebindings ( treeMakers: List [ TreeMaker ] , initial: Rebindings ) : List [ TreeMaker ]