Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SI-7933 REPL javax.script eval is cached result
The problem is that the repl underneath the script engine evaluates input to val res0..resN, so it is a one shot operation. To allow repetition, compile(script) now returns a CompiledScript object whose eval method can be called any number of times.
- Loading branch information
Showing
7 changed files
with
43 additions
and
36 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import scala.tools.nsc.interpreter.IMain | ||
|
||
object Test extends App { | ||
val engine = new IMain.Factory getScriptEngine() | ||
engine.asInstanceOf[IMain].settings.usejavacp.value = true | ||
engine put ("n", 10) | ||
engine eval "1 to n.asInstanceOf[Int] foreach print" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
hello | ||
hello |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import scala.tools.nsc.interpreter.IMain | ||
|
||
object Test extends App { | ||
val engine = new IMain.Factory getScriptEngine() | ||
engine.asInstanceOf[IMain].settings.usejavacp.value = true | ||
val res2 = engine.asInstanceOf[javax.script.Compilable] | ||
res2 compile "8" eval() | ||
val res5 = res2 compile """println("hello") ; 8""" | ||
res5 eval() | ||
res5 eval() | ||
} |