diff --git a/runtimes/jsc.js b/runtimes/jsc.js index 8cc5ecf..afbbd7e 100644 --- a/runtimes/jsc.js +++ b/runtimes/jsc.js @@ -1,31 +1,12 @@ +/* JavaScriptCore exposes a "$" object to its runtime */ +/* Using this["\x24"]; prevents overwrite by ConsoleAgent */ +var jsc = this["\x24"]; var $ = { - global: this, - createRealm(options) { - options = options || {}; - options.globals = options.globals || {}; - - var realm = createGlobalObject(); - realm.eval(this.source); - realm.$.source = this.source; - realm.$.destroy = function () { - if (options.destroy) { - options.destroy(); - } - }; - for(var glob in options.globals) { - realm.$.global[glob] = options.globals[glob]; - } - - return realm.$; - }, - evalScript(code) { - try { - loadString(code); - return { type: 'normal', value: undefined }; - } catch (e) { - return { type: 'throw', value: e } - } - }, + agent: jsc.agent, + global: jsc.global, + createRealm: jsc.createRealm, + detachArrayBuffer: jsc.detachArrayBuffer, + evalScript: jsc.evalScript, getGlobal(name) { return this.global[name]; },