Skip to content

Commit 5f4664a

Browse files
committed
WIP
1 parent 2751b14 commit 5f4664a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
8383
if (ctx.compilationUnit.needsStaging) super.run
8484

8585
protected def newTransformer(implicit ctx: Context): Transformer =
86-
new Reifier(inQuote = false, null, new LevelInfo, new Embedded, ctx)
86+
new Reifier(null, new LevelInfo, new Embedded, ctx)
8787

8888
private class LevelInfo {
8989
/** A map from locally defined symbols to the staging levels of their definitions */
@@ -115,14 +115,14 @@ class ReifyQuotes extends MacroTransformWithImplicits {
115115
* @param embedded a list of embedded quotes (if `inSplice = true`) or splices (if `inQuote = true`
116116
* @param rctx the contex in the destination lifted lambda
117117
*/
118-
private class Reifier(inQuote: Boolean, val outer: Reifier, levels: LevelInfo,
118+
private class Reifier(val outer: Reifier, levels: LevelInfo,
119119
val embedded: Embedded, val rctx: Context) extends ImplicitsTransformer {
120120
import levels._
121121

122122
/** A nested reifier for a quote (if `isQuote = true`) or a splice (if not) */
123123
def nested(isQuote: Boolean)(implicit ctx: Context): Reifier = {
124124
val nestedEmbedded = if (quotationLevel > 1 || (quotationLevel == 1 && isQuote)) embedded else new Embedded
125-
new Reifier(isQuote, this, levels, nestedEmbedded, ctx)
125+
new Reifier(this, levels, nestedEmbedded, ctx)
126126
}
127127

128128
/** We are not in a `~(...)` or a `'(...)` */
@@ -369,7 +369,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
369369
// in '{ x } to '{ x$1.unary_~ } and go directly to `x$1`
370370
capturers(body.symbol)(body)
371371
case _=>
372-
val (body1, splices) = nested(isQuote = true).split(body)(quoteContext)
372+
val (body1, splices) = nested(isQuote = true).splitQuote(body)(quoteContext)
373373
if (quotationLevel == 0 && !ctx.inInlineMethod) {
374374
val body2 =
375375
if (body1.isType) body1
@@ -424,7 +424,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
424424
body1.select(splice.name)
425425
}
426426
else if (quotationLevel == 1) {
427-
val (body1, quotes) = nested(isQuote = false).split(splice.qualifier)(spliceContext)
427+
val (body1, quotes) = nested(isQuote = false).splitSplice(splice.qualifier)(spliceContext)
428428
val tpe = outer.embedded.getHoleType(splice)
429429
val hole = makeHole(body1, quotes, tpe).withSpan(splice.span)
430430
// We do not place add the inline marker for trees that where lifted as they come from the same file as their
@@ -441,7 +441,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
441441
}
442442
else if (Splicer.canBeSpliced(splice.qualifier)) { // level 0 inside an inline definition
443443
// TODO remove?
444-
nested(isQuote = false).split(splice.qualifier)(spliceContext) // Just check PCP
444+
nested(isQuote = false).transform(splice.qualifier)(spliceContext) // Just check PCP
445445
splice
446446
}
447447
else { // level 0 inside an inline definition
@@ -537,8 +537,13 @@ class ReifyQuotes extends MacroTransformWithImplicits {
537537
/** Transform `tree` and return the resulting tree and all `embedded` quotes
538538
* or splices as a pair, after performing the `addTags` transform.
539539
*/
540-
private def split(tree: Tree)(implicit ctx: Context): (Tree, List[Tree]) = {
541-
val tree1 = if (inQuote) addTags(transform(tree)) else makeLambda(tree)
540+
private def splitQuote(tree: Tree)(implicit ctx: Context): (Tree, List[Tree]) = {
541+
val tree1 = addTags(transform(tree))
542+
(tree1, embedded.getTrees)
543+
}
544+
545+
private def splitSplice(tree: Tree)(implicit ctx: Context): (Tree, List[Tree]) = {
546+
val tree1 = makeLambda(tree)
542547
(tree1, embedded.getTrees)
543548
}
544549

@@ -614,11 +619,6 @@ class ReifyQuotes extends MacroTransformWithImplicits {
614619
EmptyTree
615620
}
616621
case _ =>
617-
// println("------------------------")
618-
// println(tree.show)
619-
// println(tree)
620-
// println()
621-
// println()
622622
markDef(tree)
623623
checkLevel(mapOverTree(enteredSyms))
624624
}

0 commit comments

Comments
 (0)