Skip to content

Commit

Permalink
Imported sbt.Process into trunk, in the guise o...
Browse files Browse the repository at this point in the history
Imported sbt.Process into trunk, in the guise of package
scala.sys.process. It is largely indistinguishable from the version in
sbt, at least from the outside.

Also, I renamed package system to sys. I wanted to do that from the
beginning and the desire has only grown since then. Sometimes a short
identifier is just critical to usability: with a function like error("")
called from hundreds of places, the difference between system.error and
sys.error is too big. sys.error and sys.exit have good vibes (at least
as good as the vibes can be for functions which error and exit.)

Note: this is just the first cut. I need to check this in to finish
fixing partest. I will be going over it with a comb and writing
documentation which will leave you enchanted, as well as removing other
bits which are now redundant or inferior. No review.
  • Loading branch information
paulp committed Jan 12, 2011
1 parent 566fefb commit 5bada81
Show file tree
Hide file tree
Showing 114 changed files with 1,134 additions and 197 deletions.
2 changes: 1 addition & 1 deletion src/actors/scala/actors/Actor.scala
Expand Up @@ -543,7 +543,7 @@ trait Actor extends AbstractActor with ReplyReactor with ActorCanReply with Inpu
received = Some(TIMEOUT)
senders = this :: senders
} else
system.error("unhandled timeout")
sys.error("unhandled timeout")
}

var done = false
Expand Down
4 changes: 2 additions & 2 deletions src/actors/scala/actors/Scheduler.scala
Expand Up @@ -45,7 +45,7 @@ object Scheduler extends DelegatingScheduler {
if (sched.isInstanceOf[ForkJoinScheduler]) {
sched.asInstanceOf[ForkJoinScheduler].snapshot()
} else
system.error("scheduler does not implement snapshot")
sys.error("scheduler does not implement snapshot")
}

/* Only <code>ForkJoinScheduler</code> implements this method.
Expand All @@ -55,7 +55,7 @@ object Scheduler extends DelegatingScheduler {
if (sched.isInstanceOf[ForkJoinScheduler]) {
sched.asInstanceOf[ForkJoinScheduler].restart()
} else
system.error("scheduler does not implement restart")
sys.error("scheduler does not implement restart")
}

}
4 changes: 2 additions & 2 deletions src/actors/scala/actors/scheduler/ForkJoinScheduler.scala
Expand Up @@ -160,9 +160,9 @@ class ForkJoinScheduler(val initCoreSize: Int, val maxSize: Int, daemon: Boolean
def restart() {
synchronized {
if (!snapshoting)
system.error("snapshot has not been invoked")
sys.error("snapshot has not been invoked")
else if (isActive)
system.error("scheduler is still active")
sys.error("scheduler is still active")
else
snapshoting = false

Expand Down
Expand Up @@ -181,9 +181,9 @@ class ResizableThreadPoolScheduler(protected val terminate: Boolean,
def restart() {
synchronized {
if (!suspending)
system.error("snapshot has not been invoked")
sys.error("snapshot has not been invoked")
else if (isActive)
system.error("scheduler is still active")
sys.error("scheduler is still active")
else
suspending = false

Expand Down
Expand Up @@ -45,7 +45,7 @@ public void run() {

/**
* Abstraction of the exception handler which receives notifications of
* exceptions occurred possibly in various parts of the system. Exception
* exceptions occurred possibly in various parts of the sys. Exception
* handlers present attractive approach to exception handling in multi-threaded
* systems, as they can handle exceptions that occurred in different threads.
* <p>
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/scala/tools/ant/Same.scala
Expand Up @@ -90,8 +90,8 @@ class Same extends ScalaMatchingTask {

/** Tests if all mandatory attributes are set and valid. */
private def validateAttributes = {
if (origin.isEmpty) system.error("Mandatory attribute 'dir' is not set.")
if (destination.isEmpty) system.error("Mandatory attribute 'todir' is not set.")
if (origin.isEmpty) sys.error("Mandatory attribute 'dir' is not set.")
if (destination.isEmpty) sys.error("Mandatory attribute 'todir' is not set.")
}

