Skip to content

Commit 9b45420

Browse files
committed
Remove interpreterSettings logic
Seems to be overkill for the current interpreter. The only thing that was needed was a configrable linewidth. A plain setting works fine for this and is in line with the way things are done elsewhere.
1 parent 41079cd commit 9b45420

File tree

5 files changed

+5
-127
lines changed

5 files changed

+5
-127
lines changed

src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class ScalaSettings extends Settings.SettingGroup {
8989
val showPhases = BooleanSetting("-Xshow-phases", "Print a synopsis of compiler phases.")
9090
val sourceReader = StringSetting("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "")
9191
val XnoValueClasses = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.")
92-
92+
val XreplLineWidth = IntSetting("-Xrepl-line-width", "Maximial number of columns per line for REPL output", 390)
9393
val XoldPatmat = BooleanSetting("-Xoldpatmat", "Use the pre-2.10 pattern matcher. Otherwise, the 'virtualizing' pattern matcher is used in 2.10.")
9494
val XnoPatmatAnalysis = BooleanSetting("-Xno-patmat-analysis", "Don't perform exhaustivity/unreachability analysis. Also, ignore @switch annotation.")
9595
val XfullLubs = BooleanSetting("-Xfull-lubs", "Retains pre 2.10 behavior of less aggressive truncation of least upper bounds.")

src/dotty/tools/dotc/repl/CompilingInterpreter.scala

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,11 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit
8888
}
8989
}
9090

91-
/** interpreter settings */
92-
override val isettings = new InterpreterSettings
93-
9491
private def newReporter = new ConsoleReporter(Console.in, out) {
9592
override def printMessage(msg: String) = {
9693
out.print(/*clean*/(msg) + "\n")
9794
// Suppress clean for now for compiler messages
98-
// Otherwise we will completely delete all references to
95+
// Otherwise we will completely delete all references to
9996
// line$object$ module classes. The previous interpreter did not
10097
// have the project because the module class was written without the final `$'
10198
// 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
200197
}
201198
}
202199

203-
/** A counter used for numbering objects created by <code>bind()</code>. */
204-
private var binderNum = 0
205-
206-
override def bind(name: String, boundType: String, value: Any)(implicit ctx: Context): Interpreter.Result = {
207-
val binderName = "binder" + binderNum
208-
binderNum += 1
209-
210-
compileString(
211-
"object " + binderName +
212-
"{ var value: " + boundType + " = _; " +
213-
" def set(x: Any) = value=x.asInstanceOf[" + boundType + "]; }")
214-
215-
val binderObject =
216-
Class.forName(binderName, true, classLoader)
217-
val setterMethod =
218-
binderObject.getDeclaredMethods.find(_.getName == "set").get
219-
var argsHolder: Array[Any] = null // this roundabout approach is to try and make sure the value is boxed
220-
argsHolder = List(value).toArray
221-
setterMethod.invoke(null, argsHolder.asInstanceOf[Array[AnyRef]])
222-
223-
interpret("val " + name + " = " + binderName + ".value")
224-
}
225-
226200
/** Trait collecting info about one of the statements of an interpreter request */
227201
private trait StatementInfo {
228202
/** The statement */
@@ -741,8 +715,8 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit
741715
}
742716

743717
/** Truncate a string if it is longer than settings.maxPrintString */
744-
private def truncPrintString(str: String): String = {
745-
val maxpr = isettings.maxPrintString
718+
private def truncPrintString(str: String)(implicit ctx: Context): String = {
719+
val maxpr = ctx.settings.XreplLineWidth.value
746720

747721
if (maxpr <= 0)
748722
return str
@@ -758,7 +732,7 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit
758732
}
759733

760734
/** Clean up a string for output */
761-
private def clean(str: String) =
735+
private def clean(str: String)(implicit ctx: Context) =
762736
truncPrintString(stripWrapperGunk(str))
763737

764738
/** Indent some code by the width of the scala> prompt.

src/dotty/tools/dotc/repl/Interpreter.scala

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,4 @@ trait Interpreter {
3838

3939
/** Suppress output during evaluation of `operation`. */
4040
def beQuietDuring[T](operation: => T): T
41-
42-
/** The interpreter settings */
43-
def isettings: InterpreterSettings
44-
45-
/** Bind a specified name to a specified value. The name may
46-
* later be used by expressions passed to interpret. Can be used to
47-
* programmatically change intepreter settings.
48-
*
49-
* @param name the variable name to bind
50-
* @param boundType the type of the variable, as a string
51-
* @param value the object value to bind to it
52-
* @return an indication of whether the binding succeeded
53-
*/
54-
def bind(name: String, boundType: String, value: Any)(implicit ctx: Context): Result
5541
}

src/dotty/tools/dotc/repl/InterpreterLoop.scala

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,6 @@ class InterpreterLoop(
4949
Thread.currentThread.setContextClassLoader(originalClassLoader)
5050
}
5151

52-
/** Bind the settings so that evaluated code can modify them */
53-
def bindSettings(): Unit = {
54-
interpreter.beQuietDuring {
55-
interpreter.compileString(InterpreterSettings.sourceCodeForClass)
56-
57-
interpreter.bind(
58-
"settings",
59-
"scala.tools.nsc.InterpreterSettings",
60-
interpreter.isettings)
61-
}
62-
}
63-
64-
6552
/** print a friendly help message */
6653
def printHelp(): Unit = {
6754
printWelcome()

src/dotty/tools/dotc/repl/InterpreterSettings.scala

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)