Created
October 22, 2012 15:02
-
-
Save paulp/3931918 to your computer and use it in GitHub Desktop.
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
def breakIf[T: ClassTag](assertion: => Boolean, args: NamedParam*): Unit = | |
if (assertion) break[T](args.toList) | |
// start a repl, binding supplied args | |
def break[T: ClassTag](args: List[NamedParam]): Unit = savingContextLoader { | |
val msg = if (args.isEmpty) "" else " Binding " + args.size + " value%s.".format( | |
if (args.size == 1) "" else "s" | |
) | |
echo("Debug repl starting." + msg) | |
val repl = new ILoop { | |
override def prompt = "\ndebug> " | |
} | |
repl.settings = new Settings(echo) | |
repl.settings.embeddedDefaults[T] | |
repl.createInterpreter() | |
repl.in = new JLineReader(new JLineCompletion(repl)) | |
// rebind exit so people don't accidentally call sys.exit by way of predef | |
repl.quietRun("""def exit = println("Type :quit to resume program execution.")""") | |
args foreach (p => repl.bind(p.name, p.tpe, p.value)) | |
repl.loop() | |
echo("\nDebug repl exiting.") | |
repl.closeInterpreter() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment