From ab40558bb53d6058b175e7f25f51470fa286d92e Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Tue, 5 Jun 2012 19:41:31 +0200 Subject: REPL bells and whistles: -Dscala.repl.autoruncode= Useful for the upcoming reflection refactoring. Previously it was more or less okay to type "import scala.reflect.mirror._", but soon we'll have multiple universes and mirrors. --- src/compiler/scala/tools/nsc/interpreter/ILoop.scala | 7 +++++++ src/compiler/scala/tools/nsc/interpreter/ReplProps.scala | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala index d2e62e171e..b1c488d9dd 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala @@ -831,6 +831,13 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) // Bind intp somewhere out of the regular namespace where // we can get at it in generated code. addThunk(intp.quietBind("$intp" -> intp)) + addThunk({ + import scala.tools.nsc.io._ + import Properties.userHome + import compat.Platform.EOL + val autorun = replProps.replAutorunCode.option flatMap (f => io.File(f).safeSlurp()) + if (autorun.isDefined) intp.quietRun(autorun.get) + }) loadFiles(settings) // it is broken on startup; go ahead and exit diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala b/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala index 5eb1e0ae18..75d7c8accf 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala @@ -19,7 +19,8 @@ class ReplProps { val trace = bool("scala.repl.trace") val power = bool("scala.repl.power") - val replInitCode = Prop[JFile]("scala.repl.initcode") - val powerInitCode = Prop[JFile]("scala.repl.power.initcode") - val powerBanner = Prop[JFile]("scala.repl.power.banner") + val replInitCode = Prop[JFile]("scala.repl.initcode") + val replAutorunCode = Prop[JFile]("scala.repl.autoruncode") + val powerInitCode = Prop[JFile]("scala.repl.power.initcode") + val powerBanner = Prop[JFile]("scala.repl.power.banner") } -- cgit v1.2.3