aboutsummaryrefslogtreecommitdiff
path: root/lib/node.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-05-27 17:25:31 +0300
committerMihai Bazon <mihai@bazon.net>2012-06-03 23:10:31 +0300
commit861e26a66639ca61eab2af53de45760370c4d534 (patch)
treec35c94fe6978dfdff6887a9e5ea03703f2e4bed4 /lib/node.js
parent22bb5e8306687fb6324f094d208b564c9e874f77 (diff)
downloadtracifyjs-861e26a66639ca61eab2af53de45760370c4d534.tar.gz
tracifyjs-861e26a66639ca61eab2af53de45760370c4d534.zip
WIP
Diffstat (limited to 'lib/node.js')
-rwxr-xr-xlib/node.js41
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");
+
+})();