Created
November 28, 2013 15:39
-
-
Save anonymous/7693857 to your computer and use it in GitHub Desktop.
inspired by Pythons:
>> import pdb;pdb.set_trace() I hacked something similar to have breakpoints in Scala 2.9 && 2.10 by typing:
import break._;break[someClass]("MainObject" -> MainObject)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.tools.nsc.interpreter._ | |
import scala.tools.nsc.Settings | |
//USAGE EXAMPLE: import break._;break[someClass]("MainObject" -> MainObject) | |
object break{ | |
def echo(x: Any) = Console.println(x) | |
def break[T: Manifest](args: NamedParam*) = { | |
val repl = new ILoop | |
repl.settings = new Settings(echo) | |
repl.settings.embeddedDefaults[T] | |
repl.createInterpreter() | |
repl.in = SimpleReader() | |
// repl.bind("p", "Array[page]", MainObject.pages) | |
val params = args.toList | |
println(args) | |
params foreach (p => repl.bind(p.name, p.tpe, p.value)) | |
var k = "" | |
while( k !="q"){ | |
k = Console.readLine() | |
repl.interpret(k) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment