Permalink
Browse files

Total repl rewrite.

All tests pass here.
  • Loading branch information...
1 parent 8ba304c commit 868b1b359775519a97ff7f1c76edc2ac48324c64 @paulp paulp committed Jun 10, 2010
Showing with 3,508 additions and 2,544 deletions.
  1. +2 −2 build.xml
  2. +40 −29 src/compiler/scala/tools/cmd/program/Tokens.scala
  3. +12 −0 src/compiler/scala/tools/nsc/Global.scala
  4. +0 −1,311 src/compiler/scala/tools/nsc/Interpreter.scala
  5. +0 −613 src/compiler/scala/tools/nsc/InterpreterLoop.scala
  6. +0 −24 src/compiler/scala/tools/nsc/InterpreterResults.scala
  7. +0 −109 src/compiler/scala/tools/nsc/InterpreterSettings.scala
  8. +0 −13 src/compiler/scala/tools/nsc/MainInterpreter.scala
  9. +0 −14 src/compiler/scala/tools/nsc/Settings.scala
  10. +2 −0 src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
  11. +20 −5 src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
  12. +0 −36 src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala
  13. +0 −112 src/compiler/scala/tools/nsc/interpreter/ReflectionCompletion.scala
  14. +0 −30 src/compiler/scala/tools/nsc/interpreter/package.scala
  15. +3 −1 src/compiler/scala/tools/nsc/io/VirtualFile.scala
  16. +10 −0 src/compiler/scala/tools/nsc/package.scala
  17. +37 −0 src/compiler/scala/tools/nsc/repl/AbstractFileClassLoader.scala
  18. +169 −0 src/compiler/scala/tools/nsc/repl/Binders.scala
  19. +10 −14 src/compiler/scala/tools/nsc/{interpreter → repl}/ByteCode.scala
  20. +55 −0 src/compiler/scala/tools/nsc/repl/Classloading.scala
  21. +23 −49 src/compiler/scala/tools/nsc/{interpreter → repl}/Completion.scala
  22. +16 −22 src/compiler/scala/tools/nsc/{interpreter → repl}/CompletionAware.scala
  23. +3 −19 src/compiler/scala/tools/nsc/{interpreter → repl}/CompletionOutput.scala
  24. +49 −0 src/compiler/scala/tools/nsc/repl/CompletionParser.scala
  25. +61 −0 src/compiler/scala/tools/nsc/repl/Debug.scala
  26. +1 −1 src/compiler/scala/tools/nsc/{interpreter → repl}/Delimited.scala
  27. +23 −0 src/compiler/scala/tools/nsc/repl/Desktop.scala
  28. +1 −1 src/compiler/scala/tools/nsc/{interpreter → repl}/FileCompletion.scala
  29. +224 −0 src/compiler/scala/tools/nsc/repl/Handlers.scala
  30. +1 −1 src/compiler/scala/tools/nsc/{interpreter → repl}/History.scala
  31. +125 −0 src/compiler/scala/tools/nsc/repl/Imports.scala
  32. +138 −0 src/compiler/scala/tools/nsc/repl/Init.scala
  33. +9 −15 src/compiler/scala/tools/nsc/{interpreter → repl}/InteractiveReader.scala
  34. +371 −0 src/compiler/scala/tools/nsc/repl/Interpreter.scala
  35. 0 src/compiler/scala/tools/nsc/{ → repl}/InterpreterCommand.scala
  36. +428 −0 src/compiler/scala/tools/nsc/repl/InterpreterLoop.scala
  37. +13 −12 src/compiler/scala/tools/nsc/{interpreter → repl}/JLineReader.scala
  38. +89 −0 src/compiler/scala/tools/nsc/repl/Javap.scala
  39. +275 −0 src/compiler/scala/tools/nsc/repl/LoopCommands.scala
  40. +3 −5 src/compiler/scala/tools/nsc/{MainGenericRunner.scala → repl/Main.scala}
  41. +63 −0 src/compiler/scala/tools/nsc/repl/Naming.scala
  42. +1 −1 src/compiler/scala/tools/nsc/{interpreter → repl}/Parsed.scala
  43. +123 −0 src/compiler/scala/tools/nsc/repl/Power.scala
  44. +4 −5 src/compiler/scala/tools/nsc/{interpreter → repl}/ProductCompletion.scala
  45. +66 −0 src/compiler/scala/tools/nsc/repl/REPLSettings.scala
  46. +337 −0 src/compiler/scala/tools/nsc/repl/Requests.scala
  47. +124 −0 src/compiler/scala/tools/nsc/repl/Scratch.scala
  48. +1 −2 src/compiler/scala/tools/nsc/{interpreter → repl}/SimpleReader.scala
  49. +119 −0 src/compiler/scala/tools/nsc/repl/Spawn.scala
  50. +76 −0 src/compiler/scala/tools/nsc/repl/Strings.scala
  51. +55 −0 src/compiler/scala/tools/nsc/repl/Symbolize.scala
  52. +74 −0 src/compiler/scala/tools/nsc/repl/TypeCache.scala
  53. +53 −0 src/compiler/scala/tools/nsc/repl/TypeStrings.scala
  54. +2 −2 src/compiler/scala/tools/nsc/{interpreter → repl}/XMLCompletion.scala
  55. +69 −0 src/compiler/scala/tools/nsc/repl/package.scala
  56. +3 −3 src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala
  57. +14 −10 src/compiler/scala/tools/nsc/settings/AbsSettings.scala
  58. +67 −56 src/compiler/scala/tools/nsc/settings/MutableSettings.scala
  59. +0 −1 src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
  60. +0 −5 src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
  61. +1 −1 src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala
  62. +1 −1 src/compiler/scala/tools/nsc/util/ShowPickled.scala
  63. +19 −0 src/compiler/scala/tools/nsc/util/package.scala
  64. +2 −1 src/library/scala/reflect/Manifest.scala
  65. +2 −2 src/partest-alternative/scala/tools/partest/Compilable.scala
  66. +1 −1 src/partest-alternative/scala/tools/partest/ant/JavaTask.scala
  67. +1 −1 src/partest-alternative/scala/tools/partest/category/Analysis.scala
  68. +1 −1 src/partest/scala/tools/partest/nest/Worker.scala
  69. +8 −4 src/scalap/scala/tools/scalap/Decode.scala
  70. +1 −1 test/files/jvm/interpreter.check
  71. +3 −3 test/files/jvm/interpreter.scala
  72. +1 −2 test/files/run/constrained-types.scala
  73. +1 −1 test/files/run/t1500.scala
  74. +1 −1 test/files/run/t1501.scala
  75. +1 −1 test/files/run/treePrint.scala