private def reportDiff(f1: File, f2: File) = {
Expand Down Expand Up @@ -150,7 +150,7 @@ class Same extends ScalaMatchingTask {
}
if (!allEqualNow)
if (failing)
system.error("There were differences between '" + origin.get + "' and '" + destination.get + "'")
sys.error("There were differences between '" + origin.get + "' and '" + destination.get + "'")
else
log("There were differences between '" + origin.get + "' and '" + destination.get + "'")
else {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/ant/sabbus/Break.scala
Expand Up @@ -20,7 +20,7 @@ class Break extends Task {
private var id: Option[String] = None

override def execute {
if (id.isEmpty) system.error("Attribute 'id' is not set")
if (id.isEmpty) sys.error("Attribute 'id' is not set")
Compilers.break(id.get)
}

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/ant/sabbus/Make.scala
Expand Up @@ -14,8 +14,8 @@ import org.apache.tools.ant.Task

class Make extends Task with TaskArgs {
override def execute {
if (id.isEmpty) system.error("Mandatory attribute 'id' is not set.")
if (compilerPath.isEmpty) system.error("Mandatory attribute 'compilerpath' is not set.")
if (id.isEmpty) sys.error("Mandatory attribute 'id' is not set.")
if (compilerPath.isEmpty) sys.error("Mandatory attribute 'compilerpath' is not set.")
val settings = new Settings
if (!destinationDir.isEmpty) settings.d = destinationDir.get
if (!compTarget.isEmpty) settings.target = compTarget.get
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/scala/tools/ant/sabbus/ScalacFork.scala
Expand Up @@ -62,9 +62,9 @@ class ScalacFork extends ScalaMatchingTask with ScalacShared with TaskArgs {

log("Executing ant task scalacfork, origin: %s".format(originOfThis), Project.MSG_VERBOSE)

val compilerPath = this.compilerPath getOrElse system.error("Mandatory attribute 'compilerpath' is not set.")
val sourceDir = this.sourceDir getOrElse system.error("Mandatory attribute 'srcdir' is not set.")
val destinationDir = this.destinationDir getOrElse system.error("Mandatory attribute 'destdir' is not set.")
val compilerPath = this.compilerPath getOrElse sys.error("Mandatory attribute 'compilerpath' is not set.")
val sourceDir = this.sourceDir getOrElse sys.error("Mandatory attribute 'srcdir' is not set.")
val destinationDir = this.destinationDir getOrElse sys.error("Mandatory attribute 'destdir' is not set.")

val settings = new Settings
settings.d = destinationDir
Expand Down Expand Up @@ -114,7 +114,7 @@ class ScalacFork extends ScalaMatchingTask with ScalacShared with TaskArgs {
val res = execWithArgFiles(java, paths)

if (failOnError && res != 0)
system.error("Compilation failed because of an internal compiler error;"+
sys.error("Compilation failed because of an internal compiler error;"+
" see the error output for details.")
}
}
8 changes: 4 additions & 4 deletions src/compiler/scala/tools/ant/sabbus/Use.scala
Expand Up @@ -39,8 +39,8 @@ class Use extends ScalaMatchingTask {
private var failOnError: Boolean = true

override def execute() {
if (id.isEmpty) system.error("Mandatory attribute 'id' is not set.")
if (sourceDir.isEmpty) system.error("Mandatory attribute 'srcdir' is not set.")
if (id.isEmpty) sys.error("Mandatory attribute 'id' is not set.")
if (sourceDir.isEmpty) sys.error("Mandatory attribute 'srcdir' is not set.")
val compiler = Compilers(id.get)
if (!destinationDir.isEmpty) compiler.settings.d = destinationDir.get
val mapper = new GlobPatternMapper()
Expand All @@ -58,7 +58,7 @@ class Use extends ScalaMatchingTask {
log("Compiling " + includedFiles.size + " file" + (if (includedFiles.size > 1) "s" else "") + " to " + compiler.settings.d.getAbsolutePath)
val (errors, warnings) = compiler.compile(includedFiles)
if (errors > 0)
system.error("Compilation failed with " + errors + " error" + (if (errors > 1) "s" else "") + ".")
sys.error("Compilation failed with " + errors + " error" + (if (errors > 1) "s" else "") + ".")
else if (warnings > 0)
log("Compilation succeeded with " + warnings + " warning" + (if (warnings > 1) "s" else "") + ".")
}
Expand All @@ -67,7 +67,7 @@ class Use extends ScalaMatchingTask {
ex.printStackTrace
val errorMsg =
"Compilation failed because of an internal compiler error (" + msg + "); see the error output for details."
if (failOnError) system.error(errorMsg) else log(errorMsg)
if (failOnError) sys.error(errorMsg) else log(errorMsg)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/cmd/Demo.scala
Expand Up @@ -48,7 +48,7 @@ object DemoSpec extends DemoSpec with Property {
type ThisCommandLine = SpecCommandLine
def creator(args: List[String]) =
new SpecCommandLine(args) {
override def errorFn(msg: String) = { println("Error: " + msg) ; system.exit(0) }
override def errorFn(msg: String) = { println("Error: " + msg) ; sys.exit(0) }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/cmd/package.scala
Expand Up @@ -12,7 +12,7 @@ package object cmd {

def runAndExit(body: => Unit): Nothing = {
body
system.exit(0)
sys.exit(0)
}

def toOpt(s: String) = if (s startsWith "--") s else "--" + s
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/cmd/program/Simple.scala
Expand Up @@ -66,8 +66,8 @@ object Simple {
* inaccessible due to the overriding var.
*/
trait Ticket2338WontFixWorkaround {
def enforceArity_=(x: Boolean): Unit = system.error("unreachable")
def onlyKnownOptions_=(x: Boolean): Unit = system.error("unreachable")
def enforceArity_=(x: Boolean): Unit = sys.error("unreachable")
def onlyKnownOptions_=(x: Boolean): Unit = sys.error("unreachable")
}

/** Configurability simplicity achieved by turning defs into vars and letting
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/CompileClient.scala
Expand Up @@ -114,7 +114,7 @@ class StandardCompileClient {
}

def main(args: Array[String]): Unit =
system.exit(try main0(args) catch { case e: Exception => 1 })
sys.exit(try main0(args) catch { case e: Exception => 1 })
}


Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/CompileServer.scala
Expand Up @@ -36,7 +36,7 @@ class StandardCompileServer extends SocketServer {
private def exit(code: Int): Nothing = {
System.err.close()
System.out.close()
system.exit(code)
sys.exit(code)
}

private val runtime = Runtime.getRuntime()
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/Global.scala
Expand Up @@ -236,7 +236,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable

// XXX: short term, but I can't bear to add another option.
// scalac -Dscala.timings will make this true.
def timings = system.props contains "scala.timings"
def timings = sys.props contains "scala.timings"

def debug = settings.debug.value
def deprecation = settings.deprecation.value
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/Interpreter.scala
Expand Up @@ -1367,7 +1367,7 @@ object Interpreter {
intLoop.createInterpreter
intLoop.in = InteractiveReader.createDefault(intLoop.interpreter)

// rebind exit so people don't accidentally call system.exit by way of predef
// rebind exit so people don't accidentally call sys.exit by way of predef
intLoop.interpreter.beQuietDuring {
intLoop.interpreter.interpret("""def exit = println("Type :quit to resume program execution.")""")
for (p <- args) {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/InterpreterLoop.scala
Expand Up @@ -117,7 +117,7 @@ class InterpreterLoop(in0: Option[BufferedReader], protected val out: PrintWrite
private def installSigIntHandler() {
def onExit() {
Console.println("") // avoiding "shell prompt in middle of line" syndrome
system.exit(1)
sys.exit(1)
}
ignoring(classOf[Exception]) {
SignalManager("INT") = {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/Main.scala
Expand Up @@ -120,7 +120,7 @@ object Main extends AnyRef with EvalLoop {

def main(args: Array[String]) {
process(args)
system exit (if (reporter.hasErrors) 1 else 0)
sys.exit(if (reporter.hasErrors) 1 else 0)
}

}
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/MainGenericRunner.scala
Expand Up @@ -31,7 +31,7 @@ object MainGenericRunner {

def main(args: Array[String]) {
if (!process(args))
system.exit(1)
sys.exit(1)
}

def process(args: Array[String]): Boolean = {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/MainTokenMetric.scala
Expand Up @@ -34,7 +34,7 @@ object MainTokenMetric {
}

def process(args: Array[String]) {
val settings = new Settings(system.error)
val settings = new Settings(sys.error)
reporter = new ConsoleReporter(settings)
val command = new CompilerCommand(args.toList, settings)
try {
Expand All @@ -50,7 +50,7 @@ object MainTokenMetric {

def main(args: Array[String]) {
process(args)
system.exit(if (reporter.hasErrors) 1 else 0)
sys.exit(if (reporter.hasErrors) 1 else 0)
}

}
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/ScalaDoc.scala
Expand Up @@ -79,6 +79,6 @@ object ScalaDoc {

def main(args: Array[String]): Unit = {
process(args)
system.exit(if (reporter.hasErrors) 1 else 0)
sys.exit(if (reporter.hasErrors) 1 else 0)
}
}
6 changes: 3 additions & 3 deletions src/compiler/scala/tools/nsc/ScriptRunner.scala
Expand Up @@ -134,7 +134,7 @@ object ScriptRunner {
scriptFileIn: String): Boolean =
{
val scriptFile = Path(scriptFileIn).toAbsolute.path
val compSettingNames = new Settings(system.error).visibleSettings.toList map (_.name)
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)
Expand Down Expand Up @@ -178,7 +178,7 @@ object ScriptRunner {
val compiledPath = Directory makeTemp "scalascript"

// delete the directory after the user code has finished
system.addShutdownHook(compiledPath.deleteRecursively())
sys.addShutdownHook(compiledPath.deleteRecursively())

settings.outdir.value = compiledPath.path

Expand All @@ -198,7 +198,7 @@ object ScriptRunner {
else None
}

/** The script runner calls system.exit to communicate a return value, but this must
/** The script runner calls sys.exit to communicate a return value, but this must
* not take place until there are no non-daemon threads running. Tickets #1955, #2006.
*/
waitingForThreads {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
Expand Up @@ -684,7 +684,7 @@ abstract class TreeBrowsers {
toDocument(thistpe) :/: ", " :/:
toDocument(supertpe) ::")"))
case _ =>
system.error("Unknown case: " + t.toString() +", "+ t.getClass)
sys.error("Unknown case: " + t.toString() +", "+ t.getClass)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala
Expand Up @@ -581,7 +581,7 @@ abstract class ScalaPrimitives {
val arrayParent = tpe :: tpe.parents collectFirst {
case TypeRef(_, ArrayClass, elem :: Nil) => elem
}
arrayParent getOrElse system.error(fun.fullName + " : " + (tpe :: tpe.baseTypeSeq.toList).mkString(", "))
arrayParent getOrElse sys.error(fun.fullName + " : " + (tpe :: tpe.baseTypeSeq.toList).mkString(", "))
}

code match {
Expand Down
Expand Up @@ -75,8 +75,8 @@ trait ExceptionHandlers {
}

object NoFinalizer extends Finalizer(null, "<no finalizer>", NoPosition) {
override def startBlock: BasicBlock = system.error("NoFinalizer cannot have a start block.");
override def setStartBlock(b: BasicBlock): Unit = system.error("NoFinalizer cannot have a start block.");
override def startBlock: BasicBlock = sys.error("NoFinalizer cannot have a start block.");
override def setStartBlock(b: BasicBlock): Unit = sys.error("NoFinalizer cannot have a start block.");
override def dup = this
}
}
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala
Expand Up @@ -191,7 +191,7 @@ trait Linearizers {
*/
class DumpLinearizer extends Linearizer {
def linearize(m: IMethod): List[BasicBlock] = m.code.blocks.toList
def linearizeAt(m: IMethod, start: BasicBlock): List[BasicBlock] = system.error("not implemented")
def linearizeAt(m: IMethod, start: BasicBlock): List[BasicBlock] = sys.error("not implemented")
}

/** The MSIL linearizer is used only for methods with at least one exception handler.
Expand Down Expand Up @@ -328,7 +328,7 @@ trait Linearizers {
}

def linearizeAt(m: IMethod, start: BasicBlock): List[BasicBlock] = {
system.error("not implemented")
sys.error("not implemented")
}
}
}
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala
Expand Up @@ -578,7 +578,7 @@ trait Opcodes { self: ICodes =>
* then pushes one exception instance.
*/
case class LOAD_EXCEPTION(clasz: Symbol) extends Instruction {
override def consumed = system.error("LOAD_EXCEPTION does clean the whole stack, no idea how many things it consumes!")
override def consumed = sys.error("LOAD_EXCEPTION does clean the whole stack, no idea how many things it consumes!")
override def produced = 1
override def producedTypes = REFERENCE(clasz) :: Nil
}
Expand Down
Expand Up @@ -301,7 +301,7 @@ abstract class CopyPropagation {
out.bindings += (LocalVar(local) -> v)
}
case Nil =>
system.error("Incorrect icode in " + method + ". Expecting something on the stack.")
sys.error("Incorrect icode in " + method + ". Expecting something on the stack.")
}
out.stack = out.stack drop 1;

Expand Down
Expand Up @@ -82,7 +82,7 @@ trait DataFlowAnalysis[L <: SemiLattice] {
Console.println("in: " + in.mkString("", "\n", ""))
Console.println("out: " + out.mkString("", "\n", ""))
e.printStackTrace
system.error("Could not find element " + e.getMessage)
sys.error("Could not find element " + e.getMessage)
}

/** ...
Expand Down
Expand Up @@ -46,7 +46,7 @@ abstract class TypeFlowAnalysis {
def lub2(exceptional: Boolean)(s1: TypeStack, s2: TypeStack) = {
if (s1 eq bottom) s2
else if (s2 eq bottom) s1
else if ((s1 eq exceptionHandlerStack) || (s2 eq exceptionHandlerStack)) system.error("merging with exhan stack")
else if ((s1 eq exceptionHandlerStack) || (s2 eq exceptionHandlerStack)) sys.error("merging with exhan stack")
else {
// if (s1.length != s2.length)
// throw new CheckerException("Incompatible stacks: " + s1 + " and " + s2);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
Expand Up @@ -296,7 +296,7 @@ abstract class Inliners extends SubComponent {
def isMonadic = isMonadicMethod(sym)

def handlers = m.exh
def blocks = if (m.code eq null) system.error("blocks = null + " + m) else m.code.blocks
def blocks = if (m.code eq null) sys.error("blocks = null + " + m) else m.code.blocks
def locals = m.locals
def length = blocks.length
def openBlocks = blocks filterNot (_.closed)
Expand Down

0 comments on commit 5bada81

Please sign in to comment.