Traverse pattern and collect all variable names with their types in buffer The variables keep their positions; whereas the pattern is converted to be synthetic for all nodes that contain a variable position.
Encode/decode fq"if $cond" enumerator as q"if
($cond)"
Encode/decode fq"$pat = $rhs" enumerator as q"$pat = $rhs"
Encode/decode fq"$pat <- $rhs" enumerator as q"<-
($pat, $rhs)"
Encode/decode body of for yield loop as q"yield
($tree)"
Translate names in Select/Ident nodes to type names.
A version of List#map, specialized for List, and optimized to avoid allocation if as
is empty
Cast tree
to pt
, unless tpe is a subtype of pt, or pt is Unit.
If this is a reference to a method with an empty parameter list, wrap it in an apply.
Builds a cast with given value and type.
Create a tree representing an assignment <lhs = rhs>
Builds a reference to value whose type is given stable prefix.
Builds a reference to value whose type is given stable prefix. If the type is unsuitable, e.g. it is a TypeRef for an abstract type variable, then an Ident will be made using termSym as the Ident's symbol. In that case, termSym must not be NoSymbol.
Builds a reference to value whose type is given stable prefix.
Builds a reference to value whose type is given stable prefix. The type must be suitable for this. For example, it must not be a TypeRef pointing to an abstract type variable.
Builds a reference to given symbol.
Builds a reference to given symbol with given stable prefix.
Builds a reference with stable type to given symbol
Create block of statements stats
Apparently we smuggle a Type around as a Literal(Constant(tp)) and the implementation of Constant#tpe is such that x.
Apparently we smuggle a Type around as a Literal(Constant(tp)) and the implementation of Constant#tpe is such that x.tpe becomes ClassType(value.asInstanceOf[Type]), i.e. java.lang.Class[Type]. Can't find any docs on how/why it's done this way. See ticket SI-490 for some interesting comments from lauri alanko suggesting that the type given by classOf[T] is too strong and should be weakened so as not to suggest that classOf[List[String]] is any different from classOf[List[Int]].
!!! See deconstMap in Erasure for one bug this encoding has induced: I would be very surprised if there aren't more.
Create tree for for-comprehension <for (enums) do body> or <for (enums) yield body> where mapName and flatMapName are chosen corresponding to whether this is a for-do or a for-yield.
Create tree for for-comprehension <for (enums) do body> or <for (enums) yield body> where mapName and flatMapName are chosen corresponding to whether this is a for-do or a for-yield. The creation performs the following rewrite rules:
1.
for (P <- G) E ==> G.foreach (P => E)
Here and in the following (P => E) is interpreted as the function (P => E) if P is a variable pattern and as the partial function { case P => E } otherwise.
2.
for (P <- G) yield E ==> G.map (P => E)
3.
for (P_1 <- G_1; P_2 <- G_2; ...) ...
4.
for (P <- G; E; ...) ...
5. For N < MaxTupleArity:
for (P_1 <- G; P_2 = E_2; val P_N = E_N; ...)
If any of the P_i are variable patterns, the corresponding x_i @ P_i' is not generated
and the variable constituting P_i is used instead of x_i
The enumerators in the for expression
Create a tree representing the function type (argtpes) => restpe
Create tree for for-comprehension generator <val pat0 <- rhs0>
Builds an instance test with given value and type.
A creator for method calls, e.
A creator for method calls, e.g. fn[T1, T2, ...](v1, v2, ...) There are a number of variations.
symbol of the method receiver
name of the method to call
type arguments (if Nil, no TypeApply node will be generated)
value arguments
the newly created trees.
Wrap an expression in a named argument.
Create positioned tree representing an object creation <new parents { stats }
Create positioned tree representing an object creation <new parents { stats }
the position of the new
the position of the anonymous class starting with parents
Builds a list with given head and tail.
Create tree for pattern definition <mods val pat0 = rhs>
Create tree for pattern definition <val pat0 = rhs>
Create a literal unit tree that is inserted by the compiler but not written by end user.
Create a literal unit tree that is inserted by the compiler but not written by end user. It's important to distinguish the two so that quasiquotes can strip synthetic ones away.
Generates a template with constructor corresponding to
Generates a template with constructor corresponding to
constrmods (vparams1_) ... (vparams_n) preSuper { presupers } extends superclass(args_1) ... (args_n) with mixins { self => body }
This gets translated to
extends superclass with mixins { self => presupers' // presupers without rhs vparamss // abstract fields corresponding to value parameters def <init>(vparamss) { presupers super.<init>(args) } body }
Create a block that wraps multiple statements but don't do any wrapping if there is just one statement.
Create a block that wraps multiple statements but don't do any wrapping if there is just one statement. Used by quasiquotes, macro c.parse api and toolbox.
Builds a tuple
Builds a type application node if args.
Builds a type application node if args.nonEmpty, returns fun otherwise.
Create visitor <x => x match cases>
Builds a tree representing an undefined local, as in var x: T = _ which is appropriate to the given Type.
Convert all occurrences of (lower-case) variables in a pattern as follows: x becomes x @ _ x: T becomes x @ (_: T)
Replaces tree type with a stable type if possible
Computes stable type for a tree if possible