summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorLex Spoon <lex@lexspoon.org>2007-01-17 16:42:44 +0000
committerLex Spoon <lex@lexspoon.org>2007-01-17 16:42:44 +0000
commit6b0dcb20529c5ae07b7a2d1b20605996408cf046 (patch)
treebe347bbdf799187807314d02cfd8762ffd60a076 /src/compiler
parentd3cc8c2190d265ca02a72d02ddde3579baf58667 (diff)
downloadscala-6b0dcb20529c5ae07b7a2d1b20605996408cf046.tar.gz
scala-6b0dcb20529c5ae07b7a2d1b20605996408cf046.tar.bz2
scala-6b0dcb20529c5ae07b7a2d1b20605996408cf046.zip
Fix the prime routine; the priming command was
hiding the first user-supplied command!
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index 43852df28b..30fcb998ad 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -148,7 +148,8 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter)
private def newLineName = {
val num = nextLineNo
nextLineNo = nextLineNo + 1
- compiler.nme.INTERPRETER_LINE_PREFIX + num
+ (compiler.nme.INTERPRETER_LINE_PREFIX +
+ (if (num>=0) num.toString else "_neg" + (-num).toString))
}
/** import statements that should be used for submitted code */
@@ -261,6 +262,7 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter)
* reporter. Values defined are available for future interpreted
* strings.
* </p>
+ *
* <p>
* The return value is whether the line was interpreter successfully,
* e.g. that there were no parse errors.
@@ -343,14 +345,13 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter)
* for interactive interpreters so that the interpreter responds
* quickly to the first user-supplied query.
*/
- def prime: Unit = beQuietDuring {
- interpret("0")
-
- // the next two lines are cosmetic; they cause
- // the line number to go back to what it was
- nextLineNo = nextLineNo - 1
- prevRequests.remove(prevRequests.length - 1)
- }
+ def prime: Unit =
+ if(prevRequests.isEmpty)
+ beQuietDuring {
+ nextLineNo = -1 // cosmetic: make the first user-requested line
+ // be number 0
+ interpret("0")
+ }
/** <p>
* This instance is no longer needed, so release any resources