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