From 5e4e0cf35036906423e13eb74093af07a29f0521 Mon Sep 17 00:00:00 2001 From: vsalvis Date: Wed, 24 Jun 2015 16:33:44 +0200 Subject: Partest 2/3: Compiler prints via context instead of println --- src/dotty/tools/dotc/Run.scala | 8 ++++---- src/dotty/tools/dotc/transform/TreeChecker.scala | 12 ++++++------ src/dotty/tools/dotc/typer/FrontEnd.scala | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala index 401608a73..553805d95 100644 --- a/src/dotty/tools/dotc/Run.scala +++ b/src/dotty/tools/dotc/Run.scala @@ -33,7 +33,7 @@ class Run(comp: Compiler)(implicit ctx: Context) { compileSources(sources) } catch { case NonFatal(ex) => - println(i"exception occurred while compiling $units%, %") + ctx.println(i"exception occurred while compiling $units%, %") throw ex } @@ -55,7 +55,7 @@ class Run(comp: Compiler)(implicit ctx: Context) { ctx.usePhases(phases) for (phase <- ctx.allPhases) if (!ctx.reporter.hasErrors) { - if (ctx.settings.verbose.value) println(s"[$phase]") + if (ctx.settings.verbose.value) ctx.println(s"[$phase]") units = phase.runOn(units) def foreachUnit(op: Context => Unit)(implicit ctx: Context): Unit = for (unit <- units) op(ctx.fresh.setPhase(phase.next).setCompilationUnit(unit)) @@ -69,8 +69,8 @@ class Run(comp: Compiler)(implicit ctx: Context) { val prevPhase = ctx.phase.prev // can be a mini-phase val squashedPhase = ctx.squashed(prevPhase) - println(s"result of $unit after ${squashedPhase}:") - println(unit.tpdTree.show(ctx)) + ctx.println(s"result of $unit after ${squashedPhase}:") + ctx.println(unit.tpdTree.show(ctx)) } def compile(sourceCode: String): Unit = { diff --git a/src/dotty/tools/dotc/transform/TreeChecker.scala b/src/dotty/tools/dotc/transform/TreeChecker.scala index 19e6aca62..347eb8c01 100644 --- a/src/dotty/tools/dotc/transform/TreeChecker.scala +++ b/src/dotty/tools/dotc/transform/TreeChecker.scala @@ -42,8 +42,8 @@ class TreeChecker extends Phase with SymTransformer { private val seenClasses = collection.mutable.HashMap[String, Symbol]() private val seenModuleVals = collection.mutable.HashMap[String, Symbol]() - def printError(str: String) = { - println(Console.RED + "[error] " + Console.WHITE + str) + def printError(str: String)(implicit ctx: Context) = { + ctx.println(Console.RED + "[error] " + Console.WHITE + str) } val NoSuperClass = Trait | Package @@ -109,7 +109,7 @@ class TreeChecker extends Phase with SymTransformer { def check(phasesToRun: Seq[Phase], ctx: Context) = { val prevPhase = ctx.phase.prev // can be a mini-phase val squahsedPhase = ctx.squashed(prevPhase) - println(s"checking ${ctx.compilationUnit} after phase ${squahsedPhase}") + ctx.println(s"checking ${ctx.compilationUnit} after phase ${squahsedPhase}") val checkingCtx = ctx.fresh .setTyperState(ctx.typerState.withReporter(new ThrowingReporter(ctx.typerState.reporter))) val checker = new Checker(previousPhases(phasesToRun.toList)(ctx)) @@ -117,7 +117,7 @@ class TreeChecker extends Phase with SymTransformer { catch { case NonFatal(ex) => implicit val ctx: Context = checkingCtx - println(i"*** error while checking after phase ${checkingCtx.phase.prev} ***") + ctx.println(i"*** error while checking after phase ${checkingCtx.phase.prev} ***") throw ex } } @@ -151,10 +151,10 @@ class TreeChecker extends Phase with SymTransformer { } nowDefinedSyms += tree.symbol - //println(i"defined: ${tree.symbol}") + //ctx.println(i"defined: ${tree.symbol}") val res = op nowDefinedSyms -= tree.symbol - //println(i"undefined: ${tree.symbol}") + //ctx.println(i"undefined: ${tree.symbol}") res case _ => op } diff --git a/src/dotty/tools/dotc/typer/FrontEnd.scala b/src/dotty/tools/dotc/typer/FrontEnd.scala index 056a57215..bd597f008 100644 --- a/src/dotty/tools/dotc/typer/FrontEnd.scala +++ b/src/dotty/tools/dotc/typer/FrontEnd.scala @@ -18,7 +18,7 @@ class FrontEnd extends Phase { try body catch { case NonFatal(ex) => - println(s"exception occurred while $doing ${ctx.compilationUnit}") + ctx.println(s"exception occurred while $doing ${ctx.compilationUnit}") throw ex } -- cgit v1.2.3