Permalink
Browse files

[ use (require 'vm) instead of Script for compatibility with recent v…

…ersions of node ]
  • Loading branch information...
1 parent 9f2bb98 commit cf2edc40312c4d08e58f8db815c40c0f60472155 @jbr committed May 21, 2011
Showing with 14 additions and 13 deletions.
  1. +3 −3 lib/cli.js
  2. +3 −3 lib/repl.js
  3. +3 −3 src/cli.sibilant
  4. +5 −4 src/repl.sibilant
View
@@ -2,8 +2,8 @@ var sibilant = require("sibilant"),
path = require("path"),
options = require("sibilant/lib/options"),
fs = require("fs"),
- script = (process.binding("evals"))["Script"],
- context = script.createContext();
+ vm = require("vm"),
+ context = vm.createContext();
var createContext = (function() {
context.initialized__QUERY = true;
(module)["filename"] = (process.cwd() + "/exec");;
@@ -33,7 +33,7 @@ var runInSandbox = (function(js, inputPath) {
return (module)["filename"] = inputPath;;
};
})();
- return script.runInContext(js, context, "sibilant");
+ return vm.runInContext(js, context, "sibilant");
});
var cli = {
View
@@ -1,13 +1,13 @@
var input = process.openStdin(),
output = process.stdout,
- script = (process.binding("evals"))["Script"],
+ vm = require("vm"),
readline = require("readline").createInterface(input, output),
sibilant = require("sibilant"),
context = undefined,
cmdBuffer = "",
sys = require("sys");
var createContext = (function() {
- var context = script.createContext();;
+ var context = vm.createContext();;
(module)["filename"] = (process.cwd() + "/exec");;
(context)["module"] = module;
(context)["require"] = require;;
@@ -47,7 +47,7 @@ readline.on("line", (function(cmd) {
// stmt:required
return jsLine = (jsLine + sibilant.translate(stmt, "statement"));
}));
- var result = script.runInContext(jsLine, context, "sibilant-repl");;
+ var result = vm.runInContext(jsLine, context, "sibilant-repl");;
(readline.history)[0] = cmdBuffer;;
(function() {
if (typeof(result) !== 'undefined') {
View
@@ -2,8 +2,8 @@
path (require 'path)
options (require "sibilant/lib/options")
fs (require 'fs)
- script (get (process.binding 'evals) "Script")
- context (script.create-context))
+ vm (require 'vm)
+ context (vm.create-context))
(defun create-context ()
(setf context.initialized? true)
@@ -18,7 +18,7 @@
(set process.argv 1 input-path)
(set context '**dirname (path.dirname input-path))
(set module 'filename input-path))
- (script.run-in-context js context 'sibilant))
+ (vm.run-in-context js context 'sibilant))
(defhash cli
v 'version
View
@@ -1,16 +1,17 @@
(defvar input (process.open-stdin)
output process.stdout
- script (get (process.binding 'evals) "Script")
+ vm (require 'vm)
readline (send (require 'readline) create-interface input output)
sibilant (require 'sibilant)
context undefined
cmd-buffer ""
sys (require 'sys))
(defun create-context ()
- (defvar context (script.create-context))
+ (defvar context (vm.create-context))
(set module 'filename (concat (process.cwd) "/exec"))
- (set context 'module module
+ (set context
+ 'module module
'require require)
(each-key key global (set context key (get global key)))
context)
@@ -35,7 +36,7 @@
(each (stmt) (sibilant.tokenize cmd-buffer)
(setf js-line (concat js-line
(sibilant.translate stmt 'statement))))
- (defvar result (script.run-in-context js-line context "sibilant-repl"))
+ (defvar result (vm.run-in-context js-line context "sibilant-repl"))
(set readline.history 0 cmd-buffer)
(when (defined? result)
(output.write (concat "result: "

0 comments on commit cf2edc4

Please sign in to comment.