1 | config = require "./config"
|
2 | kit = require "./kit"
|
3 |
|
4 |
|
5 | class Visitor
|
6 | setCtx: (@ctx) ->
|
7 | @policy = @ctx.policy
|
8 | @
|
9 |
|
10 |
|
11 | class ActiveVisitor extends Visitor
|
12 | update: -> @
|
13 | subScope: ->
|
14 | new ActiveVisitor()
|
15 |
|
16 |
|
17 |
|
18 | class DisabledVisitor extends Visitor
|
19 | update: (ctx) ->
|
20 | return (new ActiveVisitor()).setCtx(ctx) if @policy.opts.compile
|
21 | @
|
22 | subScope: ->
|
23 | if @policy.opts.compile
|
24 | new ActiveVisitor()
|
25 | else new DisabledVisitor()
|
26 | noChanges: true
|
27 |
|
28 | defaultVisitor = -> new DisabledVisitor()
|
29 |
|
30 | module.exports = {defaultVisitor,Visitor,ActiveVisitor,DisabledVisitor}
|
31 |
|