Skip to content

Instantly share code, notes, and snippets.

@rozza
Forked from anonymous/scala.breakpoint.scala
Created November 28, 2013 17:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rozza/7695002 to your computer and use it in GitHub Desktop.
Save rozza/7695002 to your computer and use it in GitHub Desktop.
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