summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorLex Spoon <lex@lexspoon.org>2006-02-27 17:15:01 +0000
committerLex Spoon <lex@lexspoon.org>2006-02-27 17:15:01 +0000
commit40dc432b5e35ffb521adaf65263d486ece7e4c6e (patch)
tree20788de81b2a58c218c36e56822285529612a23d /src/compiler
parent261195377ff2ea89a132389146025be4ffb1a574 (diff)
downloadscala-40dc432b5e35ffb521adaf65263d486ece7e4c6e.tar.gz
scala-40dc432b5e35ffb521adaf65263d486ece7e4c6e.tar.bz2
scala-40dc432b5e35ffb521adaf65263d486ece7e4c6e.zip
allocate new line numbers more eagerly, thus co...
allocate new line numbers more eagerly, thus consistently avoiding reuse of existing .class files
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index 4bcadce59b..fa2960e56c 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -92,6 +92,16 @@ class Interpreter(val compiler: Global, output: (String => Unit)) {
prevRequests.toList.reverse.find(lin => lin.boundNames.contains(vname))
}
+ /** next line number to use */
+ var nextLineNo = 0
+
+ /** allocate a fresh line name */
+ def newLineName = {
+ val num = nextLineNo
+ nextLineNo = nextLineNo + 1
+ "line" + num
+ }
+
/** generate a string using a routine that wants to write on a stream */
private def stringFrom(writer: PrintWriter=>Unit): String = {
val stringWriter = new StringWriter()
@@ -162,10 +172,9 @@ class Interpreter(val compiler: Global, output: (String => Unit)) {
val trees = parse(line)
if(trees.isEmpty) return () // parse error or empty input
- // figure out what kind of request
- val lineno = prevRequests.length
- val lineName = "line" + lineno
+ val lineName = newLineName
+ // figure out what kind of request
val req = buildRequest(trees, line, lineName)
if(req == null) return () // a disallowed statement type