holmes 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +10 -0
- data/Rakefile +1 -0
- data/holmes.gemspec +24 -0
- data/lib/holmes.rb +38 -0
- data/lib/holmes/node_modules/detective/README.markdown +64 -0
- data/lib/holmes/node_modules/detective/example/strings.js +6 -0
- data/lib/holmes/node_modules/detective/example/strings_src.js +3 -0
- data/lib/holmes/node_modules/detective/index.js +65 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/.npmignore +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/README.markdown +185 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/browserify.js +4296 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/example/microwave.js +7 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/example/web/bs.js +4832 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/example/web/index.html +14 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/example/web/main.js +17 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/example/web/server.js +12 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/example/wrap.js +7 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/index.html +8 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/index.js +208 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/main.js +11 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/.bin/uglifyjs +317 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/.npmignore +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/LICENSE +24 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/README.markdown +237 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/json.js +16 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/leaves.js +15 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/negative.js +8 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/scrub.js +10 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/stringify.js +38 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/index.js +267 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/main.js +10 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/package.json +18 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/circular.js +115 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/date.js +35 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/equal.js +220 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/instance.js +17 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/interface.js +42 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/json.js +47 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/keys.js +29 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/leaves.js +21 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/lib/deep_equal.js +92 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/mutability.js +252 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/negative.js +20 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/obj.js +15 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/siblings.js +35 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/stop.js +41 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/stringify.js +36 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/subexpr.js +34 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/super_deep.js +55 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/.npmignore +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/README.html +888 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/README.org +463 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/bin/uglifyjs +317 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/docstyle.css +75 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/object-ast.js +75 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js +1341 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/process.js +1949 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js +51 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/package.json +22 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/beautify.js +28 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/testparser.js +402 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array1.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array2.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array3.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array4.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/assignment.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/concatstring.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/const.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/forstatement.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/if.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/ifreturn2.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue10.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue11.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue13.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue14.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue16.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue17.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue20.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue21.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue25.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue27.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue28.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue29.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue30.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue34.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue4.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue48.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue50.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue53.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue68.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue69.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue9.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/mangle.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/var.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/with.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array1.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array2.js +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array3.js +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array4.js +6 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/assignment.js +20 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/concatstring.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/const.js +5 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/forstatement.js +10 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/if.js +6 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/ifreturn.js +9 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/ifreturn2.js +16 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue10.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue11.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue13.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue14.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue16.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue17.js +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue20.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue21.js +6 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue25.js +7 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue27.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue28.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue29.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue30.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue34.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue4.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue48.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue50.js +9 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue53.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue54.1.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue68.js +5 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue69.js +1 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue9.js +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/mangle.js +5 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/strict-equals.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/var.js +3 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/with.js +2 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/scripts.js +55 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/hoist.js +33 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/instrument.js +97 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/instrument2.js +138 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/test.js +16 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/uglify-js.js +17 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/package.json +43 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/server.js +4 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/ast.js +29 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/err.js +47 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/fail.js +8 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/fail/src.js +60 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/label.js +110 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/microwave.js +33 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/parent.js +26 -0
- data/lib/holmes/node_modules/detective/node_modules/burrito/test/wrap.js +157 -0
- data/lib/holmes/node_modules/detective/package.json +39 -0
- data/lib/holmes/node_modules/detective/test/both.js +10 -0
- data/lib/holmes/node_modules/detective/test/files/both.js +4 -0
- data/lib/holmes/node_modules/detective/test/files/nested.js +22 -0
- data/lib/holmes/node_modules/detective/test/files/strings.js +13 -0
- data/lib/holmes/node_modules/detective/test/files/word.js +13 -0
- data/lib/holmes/node_modules/detective/test/nested.js +8 -0
- data/lib/holmes/node_modules/detective/test/strings.js +8 -0
- data/lib/holmes/node_modules/detective/test/word.js +11 -0
- data/lib/holmes/require.js +5 -0
- data/lib/holmes/runner.js +20 -0
- data/lib/holmes/version.rb +3 -0
- metadata +223 -0
data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/instrument.js
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
// sample on how to use the parser and walker API to instrument some code
|
2
|
+
|
3
|
+
var jsp = require("uglify-js").parser;
|
4
|
+
var pro = require("uglify-js").uglify;
|
5
|
+
|
6
|
+
function instrument(code) {
|
7
|
+
var ast = jsp.parse(code, false, true); // true for the third arg specifies that we want
|
8
|
+
// to have start/end tokens embedded in the
|
9
|
+
// statements
|
10
|
+
var w = pro.ast_walker();
|
11
|
+
|
12
|
+
// we're gonna need this to push elements that we're currently looking at, to avoid
|
13
|
+
// endless recursion.
|
14
|
+
var analyzing = [];
|
15
|
+
function do_stat() {
|
16
|
+
var ret;
|
17
|
+
if (this[0].start && analyzing.indexOf(this) < 0) {
|
18
|
+
// without the `analyzing' hack, w.walk(this) would re-enter here leading
|
19
|
+
// to infinite recursion
|
20
|
+
analyzing.push(this);
|
21
|
+
ret = [ "splice", // XXX: "block" is safer
|
22
|
+
[ [ "stat",
|
23
|
+
[ "call", [ "name", "trace" ],
|
24
|
+
[ [ "string", this[0].toString() ],
|
25
|
+
[ "num", this[0].start.line ],
|
26
|
+
[ "num", this[0].start.col ],
|
27
|
+
[ "num", this[0].end.line ],
|
28
|
+
[ "num", this[0].end.col ]]]],
|
29
|
+
w.walk(this) ]];
|
30
|
+
analyzing.pop(this);
|
31
|
+
}
|
32
|
+
return ret;
|
33
|
+
};
|
34
|
+
var new_ast = w.with_walkers({
|
35
|
+
"stat" : do_stat,
|
36
|
+
"label" : do_stat,
|
37
|
+
"break" : do_stat,
|
38
|
+
"continue" : do_stat,
|
39
|
+
"debugger" : do_stat,
|
40
|
+
"var" : do_stat,
|
41
|
+
"const" : do_stat,
|
42
|
+
"return" : do_stat,
|
43
|
+
"throw" : do_stat,
|
44
|
+
"try" : do_stat,
|
45
|
+
"defun" : do_stat,
|
46
|
+
"if" : do_stat,
|
47
|
+
"while" : do_stat,
|
48
|
+
"do" : do_stat,
|
49
|
+
"for" : do_stat,
|
50
|
+
"for-in" : do_stat,
|
51
|
+
"switch" : do_stat,
|
52
|
+
"with" : do_stat
|
53
|
+
}, function(){
|
54
|
+
return w.walk(ast);
|
55
|
+
});
|
56
|
+
return pro.gen_code(new_ast, { beautify: true });
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
////// test code follows.
|
63
|
+
|
64
|
+
var code = instrument(test.toString());
|
65
|
+
console.log(code);
|
66
|
+
|
67
|
+
function test() {
|
68
|
+
// simple stats
|
69
|
+
a = 5;
|
70
|
+
c += a + b;
|
71
|
+
"foo";
|
72
|
+
|
73
|
+
// var
|
74
|
+
var foo = 5;
|
75
|
+
const bar = 6, baz = 7;
|
76
|
+
|
77
|
+
// switch block. note we can't track case lines the same way.
|
78
|
+
switch ("foo") {
|
79
|
+
case "foo":
|
80
|
+
return 1;
|
81
|
+
case "bar":
|
82
|
+
return 2;
|
83
|
+
}
|
84
|
+
|
85
|
+
// for/for in
|
86
|
+
for (var i = 0; i < 5; ++i) {
|
87
|
+
console.log("Hello " + i);
|
88
|
+
}
|
89
|
+
for (var i in [ 1, 2, 3]) {
|
90
|
+
console.log(i);
|
91
|
+
}
|
92
|
+
|
93
|
+
// note however that the following is broken. I guess we
|
94
|
+
// should add the block brackets in this case...
|
95
|
+
for (var i = 0; i < 5; ++i)
|
96
|
+
console.log("foo");
|
97
|
+
}
|
@@ -0,0 +1,138 @@
|
|
1
|
+
// sample on how to use the parser and walker API to instrument some code
|
2
|
+
|
3
|
+
var jsp = require("uglify-js").parser;
|
4
|
+
var pro = require("uglify-js").uglify;
|
5
|
+
|
6
|
+
function instrument(code) {
|
7
|
+
var ast = jsp.parse(code, false, true); // true for the third arg specifies that we want
|
8
|
+
// to have start/end tokens embedded in the
|
9
|
+
// statements
|
10
|
+
var w = pro.ast_walker();
|
11
|
+
|
12
|
+
function trace (line, comment) {
|
13
|
+
var code = pro.gen_code(line, { beautify: true });
|
14
|
+
var data = line[0]
|
15
|
+
|
16
|
+
var args = []
|
17
|
+
if (!comment) comment = ""
|
18
|
+
if (typeof data === "object") {
|
19
|
+
code = code.split(/\n/).shift()
|
20
|
+
args = [ [ "string", data.toString() ],
|
21
|
+
[ "string", code ],
|
22
|
+
[ "num", data.start.line ],
|
23
|
+
[ "num", data.start.col ],
|
24
|
+
[ "num", data.end.line ],
|
25
|
+
[ "num", data.end.col ]]
|
26
|
+
} else {
|
27
|
+
args = [ [ "string", data ],
|
28
|
+
[ "string", code ]]
|
29
|
+
|
30
|
+
}
|
31
|
+
return [ "call", [ "name", "trace" ], args ];
|
32
|
+
}
|
33
|
+
|
34
|
+
// we're gonna need this to push elements that we're currently looking at, to avoid
|
35
|
+
// endless recursion.
|
36
|
+
var analyzing = [];
|
37
|
+
function do_stat() {
|
38
|
+
var ret;
|
39
|
+
if (this[0].start && analyzing.indexOf(this) < 0) {
|
40
|
+
// without the `analyzing' hack, w.walk(this) would re-enter here leading
|
41
|
+
// to infinite recursion
|
42
|
+
analyzing.push(this);
|
43
|
+
ret = [ "splice",
|
44
|
+
[ [ "stat", trace(this) ],
|
45
|
+
w.walk(this) ]];
|
46
|
+
analyzing.pop(this);
|
47
|
+
}
|
48
|
+
return ret;
|
49
|
+
}
|
50
|
+
|
51
|
+
function do_cond(c, t, f) {
|
52
|
+
return [ this[0], w.walk(c),
|
53
|
+
["seq", trace(t), w.walk(t) ],
|
54
|
+
["seq", trace(f), w.walk(f) ]];
|
55
|
+
}
|
56
|
+
|
57
|
+
function do_binary(c, l, r) {
|
58
|
+
if (c !== "&&" && c !== "||") {
|
59
|
+
return [this[0], c, w.walk(l), w.walk(r)];
|
60
|
+
}
|
61
|
+
return [ this[0], c,
|
62
|
+
["seq", trace(l), w.walk(l) ],
|
63
|
+
["seq", trace(r), w.walk(r) ]];
|
64
|
+
}
|
65
|
+
|
66
|
+
var new_ast = w.with_walkers({
|
67
|
+
"stat" : do_stat,
|
68
|
+
"label" : do_stat,
|
69
|
+
"break" : do_stat,
|
70
|
+
"continue" : do_stat,
|
71
|
+
"debugger" : do_stat,
|
72
|
+
"var" : do_stat,
|
73
|
+
"const" : do_stat,
|
74
|
+
"return" : do_stat,
|
75
|
+
"throw" : do_stat,
|
76
|
+
"try" : do_stat,
|
77
|
+
"defun" : do_stat,
|
78
|
+
"if" : do_stat,
|
79
|
+
"while" : do_stat,
|
80
|
+
"do" : do_stat,
|
81
|
+
"for" : do_stat,
|
82
|
+
"for-in" : do_stat,
|
83
|
+
"switch" : do_stat,
|
84
|
+
"with" : do_stat,
|
85
|
+
"conditional" : do_cond,
|
86
|
+
"binary" : do_binary
|
87
|
+
}, function(){
|
88
|
+
return w.walk(ast);
|
89
|
+
});
|
90
|
+
return pro.gen_code(new_ast, { beautify: true });
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
////// test code follows.
|
95
|
+
|
96
|
+
var code = instrument(test.toString());
|
97
|
+
console.log(code);
|
98
|
+
|
99
|
+
function test() {
|
100
|
+
// simple stats
|
101
|
+
a = 5;
|
102
|
+
c += a + b;
|
103
|
+
"foo";
|
104
|
+
|
105
|
+
// var
|
106
|
+
var foo = 5;
|
107
|
+
const bar = 6, baz = 7;
|
108
|
+
|
109
|
+
// switch block. note we can't track case lines the same way.
|
110
|
+
switch ("foo") {
|
111
|
+
case "foo":
|
112
|
+
return 1;
|
113
|
+
case "bar":
|
114
|
+
return 2;
|
115
|
+
}
|
116
|
+
|
117
|
+
// for/for in
|
118
|
+
for (var i = 0; i < 5; ++i) {
|
119
|
+
console.log("Hello " + i);
|
120
|
+
}
|
121
|
+
for (var i in [ 1, 2, 3]) {
|
122
|
+
console.log(i);
|
123
|
+
}
|
124
|
+
|
125
|
+
for (var i = 0; i < 5; ++i)
|
126
|
+
console.log("foo");
|
127
|
+
|
128
|
+
for (var i = 0; i < 5; ++i) {
|
129
|
+
console.log("foo");
|
130
|
+
}
|
131
|
+
|
132
|
+
var k = plurp() ? 1 : 0;
|
133
|
+
var x = a ? doX(y) && goZoo("zoo")
|
134
|
+
: b ? blerg({ x: y })
|
135
|
+
: null;
|
136
|
+
|
137
|
+
var x = X || Y;
|
138
|
+
}
|
data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/test.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#! /usr/bin/env node
|
2
|
+
|
3
|
+
global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util");
|
4
|
+
var fs = require("fs");
|
5
|
+
var uglify = require("uglify-js"), // symlink ~/.node_libraries/uglify-js.js to ../uglify-js.js
|
6
|
+
jsp = uglify.parser,
|
7
|
+
pro = uglify.uglify;
|
8
|
+
|
9
|
+
var code = fs.readFileSync("hoist.js", "utf8");
|
10
|
+
var ast = jsp.parse(code);
|
11
|
+
|
12
|
+
ast = pro.ast_lift_variables(ast);
|
13
|
+
|
14
|
+
console.log(pro.gen_code(ast, {
|
15
|
+
beautify: true
|
16
|
+
}));
|
data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/uglify-js.js
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
//convienence function(src, [options]);
|
2
|
+
function uglify(orig_code, options){
|
3
|
+
options || (options = {});
|
4
|
+
var jsp = uglify.parser;
|
5
|
+
var pro = uglify.uglify;
|
6
|
+
|
7
|
+
var ast = jsp.parse(orig_code, options.strict_semicolons); // parse code and get the initial AST
|
8
|
+
ast = pro.ast_mangle(ast, options.mangle_options); // get a new AST with mangled names
|
9
|
+
ast = pro.ast_squeeze(ast, options.squeeze_options); // get an AST with compression optimizations
|
10
|
+
var final_code = pro.gen_code(ast, options.gen_options); // compressed code here
|
11
|
+
return final_code;
|
12
|
+
};
|
13
|
+
|
14
|
+
uglify.parser = require("./lib/parse-js");
|
15
|
+
uglify.uglify = require("./lib/process");
|
16
|
+
|
17
|
+
module.exports = uglify
|
@@ -0,0 +1,43 @@
|
|
1
|
+
{
|
2
|
+
"name" : "burrito",
|
3
|
+
"description" : "Wrap up expressions with a trace function while walking the AST with rice and beans on the side",
|
4
|
+
"version" : "0.2.11",
|
5
|
+
"repository" : {
|
6
|
+
"type" : "git",
|
7
|
+
"url" : "git://github.com/substack/node-burrito.git"
|
8
|
+
},
|
9
|
+
"main" : "./index.js",
|
10
|
+
"keywords" : [
|
11
|
+
"trace",
|
12
|
+
"ast",
|
13
|
+
"walk",
|
14
|
+
"syntax",
|
15
|
+
"source",
|
16
|
+
"tree",
|
17
|
+
"uglify"
|
18
|
+
],
|
19
|
+
"directories" : {
|
20
|
+
"lib" : ".",
|
21
|
+
"example" : "example",
|
22
|
+
"test" : "test"
|
23
|
+
},
|
24
|
+
"scripts" : {
|
25
|
+
"test" : "expresso"
|
26
|
+
},
|
27
|
+
"dependencies" : {
|
28
|
+
"traverse" : ">=0.5.1 <0.6.0",
|
29
|
+
"uglify-js" : "1.0.7"
|
30
|
+
},
|
31
|
+
"devDependencies" : {
|
32
|
+
"expresso" : "=0.7.x"
|
33
|
+
},
|
34
|
+
"engines" : {
|
35
|
+
"node" : ">=0.4.0"
|
36
|
+
},
|
37
|
+
"license" : "BSD",
|
38
|
+
"author" : {
|
39
|
+
"name" : "James Halliday",
|
40
|
+
"email" : "mail@substack.net",
|
41
|
+
"url" : "http://substack.net"
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
var assert = require('assert');
|
2
|
+
var burrito = require('../');
|
3
|
+
var vm = require('vm');
|
4
|
+
|
5
|
+
exports.ast = function () {
|
6
|
+
var ast = burrito.parse('f(g(h(5)))', false, true);
|
7
|
+
var src = burrito(ast, function (node) {
|
8
|
+
if (node.name === 'call') {
|
9
|
+
node.wrap(function (s) {
|
10
|
+
return 'z(' + s + ')';
|
11
|
+
});
|
12
|
+
}
|
13
|
+
});
|
14
|
+
|
15
|
+
var times = 0;
|
16
|
+
assert.equal(
|
17
|
+
vm.runInNewContext(src, {
|
18
|
+
f : function (x) { return x + 1 },
|
19
|
+
g : function (x) { return x + 2 },
|
20
|
+
h : function (x) { return x + 3 },
|
21
|
+
z : function (x) {
|
22
|
+
times ++;
|
23
|
+
return x * 10;
|
24
|
+
},
|
25
|
+
}),
|
26
|
+
(((((5 + 3) * 10) + 2) * 10) + 1) * 10
|
27
|
+
);
|
28
|
+
assert.equal(times, 3);
|
29
|
+
};
|
@@ -0,0 +1,47 @@
|
|
1
|
+
var assert = require('assert');
|
2
|
+
var burrito = require('../');
|
3
|
+
|
4
|
+
exports.wrapError = function () {
|
5
|
+
try {
|
6
|
+
var src = burrito('f() && g()', function (node) {
|
7
|
+
if (node.name === 'binary') node.wrap('h(%a, %b')
|
8
|
+
});
|
9
|
+
assert.fail('should have blown up');
|
10
|
+
}
|
11
|
+
catch (err) {
|
12
|
+
assert.ok(err.message.match(/unexpected/i));
|
13
|
+
assert.ok(err instanceof SyntaxError);
|
14
|
+
assert.ok(!err.stack.match(/uglify-js/));
|
15
|
+
assert.equal(err.line, 0);
|
16
|
+
assert.equal(err.col, 10);
|
17
|
+
assert.equal(err.pos, 10);
|
18
|
+
}
|
19
|
+
};
|
20
|
+
|
21
|
+
exports.nonString = function () {
|
22
|
+
assert.throws(function () {
|
23
|
+
burrito.parse(new Buffer('[]'));
|
24
|
+
});
|
25
|
+
|
26
|
+
assert.throws(function () {
|
27
|
+
burrito.parse(new String('[]'));
|
28
|
+
});
|
29
|
+
|
30
|
+
assert.throws(function () {
|
31
|
+
burrito.parse();
|
32
|
+
});
|
33
|
+
};
|
34
|
+
|
35
|
+
exports.syntaxError = function () {
|
36
|
+
try {
|
37
|
+
var src = burrito('f() && g())', function (node) {
|
38
|
+
if (node.name === 'binary') node.wrap('h(%a, %b)')
|
39
|
+
});
|
40
|
+
assert.fail('should have blown up');
|
41
|
+
}
|
42
|
+
catch (err) {
|
43
|
+
assert.ok(err.message.match(/unexpected/i));
|
44
|
+
assert.ok(err instanceof SyntaxError);
|
45
|
+
assert.ok(!err.stack.match(/uglify-js/));
|
46
|
+
}
|
47
|
+
};
|
@@ -0,0 +1,60 @@
|
|
1
|
+
var path = require('path')
|
2
|
+
|
3
|
+
module.exports = function(fs, ready) {
|
4
|
+
var global_files = {}
|
5
|
+
|
6
|
+
var recurse = function(dir, okay) {
|
7
|
+
fs.readdir(dir, function(err, dir_files) {
|
8
|
+
var countdown = 0
|
9
|
+
, files = []
|
10
|
+
, dirs = []
|
11
|
+
, checked = 0
|
12
|
+
dir_files.forEach(function(file, idx, all) {
|
13
|
+
fs.stat(path.join(dir, file), function(err, stat) {
|
14
|
+
if(stat.isDirectory() && !/node_modules/g.test(dir)) {
|
15
|
+
dirs.push(file)
|
16
|
+
} else if(/\.js$/g.test(file)) {
|
17
|
+
files.push(file)
|
18
|
+
}
|
19
|
+
|
20
|
+
if(++checked >= dir_files.length)
|
21
|
+
recurse_dirs()
|
22
|
+
})
|
23
|
+
})
|
24
|
+
|
25
|
+
function recurse_dirs() {
|
26
|
+
var total = 0
|
27
|
+
dirs.forEach(function(this_dir) {
|
28
|
+
recurse(path.join(dir, this_dir), function(err, data) {
|
29
|
+
if(++total >= dirs.length)
|
30
|
+
recurse_files()
|
31
|
+
})
|
32
|
+
})
|
33
|
+
|
34
|
+
if(!dirs.length)
|
35
|
+
recurse_files()
|
36
|
+
}
|
37
|
+
|
38
|
+
function recurse_files() {
|
39
|
+
var total = 0
|
40
|
+
files.forEach(function(file) {
|
41
|
+
fs.readFile(path.join(dir, file), 'utf8', function(err, src) {
|
42
|
+
global_files[path.join(dir, file)] = src
|
43
|
+
++total >= files.length &&
|
44
|
+
okay(null, global_files)
|
45
|
+
})
|
46
|
+
})
|
47
|
+
|
48
|
+
if(!files.length)
|
49
|
+
okay(null, global_files)
|
50
|
+
}
|
51
|
+
|
52
|
+
if(!dir_files.length)
|
53
|
+
okay(null, global_files)
|
54
|
+
})
|
55
|
+
}
|
56
|
+
|
57
|
+
recurse('.', ready)
|
58
|
+
}
|
59
|
+
|
60
|
+
|