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,157 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("../Node").Node,
|
4
|
+
Parameter = module.require("../Parameter").Parameter,
|
5
|
+
CallExpression = module.require("../expressions/CallExpression").CallExpression;
|
6
|
+
function FunctionExpression(id, params, body, inheritsFrom, operator) {
|
7
|
+
Node.call(this);
|
8
|
+
if (operator === "=>") {
|
9
|
+
this.type = "ArrowFunctionExpression";
|
10
|
+
} else {
|
11
|
+
this.type = "FunctionExpression";
|
12
|
+
}
|
13
|
+
this.defaults = [];
|
14
|
+
this.rest = null;
|
15
|
+
this.generator = false;
|
16
|
+
this.expression = false;
|
17
|
+
this.operator = operator;
|
18
|
+
this.id = id;
|
19
|
+
if (typeof this.id !== "undefined" && this.id !== null) {
|
20
|
+
this.id.parent = this;
|
21
|
+
}
|
22
|
+
this.body = body;
|
23
|
+
this.params = params;
|
24
|
+
body.parent = this;
|
25
|
+
for (var $__0 = params[$traceurRuntime.toProperty(Symbol.iterator)](),
|
26
|
+
$__1; !($__1 = $__0.next()).done; ) {
|
27
|
+
var param = $__1.value;
|
28
|
+
{
|
29
|
+
param.parent = this;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
this.inheritsFrom = inheritsFrom;
|
33
|
+
if (typeof this.inheritsFrom !== "undefined" && this.inheritsFrom !== null) {
|
34
|
+
this.inheritsFrom.parent = this;
|
35
|
+
}
|
36
|
+
if (this.body.type !== "BlockStatement") {
|
37
|
+
this.autoBlock = true;
|
38
|
+
this.body = {
|
39
|
+
"type": "BlockStatement",
|
40
|
+
"body": [{
|
41
|
+
"type": "ReturnStatement",
|
42
|
+
"argument": this.body
|
43
|
+
}]
|
44
|
+
};
|
45
|
+
var self = this;
|
46
|
+
this.getContext = function() {
|
47
|
+
return {
|
48
|
+
node: self.body,
|
49
|
+
position: -1
|
50
|
+
};
|
51
|
+
};
|
52
|
+
}
|
53
|
+
}
|
54
|
+
FunctionExpression.prototype = Object.create(Node);
|
55
|
+
FunctionExpression.prototype.codegen = function() {
|
56
|
+
if (!Node.prototype.codegen.call(this)) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
if (typeof this.id !== "undefined" && this.id !== null) {
|
60
|
+
this.id = this.id.codegen(false);
|
61
|
+
}
|
62
|
+
Parameter.generateFunctionBody(this, this.params, this.body, this.defaults);
|
63
|
+
if (this.autoBlock) {
|
64
|
+
this.body.body[0].argument = this.body.body[this.body.body.length - 1].argument.codegen();
|
65
|
+
} else {
|
66
|
+
this.body = this.body.codegen();
|
67
|
+
}
|
68
|
+
if (typeof this.inheritsFrom !== "undefined" && this.inheritsFrom !== null) {
|
69
|
+
if (this.inheritsFrom.type !== "CallExpression") {
|
70
|
+
this.inheritsFrom = new CallExpression(this.inheritsFrom, []);
|
71
|
+
this.inheritsFrom.parent = this;
|
72
|
+
}
|
73
|
+
var context = this.getContext();
|
74
|
+
this.body.body.splice(0, 0, {
|
75
|
+
"type": "ExpressionStatement",
|
76
|
+
"expression": {
|
77
|
+
"type": "CallExpression",
|
78
|
+
"callee": {
|
79
|
+
"type": "MemberExpression",
|
80
|
+
"computed": false,
|
81
|
+
"object": this.inheritsFrom.callee,
|
82
|
+
"property": {
|
83
|
+
"type": "Identifier",
|
84
|
+
"name": "call"
|
85
|
+
}
|
86
|
+
},
|
87
|
+
"arguments": [{"type": "ThisExpression"}].concat(this.inheritsFrom.arguments)
|
88
|
+
}
|
89
|
+
});
|
90
|
+
var id = {
|
91
|
+
"type": "Identifier",
|
92
|
+
"name": FunctionExpression.getNextVariableName()
|
93
|
+
};
|
94
|
+
context.node.body.splice(context.position, 0, {
|
95
|
+
"type": "VariableDeclaration",
|
96
|
+
"declarations": [{
|
97
|
+
"type": "VariableDeclarator",
|
98
|
+
"id": id,
|
99
|
+
"init": this
|
100
|
+
}],
|
101
|
+
"kind": "let",
|
102
|
+
"codeGenerated": true
|
103
|
+
});
|
104
|
+
context.node.body.splice(context.position + 1, 0, {
|
105
|
+
"type": "ExpressionStatement",
|
106
|
+
"codeGenerated": "true",
|
107
|
+
"expression": {
|
108
|
+
"type": "AssignmentExpression",
|
109
|
+
"operator": "=",
|
110
|
+
"left": {
|
111
|
+
"type": "MemberExpression",
|
112
|
+
"computed": false,
|
113
|
+
"object": id,
|
114
|
+
"property": {
|
115
|
+
"type": "Identifier",
|
116
|
+
"name": "prototype"
|
117
|
+
}
|
118
|
+
},
|
119
|
+
"right": {
|
120
|
+
"type": "CallExpression",
|
121
|
+
"callee": {
|
122
|
+
"type": "MemberExpression",
|
123
|
+
"computed": false,
|
124
|
+
"object": {
|
125
|
+
"type": "Identifier",
|
126
|
+
"name": "Object"
|
127
|
+
},
|
128
|
+
"property": {
|
129
|
+
"type": "Identifier",
|
130
|
+
"name": "create"
|
131
|
+
}
|
132
|
+
},
|
133
|
+
"arguments": [this.inheritsFrom.callee]
|
134
|
+
}
|
135
|
+
}
|
136
|
+
});
|
137
|
+
return id;
|
138
|
+
}
|
139
|
+
return this;
|
140
|
+
};
|
141
|
+
FunctionExpression.prototype.hasCallExpression = function() {
|
142
|
+
return true;
|
143
|
+
};
|
144
|
+
FunctionExpression.getNextVariableName = function() {
|
145
|
+
if (!(typeof this.functionExpressionIndex !== "undefined" && this.functionExpressionIndex !== null)) {
|
146
|
+
this.functionExpressionIndex = 0;
|
147
|
+
}
|
148
|
+
return "functionExpression" + this.functionExpressionIndex++;
|
149
|
+
};
|
150
|
+
FunctionExpression.resetVariableNames = function() {
|
151
|
+
this.functionExpressionIndex = 0;
|
152
|
+
};
|
153
|
+
exports.FunctionExpression = FunctionExpression;
|
154
|
+
return {};
|
155
|
+
});
|
156
|
+
|
157
|
+
//# sourceMappingURL=FunctionExpression.map
|
@@ -0,0 +1,99 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("../Node").Node;
|
4
|
+
function InExpression(left, right) {
|
5
|
+
Node.call(this);
|
6
|
+
this.type = "InExpression";
|
7
|
+
this.left = left;
|
8
|
+
this.left.parent = this;
|
9
|
+
this.right = right;
|
10
|
+
this.right.parent = this;
|
11
|
+
}
|
12
|
+
InExpression.prototype = Object.create(Node);
|
13
|
+
InExpression.prototype.codegen = function() {
|
14
|
+
if (!Node.prototype.codegen.call(this)) {
|
15
|
+
return;
|
16
|
+
}
|
17
|
+
this.left = this.left.codegen();
|
18
|
+
this.right = this.right.codegen();
|
19
|
+
if (typeof this.right.hasCallExpression === "function" ? this.right.hasCallExpression() : void 0) {
|
20
|
+
var context = this.getContext();
|
21
|
+
var id = {
|
22
|
+
"type": "Identifier",
|
23
|
+
"name": InExpression.getNextVariableName(),
|
24
|
+
"codeGenerated": true
|
25
|
+
};
|
26
|
+
context.node.body.splice(context.position + (InExpression.inExpressionIndex - 2), 0, {
|
27
|
+
"type": "VariableDeclaration",
|
28
|
+
"declarations": [{
|
29
|
+
"type": "VariableDeclarator",
|
30
|
+
"id": id,
|
31
|
+
"init": this.right
|
32
|
+
}],
|
33
|
+
"kind": "let",
|
34
|
+
"codeGenerated": true
|
35
|
+
});
|
36
|
+
this.right = id;
|
37
|
+
}
|
38
|
+
this.type = "ConditionalExpression";
|
39
|
+
this.test = {
|
40
|
+
"type": "BinaryExpression",
|
41
|
+
"operator": "instanceof",
|
42
|
+
"left": this.right,
|
43
|
+
"right": {
|
44
|
+
"type": "Identifier",
|
45
|
+
"name": "Array"
|
46
|
+
}
|
47
|
+
};
|
48
|
+
this.consequent = {
|
49
|
+
"type": "BinaryExpression",
|
50
|
+
"operator": "!==",
|
51
|
+
"left": {
|
52
|
+
"type": "CallExpression",
|
53
|
+
"callee": {
|
54
|
+
"type": "MemberExpression",
|
55
|
+
"computed": false,
|
56
|
+
"object": this.right,
|
57
|
+
"property": {
|
58
|
+
"type": "Identifier",
|
59
|
+
"name": "indexOf"
|
60
|
+
}
|
61
|
+
},
|
62
|
+
"arguments": [this.left]
|
63
|
+
},
|
64
|
+
"right": {
|
65
|
+
"type": "UnaryExpression",
|
66
|
+
"operator": "-",
|
67
|
+
"argument": {
|
68
|
+
"type": "Literal",
|
69
|
+
"value": 1,
|
70
|
+
"raw": "1"
|
71
|
+
},
|
72
|
+
"prefix": true
|
73
|
+
}
|
74
|
+
};
|
75
|
+
this.alternate = {
|
76
|
+
"type": "BinaryExpression",
|
77
|
+
"operator": "in",
|
78
|
+
"left": this.left,
|
79
|
+
"right": this.right
|
80
|
+
};
|
81
|
+
return this;
|
82
|
+
};
|
83
|
+
InExpression.prototype.hasCallExpression = function() {
|
84
|
+
return true;
|
85
|
+
};
|
86
|
+
InExpression.getNextVariableName = function() {
|
87
|
+
if (!(typeof this.inExpressionIndex !== "undefined" && this.inExpressionIndex !== null)) {
|
88
|
+
this.inExpressionIndex = 0;
|
89
|
+
}
|
90
|
+
return "inExpression" + this.inExpressionIndex++;
|
91
|
+
};
|
92
|
+
InExpression.resetVariableNames = function() {
|
93
|
+
this.inExpressionIndex = 0;
|
94
|
+
};
|
95
|
+
exports.InExpression = InExpression;
|
96
|
+
return {};
|
97
|
+
});
|
98
|
+
|
99
|
+
//# sourceMappingURL=InExpression.map
|
@@ -0,0 +1,50 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("../Node").Node;
|
4
|
+
function LogicalExpression(left, operator, right) {
|
5
|
+
Node.call(this);
|
6
|
+
this.type = "LogicalExpression";
|
7
|
+
this.operator = operator;
|
8
|
+
if (this.operator === "and") {
|
9
|
+
this.operator = "&&";
|
10
|
+
} else if (this.operator === "or") {
|
11
|
+
this.operator = "||";
|
12
|
+
}
|
13
|
+
this.left = left;
|
14
|
+
this.left.parent = this;
|
15
|
+
this.right = right;
|
16
|
+
this.right.parent = this;
|
17
|
+
}
|
18
|
+
LogicalExpression.prototype = Object.create(Node);
|
19
|
+
LogicalExpression.prototype.codegen = function() {
|
20
|
+
if (!Node.prototype.codegen.call(this)) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
var enforceBooleanExpression = function(o) {
|
24
|
+
if (!!(o.type === "UnaryExpression") && !!(o.operator === "!")) {
|
25
|
+
return o;
|
26
|
+
}
|
27
|
+
return {
|
28
|
+
"type": "UnaryExpression",
|
29
|
+
"operator": "!",
|
30
|
+
"argument": {
|
31
|
+
"type": "UnaryExpression",
|
32
|
+
"operator": "!",
|
33
|
+
"argument": o,
|
34
|
+
"prefix": true
|
35
|
+
},
|
36
|
+
"prefix": true
|
37
|
+
};
|
38
|
+
};
|
39
|
+
this.left = enforceBooleanExpression(this.left.codegen());
|
40
|
+
this.right = enforceBooleanExpression(this.right.codegen());
|
41
|
+
return this;
|
42
|
+
};
|
43
|
+
LogicalExpression.prototype.hasCallExpression = function() {
|
44
|
+
return !!(typeof this.left !== "undefined" && this.left !== null ? this.left.hasCallExpression() : void 0) || !!(typeof this.right !== "undefined" && this.right !== null ? this.right.hasCallExpression() : void 0);
|
45
|
+
};
|
46
|
+
exports.LogicalExpression = LogicalExpression;
|
47
|
+
return {};
|
48
|
+
});
|
49
|
+
|
50
|
+
//# sourceMappingURL=LogicalExpression.map
|
@@ -0,0 +1,43 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("../Node").Node;
|
4
|
+
function MemberExpression(left, right, computed) {
|
5
|
+
Node.call(this);
|
6
|
+
this.type = "MemberExpression";
|
7
|
+
this.computed = computed;
|
8
|
+
this.object = left;
|
9
|
+
this.object.parent = this;
|
10
|
+
this.property = right;
|
11
|
+
this.property.parent = this;
|
12
|
+
}
|
13
|
+
MemberExpression.prototype = Object.create(Node);
|
14
|
+
MemberExpression.prototype.codegen = function() {
|
15
|
+
if (!Node.prototype.codegen.call(this)) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
var objectType = this.object.type;
|
19
|
+
this.object = this.object.codegen();
|
20
|
+
if (!this.property.codeGenerated) {
|
21
|
+
this.property = this.property.codegen(false);
|
22
|
+
}
|
23
|
+
if (!!(this.object.type === "ConditionalExpression") && !!(!!(!!(!!(objectType === "NullPropagatingExpression") || !!(objectType === "MemberExpression")) || !!(objectType === "CallExpression")) || !!(objectType === "NullCheckCallExpression"))) {
|
24
|
+
this.type = this.object.type;
|
25
|
+
this.test = this.object.test;
|
26
|
+
this.alternate = this.object.alternate;
|
27
|
+
this.consequent = {
|
28
|
+
type: "MemberExpression",
|
29
|
+
object: this.object.consequent,
|
30
|
+
property: this.property,
|
31
|
+
computed: this.computed
|
32
|
+
};
|
33
|
+
}
|
34
|
+
return this;
|
35
|
+
};
|
36
|
+
MemberExpression.prototype.hasCallExpression = function() {
|
37
|
+
return !!(!!this.object.__null_propagating || !!(typeof this.object !== "undefined" && this.object !== null && typeof this.object.hasCallExpression === "function" ? this.object.hasCallExpression() : void 0)) || !!(typeof this.property !== "undefined" && this.property !== null ? this.property.hasCallExpression() : void 0);
|
38
|
+
};
|
39
|
+
exports.MemberExpression = MemberExpression;
|
40
|
+
return {};
|
41
|
+
});
|
42
|
+
|
43
|
+
//# sourceMappingURL=MemberExpression.map
|
@@ -0,0 +1,46 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("../Node").Node;
|
4
|
+
function NewExpression(callee, args) {
|
5
|
+
Node.call(this);
|
6
|
+
this.type = "NewExpression";
|
7
|
+
this.callee = callee;
|
8
|
+
this.callee.parent = this;
|
9
|
+
Object.defineProperty(this, "arguments", {
|
10
|
+
value: args,
|
11
|
+
enumerable: true
|
12
|
+
});
|
13
|
+
for (var $__0 = args[$traceurRuntime.toProperty(Symbol.iterator)](),
|
14
|
+
$__1; !($__1 = $__0.next()).done; ) {
|
15
|
+
var arg = $__1.value;
|
16
|
+
{
|
17
|
+
arg.parent = this;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
NewExpression.prototype = Object.create(Node);
|
22
|
+
NewExpression.prototype.codegen = function() {
|
23
|
+
if (!Node.prototype.codegen.call(this)) {
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
this.callee = this.callee.codegen();
|
27
|
+
var args = this.arguments;
|
28
|
+
var i = 0;
|
29
|
+
for (var $__0 = args[$traceurRuntime.toProperty(Symbol.iterator)](),
|
30
|
+
$__1; !($__1 = $__0.next()).done; ) {
|
31
|
+
var arg = $__1.value;
|
32
|
+
{
|
33
|
+
args[i] = arg.codegen();
|
34
|
+
i++;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
return this;
|
38
|
+
};
|
39
|
+
NewExpression.prototype.hasCallExpression = function() {
|
40
|
+
return true;
|
41
|
+
};
|
42
|
+
exports.NewExpression = NewExpression;
|
43
|
+
return {};
|
44
|
+
});
|
45
|
+
|
46
|
+
//# sourceMappingURL=NewExpression.map
|
@@ -0,0 +1,132 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("../Node").Node,
|
4
|
+
CallExpression = module.require("./CallExpression").CallExpression;
|
5
|
+
function NullCheckCallExpression(callee, args) {
|
6
|
+
Node.call(this);
|
7
|
+
this.type = "NullCheckCallExpression";
|
8
|
+
this.callee = callee;
|
9
|
+
this.callee.parent = this;
|
10
|
+
this.args = args;
|
11
|
+
for (var $__0 = args[$traceurRuntime.toProperty(Symbol.iterator)](),
|
12
|
+
$__1; !($__1 = $__0.next()).done; ) {
|
13
|
+
var arg = $__1.value;
|
14
|
+
{
|
15
|
+
arg.parent = this;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
NullCheckCallExpression.prototype = Object.create(Node);
|
20
|
+
NullCheckCallExpression.prototype.codegen = function() {
|
21
|
+
if (!Node.prototype.codegen.call(this)) {
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
var calleeType = this.callee.type;
|
25
|
+
this.callee = this.callee.codegen();
|
26
|
+
var args = this.args;
|
27
|
+
var i = 0;
|
28
|
+
for (var $__0 = args[$traceurRuntime.toProperty(Symbol.iterator)](),
|
29
|
+
$__1; !($__1 = $__0.next()).done; ) {
|
30
|
+
var arg = $__1.value;
|
31
|
+
{
|
32
|
+
var isSplat = args[i].type === "SplatExpression";
|
33
|
+
args[i] = arg.codegen();
|
34
|
+
args[i].codeGenerated = true;
|
35
|
+
if (isSplat) {
|
36
|
+
args[i].__splat = true;
|
37
|
+
}
|
38
|
+
i++;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
if (typeof this.callee.hasCallExpression === "function" ? this.callee.hasCallExpression() : void 0) {
|
42
|
+
var context = this.getContext();
|
43
|
+
var id = {
|
44
|
+
"type": "Identifier",
|
45
|
+
"name": NullCheckCallExpression.getNextVariableName(),
|
46
|
+
"codeGenerated": true
|
47
|
+
};
|
48
|
+
context.node.body.splice(context.position + (NullCheckCallExpression.nullCheckIndex - 2), 0, {
|
49
|
+
"type": "VariableDeclaration",
|
50
|
+
"declarations": [{
|
51
|
+
"type": "VariableDeclarator",
|
52
|
+
"id": id,
|
53
|
+
"init": this.callee
|
54
|
+
}],
|
55
|
+
"kind": "let",
|
56
|
+
"codeGenerated": true
|
57
|
+
});
|
58
|
+
this.callee = id;
|
59
|
+
}
|
60
|
+
var test = {
|
61
|
+
"type": "BinaryExpression",
|
62
|
+
"operator": "===",
|
63
|
+
"left": {
|
64
|
+
"type": "UnaryExpression",
|
65
|
+
"operator": "typeof",
|
66
|
+
"argument": this.callee,
|
67
|
+
"prefix": true
|
68
|
+
},
|
69
|
+
"right": {
|
70
|
+
"type": "Literal",
|
71
|
+
"value": "function",
|
72
|
+
"raw": "\"function\""
|
73
|
+
}
|
74
|
+
};
|
75
|
+
var argument = test.left.argument;
|
76
|
+
if (calleeType === "NullPropagatingExpression") {
|
77
|
+
argument = argument.consequent;
|
78
|
+
test.left.argument = argument;
|
79
|
+
test = {
|
80
|
+
"type": "LogicalExpression",
|
81
|
+
"operator": "&&",
|
82
|
+
"left": this.callee.test,
|
83
|
+
"right": test
|
84
|
+
};
|
85
|
+
}
|
86
|
+
argument.codeGenerated = true;
|
87
|
+
var consequent = new CallExpression(argument, args).codegen();
|
88
|
+
if (this.parent.type === "ExpressionStatement") {
|
89
|
+
this.parent.type = "IfStatement";
|
90
|
+
this.parent.test = test;
|
91
|
+
this.parent.consequent = {
|
92
|
+
type: "BlockStatement",
|
93
|
+
body: [{
|
94
|
+
type: "ExpressionStatement",
|
95
|
+
expression: consequent
|
96
|
+
}]
|
97
|
+
};
|
98
|
+
this.parent.alternate = null;
|
99
|
+
} else {
|
100
|
+
this.type = "ConditionalExpression";
|
101
|
+
this.test = test;
|
102
|
+
this.consequent = consequent;
|
103
|
+
this.alternate = {
|
104
|
+
"type": "UnaryExpression",
|
105
|
+
"operator": "void",
|
106
|
+
"argument": {
|
107
|
+
"type": "Literal",
|
108
|
+
"value": 0,
|
109
|
+
"raw": "0"
|
110
|
+
},
|
111
|
+
"prefix": true
|
112
|
+
};
|
113
|
+
}
|
114
|
+
return this;
|
115
|
+
};
|
116
|
+
NullCheckCallExpression.prototype.hasCallExpression = function() {
|
117
|
+
return true;
|
118
|
+
};
|
119
|
+
NullCheckCallExpression.getNextVariableName = function() {
|
120
|
+
if (!(typeof this.nullCheckIndex !== "undefined" && this.nullCheckIndex !== null)) {
|
121
|
+
this.nullCheckIndex = 0;
|
122
|
+
}
|
123
|
+
return "nullCheck" + this.nullCheckIndex++;
|
124
|
+
};
|
125
|
+
NullCheckCallExpression.resetVariableNames = function() {
|
126
|
+
this.nullCheckIndex = 0;
|
127
|
+
};
|
128
|
+
exports.NullCheckCallExpression = NullCheckCallExpression;
|
129
|
+
return {};
|
130
|
+
});
|
131
|
+
|
132
|
+
//# sourceMappingURL=NullCheckCallExpression.map
|
@@ -0,0 +1,114 @@
|
|
1
|
+
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
2
|
+
"use strict";
|
3
|
+
var Node = module.require("../Node").Node;
|
4
|
+
function NullCoalescingExpression(left, right) {
|
5
|
+
Node.call(this);
|
6
|
+
this.type = "NullCoalescingExpression";
|
7
|
+
this.left = left;
|
8
|
+
this.left.parent = this;
|
9
|
+
this.right = right;
|
10
|
+
this.right.parent = this;
|
11
|
+
}
|
12
|
+
NullCoalescingExpression.prototype = Object.create(Node);
|
13
|
+
NullCoalescingExpression.prototype.codegen = function() {
|
14
|
+
if (!Node.prototype.codegen.call(this)) {
|
15
|
+
return;
|
16
|
+
}
|
17
|
+
var leftType = this.left.type;
|
18
|
+
this.left = this.left.codegen();
|
19
|
+
this.right = this.right.codegen();
|
20
|
+
var context = this.getContext();
|
21
|
+
var addUndefinedCheck = true;
|
22
|
+
if (!!(!!(leftType === "NullPropagatingExpression") || !!(leftType === "NullCoalescingExpression")) || !!(typeof this.left.hasCallExpression === "function" ? this.left.hasCallExpression() : void 0)) {
|
23
|
+
var id = {
|
24
|
+
"type": "Identifier",
|
25
|
+
"name": NullCoalescingExpression.getNextLeftName()
|
26
|
+
};
|
27
|
+
context.node.body.splice(context.position, 0, {
|
28
|
+
"type": "VariableDeclaration",
|
29
|
+
"declarations": [{
|
30
|
+
"type": "VariableDeclarator",
|
31
|
+
"id": id,
|
32
|
+
"init": this.left
|
33
|
+
}],
|
34
|
+
"kind": "let",
|
35
|
+
"codeGenerated": true
|
36
|
+
});
|
37
|
+
this.left = id;
|
38
|
+
addUndefinedCheck = false;
|
39
|
+
}
|
40
|
+
var test = {
|
41
|
+
"type": "BinaryExpression",
|
42
|
+
"operator": "==",
|
43
|
+
"left": this.left,
|
44
|
+
"right": {
|
45
|
+
"type": "Literal",
|
46
|
+
"value": null,
|
47
|
+
"raw": "null"
|
48
|
+
}
|
49
|
+
};
|
50
|
+
if (this.left.type !== "Identifier") {
|
51
|
+
addUndefinedCheck = false;
|
52
|
+
}
|
53
|
+
if (addUndefinedCheck) {
|
54
|
+
test = {
|
55
|
+
"type": "LogicalExpression",
|
56
|
+
"operator": "||",
|
57
|
+
"left": {
|
58
|
+
"type": "BinaryExpression",
|
59
|
+
"operator": "===",
|
60
|
+
"left": {
|
61
|
+
"type": "UnaryExpression",
|
62
|
+
"operator": "typeof",
|
63
|
+
"argument": this.left,
|
64
|
+
"prefix": true
|
65
|
+
},
|
66
|
+
"right": {
|
67
|
+
"type": "Literal",
|
68
|
+
"value": "undefined",
|
69
|
+
"raw": "'undefined'"
|
70
|
+
}
|
71
|
+
},
|
72
|
+
"right": test
|
73
|
+
};
|
74
|
+
}
|
75
|
+
if ((typeof this.parent !== "undefined" && this.parent !== null ? this.parent.type : void 0) === "ExpressionStatement") {
|
76
|
+
if (!this.right.hasCallExpression()) {
|
77
|
+
this.parent.type = "EmptyStatement";
|
78
|
+
return this;
|
79
|
+
}
|
80
|
+
this.parent.type = "IfStatement";
|
81
|
+
this.parent.test = test;
|
82
|
+
this.parent.consequent = {
|
83
|
+
"type": "BlockStatement",
|
84
|
+
"body": [{
|
85
|
+
"type": "ExpressionStatement",
|
86
|
+
"expression": this.right
|
87
|
+
}]
|
88
|
+
};
|
89
|
+
} else {
|
90
|
+
return {
|
91
|
+
"type": "ConditionalExpression",
|
92
|
+
"test": test,
|
93
|
+
"consequent": this.right,
|
94
|
+
"alternate": this.left
|
95
|
+
};
|
96
|
+
}
|
97
|
+
};
|
98
|
+
NullCoalescingExpression.prototype.hasCallExpression = function() {
|
99
|
+
return !!(typeof this.left !== "undefined" && this.left !== null ? this.left.hasCallExpression() : void 0) || !!(typeof this.right !== "undefined" && this.right !== null ? this.right.hasCallExpression() : void 0);
|
100
|
+
};
|
101
|
+
NullCoalescingExpression.getNextLeftName = function() {
|
102
|
+
if (!(typeof this.nullCoalescingIndex !== "undefined" && this.nullCoalescingIndex !== null)) {
|
103
|
+
this.nullCoalescingIndex = 0;
|
104
|
+
}
|
105
|
+
return "nullCoalescing" + this.nullCoalescingIndex++;
|
106
|
+
};
|
107
|
+
NullCoalescingExpression.resetVariableNames = function() {
|
108
|
+
this.nullCoalescingIndex = 0;
|
109
|
+
};
|
110
|
+
exports.NullCoalescingExpression = NullCoalescingExpression;
|
111
|
+
return {};
|
112
|
+
});
|
113
|
+
|
114
|
+
//# sourceMappingURL=NullCoalescingExpression.map
|