summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-03-19 15:38:06 +0000
committerPaul Phillips <paulp@improving.org>2011-03-19 15:38:06 +0000
commit01203c2844e196696b8fe35acfae0ee6ede90ffa (patch)
treed9200933daa90f7851d934a4927fd6c9abe79adb /src/compiler/scala/tools/nsc/interpreter/ILoop.scala
parent5bb967a3de039830dcc453bb92d3b6a0b794684f (diff)
downloadscala-01203c2844e196696b8fe35acfae0ee6ede90ffa.tar.gz
scala-01203c2844e196696b8fe35acfae0ee6ede90ffa.tar.bz2
scala-01203c2844e196696b8fe35acfae0ee6ede90ffa.zip
Added a :type command to the repl, no review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/interpreter/ILoop.scala')
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ILoop.scala10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
index 53a3448c20..3d4ff7a20b 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
@@ -216,7 +216,8 @@ class ILoop(in0: Option[BufferedReader], protected val out: PrintWriter)
NoArgs("quit", "exit the interpreter", () => Result(false, None)),
NoArgs("replay", "reset execution and replay all previous commands", replay),
LineArg("sh", "fork a shell and run a command", shCommand),
- NoArgs("silent", "disable/enable automatic printing of results", verbosity)
+ NoArgs("silent", "disable/enable automatic printing of results", verbosity),
+ LineArg("type", "display the type of an expression without evaluating it", typeCommand)
)
}
@@ -315,6 +316,13 @@ class ILoop(in0: Option[BufferedReader], protected val out: PrintWriter)
}
}
+ private def typeCommand(line: String): Result = {
+ intp.typeOfExpression(line) match {
+ case Some(tp) => tp.toString
+ case _ => "Failed to determine type."
+ }
+ }
+
private def javapCommand(line: String): Result = {
if (line == "")
return ":javap [-lcsvp] [path1 path2 ...]"