Created
July 1, 2010 03:57
-
-
Save canonic-epicure/459552 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
var Script = process.binding('evals').Script | |
var sys = require('sys') | |
var puts = sys.puts | |
var runner = function (code) { return eval(code) } | |
var sandbox = {} | |
sandbox.me = sandbox | |
var innerRunner = Script.runInNewContext('var SELF = me; __RUNNER__ = ' + runner.toString(), sandbox) | |
innerRunner('Object.yo = 1') | |
innerRunner('foo = 1') | |
puts("Object.yo = " + Object.yo) | |
puts("inner Object.yo = " + innerRunner('Object.yo')) | |
puts("inner foo = " + innerRunner('foo')) | |
puts("sandbox.foo = " + sandbox.foo) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment