diff options
author | Lex Spoon <lex@lexspoon.org> | 2009-02-06 16:59:38 +0000 |
---|---|---|
committer | Lex Spoon <lex@lexspoon.org> | 2009-02-06 16:59:38 +0000 |
commit | c1e179743e6c165a8bddd214f46335620d36704d (patch) | |
tree | e7d52366da5eaa7b45fde3ea773107b9ae466762 /src | |
parent | bb6969c63808cf29f137f6f5586efaca5fad5243 (diff) | |
download | scala-c1e179743e6c165a8bddd214f46335620d36704d.tar.gz scala-c1e179743e6c165a8bddd214f46335620d36704d.tar.bz2 scala-c1e179743e6c165a8bddd214f46335620d36704d.zip |
Adds Interpreter.reset(), a fast method for res...
Adds Interpreter.reset(), a fast method for resetting an existing
interpreter instance to a clean slate.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/Interpreter.scala | 15 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/io/VirtualDirectory.scala | 4 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index cf1fa8580b..8dcaf64b0b 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -155,8 +155,8 @@ class Interpreter(val settings: Settings, out: PrintWriter) { shadow the old ones, and old code objects refer to the old definitions. */ - /** class loader used to load compiled code */ - private val classLoader = { + private var classLoader = makeClassLoader() + private def makeClassLoader(): ClassLoader = { val parent = if (parentClassLoader == null) new URLClassLoader(compilerClasspath.toArray) @@ -247,7 +247,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) { truncPrintString(Interpreter.stripWrapperGunk(str)) /** Indent some code by the width of the scala> prompt. - * This way, compiler error messages read beettr. + * This way, compiler error messages read better. */ def indentCode(code: String) = { val spaces = " " @@ -560,6 +560,15 @@ class Interpreter(val settings: Settings, out: PrintWriter) { interpret("val " + name + " = " + binderName + ".value") } + /** Reset this interpreter, forgetting all user-specified + * requests. */ + def reset() { + virtualDirectory.clear() + classLoader = makeClassLoader() + nextLineNo = 0 + nextVarNameNo = 0 + prevRequests.clear() + } /** <p> * This instance is no longer needed, so release any resources diff --git a/src/compiler/scala/tools/nsc/io/VirtualDirectory.scala b/src/compiler/scala/tools/nsc/io/VirtualDirectory.scala index 5507ea0123..29ec6b2344 100644 --- a/src/compiler/scala/tools/nsc/io/VirtualDirectory.scala +++ b/src/compiler/scala/tools/nsc/io/VirtualDirectory.scala @@ -65,4 +65,8 @@ extends AbstractFile { existing } } + + def clear() { + files.clear(); + } } |