Skip to content

Instantly share code, notes, and snippets.

@skalarproduktraum
Created April 24, 2016 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skalarproduktraum/f8c7965bf695e17397dc090f9ff5ef49 to your computer and use it in GitHub Desktop.
Save skalarproduktraum/f8c7965bf695e17397dc090f9ff5ef49 to your computer and use it in GitHub Desktop.
How I currently access the REPL's interpreter
val context: Context = Context()
context.getService(ObjectService::class.java).addObject(scene)
context.getService(ObjectService::class.java).addObject(deferredRenderer)
interpreter = InterpreterWindow(context)
interpreter?.isVisible = true
/* some other init stuff */
/* here's what I want to do -- access the REPL's interpreter, feed it a file,
and have that accessible in the REPL. This does not work with context.getService(ScriptService.class).run(...),
as it seems to launch an own interpreter decoupled from the REPL's (which makes sense).
I changed the InterpreterWindow's code such that it exposes a function `getREPL()`, so
the interpreter becomes accessible. From InterpreterWindow, the REPL is accessible, as
InterpreterPane exposes it.
*/
val startup = Scanner(DeferredLightingRenderer::class.java.getResourceAsStream("startup.js"), "UTF-8").useDelimiter("\\A").next()
interpreter?.repl?.interpreter?.eval(startup)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment