diff options
author | Lex Spoon <lex@lexspoon.org> | 2006-06-15 14:54:14 +0000 |
---|---|---|
committer | Lex Spoon <lex@lexspoon.org> | 2006-06-15 14:54:14 +0000 |
commit | 1b68ef970c8728a871e8f0ee586a0200602146e1 (patch) | |
tree | abac4cac065d45b36065bea36b9e5dd6682d1525 /src/compiler | |
parent | a605ab716e02a220568b4a315503356630268896 (diff) | |
download | scala-1b68ef970c8728a871e8f0ee586a0200602146e1.tar.gz scala-1b68ef970c8728a871e8f0ee586a0200602146e1.tar.bz2 scala-1b68ef970c8728a871e8f0ee586a0200602146e1.zip |
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/MainGenericRunner.scala | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/MainGenericRunner.scala b/src/compiler/scala/tools/nsc/MainGenericRunner.scala new file mode 100644 index 0000000000..2df23c2539 --- /dev/null +++ b/src/compiler/scala/tools/nsc/MainGenericRunner.scala @@ -0,0 +1,64 @@ +package scala.tools.nsc +import java.io.File + +/* NSC -- new scala compiler + * Copyright 2006 LAMP/EPFL + * @author Lex Spoon + */ +// $Id$ + +/** An object that runs Scala code. It has three possible + * sources for the code to run: pre-compiled code, a script file, + * or interactive entry. + */ +object MainGenericRunner { + def main(args: Array[String]): Unit = { + def error(str: String) = Console.println(str) + val command = new GenericRunnerCommand(args.toList, error) + if(!command.ok) { + Console.println(command.usageMessage) + return () + } + + val settings = command.settings + + if(settings.help.value) { + Console.println(command.usageMessage) + return () + } + + if(settings.version.value) { + val version = + System.getProperty("scala.tool.version", "unknown version") + Console.println("scala version " + version) + Console.println("(c) 2002-2006 LAMP/EPFL") + return () + } + + command.thingToRun match { + case None => { + (new InterpreterLoop).main(settings) + } + case Some(thingToRun) => { + val isObjectName = + settings.howtorun.value match { + case "guess" => !(new File(thingToRun)).exists + case "object" => true + case "script" => false + } + + if(isObjectName) { + def paths(str: String) = str.split(File.pathSeparator).toList + + val classpath = + paths(settings.bootclasspath.value) ::: + paths(settings.classpath.value) + + ObjectRunner.run(classpath, thingToRun, command.arguments) + } else { + MainScript.runScript(settings, thingToRun, command.arguments) + } + } + } + } +} |