1 |
|
2 | (function() {
|
3 | var ActiveVisitor, DisabledVisitor, Visitor, config, defaultVisitor, kit,
|
4 | extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
5 | hasProp = {}.hasOwnProperty;
|
6 |
|
7 | config = require("./config");
|
8 |
|
9 | kit = require("./kit");
|
10 |
|
11 | Visitor = (function() {
|
12 | function Visitor() {}
|
13 |
|
14 | Visitor.prototype.setCtx = function(ctx1) {
|
15 | this.ctx = ctx1;
|
16 | this.policy = this.ctx.policy;
|
17 | return this;
|
18 | };
|
19 |
|
20 | return Visitor;
|
21 |
|
22 | })();
|
23 |
|
24 | ActiveVisitor = (function(superClass) {
|
25 | extend(ActiveVisitor, superClass);
|
26 |
|
27 | function ActiveVisitor() {
|
28 | return ActiveVisitor.__super__.constructor.apply(this, arguments);
|
29 | }
|
30 |
|
31 | ActiveVisitor.prototype.update = function() {
|
32 | return this;
|
33 | };
|
34 |
|
35 | ActiveVisitor.prototype.subScope = function() {
|
36 | return new ActiveVisitor();
|
37 | };
|
38 |
|
39 | return ActiveVisitor;
|
40 |
|
41 | })(Visitor);
|
42 |
|
43 | DisabledVisitor = (function(superClass) {
|
44 | extend(DisabledVisitor, superClass);
|
45 |
|
46 | function DisabledVisitor() {
|
47 | return DisabledVisitor.__super__.constructor.apply(this, arguments);
|
48 | }
|
49 |
|
50 | DisabledVisitor.prototype.update = function(ctx) {
|
51 | if (this.policy.opts.compile) {
|
52 | return (new ActiveVisitor()).setCtx(ctx);
|
53 | }
|
54 | return this;
|
55 | };
|
56 |
|
57 | DisabledVisitor.prototype.subScope = function() {
|
58 | if (this.policy.opts.compile) {
|
59 | return new ActiveVisitor();
|
60 | } else {
|
61 | return new DisabledVisitor();
|
62 | }
|
63 | };
|
64 |
|
65 | DisabledVisitor.prototype.noChanges = true;
|
66 |
|
67 | return DisabledVisitor;
|
68 |
|
69 | })(Visitor);
|
70 |
|
71 | defaultVisitor = function() {
|
72 | return new DisabledVisitor();
|
73 | };
|
74 |
|
75 | module.exports = {
|
76 | defaultVisitor: defaultVisitor,
|
77 | Visitor: Visitor,
|
78 | ActiveVisitor: ActiveVisitor,
|
79 | DisabledVisitor: DisabledVisitor
|
80 | };
|
81 |
|
82 | }).call(this);
|