View
@@ -755,7 +755,7 @@ QUICK BUILD (QUICK)
<mkdir dir="${build-quick.dir}/bin"/>
<quick-bin
file="${build-quick.dir}/bin/scala"
- class="scala.tools.nsc.MainGenericRunner"
+ class="scala.tools.nsc.repl.Main"
javaFlags="${java.flags}"
classpathref="quick.bin.classpath"/>
<quick-bin
@@ -922,7 +922,7 @@ PACKED QUICK BUILD (PACK)
<mkdir dir="${build-pack.dir}/bin"/>
<pack-bin
file="${build-pack.dir}/bin/scala"
- class="scala.tools.nsc.MainGenericRunner"
+ class="scala.tools.nsc.repl.Main"
javaFlags="${java.flags}"/>
<pack-bin
file="${build-pack.dir}/bin/scalac"
@@ -12,10 +12,49 @@ import util.Chars.char2uescape
import io._
import ast.parser.Tokens._
+trait GlobalTokenizer {
+ // Can be overridden for a reusable one.
+ def global: Global = new Global(new Settings())
+
+ def fromScalaString(code: String): List[Any] = {
+ val f = File.makeTemp("tokens")
+ f writeAll code
+ fromScalaSource(f)
+ }
+
+ /** Tokenizes a single scala file.
+ */
+ def fromScalaSource(file: Path): List[Any] = fromScalaSource(file.path)
+ def fromScalaSource(file: String): List[Any] = {
+ val g = global
+ import g._
+ import syntaxAnalyzer.{ UnitScanner, token2string }
+
+ val in = new UnitScanner(new CompilationUnit(getSourceFile(file)))
+ in.init()
+
+ Iterator continually {
+ val token = in.token match {
+ case IDENTIFIER | BACKQUOTED_IDENT => in.name
+ case CHARLIT | INTLIT | LONGLIT => in.intVal
+ case DOUBLELIT | FLOATLIT => in.floatVal
+ case STRINGLIT => "\"" + in.strVal + "\""
+ case SEMI | NEWLINE => ";"
+ case NEWLINES => ";;"
+ case COMMA => ","
+ case EOF => null
+ case x => token2string(x)
+ }
+ in.nextToken()
+ token
+ } takeWhile (_ != null) toList
+ }
+}
+
/** Given paths on the command line, tokenizes any scala files found
* and prints one token per line.
*/
-object Tokens {
+object Tokens extends GlobalTokenizer {
private val tokensUsage = "Usage: tokens [options] <path1 path2 ...>\n\nOptions:"
private val tokensUnary = List(
"verbose" -> "be more verbose",
@@ -69,32 +108,4 @@ object Tokens {
Path onlyFiles traverse filter (_ hasExtension "scala") toList
}
-
- /** Tokenizes a single scala file.
- */
- def fromScalaSource(file: Path): List[Any] = fromScalaSource(file.path)
- def fromScalaSource(file: String): List[Any] = {
- val global = new Global(new Settings())
- import global._
- import syntaxAnalyzer.{ UnitScanner, token2string }
-
- val in = new UnitScanner(new CompilationUnit(getSourceFile(file)))
- in.init()
-
- Iterator continually {
- val token = in.token match {
- case IDENTIFIER | BACKQUOTED_IDENT => in.name
- case CHARLIT | INTLIT | LONGLIT => in.intVal
- case DOUBLELIT | FLOATLIT => in.floatVal
- case STRINGLIT => "\"" + in.strVal + "\""
- case SEMI | NEWLINE => ";"
- case NEWLINES => ";;"
- case COMMA => ","
- case EOF => null
- case x => token2string(x)
- }
- in.nextToken()
- token
- } takeWhile (_ != null) toList
- }
}
@@ -44,6 +44,18 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
def this(settings: Settings) =
this(settings, new ConsoleReporter(settings))
+ // debug
+
+ /** Break into repl debugger if assertion is true */
+ import repl.{ Debug, DebugParam, GlobalParam, SettingsParam }
+ def breakIf(assertion: => Boolean, args: DebugParam[_]*): Unit = {
+ def globalParam = GlobalParam(this)
+ def settingsParam = SettingsParam(settings)
+
+ if (assertion)
+ Debug.break(globalParam :: settingsParam :: args.toList)
+ }
+
// platform specific elements
type ThisPlatform = Platform[_] { val global: Global.this.type }
Oops, something went wrong.

0 comments on commit 868b1b3

Please sign in to comment.