diff options
Diffstat (limited to 'src/dotty')
-rw-r--r-- | src/dotty/tools/dotc/config/ScalaSettings.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/repl/CompilingInterpreter.scala | 34 | ||||
-rw-r--r-- | src/dotty/tools/dotc/repl/Interpreter.scala | 14 | ||||
-rw-r--r-- | src/dotty/tools/dotc/repl/InterpreterLoop.scala | 13 | ||||
-rw-r--r-- | src/dotty/tools/dotc/repl/InterpreterSettings.scala | 69 |
5 files changed, 5 insertions, 127 deletions
diff --git a/src/dotty/tools/dotc/config/ScalaSettings.scala b/src/dotty/tools/dotc/config/ScalaSettings.scala index 035b20130..65bc9ba23 100644 --- a/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -89,7 +89,7 @@ class ScalaSettings extends Settings.SettingGroup { val showPhases = BooleanSetting("-Xshow-phases", "Print a synopsis of compiler phases.") val sourceReader = StringSetting("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "") val XnoValueClasses = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.") - + val XreplLineWidth = IntSetting("-Xrepl-line-width", "Maximial number of columns per line for REPL output", 390) val XoldPatmat = BooleanSetting("-Xoldpatmat", "Use the pre-2.10 pattern matcher. Otherwise, the 'virtualizing' pattern matcher is used in 2.10.") val XnoPatmatAnalysis = BooleanSetting("-Xno-patmat-analysis", "Don't perform exhaustivity/unreachability analysis. Also, ignore @switch annotation.") val XfullLubs = BooleanSetting("-Xfull-lubs", "Retains pre 2.10 behavior of less aggressive truncation of least upper bounds.") diff --git a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala index 954612f1d..7d1da1419 100644 --- a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala +++ b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala @@ -88,14 +88,11 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit } } - /** interpreter settings */ - override val isettings = new InterpreterSettings - private def newReporter = new ConsoleReporter(Console.in, out) { override def printMessage(msg: String) = { out.print(/*clean*/(msg) + "\n") // Suppress clean for now for compiler messages - // Otherwise we will completely delete all references to + // Otherwise we will completely delete all references to // line$object$ module classes. The previous interpreter did not // have the project because the module class was written without the final `$' // and therefore escaped the purge. We can turn this back on once @@ -200,29 +197,6 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit } } - /** A counter used for numbering objects created by <code>bind()</code>. */ - private var binderNum = 0 - - override def bind(name: String, boundType: String, value: Any)(implicit ctx: Context): Interpreter.Result = { - val binderName = "binder" + binderNum - binderNum += 1 - - compileString( - "object " + binderName + - "{ var value: " + boundType + " = _; " + - " def set(x: Any) = value=x.asInstanceOf[" + boundType + "]; }") - - val binderObject = - Class.forName(binderName, true, classLoader) - val setterMethod = - binderObject.getDeclaredMethods.find(_.getName == "set").get - var argsHolder: Array[Any] = null // this roundabout approach is to try and make sure the value is boxed - argsHolder = List(value).toArray - setterMethod.invoke(null, argsHolder.asInstanceOf[Array[AnyRef]]) - - interpret("val " + name + " = " + binderName + ".value") - } - /** Trait collecting info about one of the statements of an interpreter request */ private trait StatementInfo { /** The statement */ @@ -741,8 +715,8 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit } /** Truncate a string if it is longer than settings.maxPrintString */ - private def truncPrintString(str: String): String = { - val maxpr = isettings.maxPrintString + private def truncPrintString(str: String)(implicit ctx: Context): String = { + val maxpr = ctx.settings.XreplLineWidth.value if (maxpr <= 0) return str @@ -758,7 +732,7 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit } /** Clean up a string for output */ - private def clean(str: String) = + private def clean(str: String)(implicit ctx: Context) = truncPrintString(stripWrapperGunk(str)) /** Indent some code by the width of the scala> prompt. diff --git a/src/dotty/tools/dotc/repl/Interpreter.scala b/src/dotty/tools/dotc/repl/Interpreter.scala index 9967aa347..1912e4594 100644 --- a/src/dotty/tools/dotc/repl/Interpreter.scala +++ b/src/dotty/tools/dotc/repl/Interpreter.scala @@ -38,18 +38,4 @@ trait Interpreter { /** Suppress output during evaluation of `operation`. */ def beQuietDuring[T](operation: => T): T - - /** The interpreter settings */ - def isettings: InterpreterSettings - - /** Bind a specified name to a specified value. The name may - * later be used by expressions passed to interpret. Can be used to - * programmatically change intepreter settings. - * - * @param name the variable name to bind - * @param boundType the type of the variable, as a string - * @param value the object value to bind to it - * @return an indication of whether the binding succeeded - */ - def bind(name: String, boundType: String, value: Any)(implicit ctx: Context): Result } diff --git a/src/dotty/tools/dotc/repl/InterpreterLoop.scala b/src/dotty/tools/dotc/repl/InterpreterLoop.scala index e096b7f86..8cc4d0927 100644 --- a/src/dotty/tools/dotc/repl/InterpreterLoop.scala +++ b/src/dotty/tools/dotc/repl/InterpreterLoop.scala @@ -49,19 +49,6 @@ class InterpreterLoop( Thread.currentThread.setContextClassLoader(originalClassLoader) } - /** Bind the settings so that evaluated code can modify them */ - def bindSettings(): Unit = { - interpreter.beQuietDuring { - interpreter.compileString(InterpreterSettings.sourceCodeForClass) - - interpreter.bind( - "settings", - "scala.tools.nsc.InterpreterSettings", - interpreter.isettings) - } - } - - /** print a friendly help message */ def printHelp(): Unit = { printWelcome() diff --git a/src/dotty/tools/dotc/repl/InterpreterSettings.scala b/src/dotty/tools/dotc/repl/InterpreterSettings.scala deleted file mode 100644 index ee2f9335e..000000000 --- a/src/dotty/tools/dotc/repl/InterpreterSettings.scala +++ /dev/null @@ -1,69 +0,0 @@ -package dotty.tools -package dotc -package repl - -/** Settings for the interpreter - * - * @version 1.0 - * @author Lex Spoon, 2007/3/24 - **/ -class InterpreterSettings { - /** A list of paths where :load should look */ - var loadPath = List(".") - - /** The maximum length of toString to use when printing the result - * of an evaluation. 0 means no maximum. If a printout requires - * more than this number of characters, then the printout is - * truncated. - */ - var maxPrintString = 390 - - override def toString = - "InterpreterSettings {\n" + -// " loadPath = " + loadPath + "\n" + - " maxPrintString = " + maxPrintString + "\n" + - "}" -} - - - -/* Utilities for the InterpreterSettings class - * - * @version 1.0 - * @author Lex Spoon, 2007/5/24 - */ -object InterpreterSettings { - /** Source code for the InterpreterSettings class. This is - * used so that the interpreter is sure to have the code - * available. - */ - val sourceCodeForClass = -""" -package scala.tools.nsc - -/** Settings for the interpreter - * - * @version 1.0 - * @author Lex Spoon, 2007/3/24 - **/ -class InterpreterSettings { - /** A list of paths where :load should look */ - var loadPath = List(".") - - /** The maximum length of toString to use when printing the result - * of an evaluation. 0 means no maximum. If a printout requires - * more than this number of characters, then the printout is - * truncated. - */ - var maxPrintString = 390 - - override def toString = - "InterpreterSettings {\n" + -// " loadPath = " + loadPath + "\n" + - " maxPrintString = " + maxPrintString + "\n" + - "}" -} - -""" - -} |