From 9e4bdd411cbc3db5064dcd01a9c35bd46508ceb4 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 8 Aug 2011 07:25:47 +0000 Subject: Made the thread behavior of the repl a little b... Made the thread behavior of the repl a little bit configurable. Every line will run in the same thread: scala -Dscala.repl.no-threads This mechanism is likely to change. Repl is obscenely overdue for a config file. No review. --- src/compiler/scala/tools/nsc/interpreter/IMain.scala | 7 ++++++- src/compiler/scala/tools/nsc/interpreter/ReplProps.scala | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 207def1eb2..3abcb3e416 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -240,7 +240,8 @@ class IMain(val settings: Settings, protected val out: JPrintWriter) extends Imp lazy val isettings = new ISettings(this) /** Create a line manager. Overridable. */ - protected def createLineManager(): Line.Manager = new Line.Manager + protected def createLineManager(): Line.Manager = + if (replProps.noThreads) null else new Line.Manager /** Instantiate a compiler. Overridable. */ protected def newCompiler(settings: Settings, reporter: Reporter) = { @@ -912,6 +913,10 @@ class IMain(val settings: Settings, protected val out: JPrintWriter) extends Imp /** load and run the code using reflection */ def loadAndRun: (String, Boolean) = { + if (replProps.noThreads) return { + try { ("" + (lineRep call sessionNames.print), true) } + catch { case ex => (lineRep.bindError(ex), false) } + } import interpreter.Line._ try { diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala b/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala index 5eb1e0ae18..72bfb2eeff 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala @@ -13,6 +13,7 @@ class ReplProps { val jlineDebug = bool("scala.tools.jline.internal.Log.debug") val jlineTrace = bool("scala.tools.jline.internal.Log.trace") + val noThreads = bool("scala.repl.no-threads") val info = bool("scala.repl.info") val debug = bool("scala.repl.debug") -- cgit v1.2.3