Compiling for a sandboxed context

40 views
Skip to first unread message

Juha Paananen

unread,
Mar 9, 2014, 1:43:18 PM3/9/14
to roy...@googlegroups.com
In my Turtle Roy application (http://turtle-roy.herokuapp.com/) I have a Roy REPL. Currently all code that's evaluated there, is run in the global (window) context, in the sense that when I defined a function, like "let id x = x", it'll be a global var.

To be able to embed the Turtle Roy console on an arbitrary website (I do have a very particular need though) I need to be able to output something like

    compileContext.id = function(x) { return x }

instead of just

    var id = function(x) { return x }

This was I could sandbox the REPL and avoid polluting the global namespace.

Does the compiler support something like this or would it be easy to modify it thus?

-juha-

BTW I call the compiler like this: roy.compile(code, env, aliases, {nodejs:true})
Reply all
Reply to author
Forward
0 new messages