@@ -49,7 +49,7 @@ class Staging extends MacroTransformWithImplicits {
49
49
if (ctx.compilationUnit.needsStaging) super .run
50
50
51
51
protected def newTransformer (implicit ctx : Context ): Transformer =
52
- new Reifier (inQuote = false , null , 0 , new LevelInfo , new Embedded , ctx)
52
+ new Reifier (inQuote = false , null , 0 , new LevelInfo , ctx)
53
53
54
54
private class LevelInfo {
55
55
/** A map from locally defined symbols to the staging levels of their definitions */
@@ -63,18 +63,16 @@ class Staging extends MacroTransformWithImplicits {
63
63
* The initial level is 0, a level `l` where `l > 0` implies code has been quoted `l` times
64
64
* and `l == -1` is code inside a top level splice (in an inline method).
65
65
* @param levels a stacked map from symbols to the levels in which they were defined
66
- * @param embedded a list of embedded quotes (if `inSplice = true`) or splices (if `inQuote = true`
67
66
* @param rctx the contex in the destination lifted lambda
68
67
*/
69
68
private class Reifier (inQuote : Boolean , val outer : Reifier , val level : Int , levels : LevelInfo ,
70
- val embedded : Embedded , val rctx : Context ) extends ImplicitsTransformer {
69
+ val rctx : Context ) extends ImplicitsTransformer {
71
70
import levels ._
72
71
assert(level >= - 1 )
73
72
74
73
/** A nested reifier for a quote (if `isQuote = true`) or a splice (if not) */
75
74
def nested (isQuote : Boolean )(implicit ctx : Context ): Reifier = {
76
- val nestedEmbedded = if (level > 1 || (level == 1 && isQuote)) embedded else new Embedded
77
- new Reifier (isQuote, this , if (isQuote) level + 1 else level - 1 , levels, nestedEmbedded, ctx)
75
+ new Reifier (isQuote, this , if (isQuote) level + 1 else level - 1 , levels, ctx)
78
76
}
79
77
80
78
/** We are in a `~(...)` context that is not shadowed by a nested `'(...)` */
@@ -451,39 +449,5 @@ class Staging extends MacroTransformWithImplicits {
451
449
}
452
450
453
451
object Staging {
454
-
455
452
val name : String = " staging"
456
-
457
- def toValue (tree : tpd.Tree ): Option [Any ] = tree match {
458
- case Literal (Constant (c)) => Some (c)
459
- case Block (Nil , e) => toValue(e)
460
- case Inlined (_, Nil , e) => toValue(e)
461
- case _ => None
462
- }
463
-
464
- class Embedded (trees : mutable.ListBuffer [tpd.Tree ] = mutable.ListBuffer .empty, map : mutable.Map [Symbol , tpd.Tree ] = mutable.Map .empty) {
465
- /** Adds the tree and returns it's index */
466
- def addTree (tree : tpd.Tree , liftedSym : Symbol ): Int = {
467
- trees += tree
468
- if (liftedSym ne NoSymbol )
469
- map.put(liftedSym, tree)
470
- trees.length - 1
471
- }
472
-
473
- /** Type used for the hole that will replace this splice */
474
- def getHoleType (splice : tpd.Select )(implicit ctx : Context ): Type = {
475
- // For most expressions the splice.tpe but there are some types that are lost by lifting
476
- // that can be recoverd from the original tree. Currently the cases are:
477
- // * Method types: the splice represents a method reference
478
- map.get(splice.qualifier.symbol).map(_.tpe.widen).getOrElse(splice.tpe)
479
- }
480
-
481
- def isLiftedSymbol (sym : Symbol )(implicit ctx : Context ): Boolean = map.contains(sym)
482
-
483
- /** Get the list of embedded trees */
484
- def getTrees : List [tpd.Tree ] = trees.toList
485
-
486
- override def toString : String = s " Embedded( $trees, $map) "
487
-
488
- }
489
453
}
0 commit comments