org.scalamacros.paradise.quasiquotes.Reifiers
Splits list into a list of groups where subsequent elements are considered similar by the corresponding function.
Splits list into a list of groups where subsequent elements are considered similar by the corresponding function.
Example:
> group(List(1, 1, 0, 0, 1, 0)) { _ == _ } List(List(1, 1), List(0, 0), List(1), List(0))
Map that stores freshly generated names linked to the corresponding names in the reified tree.
Map that stores freshly generated names linked to the corresponding names in the reified tree. This information is used to reify names created by calls to freshTermName and freshTypeName.
Reifies list filling all the valid holeMap.
Reifies list filling all the valid holeMap.
Reification of non-trivial list is done in two steps:
2. fold the groups into a sequence of lists added together with ++ using fill reification for holeMap and fallback reification for non-holeMap.
Example:
reifyHighRankList(lst) { // first we define patterns that extract high-rank holeMap (currently ..) case Placeholder(IterableType(_, _)) => tree } { // in the end we define how single elements are reified, typically with default reify call reify(_) }
Sample execution of previous concrete list reifier:
> val lst = List(foo, bar, qq$f3948f9s$1) > reifyHighRankList(lst) { ... } { ... } q"List($foo, $bar) ++ ${holeMap(qq$f3948f9s$1).tree}"
Reifies arbitrary list filling .
Reifies arbitrary list filling ..$x and ...$y holeMap when they are put in the correct position. Fallbacks to regular reification for zero rank elements.
Wraps expressions into: a block which starts with a sequence of vals that correspond to fresh names that has to be created at evaluation of the quasiquote and ends with reified tree:
Wraps expressions into: a block which starts with a sequence of vals that correspond to fresh names that has to be created at evaluation of the quasiquote and ends with reified tree:
{ val name$1: universe.TermName = universe.build.freshTermName(prefix1) ... val name$N: universe.TermName = universe.build.freshTermName(prefixN) tree }
Wraps patterns into: a call into anonymous class' unapply method required by unapply macro expansion:
new { def unapply(tree) = tree match { case pattern if guard => Some(result) case _ => None } }.unapply(<unapply-selector>)
where pattern corresponds to reified tree and guard represents conjunction of equalities which check that pairs of names in nameMap.values are equal between each other. NOTE: would love to do something like that in Scala 2.10, but name-based pattern matching is not supported and introduceTopLevel-like shenanigans usually lead to big troubles with SBT