diff options
Diffstat (limited to 'lib/node.js')
-rwxr-xr-x | lib/node.js | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/lib/node.js b/lib/node.js index 36bc18a0..9089a5fe 100755 --- a/lib/node.js +++ b/lib/node.js @@ -1,20 +1,35 @@ #! /usr/bin/env node -var fs = require("fs"); +(function(){ -function load_global(file) { - var code = fs.readFileSync(file, "utf8"); - return global.eval(code); -}; + var fs = require("fs"); + var vm = require("vm"); + var sys = require("util"); -load_global("./utils.js"); -load_global("./ast.js"); -load_global("./parse.js"); + function load_global(file) { + var code = fs.readFileSync(file, "utf8"); + return vm.runInThisContext(code, file); + }; -/// + load_global("./utils.js"); + load_global("./output.js"); + load_global("./ast.js"); + load_global("./parse.js"); -var filename = process.argv[2]; -console.time("parse"); -var ast = parse(fs.readFileSync(filename, "utf8")); -console.timeEnd("parse"); + /// + var filename = process.argv[2]; + console.time("parse"); + var ast = parse(fs.readFileSync(filename, "utf8")); + console.timeEnd("parse"); + + console.time("walk"); + ast.walk({ + _visit: function(node, descend) { + //console.log(node); + if (descend) descend.call(node); + } + }); + console.timeEnd("walk"); + +})(); |