diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-06-02 20:18:02 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-06-03 09:23:50 +0200 |
commit | d4d9009a564a7c2a30a1a962da08bdab8408d717 (patch) | |
tree | b8c34a5ac084b93e15cf72453f60651664b9dc95 /src/dotty/tools/dotc/repl/InterpreterLoop.scala | |
parent | dded5473c2fce3e6ad814536b0f604ebacba1e3a (diff) | |
download | dotty-d4d9009a564a7c2a30a1a962da08bdab8408d717.tar.gz dotty-d4d9009a564a7c2a30a1a962da08bdab8408d717.tar.bz2 dotty-d4d9009a564a7c2a30a1a962da08bdab8408d717.zip |
Add ability to bind values from runtime
Diffstat (limited to 'src/dotty/tools/dotc/repl/InterpreterLoop.scala')
-rw-r--r-- | src/dotty/tools/dotc/repl/InterpreterLoop.scala | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/repl/InterpreterLoop.scala b/src/dotty/tools/dotc/repl/InterpreterLoop.scala index 95197f27f..7e5dcc7f1 100644 --- a/src/dotty/tools/dotc/repl/InterpreterLoop.scala +++ b/src/dotty/tools/dotc/repl/InterpreterLoop.scala @@ -170,6 +170,11 @@ class InterpreterLoop(compiler: Compiler, config: REPL.Config)(implicit ctx: Con interpreter.beQuietDuring(interpreter.interpret(cmd)) } + def silentlyBind(values: Array[(String, Any)]): Unit = values.foreach { case (id, value) => + interpreter.beQuietDuring( + interpreter.bind(id, value.asInstanceOf[AnyRef].getClass.getName, value.asInstanceOf[AnyRef])) + } + /** Interpret expressions starting with the first line. * Read lines until a complete compilation unit is available * or until a syntax error has been seen. If a full unit is @@ -201,6 +206,7 @@ class InterpreterLoop(compiler: Compiler, config: REPL.Config)(implicit ctx: Con if (!ctx.reporter.hasErrors) { // if there are already errors, no sense to continue printWelcome() silentlyRun(config.initialCommands) + silentlyBind(config.boundValues) repl(in.readLine(prompt)) silentlyRun(config.cleanupCommands) } |