Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class ScalaSettings extends Settings.SettingGroup {
val YprintDebug: Setting[Boolean] = BooleanSetting("-Yprint-debug", "when printing trees, print some extra information useful for debugging.")
val YprintDebugOwners: Setting[Boolean] = BooleanSetting("-Yprint-debug-owners", "when printing trees, print owners of definitions.")
val YshowPrintErrors: Setting[Boolean] = BooleanSetting("-Yshow-print-errors", "don't suppress exceptions thrown during tree printing.")
val YshowRawQuoteTrees: Setting[Boolean] = BooleanSetting("-Yshow-raw-tree", "don't remove quote artifacts")
val YtestPickler: Setting[Boolean] = BooleanSetting("-Ytest-pickler", "self-test for pickling functionality; should be used with -Ystop-after:pickler")
val YcheckReentrant: Setting[Boolean] = BooleanSetting("-Ycheck-reentrant", "check that compiled program does not contain vars that can be accessed from a global root.")
val YdropComments: Setting[Boolean] = BooleanSetting("-Ydrop-comments", "Drop comments when scanning source files.")
Expand Down
16 changes: 10 additions & 6 deletions compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class QuoteDriver extends Driver {
}

val (_, ctx0: Context) = setup(settings.compilerArgs.toArray :+ "dummy.scala", initCtx.fresh)
val ctx = setColor(ctx0.fresh.setSetting(ctx0.settings.outputDir, outDir), settings)
val ctx = setToolboxSettings(ctx0.fresh.setSetting(ctx0.settings.outputDir, outDir), settings)

val driver = new QuoteCompiler
driver.newRun(ctx).compileExpr(expr)
Expand All @@ -43,14 +43,17 @@ class QuoteDriver extends Driver {

def show(expr: Expr[_], settings: Toolbox.Settings): String = {
def show(tree: Tree, ctx: Context): String = {
val tree1 = if (settings.showRawTree) tree else (new TreeCleaner).transform(tree)(ctx)
new TastyImpl(ctx).showSourceCode.showTree(tree1)(ctx)
implicit val c: Context = ctx
val tree1 =
if (ctx.settings.YshowRawQuoteTrees.value) tree
else (new TreeCleaner).transform(tree)
new TastyImpl(ctx).showSourceCode.showTree(tree1)
}
withTree(expr, show, settings)
}

def withTree[T](expr: Expr[_], f: (Tree, Context) => T, settings: Toolbox.Settings): T = {
val ctx = setColor(setup(settings.compilerArgs.toArray :+ "dummy.scala", initCtx.fresh)._2.fresh, settings)
val ctx = setToolboxSettings(setup(settings.compilerArgs.toArray :+ "dummy.scala", initCtx.fresh)._2.fresh, settings)

var output: Option[T] = None
def registerTree(tree: tpd.Tree)(ctx: Context): Unit = {
Expand Down Expand Up @@ -79,9 +82,10 @@ class QuoteDriver extends Driver {
ictx
}

private def setColor(ctx: FreshContext, settings: Toolbox.Settings): FreshContext =
private def setToolboxSettings(ctx: FreshContext, settings: Toolbox.Settings): ctx.type = {
ctx.setSetting(ctx.settings.color, if (settings.color) "always" else "never")

ctx.setSetting(ctx.settings.YshowRawQuoteTrees, settings.showRawTree)
}
}

object QuoteDriver {
Expand Down