summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLex Spoon <lex@lexspoon.org>2007-05-24 20:02:21 +0000
committerLex Spoon <lex@lexspoon.org>2007-05-24 20:02:21 +0000
commit6ea7d123d3ad0ab2b2b090b380c67fc216fe2ce8 (patch)
treeab6b689c8f776996c65e1b178e2d8f0cf92e5820
parentfcc4d182dd4239df45b9629bc23a8a9c799cf9ce (diff)
downloadscala-6ea7d123d3ad0ab2b2b090b380c67fc216fe2ce8.tar.gz
scala-6ea7d123d3ad0ab2b2b090b380c67fc216fe2ce8.tar.bz2
scala-6ea7d123d3ad0ab2b2b090b380c67fc216fe2ce8.zip
In the interpreter, compile the source code of ...
In the interpreter, compile the source code of InterpreterSettings, so that it is available even if scala-compiler is not on the interpreter's classpath.
-rw-r--r--src/compiler/scala/tools/nsc/InterpreterLoop.scala9
-rw-r--r--src/compiler/scala/tools/nsc/InterpreterSettings.scala51
2 files changed, 51 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/InterpreterLoop.scala b/src/compiler/scala/tools/nsc/InterpreterLoop.scala
index b50633d043..9b1f2f20ac 100644
--- a/src/compiler/scala/tools/nsc/InterpreterLoop.scala
+++ b/src/compiler/scala/tools/nsc/InterpreterLoop.scala
@@ -11,7 +11,6 @@ import java.lang.ClassLoader
import java.io.{BufferedReader, InputStreamReader, File, FileReader, PrintWriter}
import java.io.IOException
-import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
import scala.tools.nsc.util.Position
import nsc.{InterpreterResults=>IR}
@@ -75,13 +74,9 @@ class InterpreterLoop(in0: BufferedReader, out: PrintWriter) {
/** Bind the settings so that evaluated code can modiy them */
def bindSettings() {
-// TODO: The isettings should not be bound like this,
-// because the interpreter should not be forced to
-// use a compatible classloader. Instead, the
-// settings object should be compiled inside the
-// interpreter, and InterpreterLoop should grab the
-// settings via reflection.
interpreter.beQuietDuring {
+ interpreter.compileString(InterpreterSettings.sourceCodeForClass)
+
interpreter.bind(
"settings",
"scala.tools.nsc.InterpreterSettings",
diff --git a/src/compiler/scala/tools/nsc/InterpreterSettings.scala b/src/compiler/scala/tools/nsc/InterpreterSettings.scala
index 7e5d0a5cc4..be932b0833 100644
--- a/src/compiler/scala/tools/nsc/InterpreterSettings.scala
+++ b/src/compiler/scala/tools/nsc/InterpreterSettings.scala
@@ -1,9 +1,13 @@
package scala.tools.nsc
-/** Settings for the interpreter */
+/** 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(".", "/home/lex/tmp") // XXX remove tmp, just for testing
+ 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
@@ -18,3 +22,46 @@ class InterpreterSettings {
" 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" +
+ "}"
+}
+
+"""
+
+}