diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/Main.scala | 21 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/Settings.scala | 1 | ||||
-rwxr-xr-x | src/compiler/scala/tools/nsc/interactive/RangePositions.scala | 18 |
3 files changed, 35 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala index 799d9810f2..dcccf8724a 100644 --- a/src/compiler/scala/tools/nsc/Main.scala +++ b/src/compiler/scala/tools/nsc/Main.scala @@ -8,8 +8,10 @@ package scala.tools.nsc import java.io.File +import scala.concurrent.SyncVar + import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} -import scala.tools.nsc.util.FakePos //{Position} +import scala.tools.nsc.util.{ BatchSourceFile, FakePos } //{Position} /** The main class for NSC, a compiler for the programming * language Scala. @@ -46,6 +48,23 @@ object Main extends AnyRef with EvalLoop { val command = new CompilerCommand(args.toList, settings, error, false) if (command.settings.version.value) reporter.info(null, versionMsg, true) + else if (command.settings.Yidedebug.value) { + val compiler = new interactive.Global(command.settings, reporter) + import compiler._ + for (file <- command.files) { + val sf = getSourceFile(file) + var cu = unitOf(sf) + val reloaded = new SyncVar[Either[Unit, Throwable]] + askReload(List(sf), reloaded) + reloaded.get.right.toOption match { + case Some(thr) => logError("Failure in presentation compiler", thr) + case _ => + } + cu = unitOf(sf) + val tree = cu.body + treePrinters.create(System.out).print(tree) + } + } else { if (command.settings.target.value == "msil") { val libpath = System.getProperty("msil.libpath") diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index 8ef1ee0939..c0b26ff620 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -794,6 +794,7 @@ trait ScalacSettings { val Xwarndeadcode = BooleanSetting ("-Ywarn-dead-code", "Emit warnings for dead code") val specialize = BooleanSetting ("-Yspecialize", "Specialize generic code on types.") val Yrangepos = BooleanSetting ("-Yrangepos", "Use range positions for syntax trees.") + val Yidedebug = BooleanSetting ("-Yide-debug", "Generate, validate and output trees using the interactive compiler.") /** * -P "Plugin" settings diff --git a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala index 727b3e8cb2..5dbce2418a 100755 --- a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala +++ b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala @@ -152,7 +152,7 @@ self: nsc.Global => println(tree.id) tree } - throw new Error()//debug + //throw new Error()//debug // println("splitting "+splitNode) splitNode setPos new TransparentPosition(splitNode.pos.source.get, splitNode.pos.start, splitNode.pos.point, splitNode.pos.end) @@ -234,7 +234,7 @@ self: nsc.Global => inform(msg) inform("================= in =================") inform(tree.toString) - throw new ValidateError + throw new ValidateError(msg) } def validate(tree: Tree, encltree: Tree): Unit = try { if (!tree.isEmpty) { @@ -247,7 +247,17 @@ self: nsc.Global => error(encltree+" does not include "+tree) findOverlapping(tree.children flatMap solidDescendants) match { case List() => ; - case xs => error("overlapping trees: "+xs) + case xs => { + for((x, y) <- xs) { + println("Overlapping tree x: "+x.pos+" "+x.getClass.getName) + println(x) + println("Overlapping tree y: "+y.pos+" "+y.getClass.getName) + println(y) + } + println("Ancestor: "+tree.getClass.getName) + + error("overlapping trees: "+xs) + } } } for (ct <- tree.children flatMap solidDescendants) validate(ct, tree) @@ -260,7 +270,7 @@ self: nsc.Global => validate(tree, tree) } - class ValidateError extends Exception + class ValidateError(msg : String) extends Exception(msg) // ---------------- Locating trees ---------------------------------- |