1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | var Node = require('./node');
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | var If = module.exports = function If(cond, negate){
|
23 | Node.call(this);
|
24 | this.cond = cond;
|
25 | this.elses = [];
|
26 | if (negate && negate.nodeName) {
|
27 | this.block = negate;
|
28 | } else {
|
29 | this.negate = negate;
|
30 | }
|
31 | };
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | If.prototype.__proto__ = Node.prototype;
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | If.prototype.clone = function(parent){
|
47 | var clone = new If();
|
48 | clone.cond = this.cond.clone(parent, clone);
|
49 | clone.block = this.block.clone(parent, clone);
|
50 | clone.elses = this.elses.map(function(node){ return node.clone(parent, clone); });
|
51 | clone.negate = this.negate;
|
52 | clone.postfix = this.postfix;
|
53 | clone.lineno = this.lineno;
|
54 | clone.column = this.column;
|
55 | clone.filename = this.filename;
|
56 | return clone;
|
57 | };
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | If.prototype.toJSON = function(){
|
67 | return {
|
68 | __type: 'If',
|
69 | cond: this.cond,
|
70 | block: this.block,
|
71 | elses: this.elses,
|
72 | negate: this.negate,
|
73 | postfix: this.postfix,
|
74 | lineno: this.lineno,
|
75 | column: this.column,
|
76 | filename: this.filename
|
77 | };
|
78 | };
|