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 Member = module.exports = function Member(left, right){
|
23 | Node.call(this);
|
24 | this.left = left;
|
25 | this.right = right;
|
26 | };
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | Member.prototype.__proto__ = Node.prototype;
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | Member.prototype.clone = function(parent){
|
42 | var clone = new Member;
|
43 | clone.left = this.left.clone(parent, clone);
|
44 | clone.right = this.right.clone(parent, clone);
|
45 | if (this.val) clone.val = this.val.clone(parent, clone);
|
46 | clone.lineno = this.lineno;
|
47 | clone.column = this.column;
|
48 | clone.filename = this.filename;
|
49 | return clone;
|
50 | };
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | Member.prototype.toJSON = function(){
|
60 | var json = {
|
61 | __type: 'Member',
|
62 | left: this.left,
|
63 | right: this.right,
|
64 | lineno: this.lineno,
|
65 | column: this.column,
|
66 | filename: this.filename
|
67 | };
|
68 | if (this.val) json.val = this.val;
|
69 | return json;
|
70 | };
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | Member.prototype.toString = function(){
|
80 | return this.left.toString()
|
81 | + '.' + this.right.toString();
|
82 | };
|