/
methodTracer.js
86 lines (76 loc) · 2.14 KB
/
methodTracer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Generated by CoffeeScript 1.9.0
(function() {
var __slice = [].slice;
this.MethodTracer = (function() {
function MethodTracer() {
this.tracer = {};
}
MethodTracer.prototype.trace = function(clasname) {
var clas, f, name, tracer, uniqueId, _ref;
clas = eval(clasname);
_ref = clas.prototype;
for (name in _ref) {
f = _ref[name];
if (!(typeof f === 'function')) {
continue;
}
uniqueId = clasname + "#" + name;
tracer = this.tracer;
tracer[uniqueId] = false;
clas.prototype[name] = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
tracer[uniqueId] = true;
return f.apply(null, args);
};
}
return this;
};
MethodTracer.prototype.traceClasses = function(classNames) {
var clas, _i, _len, _ref;
_ref = classNames.split(' ');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
clas = _ref[_i];
this.trace(clas);
}
return this;
};
MethodTracer.prototype.traceModule = function(module, moduleName) {
var f, name, tracer, uniqueId;
for (name in module) {
f = module[name];
if (!(typeof f === 'function')) {
continue;
}
uniqueId = "Module " + moduleName + "#" + name;
tracer = this.tracer;
tracer[uniqueId] = false;
module[name] = this.wrapfn(module, uniqueId, f);
}
return this;
};
MethodTracer.prototype.wrapfn = function(module, uniqueId, f) {
var self;
self = this;
return function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
self.tracer[uniqueId] = true;
return f.apply(module, args);
};
};
MethodTracer.prototype.printUnused = function() {
var id, used, _ref;
_ref = this.tracer;
for (id in _ref) {
used = _ref[id];
if (!used) {
puts(id);
}
}
return this;
};
return MethodTracer;
})();
}).call(this);
//# sourceMappingURL=methodTracer.js.map