spider-src 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +74 -0
- data/README.md +37 -0
- data/Rakefile +25 -0
- data/lib/spider-src/support/spider/.eslintrc +17 -0
- data/lib/spider-src/support/spider/.npmignore +9 -0
- data/lib/spider-src/support/spider/.travis.yml +7 -0
- data/lib/spider-src/support/spider/.yo-rc.json +3 -0
- data/lib/spider-src/support/spider/CHANGELOG.md +64 -0
- data/lib/spider-src/support/spider/Gruntfile.js +97 -0
- data/lib/spider-src/support/spider/Gruntfile.spider +93 -0
- data/lib/spider-src/support/spider/LICENSE +201 -0
- data/lib/spider-src/support/spider/README.md +50 -0
- data/lib/spider-src/support/spider/cli.js +119 -0
- data/lib/spider-src/support/spider/lib/ast/CaseClause.js +179 -0
- data/lib/spider-src/support/spider/lib/ast/CatchClause.js +26 -0
- data/lib/spider-src/support/spider/lib/ast/ExportBatchSpecifier.js +19 -0
- data/lib/spider-src/support/spider/lib/ast/ExportSpecifier.js +33 -0
- data/lib/spider-src/support/spider/lib/ast/ImportDefaultSpecifier.js +23 -0
- data/lib/spider-src/support/spider/lib/ast/ImportNamespaceSpecifier.js +23 -0
- data/lib/spider-src/support/spider/lib/ast/ImportSpecifier.js +40 -0
- data/lib/spider-src/support/spider/lib/ast/Node.js +93 -0
- data/lib/spider-src/support/spider/lib/ast/Parameter.js +229 -0
- data/lib/spider-src/support/spider/lib/ast/Program.js +58 -0
- data/lib/spider-src/support/spider/lib/ast/Property.js +32 -0
- data/lib/spider-src/support/spider/lib/ast/Range.js +257 -0
- data/lib/spider-src/support/spider/lib/ast/VariableDeclarator.js +29 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/ArrayExpression.js +41 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/ArrayPattern.js +45 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/AssignmentExpression.js +29 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/BinaryExpression.js +104 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/CallExpression.js +139 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/ConditionalExpression.js +31 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/CurryCallExpression.js +102 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/ExistentialExpression.js +83 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/ForInExpression.js +116 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/FunctionExpression.js +157 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/InExpression.js +99 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/LogicalExpression.js +50 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/MemberExpression.js +43 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/NewExpression.js +46 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/NullCheckCallExpression.js +132 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/NullCoalescingExpression.js +114 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/NullPropagatingExpression.js +161 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/ObjectExpression.js +39 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/ObjectPattern.js +49 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/RangeMemberExpression.js +157 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/SplatExpression.js +48 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/SuperExpression.js +170 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/ThisExpression.js +22 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/UnaryExpression.js +147 -0
- data/lib/spider-src/support/spider/lib/ast/expressions/UpdateExpression.js +26 -0
- data/lib/spider-src/support/spider/lib/ast/literals/BooleanLiteral.js +24 -0
- data/lib/spider-src/support/spider/lib/ast/literals/Identifier.js +60 -0
- data/lib/spider-src/support/spider/lib/ast/literals/NullLiteral.js +24 -0
- data/lib/spider-src/support/spider/lib/ast/literals/NumberLiteral.js +24 -0
- data/lib/spider-src/support/spider/lib/ast/literals/RegularExpressionLiteral.js +25 -0
- data/lib/spider-src/support/spider/lib/ast/literals/StringLiteral.js +90 -0
- data/lib/spider-src/support/spider/lib/ast/literals/UndefinedLiteral.js +30 -0
- data/lib/spider-src/support/spider/lib/ast/statements/BlockStatement.js +47 -0
- data/lib/spider-src/support/spider/lib/ast/statements/BreakStatement.js +19 -0
- data/lib/spider-src/support/spider/lib/ast/statements/ContinueStatement.js +19 -0
- data/lib/spider-src/support/spider/lib/ast/statements/DebuggerStatement.js +19 -0
- data/lib/spider-src/support/spider/lib/ast/statements/DoWhileStatement.js +25 -0
- data/lib/spider-src/support/spider/lib/ast/statements/ExportDeclarationStatement.js +51 -0
- data/lib/spider-src/support/spider/lib/ast/statements/ExpressionStatement.js +22 -0
- data/lib/spider-src/support/spider/lib/ast/statements/FallthroughStatement.js +74 -0
- data/lib/spider-src/support/spider/lib/ast/statements/ForInStatement.js +79 -0
- data/lib/spider-src/support/spider/lib/ast/statements/ForOfStatement.js +98 -0
- data/lib/spider-src/support/spider/lib/ast/statements/ForStatement.js +43 -0
- data/lib/spider-src/support/spider/lib/ast/statements/FunctionDeclarationStatement.js +104 -0
- data/lib/spider-src/support/spider/lib/ast/statements/GoStatement.js +41 -0
- data/lib/spider-src/support/spider/lib/ast/statements/IfStatement.js +32 -0
- data/lib/spider-src/support/spider/lib/ast/statements/ImportDeclarationStatement.js +40 -0
- data/lib/spider-src/support/spider/lib/ast/statements/PushStatement.js +37 -0
- data/lib/spider-src/support/spider/lib/ast/statements/ReturnStatement.js +26 -0
- data/lib/spider-src/support/spider/lib/ast/statements/SwitchStatement.js +159 -0
- data/lib/spider-src/support/spider/lib/ast/statements/ThrowStatement.js +22 -0
- data/lib/spider-src/support/spider/lib/ast/statements/TryStatement.js +36 -0
- data/lib/spider-src/support/spider/lib/ast/statements/UntilStatement.js +31 -0
- data/lib/spider-src/support/spider/lib/ast/statements/UseStatement.js +49 -0
- data/lib/spider-src/support/spider/lib/ast/statements/VariableDeclarationStatement.js +36 -0
- data/lib/spider-src/support/spider/lib/ast/statements/WhileStatement.js +25 -0
- data/lib/spider-src/support/spider/lib/ast.js +16 -0
- data/lib/spider-src/support/spider/lib/parser.js +14878 -0
- data/lib/spider-src/support/spider/lib/spider.js +217 -0
- data/lib/spider-src/support/spider/package.json +61 -0
- data/lib/spider-src/support/spider/spider-script.js +6 -0
- data/lib/spider-src/support/spider/src/ast/CaseClause.spider +179 -0
- data/lib/spider-src/support/spider/src/ast/CatchClause.spider +30 -0
- data/lib/spider-src/support/spider/src/ast/ExportBatchSpecifier.spider +19 -0
- data/lib/spider-src/support/spider/src/ast/ExportSpecifier.spider +37 -0
- data/lib/spider-src/support/spider/src/ast/ImportDefaultSpecifier.spider +25 -0
- data/lib/spider-src/support/spider/src/ast/ImportNamespaceSpecifier.spider +25 -0
- data/lib/spider-src/support/spider/src/ast/ImportSpecifier.spider +44 -0
- data/lib/spider-src/support/spider/src/ast/Node.spider +104 -0
- data/lib/spider-src/support/spider/src/ast/Parameter.spider +233 -0
- data/lib/spider-src/support/spider/src/ast/Program.spider +109 -0
- data/lib/spider-src/support/spider/src/ast/Property.spider +36 -0
- data/lib/spider-src/support/spider/src/ast/Range.spider +291 -0
- data/lib/spider-src/support/spider/src/ast/VariableDeclarator.spider +33 -0
- data/lib/spider-src/support/spider/src/ast/expressions/ArrayExpression.spider +32 -0
- data/lib/spider-src/support/spider/src/ast/expressions/ArrayPattern.spider +37 -0
- data/lib/spider-src/support/spider/src/ast/expressions/AssignmentExpression.spider +34 -0
- data/lib/spider-src/support/spider/src/ast/expressions/BinaryExpression.spider +125 -0
- data/lib/spider-src/support/spider/src/ast/expressions/CallExpression.spider +149 -0
- data/lib/spider-src/support/spider/src/ast/expressions/ConditionalExpression.spider +34 -0
- data/lib/spider-src/support/spider/src/ast/expressions/CurryCallExpression.spider +109 -0
- data/lib/spider-src/support/spider/src/ast/expressions/ExistentialExpression.spider +102 -0
- data/lib/spider-src/support/spider/src/ast/expressions/ForInExpression.spider +140 -0
- data/lib/spider-src/support/spider/src/ast/expressions/FunctionExpression.spider +183 -0
- data/lib/spider-src/support/spider/src/ast/expressions/InExpression.spider +114 -0
- data/lib/spider-src/support/spider/src/ast/expressions/LogicalExpression.spider +62 -0
- data/lib/spider-src/support/spider/src/ast/expressions/MemberExpression.spider +57 -0
- data/lib/spider-src/support/spider/src/ast/expressions/NewExpression.spider +40 -0
- data/lib/spider-src/support/spider/src/ast/expressions/NullCheckCallExpression.spider +151 -0
- data/lib/spider-src/support/spider/src/ast/expressions/NullCoalescingExpression.spider +151 -0
- data/lib/spider-src/support/spider/src/ast/expressions/NullPropagatingExpression.spider +190 -0
- data/lib/spider-src/support/spider/src/ast/expressions/ObjectExpression.spider +30 -0
- data/lib/spider-src/support/spider/src/ast/expressions/ObjectPattern.spider +42 -0
- data/lib/spider-src/support/spider/src/ast/expressions/RangeMemberExpression.spider +179 -0
- data/lib/spider-src/support/spider/src/ast/expressions/SplatExpression.spider +49 -0
- data/lib/spider-src/support/spider/src/ast/expressions/SuperExpression.spider +235 -0
- data/lib/spider-src/support/spider/src/ast/expressions/ThisExpression.spider +21 -0
- data/lib/spider-src/support/spider/src/ast/expressions/UnaryExpression.spider +158 -0
- data/lib/spider-src/support/spider/src/ast/expressions/UpdateExpression.spider +28 -0
- data/lib/spider-src/support/spider/src/ast/literals/BooleanLiteral.spider +23 -0
- data/lib/spider-src/support/spider/src/ast/literals/Identifier.spider +68 -0
- data/lib/spider-src/support/spider/src/ast/literals/NullLiteral.spider +23 -0
- data/lib/spider-src/support/spider/src/ast/literals/NumberLiteral.spider +23 -0
- data/lib/spider-src/support/spider/src/ast/literals/RegularExpressionLiteral.spider +24 -0
- data/lib/spider-src/support/spider/src/ast/literals/StringLiteral.spider +91 -0
- data/lib/spider-src/support/spider/src/ast/literals/UndefinedLiteral.spider +30 -0
- data/lib/spider-src/support/spider/src/ast/statements/BlockStatement.spider +45 -0
- data/lib/spider-src/support/spider/src/ast/statements/BreakStatement.spider +19 -0
- data/lib/spider-src/support/spider/src/ast/statements/ContinueStatement.spider +19 -0
- data/lib/spider-src/support/spider/src/ast/statements/DebuggerStatement.spider +19 -0
- data/lib/spider-src/support/spider/src/ast/statements/DoWhileStatement.spider +28 -0
- data/lib/spider-src/support/spider/src/ast/statements/ExportDeclarationStatement.spider +46 -0
- data/lib/spider-src/support/spider/src/ast/statements/ExpressionStatement.spider +22 -0
- data/lib/spider-src/support/spider/src/ast/statements/FallthroughStatement.spider +85 -0
- data/lib/spider-src/support/spider/src/ast/statements/ForInStatement.spider +92 -0
- data/lib/spider-src/support/spider/src/ast/statements/ForOfStatement.spider +117 -0
- data/lib/spider-src/support/spider/src/ast/statements/ForStatement.spider +51 -0
- data/lib/spider-src/support/spider/src/ast/statements/FunctionDeclarationStatement.spider +115 -0
- data/lib/spider-src/support/spider/src/ast/statements/GoStatement.spider +44 -0
- data/lib/spider-src/support/spider/src/ast/statements/IfStatement.spider +38 -0
- data/lib/spider-src/support/spider/src/ast/statements/ImportDeclarationStatement.spider +33 -0
- data/lib/spider-src/support/spider/src/ast/statements/PushStatement.spider +40 -0
- data/lib/spider-src/support/spider/src/ast/statements/ReturnStatement.spider +28 -0
- data/lib/spider-src/support/spider/src/ast/statements/SwitchStatement.spider +161 -0
- data/lib/spider-src/support/spider/src/ast/statements/ThrowStatement.spider +23 -0
- data/lib/spider-src/support/spider/src/ast/statements/TryStatement.spider +42 -0
- data/lib/spider-src/support/spider/src/ast/statements/UntilStatement.spider +36 -0
- data/lib/spider-src/support/spider/src/ast/statements/UseStatement.spider +62 -0
- data/lib/spider-src/support/spider/src/ast/statements/VariableDeclarationStatement.spider +34 -0
- data/lib/spider-src/support/spider/src/ast/statements/WhileStatement.spider +28 -0
- data/lib/spider-src/support/spider/src/ast.spider +80 -0
- data/lib/spider-src/support/spider/src/spider.pegjs +1434 -0
- data/lib/spider-src/support/spider/src/spider.spider +276 -0
- data/lib/spider-src/support/spider/test/spider_test.js +1787 -0
- data/lib/spider-src/version.rb +5 -0
- data/lib/spider-src.rb +37 -0
- data/spider-src.gemspec +24 -0
- data/test/test_spider_src.rb +33 -0
- metadata +225 -0
@@ -0,0 +1,229 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("./Node").Node;
|
4
|
+
function Parameter(id, defaultValue, splat) {
|
5
|
+
Node.call(this);
|
6
|
+
this.type = "Parameter";
|
7
|
+
this.splat = splat;
|
8
|
+
this.id = id;
|
9
|
+
this.id.parent = this;
|
10
|
+
this.defaultValue = defaultValue;
|
11
|
+
if (typeof this.defaultValue !== "undefined" && this.defaultValue !== null) {
|
12
|
+
this.defaultValue.parent = this;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
Parameter.prototype = Object.create(Node);
|
16
|
+
Parameter.prototype.codegen = function() {
|
17
|
+
if (!Node.prototype.codegen.call(this)) {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
this.id = this.id.codegen(false);
|
21
|
+
if (typeof this.defaultValue !== "undefined" && this.defaultValue !== null) {
|
22
|
+
this.defaultValue = this.defaultValue.codegen();
|
23
|
+
}
|
24
|
+
return this;
|
25
|
+
};
|
26
|
+
Parameter.prototype.hasCallExpression = function() {
|
27
|
+
return false;
|
28
|
+
};
|
29
|
+
Parameter.generateFunctionBody = function(func, params, body, defaults) {
|
30
|
+
var splatPosition = -1;
|
31
|
+
var i = 0;
|
32
|
+
for (var $__0 = params[$traceurRuntime.toProperty(Symbol.iterator)](),
|
33
|
+
$__1; !($__1 = $__0.next()).done; ) {
|
34
|
+
var param = $__1.value;
|
35
|
+
{
|
36
|
+
if (param.splat) {
|
37
|
+
if (splatPosition !== -1) {
|
38
|
+
Node.getErrorManager().error({
|
39
|
+
type: "MultipleSplatsDisallowed",
|
40
|
+
message: "multiple splats are disallowed in a function declaration",
|
41
|
+
loc: param.loc
|
42
|
+
});
|
43
|
+
}
|
44
|
+
splatPosition = i;
|
45
|
+
}
|
46
|
+
param = param.codegen();
|
47
|
+
defaults.push(param.defaultValue);
|
48
|
+
params[i] = param.id;
|
49
|
+
func.defineIdentifier(param.id);
|
50
|
+
i++;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
if (splatPosition !== -1) {
|
54
|
+
var declarations = [{
|
55
|
+
"type": "VariableDeclarator",
|
56
|
+
"id": {
|
57
|
+
"type": "Identifier",
|
58
|
+
"name": "__splat"
|
59
|
+
},
|
60
|
+
"init": null
|
61
|
+
}];
|
62
|
+
var i$__4 = 0;
|
63
|
+
for (var $__2 = params[$traceurRuntime.toProperty(Symbol.iterator)](),
|
64
|
+
$__3; !($__3 = $__2.next()).done; ) {
|
65
|
+
var param$__5 = $__3.value;
|
66
|
+
{
|
67
|
+
var init;
|
68
|
+
if (i$__4 < splatPosition) {
|
69
|
+
init = {
|
70
|
+
"type": "MemberExpression",
|
71
|
+
"computed": true,
|
72
|
+
"object": {
|
73
|
+
"type": "Identifier",
|
74
|
+
"name": "arguments"
|
75
|
+
},
|
76
|
+
"property": {
|
77
|
+
"type": "Literal",
|
78
|
+
"value": i$__4
|
79
|
+
}
|
80
|
+
};
|
81
|
+
} else {
|
82
|
+
if (i$__4 === splatPosition) {
|
83
|
+
init = {
|
84
|
+
"type": "ConditionalExpression",
|
85
|
+
"test": {
|
86
|
+
"type": "BinaryExpression",
|
87
|
+
"operator": "<=",
|
88
|
+
"left": {
|
89
|
+
"type": "Literal",
|
90
|
+
"value": params.length
|
91
|
+
},
|
92
|
+
"right": {
|
93
|
+
"type": "MemberExpression",
|
94
|
+
"computed": false,
|
95
|
+
"object": {
|
96
|
+
"type": "Identifier",
|
97
|
+
"name": "arguments"
|
98
|
+
},
|
99
|
+
"property": {
|
100
|
+
"type": "Identifier",
|
101
|
+
"name": "length"
|
102
|
+
}
|
103
|
+
}
|
104
|
+
},
|
105
|
+
"consequent": {
|
106
|
+
"type": "CallExpression",
|
107
|
+
"callee": {
|
108
|
+
"type": "MemberExpression",
|
109
|
+
"computed": false,
|
110
|
+
"object": {
|
111
|
+
"type": "MemberExpression",
|
112
|
+
"computed": false,
|
113
|
+
"object": {
|
114
|
+
"type": "ArrayExpression",
|
115
|
+
"elements": []
|
116
|
+
},
|
117
|
+
"property": {
|
118
|
+
"type": "Identifier",
|
119
|
+
"name": "slice"
|
120
|
+
}
|
121
|
+
},
|
122
|
+
"property": {
|
123
|
+
"type": "Identifier",
|
124
|
+
"name": "call"
|
125
|
+
}
|
126
|
+
},
|
127
|
+
"arguments": [{
|
128
|
+
"type": "Identifier",
|
129
|
+
"name": "arguments"
|
130
|
+
}, {
|
131
|
+
"type": "Literal",
|
132
|
+
"value": splatPosition
|
133
|
+
}]
|
134
|
+
},
|
135
|
+
"alternate": {
|
136
|
+
"type": "ArrayExpression",
|
137
|
+
"elements": []
|
138
|
+
}
|
139
|
+
};
|
140
|
+
if (splatPosition < params.length - 1) {
|
141
|
+
init.consequent.arguments.push({
|
142
|
+
"type": "AssignmentExpression",
|
143
|
+
"operator": "=",
|
144
|
+
"left": {
|
145
|
+
"type": "Identifier",
|
146
|
+
"name": "__splat"
|
147
|
+
},
|
148
|
+
"right": {
|
149
|
+
"type": "BinaryExpression",
|
150
|
+
"operator": "-",
|
151
|
+
"left": {
|
152
|
+
"type": "MemberExpression",
|
153
|
+
"computed": false,
|
154
|
+
"object": {
|
155
|
+
"type": "Identifier",
|
156
|
+
"name": "arguments"
|
157
|
+
},
|
158
|
+
"property": {
|
159
|
+
"type": "Identifier",
|
160
|
+
"name": "length"
|
161
|
+
}
|
162
|
+
},
|
163
|
+
"right": {
|
164
|
+
"type": "Literal",
|
165
|
+
"value": params.length - splatPosition - 1
|
166
|
+
}
|
167
|
+
}
|
168
|
+
});
|
169
|
+
init.alternate = {
|
170
|
+
"type": "SequenceExpression",
|
171
|
+
"expressions": [{
|
172
|
+
"type": "AssignmentExpression",
|
173
|
+
"operator": "=",
|
174
|
+
"left": {
|
175
|
+
"type": "Identifier",
|
176
|
+
"name": "__splat"
|
177
|
+
},
|
178
|
+
"right": {
|
179
|
+
"type": "Literal",
|
180
|
+
"value": splatPosition
|
181
|
+
}
|
182
|
+
}, {
|
183
|
+
"type": "ArrayExpression",
|
184
|
+
"elements": []
|
185
|
+
}]
|
186
|
+
};
|
187
|
+
}
|
188
|
+
} else {
|
189
|
+
init = {
|
190
|
+
"type": "MemberExpression",
|
191
|
+
"computed": true,
|
192
|
+
"object": {
|
193
|
+
"type": "Identifier",
|
194
|
+
"name": "arguments"
|
195
|
+
},
|
196
|
+
"property": {
|
197
|
+
"type": "UpdateExpression",
|
198
|
+
"operator": "++",
|
199
|
+
"argument": {
|
200
|
+
"type": "Identifier",
|
201
|
+
"name": "__splat"
|
202
|
+
},
|
203
|
+
"prefix": false
|
204
|
+
}
|
205
|
+
};
|
206
|
+
}
|
207
|
+
}
|
208
|
+
declarations.push({
|
209
|
+
"type": "VariableDeclarator",
|
210
|
+
"id": param$__5,
|
211
|
+
"init": init
|
212
|
+
});
|
213
|
+
i$__4++;
|
214
|
+
}
|
215
|
+
}
|
216
|
+
body.body = [{
|
217
|
+
"type": "VariableDeclaration",
|
218
|
+
"codeGenerated": true,
|
219
|
+
"declarations": declarations,
|
220
|
+
"kind": "let"
|
221
|
+
}].concat(body.body);
|
222
|
+
params.length = 0;
|
223
|
+
}
|
224
|
+
};
|
225
|
+
exports.Parameter = Parameter;
|
226
|
+
return {};
|
227
|
+
});
|
228
|
+
|
229
|
+
//# sourceMappingURL=Parameter.map
|
@@ -0,0 +1,58 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("./Node").Node;
|
4
|
+
function Program(body) {
|
5
|
+
Node.call(this);
|
6
|
+
this.type = "Program";
|
7
|
+
this.body = body;
|
8
|
+
var i = 0;
|
9
|
+
for (var $__0 = body[$traceurRuntime.toProperty(Symbol.iterator)](),
|
10
|
+
$__1; !($__1 = $__0.next()).done; ) {
|
11
|
+
var statement = $__1.value;
|
12
|
+
{
|
13
|
+
if (typeof statement !== "undefined" && statement !== null) {
|
14
|
+
statement.parent = this;
|
15
|
+
} else {
|
16
|
+
body[i] = {type: "EmptyStatement"};
|
17
|
+
}
|
18
|
+
i++;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
this.definedIdentifiers = Program.prototype.generateIdentifiers("Infinity", "NaN", "eval", "uneval", "isFinite", "isNaN", "parseFloat", "parseInt", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape", "unescape", "Object", "Function", "Boolean", "Symbol", "Error", "EvalError", "InternalError", "RangeError", "ReferenceError", "StopIteration", "SyntaxError", "TypeError", "URIError", "Number", "Math", "Date", "String", "RegExp", "Array", "Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "Map", "Set", "WeakMap", "WeakSet", "ArrayBuffer", "DataView", "JSON", "Iterator", "Generator", "Promise", "arguments");
|
22
|
+
}
|
23
|
+
Program.prototype = Object.create(Node);
|
24
|
+
Program.prototype.codegen = function() {
|
25
|
+
if (!Node.prototype.codegen.call(this)) {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
var i = 0;
|
29
|
+
while (i < this.body.length) {
|
30
|
+
var statement = this.body[i];
|
31
|
+
if (!statement || !!statement.codeGenerated) {
|
32
|
+
i++;
|
33
|
+
continue;
|
34
|
+
}
|
35
|
+
if (!!statement.codegen && !!statement.codegen()) {
|
36
|
+
this.body[this.body.indexOf(statement)] = statement;
|
37
|
+
i++;
|
38
|
+
} else {
|
39
|
+
this.body.splice(i, 1);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
return this;
|
43
|
+
};
|
44
|
+
Program.prototype.generateIdentifiers = function() {
|
45
|
+
var __splat,
|
46
|
+
identifiers = 1 <= arguments.length ? [].slice.call(arguments, 0) : [];
|
47
|
+
return identifiers.map(function(id) {
|
48
|
+
return {
|
49
|
+
"type": "Identifier",
|
50
|
+
"name": id
|
51
|
+
};
|
52
|
+
});
|
53
|
+
};
|
54
|
+
exports.Program = Program;
|
55
|
+
return {};
|
56
|
+
});
|
57
|
+
|
58
|
+
//# sourceMappingURL=Program.map
|
@@ -0,0 +1,32 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("./Node").Node;
|
4
|
+
function Property(key, value, shorthand, method) {
|
5
|
+
Node.call(this);
|
6
|
+
this.type = "Property";
|
7
|
+
this.kind = "init";
|
8
|
+
this.method = method;
|
9
|
+
this.shorthand = shorthand;
|
10
|
+
this.computed = false;
|
11
|
+
this.key = key;
|
12
|
+
this.key.parent = this;
|
13
|
+
this.value = value;
|
14
|
+
this.value.parent = this;
|
15
|
+
}
|
16
|
+
Property.prototype = Object.create(Node);
|
17
|
+
Property.prototype.codegen = function() {
|
18
|
+
if (!Node.prototype.codegen.call(this)) {
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
this.key = this.key.codegen(false);
|
22
|
+
this.value = this.value.codegen(this.parent.type !== "ObjectPattern");
|
23
|
+
return this;
|
24
|
+
};
|
25
|
+
Property.prototype.hasCallExpression = function() {
|
26
|
+
return this.value.hasCallExpression();
|
27
|
+
};
|
28
|
+
exports.Property = Property;
|
29
|
+
return {};
|
30
|
+
});
|
31
|
+
|
32
|
+
//# sourceMappingURL=Property.map
|
@@ -0,0 +1,257 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("./Node").Node;
|
4
|
+
function Range(start, operator, to) {
|
5
|
+
Node.call(this);
|
6
|
+
this.type = "Range";
|
7
|
+
this.operator = operator;
|
8
|
+
this.start = start;
|
9
|
+
if (typeof this.start !== "undefined" && this.start !== null) {
|
10
|
+
this.start.parent = this;
|
11
|
+
}
|
12
|
+
this.to = to;
|
13
|
+
if (typeof this.to !== "undefined" && this.to !== null) {
|
14
|
+
this.to.parent = this;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
Range.prototype = Object.create(Node);
|
18
|
+
Range.prototype.codegen = function() {
|
19
|
+
if (!Node.prototype.codegen.call(this)) {
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
var isNumber = function(n) {
|
23
|
+
return !isNaN(parseFloat(n)) && !!isFinite(n);
|
24
|
+
};
|
25
|
+
var isNumeric = !!isNumber(this.start.value) && !!isNumber(this.to.value);
|
26
|
+
this.start = this.start.codegen();
|
27
|
+
this.to = this.to.codegen();
|
28
|
+
var updateOperator,
|
29
|
+
testOperator;
|
30
|
+
if (isNumeric) {
|
31
|
+
updateOperator = this.start.value < this.to.value ? "++" : "--";
|
32
|
+
testOperator = this.start.value < this.to.value ? "<" : ">";
|
33
|
+
if (this.operator === "..") {
|
34
|
+
testOperator += "=";
|
35
|
+
}
|
36
|
+
}
|
37
|
+
if (!!isNumeric && !!(Math.abs(this.to.value - this.start.value) <= 20)) {
|
38
|
+
this.type = "ArrayExpression";
|
39
|
+
this.elements = [];
|
40
|
+
var test = function(i) {
|
41
|
+
if (testOperator === ">") {
|
42
|
+
return i > this.to.value;
|
43
|
+
} else if (testOperator === "<") {
|
44
|
+
return i < this.to.value;
|
45
|
+
} else if (testOperator === ">=") {
|
46
|
+
return i >= this.to.value;
|
47
|
+
} else if (testOperator === "<=") {
|
48
|
+
return i <= this.to.value;
|
49
|
+
}
|
50
|
+
};
|
51
|
+
for (var i = this.start.value; test.call(this, i); updateOperator === "++" ? i++ : i--) {
|
52
|
+
this.elements.push({
|
53
|
+
"type": "Literal",
|
54
|
+
"value": i
|
55
|
+
});
|
56
|
+
}
|
57
|
+
} else {
|
58
|
+
var testExpression,
|
59
|
+
updateExpression;
|
60
|
+
var declarations = [{
|
61
|
+
"type": "VariableDeclarator",
|
62
|
+
"id": {
|
63
|
+
"type": "Identifier",
|
64
|
+
"name": "_results"
|
65
|
+
},
|
66
|
+
"init": {
|
67
|
+
"type": "ArrayExpression",
|
68
|
+
"elements": []
|
69
|
+
}
|
70
|
+
}];
|
71
|
+
if (isNumeric) {
|
72
|
+
testExpression = {
|
73
|
+
"type": "BinaryExpression",
|
74
|
+
"operator": testOperator,
|
75
|
+
"left": {
|
76
|
+
"type": "Identifier",
|
77
|
+
"name": "_i"
|
78
|
+
},
|
79
|
+
"right": this.to
|
80
|
+
};
|
81
|
+
updateExpression = {
|
82
|
+
"type": "UpdateExpression",
|
83
|
+
"operator": updateOperator,
|
84
|
+
"argument": {
|
85
|
+
"type": "Identifier",
|
86
|
+
"name": "_i"
|
87
|
+
},
|
88
|
+
"prefix": false
|
89
|
+
};
|
90
|
+
} else {
|
91
|
+
if (this.start.hasCallExpression()) {
|
92
|
+
var startId = {
|
93
|
+
"type": "Identifier",
|
94
|
+
"name": "_start"
|
95
|
+
};
|
96
|
+
declarations.push({
|
97
|
+
"type": "VariableDeclarator",
|
98
|
+
"id": startId,
|
99
|
+
"init": this.start
|
100
|
+
});
|
101
|
+
this.start = startId;
|
102
|
+
}
|
103
|
+
if (this.to.hasCallExpression()) {
|
104
|
+
var endId = {
|
105
|
+
"type": "Identifier",
|
106
|
+
"name": "_end"
|
107
|
+
};
|
108
|
+
declarations.push({
|
109
|
+
"type": "VariableDeclarator",
|
110
|
+
"id": endId,
|
111
|
+
"init": this.to
|
112
|
+
});
|
113
|
+
this.to = endId;
|
114
|
+
}
|
115
|
+
testExpression = {
|
116
|
+
"type": "ConditionalExpression",
|
117
|
+
"test": {
|
118
|
+
"type": "BinaryExpression",
|
119
|
+
"operator": "<=",
|
120
|
+
"left": this.start,
|
121
|
+
"right": this.to
|
122
|
+
},
|
123
|
+
"consequent": {
|
124
|
+
"type": "BinaryExpression",
|
125
|
+
"operator": "<" + (this.operator === ".." ? "=" : ""),
|
126
|
+
"left": {
|
127
|
+
"type": "Identifier",
|
128
|
+
"name": "_i"
|
129
|
+
},
|
130
|
+
"right": this.to
|
131
|
+
},
|
132
|
+
"alternate": {
|
133
|
+
"type": "BinaryExpression",
|
134
|
+
"operator": ">" + (this.operator === ".." ? "=" : ""),
|
135
|
+
"left": {
|
136
|
+
"type": "Identifier",
|
137
|
+
"name": "_i"
|
138
|
+
},
|
139
|
+
"right": this.to
|
140
|
+
}
|
141
|
+
};
|
142
|
+
updateExpression = {
|
143
|
+
"type": "ConditionalExpression",
|
144
|
+
"test": {
|
145
|
+
"type": "BinaryExpression",
|
146
|
+
"operator": "<=",
|
147
|
+
"left": this.start,
|
148
|
+
"right": this.to
|
149
|
+
},
|
150
|
+
"consequent": {
|
151
|
+
"type": "UpdateExpression",
|
152
|
+
"operator": "++",
|
153
|
+
"argument": {
|
154
|
+
"type": "Identifier",
|
155
|
+
"name": "_i"
|
156
|
+
},
|
157
|
+
"prefix": false
|
158
|
+
},
|
159
|
+
"alternate": {
|
160
|
+
"type": "UpdateExpression",
|
161
|
+
"operator": "--",
|
162
|
+
"argument": {
|
163
|
+
"type": "Identifier",
|
164
|
+
"name": "_i"
|
165
|
+
},
|
166
|
+
"prefix": false
|
167
|
+
}
|
168
|
+
};
|
169
|
+
}
|
170
|
+
this.type = "CallExpression";
|
171
|
+
this.callee = {
|
172
|
+
"type": "MemberExpression",
|
173
|
+
"computed": false,
|
174
|
+
"object": {
|
175
|
+
"type": "FunctionExpression",
|
176
|
+
"id": null,
|
177
|
+
"params": [],
|
178
|
+
"defaults": [],
|
179
|
+
"body": {
|
180
|
+
"type": "BlockStatement",
|
181
|
+
"body": [{
|
182
|
+
"type": "VariableDeclaration",
|
183
|
+
"declarations": declarations,
|
184
|
+
"kind": "let"
|
185
|
+
}, {
|
186
|
+
"type": "ForStatement",
|
187
|
+
"init": {
|
188
|
+
"type": "VariableDeclaration",
|
189
|
+
"declarations": [{
|
190
|
+
"type": "VariableDeclarator",
|
191
|
+
"id": {
|
192
|
+
"type": "Identifier",
|
193
|
+
"name": "_i"
|
194
|
+
},
|
195
|
+
"init": this.start
|
196
|
+
}],
|
197
|
+
"kind": "let"
|
198
|
+
},
|
199
|
+
"test": testExpression,
|
200
|
+
"update": updateExpression,
|
201
|
+
"body": {
|
202
|
+
"type": "BlockStatement",
|
203
|
+
"body": [{
|
204
|
+
"type": "ExpressionStatement",
|
205
|
+
"expression": {
|
206
|
+
"type": "CallExpression",
|
207
|
+
"callee": {
|
208
|
+
"type": "MemberExpression",
|
209
|
+
"computed": false,
|
210
|
+
"object": {
|
211
|
+
"type": "Identifier",
|
212
|
+
"name": "_results"
|
213
|
+
},
|
214
|
+
"property": {
|
215
|
+
"type": "Identifier",
|
216
|
+
"name": "push"
|
217
|
+
}
|
218
|
+
},
|
219
|
+
"arguments": [{
|
220
|
+
"type": "Identifier",
|
221
|
+
"name": "_i"
|
222
|
+
}]
|
223
|
+
}
|
224
|
+
}]
|
225
|
+
}
|
226
|
+
}, {
|
227
|
+
"type": "ReturnStatement",
|
228
|
+
"argument": {
|
229
|
+
"type": "Identifier",
|
230
|
+
"name": "_results"
|
231
|
+
}
|
232
|
+
}]
|
233
|
+
},
|
234
|
+
"rest": null,
|
235
|
+
"generator": false,
|
236
|
+
"expression": false
|
237
|
+
},
|
238
|
+
"property": {
|
239
|
+
"type": "Identifier",
|
240
|
+
"name": "apply"
|
241
|
+
}
|
242
|
+
};
|
243
|
+
Object.defineProperty(this, "arguments", {
|
244
|
+
value: [{"type": "ThisExpression"}],
|
245
|
+
enumerable: true
|
246
|
+
});
|
247
|
+
}
|
248
|
+
return this;
|
249
|
+
};
|
250
|
+
Range.prototype.hasCallExpression = function() {
|
251
|
+
return true;
|
252
|
+
};
|
253
|
+
exports.Range = Range;
|
254
|
+
return {};
|
255
|
+
});
|
256
|
+
|
257
|
+
//# sourceMappingURL=Range.map
|
@@ -0,0 +1,29 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("./Node").Node;
|
4
|
+
function VariableDeclarator(id, init) {
|
5
|
+
Node.call(this);
|
6
|
+
this.type = "VariableDeclarator";
|
7
|
+
this.id = id;
|
8
|
+
this.id.parent = this;
|
9
|
+
this.init = init;
|
10
|
+
if (typeof this.init !== "undefined" && this.init !== null) {
|
11
|
+
this.init.parent = this;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
VariableDeclarator.prototype = Object.create(Node);
|
15
|
+
VariableDeclarator.prototype.codegen = function() {
|
16
|
+
if (!Node.prototype.codegen.call(this)) {
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
if (typeof this.init !== "undefined" && this.init !== null) {
|
20
|
+
this.init = this.init.codegen();
|
21
|
+
}
|
22
|
+
this.id = this.id.codegen();
|
23
|
+
return this;
|
24
|
+
};
|
25
|
+
exports.VariableDeclarator = VariableDeclarator;
|
26
|
+
return {};
|
27
|
+
});
|
28
|
+
|
29
|
+
//# sourceMappingURL=VariableDeclarator.map
|
@@ -0,0 +1,41 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("../Node").Node;
|
4
|
+
function ArrayExpression(elements) {
|
5
|
+
Node.call(this);
|
6
|
+
this.type = "ArrayExpression";
|
7
|
+
this.elements = elements;
|
8
|
+
for (var $__0 = this.elements[$traceurRuntime.toProperty(Symbol.iterator)](),
|
9
|
+
$__1; !($__1 = $__0.next()).done; ) {
|
10
|
+
var element = $__1.value;
|
11
|
+
{
|
12
|
+
if (typeof element !== "undefined" && element !== null) {
|
13
|
+
element.parent = this;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
ArrayExpression.prototype = Object.create(Node);
|
19
|
+
ArrayExpression.prototype.codegen = function() {
|
20
|
+
if (!Node.prototype.codegen.call(this)) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
var i = 0;
|
24
|
+
for (var $__0 = this.elements[$traceurRuntime.toProperty(Symbol.iterator)](),
|
25
|
+
$__1; !($__1 = $__0.next()).done; ) {
|
26
|
+
var element = $__1.value;
|
27
|
+
{
|
28
|
+
this.elements[i] = typeof element !== "undefined" && element !== null ? element.codegen() : void 0;
|
29
|
+
i++;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return this;
|
33
|
+
};
|
34
|
+
ArrayExpression.prototype.hasCallExpression = function() {
|
35
|
+
return true;
|
36
|
+
};
|
37
|
+
exports.ArrayExpression = ArrayExpression;
|
38
|
+
return {};
|
39
|
+
});
|
40
|
+
|
41
|
+
//# sourceMappingURL=ArrayExpression.map
|
@@ -0,0 +1,45 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("../Node").Node;
|
4
|
+
function ArrayPattern(elements) {
|
5
|
+
Node.call(this);
|
6
|
+
this.type = "ArrayPattern";
|
7
|
+
this.elements = elements;
|
8
|
+
for (var $__0 = this.elements[$traceurRuntime.toProperty(Symbol.iterator)](),
|
9
|
+
$__1; !($__1 = $__0.next()).done; ) {
|
10
|
+
var element = $__1.value;
|
11
|
+
{
|
12
|
+
if (typeof element !== "undefined" && element !== null) {
|
13
|
+
element.parent = this;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
ArrayPattern.prototype = Object.create(Node);
|
19
|
+
ArrayPattern.prototype.codegen = function() {
|
20
|
+
if (!Node.prototype.codegen.call(this)) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
var context = this.getContext().node;
|
24
|
+
var i = 0;
|
25
|
+
for (var $__0 = this.elements[$traceurRuntime.toProperty(Symbol.iterator)](),
|
26
|
+
$__1; !($__1 = $__0.next()).done; ) {
|
27
|
+
var element = $__1.value;
|
28
|
+
{
|
29
|
+
this.elements[i] = typeof element !== "undefined" && element !== null ? element.codegen(false) : void 0;
|
30
|
+
if (!!(typeof element !== "undefined" && element !== null) && !!(element.type === "Identifier")) {
|
31
|
+
context.defineIdentifier(element);
|
32
|
+
}
|
33
|
+
i++;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return this;
|
37
|
+
};
|
38
|
+
ArrayPattern.prototype.hasCallExpression = function() {
|
39
|
+
return true;
|
40
|
+
};
|
41
|
+
exports.ArrayPattern = ArrayPattern;
|
42
|
+
return {};
|
43
|
+
});
|
44
|
+
|
45
|
+
//# sourceMappingURL=ArrayPattern.map
|