diff options
author | Paul Phillips <paulp@improving.org> | 2011-02-01 08:27:18 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-02-01 08:27:18 +0000 |
commit | ee4e09235afa578a7a33267061179ca338e396c0 (patch) | |
tree | 52ff21a786e84f0a3c47ef5666746591301cc47c /src/compiler/scala/tools/nsc/ScriptRunner.scala | |
parent | d59d7f928d8a71d73d198690ab5816af3be90d6b (diff) | |
download | scala-ee4e09235afa578a7a33267061179ca338e396c0.tar.gz scala-ee4e09235afa578a7a33267061179ca338e396c0.tar.bz2 scala-ee4e09235afa578a7a33267061179ca338e396c0.zip |
Eliminating duplication and trying to outrun ob...
Eliminating duplication and trying to outrun obsolescence in the
exciting world of fsc. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ScriptRunner.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ScriptRunner.scala | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala index 0733254356..fcfb827089 100644 --- a/src/compiler/scala/tools/nsc/ScriptRunner.scala +++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala @@ -47,7 +47,9 @@ import util.Exceptional.unwrap * @todo It would be better if error output went to stderr instead * of stdout... */ -object ScriptRunner { +class ScriptRunner extends CompileSocketShared { + lazy val compileSocket = CompileSocket + /* While I'm chasing down the fsc and script bugs. */ def DBG(msg: Any) { System.err.println(msg.toString) @@ -124,38 +126,18 @@ object ScriptRunner { } /** Compile a script using the fsc compilation daemon. - * - * @param settings ... - * @param scriptFileIn ... - * @return ... */ - private def compileWithDaemon( - settings: GenericRunnerSettings, - scriptFileIn: String): Boolean = - { - val scriptFile = Path(scriptFileIn).toAbsolute.path - val compSettingNames = new Settings(sys.error).visibleSettings.toList map (_.name) - val compSettings = settings.visibleSettings.toList filter (compSettingNames contains _.name) - val coreCompArgs = compSettings flatMap (_.unparse) - val compArgs = coreCompArgs ::: List("-Xscript", scriptMain(settings), scriptFile) - var compok = true - - val socket = CompileSocket getOrCreateSocket "" getOrElse (return false) - socket.applyReaderAndWriter { (in, out) => - out println (CompileSocket getPassword socket.getPort) - out println (compArgs mkString "\0") - - try { - for (fromServer <- (Iterator continually in.readLine()) takeWhile (_ != null)) { - Console.err println fromServer - if (CompileSocket.errorPattern matcher fromServer matches) - compok = false - } - } - finally socket.close() + private def compileWithDaemon(settings: GenericRunnerSettings, scriptFileIn: String) = { + val scriptFile = Path(scriptFileIn).toAbsolute.path + val compSettingNames = new Settings(sys.error).visibleSettings.toList map (_.name) + val compSettings = settings.visibleSettings.toList filter (compSettingNames contains _.name) + val coreCompArgs = compSettings flatMap (_.unparse) + val compArgs = coreCompArgs ++ List("-Xscript", scriptMain(settings), scriptFile) + + CompileSocket getOrCreateSocket "" match { + case Some(sock) => fscCompile(sock, compArgs) + case _ => false } - - compok } protected def newGlobal(settings: Settings, reporter: Reporter) = @@ -293,3 +275,5 @@ object ScriptRunner { finally scriptFile.delete() // in case there was a compilation error } } + +object ScriptRunner extends ScriptRunner { }
\ No newline at end of file |