react 0.12.0-rc1 → 0.13.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/JSXTransformer.js +1862 -519
- package/dist/react-with-addons.js +4099 -3299
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +3893 -3353
- package/dist/react.min.js +6 -6
- package/lib/BeforeInputEventPlugin.js +388 -111
- package/lib/CSSProperty.js +5 -2
- package/lib/CSSPropertyOperations.js +20 -0
- package/lib/ChangeEventPlugin.js +2 -2
- package/lib/Danger.js +1 -1
- package/lib/DefaultEventPluginOrder.js +0 -1
- package/lib/ExecutionEnvironment.js +2 -3
- package/lib/FallbackCompositionState.js +87 -0
- package/lib/HTMLDOMPropertyConfig.js +7 -0
- package/lib/Object.assign.js +3 -1
- package/lib/React.js +14 -49
- package/lib/ReactBrowserComponentMixin.js +2 -12
- package/lib/ReactBrowserEventEmitter.js +2 -4
- package/lib/ReactCSSTransitionGroup.js +3 -0
- package/lib/ReactCSSTransitionGroupChild.js +8 -0
- package/lib/ReactChildReconciler.js +121 -0
- package/lib/ReactClass.js +916 -0
- package/lib/ReactComponent.js +36 -286
- package/lib/ReactComponentBrowserEnvironment.js +9 -82
- package/lib/ReactComponentEnvironment.js +57 -0
- package/lib/ReactCompositeComponent.js +608 -1026
- package/lib/ReactContext.js +5 -1
- package/lib/ReactDOM.js +2 -7
- package/lib/ReactDOMButton.js +4 -5
- package/lib/ReactDOMComponent.js +97 -69
- package/lib/ReactDOMForm.js +4 -5
- package/lib/ReactDOMIDOperations.js +55 -73
- package/lib/ReactDOMImg.js +3 -5
- package/lib/ReactDOMInput.js +4 -5
- package/lib/ReactDOMOption.js +4 -5
- package/lib/ReactDOMSelect.js +55 -63
- package/lib/ReactDOMSelection.js +5 -1
- package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +54 -34
- package/lib/ReactDOMTextarea.js +4 -5
- package/lib/ReactDefaultInjection.js +13 -7
- package/lib/ReactDefaultPerf.js +7 -6
- package/lib/ReactDefaultPerfAnalysis.js +1 -1
- package/lib/ReactElement.js +24 -5
- package/lib/ReactElementValidator.js +101 -52
- package/lib/ReactEmptyComponent.js +17 -10
- package/lib/ReactInjection.js +6 -4
- package/lib/ReactInputSelection.js +2 -3
- package/lib/ReactInstanceMap.js +47 -0
- package/lib/ReactMount.js +193 -64
- package/lib/ReactMultiChild.js +32 -42
- package/lib/ReactNativeComponent.js +46 -9
- package/lib/ReactOwner.js +3 -47
- package/lib/ReactPerf.js +20 -0
- package/lib/ReactPropTransferer.js +0 -55
- package/lib/ReactPropTypes.js +1 -17
- package/lib/ReactRef.js +96 -0
- package/lib/ReactServerRendering.js +3 -2
- package/lib/ReactTestUtils.js +82 -25
- package/lib/ReactTransitionGroup.js +47 -6
- package/lib/ReactUpdates.js +43 -42
- package/lib/SyntheticMouseEvent.js +1 -3
- package/lib/ViewportMetrics.js +1 -4
- package/lib/accumulate.js +47 -0
- package/lib/cloneWithProps.js +2 -2
- package/lib/copyProperties.js +2 -0
- package/lib/createFullPageComponent.js +2 -2
- package/lib/findDOMNode.js +52 -0
- package/lib/flattenChildren.js +1 -14
- package/lib/getIteratorFn.js +42 -0
- package/lib/instantiateReactComponent.js +88 -65
- package/lib/isNode.js +3 -4
- package/lib/isTextInputElement.js +1 -2
- package/lib/shouldUpdateReactComponent.js +13 -5
- package/lib/traverseAllChildren.js +110 -54
- package/lib/warning.js +1 -1
- package/package.json +1 -1
- package/lib/CompositionEventPlugin.js +0 -257
- package/lib/ReactLegacyElement.js +0 -232
- package/lib/deprecated.js +0 -47
package/dist/JSXTransformer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JSXTransformer v0.
|
|
2
|
+
* JSXTransformer v0.13.0-alpha.1
|
|
3
3
|
*/
|
|
4
4
|
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.JSXTransformer=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
|
5
5
|
/**
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
var buffer = _dereq_('buffer');
|
|
19
19
|
var transform = _dereq_('jstransform').transform;
|
|
20
|
+
var typesSyntax = _dereq_('jstransform/visitors/type-syntax');
|
|
20
21
|
var visitors = _dereq_('./fbtransform/visitors');
|
|
21
22
|
|
|
22
23
|
var headEl;
|
|
@@ -46,6 +47,14 @@ function transformReact(source, options) {
|
|
|
46
47
|
visitorList = visitors.transformVisitors.react;
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
if (options.stripTypes) {
|
|
51
|
+
// Stripping types needs to happen before the other transforms
|
|
52
|
+
// unfortunately, due to bad interactions. For example,
|
|
53
|
+
// es6-rest-param-visitors conflict with stripping rest param type
|
|
54
|
+
// annotation
|
|
55
|
+
source = transform(typesSyntax.visitorList, source, options).code;
|
|
56
|
+
}
|
|
57
|
+
|
|
49
58
|
return transform(visitorList, source, {
|
|
50
59
|
sourceMap: supportsAccessors && options.sourceMap
|
|
51
60
|
});
|
|
@@ -242,7 +251,10 @@ function loadScripts(scripts) {
|
|
|
242
251
|
sourceMap: true
|
|
243
252
|
};
|
|
244
253
|
if (/;harmony=true(;|$)/.test(script.type)) {
|
|
245
|
-
options.harmony = true
|
|
254
|
+
options.harmony = true;
|
|
255
|
+
}
|
|
256
|
+
if (/;stripTypes=true(;|$)/.test(script.type)) {
|
|
257
|
+
options.stripTypes = true;
|
|
246
258
|
}
|
|
247
259
|
|
|
248
260
|
// script.async is always true for non-javascript script tags
|
|
@@ -330,7 +342,7 @@ module.exports = {
|
|
|
330
342
|
exec: exec
|
|
331
343
|
};
|
|
332
344
|
|
|
333
|
-
},{"./fbtransform/visitors":37,"buffer":2,"jstransform":21}],2:[function(_dereq_,module,exports){
|
|
345
|
+
},{"./fbtransform/visitors":37,"buffer":2,"jstransform":21,"jstransform/visitors/type-syntax":33}],2:[function(_dereq_,module,exports){
|
|
334
346
|
/*!
|
|
335
347
|
* The buffer module from node.js, for the browser.
|
|
336
348
|
*
|
|
@@ -682,7 +694,7 @@ function base64Write (buf, string, offset, length) {
|
|
|
682
694
|
}
|
|
683
695
|
|
|
684
696
|
function utf16leWrite (buf, string, offset, length) {
|
|
685
|
-
var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
|
|
697
|
+
var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length, 2)
|
|
686
698
|
return charsWritten
|
|
687
699
|
}
|
|
688
700
|
|
|
@@ -1170,7 +1182,7 @@ Buffer.prototype.copy = function (target, target_start, start, end) {
|
|
|
1170
1182
|
|
|
1171
1183
|
var len = end - start
|
|
1172
1184
|
|
|
1173
|
-
if (len <
|
|
1185
|
+
if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1174
1186
|
for (var i = 0; i < len; i++) {
|
|
1175
1187
|
target[i + target_start] = this[i + start]
|
|
1176
1188
|
}
|
|
@@ -1239,6 +1251,7 @@ var BP = Buffer.prototype
|
|
|
1239
1251
|
* Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
|
|
1240
1252
|
*/
|
|
1241
1253
|
Buffer._augment = function (arr) {
|
|
1254
|
+
arr.constructor = Buffer
|
|
1242
1255
|
arr._isBuffer = true
|
|
1243
1256
|
|
|
1244
1257
|
// save reference to original Uint8Array get/set methods before overwriting
|
|
@@ -1365,7 +1378,8 @@ function base64ToBytes (str) {
|
|
|
1365
1378
|
return base64.toByteArray(str)
|
|
1366
1379
|
}
|
|
1367
1380
|
|
|
1368
|
-
function blitBuffer (src, dst, offset, length) {
|
|
1381
|
+
function blitBuffer (src, dst, offset, length, unitSize) {
|
|
1382
|
+
if (unitSize) length -= length % unitSize;
|
|
1369
1383
|
for (var i = 0; i < length; i++) {
|
|
1370
1384
|
if ((i + offset >= dst.length) || (i >= src.length))
|
|
1371
1385
|
break
|
|
@@ -1942,6 +1956,34 @@ process.chdir = function (dir) {
|
|
|
1942
1956
|
};
|
|
1943
1957
|
|
|
1944
1958
|
},{}],8:[function(_dereq_,module,exports){
|
|
1959
|
+
var Base62 = (function (my) {
|
|
1960
|
+
my.chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
|
|
1961
|
+
|
|
1962
|
+
my.encode = function(i){
|
|
1963
|
+
if (i === 0) {return '0'}
|
|
1964
|
+
var s = ''
|
|
1965
|
+
while (i > 0) {
|
|
1966
|
+
s = this.chars[i % 62] + s
|
|
1967
|
+
i = Math.floor(i/62)
|
|
1968
|
+
}
|
|
1969
|
+
return s
|
|
1970
|
+
};
|
|
1971
|
+
my.decode = function(a,b,c,d){
|
|
1972
|
+
for (
|
|
1973
|
+
b = c = (
|
|
1974
|
+
a === (/\W|_|^$/.test(a += "") || a)
|
|
1975
|
+
) - 1;
|
|
1976
|
+
d = a.charCodeAt(c++);
|
|
1977
|
+
)
|
|
1978
|
+
b = b * 62 + d - [, 48, 29, 87][d >> 5];
|
|
1979
|
+
return b
|
|
1980
|
+
};
|
|
1981
|
+
|
|
1982
|
+
return my;
|
|
1983
|
+
}({}));
|
|
1984
|
+
|
|
1985
|
+
module.exports = Base62
|
|
1986
|
+
},{}],9:[function(_dereq_,module,exports){
|
|
1945
1987
|
/*
|
|
1946
1988
|
Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
|
|
1947
1989
|
Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
|
|
@@ -1979,18 +2021,23 @@ process.chdir = function (dir) {
|
|
|
1979
2021
|
throwError: true, generateStatement: true, peek: true,
|
|
1980
2022
|
parseAssignmentExpression: true, parseBlock: true,
|
|
1981
2023
|
parseClassExpression: true, parseClassDeclaration: true, parseExpression: true,
|
|
2024
|
+
parseDeclareClass: true, parseDeclareFunction: true,
|
|
2025
|
+
parseDeclareModule: true, parseDeclareVariable: true,
|
|
1982
2026
|
parseForStatement: true,
|
|
1983
2027
|
parseFunctionDeclaration: true, parseFunctionExpression: true,
|
|
1984
2028
|
parseFunctionSourceElements: true, parseVariableIdentifier: true,
|
|
1985
|
-
parseImportSpecifier: true,
|
|
2029
|
+
parseImportSpecifier: true, parseInterface: true,
|
|
1986
2030
|
parseLeftHandSideExpression: true, parseParams: true, validateParam: true,
|
|
1987
2031
|
parseSpreadOrAssignmentExpression: true,
|
|
1988
|
-
parseStatement: true, parseSourceElement: true,
|
|
2032
|
+
parseStatement: true, parseSourceElement: true, parseConciseBody: true,
|
|
1989
2033
|
advanceXJSChild: true, isXJSIdentifierStart: true, isXJSIdentifierPart: true,
|
|
1990
2034
|
scanXJSStringLiteral: true, scanXJSIdentifier: true,
|
|
1991
2035
|
parseXJSAttributeValue: true, parseXJSChild: true, parseXJSElement: true, parseXJSExpressionContainer: true, parseXJSEmptyExpression: true,
|
|
1992
|
-
|
|
1993
|
-
|
|
2036
|
+
parseFunctionTypeParam: true,
|
|
2037
|
+
parsePrimaryType: true,
|
|
2038
|
+
parseTypeAlias: true,
|
|
2039
|
+
parseType: true, parseTypeAnnotatableIdentifier: true, parseTypeAnnotation: true,
|
|
2040
|
+
parseYieldExpression: true, parseAwaitExpression: true
|
|
1994
2041
|
*/
|
|
1995
2042
|
|
|
1996
2043
|
(function (root, factory) {
|
|
@@ -2069,24 +2116,32 @@ parseYieldExpression: true
|
|
|
2069
2116
|
'<=', '<', '>', '!=', '!=='];
|
|
2070
2117
|
|
|
2071
2118
|
Syntax = {
|
|
2119
|
+
AnyTypeAnnotation: 'AnyTypeAnnotation',
|
|
2072
2120
|
ArrayExpression: 'ArrayExpression',
|
|
2073
2121
|
ArrayPattern: 'ArrayPattern',
|
|
2122
|
+
ArrayTypeAnnotation: 'ArrayTypeAnnotation',
|
|
2074
2123
|
ArrowFunctionExpression: 'ArrowFunctionExpression',
|
|
2075
2124
|
AssignmentExpression: 'AssignmentExpression',
|
|
2076
2125
|
BinaryExpression: 'BinaryExpression',
|
|
2077
2126
|
BlockStatement: 'BlockStatement',
|
|
2127
|
+
BooleanTypeAnnotation: 'BooleanTypeAnnotation',
|
|
2078
2128
|
BreakStatement: 'BreakStatement',
|
|
2079
2129
|
CallExpression: 'CallExpression',
|
|
2080
2130
|
CatchClause: 'CatchClause',
|
|
2081
2131
|
ClassBody: 'ClassBody',
|
|
2082
2132
|
ClassDeclaration: 'ClassDeclaration',
|
|
2083
2133
|
ClassExpression: 'ClassExpression',
|
|
2134
|
+
ClassImplements: 'ClassImplements',
|
|
2084
2135
|
ClassProperty: 'ClassProperty',
|
|
2085
2136
|
ComprehensionBlock: 'ComprehensionBlock',
|
|
2086
2137
|
ComprehensionExpression: 'ComprehensionExpression',
|
|
2087
2138
|
ConditionalExpression: 'ConditionalExpression',
|
|
2088
2139
|
ContinueStatement: 'ContinueStatement',
|
|
2089
2140
|
DebuggerStatement: 'DebuggerStatement',
|
|
2141
|
+
DeclareClass: 'DeclareClass',
|
|
2142
|
+
DeclareFunction: 'DeclareFunction',
|
|
2143
|
+
DeclareModule: 'DeclareModule',
|
|
2144
|
+
DeclareVariable: 'DeclareVariable',
|
|
2090
2145
|
DoWhileStatement: 'DoWhileStatement',
|
|
2091
2146
|
EmptyStatement: 'EmptyStatement',
|
|
2092
2147
|
ExportDeclaration: 'ExportDeclaration',
|
|
@@ -2098,29 +2153,42 @@ parseYieldExpression: true
|
|
|
2098
2153
|
ForStatement: 'ForStatement',
|
|
2099
2154
|
FunctionDeclaration: 'FunctionDeclaration',
|
|
2100
2155
|
FunctionExpression: 'FunctionExpression',
|
|
2156
|
+
FunctionTypeAnnotation: 'FunctionTypeAnnotation',
|
|
2157
|
+
FunctionTypeParam: 'FunctionTypeParam',
|
|
2158
|
+
GenericTypeAnnotation: 'GenericTypeAnnotation',
|
|
2101
2159
|
Identifier: 'Identifier',
|
|
2102
2160
|
IfStatement: 'IfStatement',
|
|
2103
2161
|
ImportDeclaration: 'ImportDeclaration',
|
|
2162
|
+
ImportDefaultSpecifier: 'ImportDefaultSpecifier',
|
|
2163
|
+
ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
|
|
2104
2164
|
ImportSpecifier: 'ImportSpecifier',
|
|
2165
|
+
InterfaceDeclaration: 'InterfaceDeclaration',
|
|
2166
|
+
InterfaceExtends: 'InterfaceExtends',
|
|
2167
|
+
IntersectionTypeAnnotation: 'IntersectionTypeAnnotation',
|
|
2105
2168
|
LabeledStatement: 'LabeledStatement',
|
|
2106
2169
|
Literal: 'Literal',
|
|
2107
2170
|
LogicalExpression: 'LogicalExpression',
|
|
2108
2171
|
MemberExpression: 'MemberExpression',
|
|
2109
2172
|
MethodDefinition: 'MethodDefinition',
|
|
2110
|
-
|
|
2173
|
+
ModuleSpecifier: 'ModuleSpecifier',
|
|
2111
2174
|
NewExpression: 'NewExpression',
|
|
2175
|
+
NullableTypeAnnotation: 'NullableTypeAnnotation',
|
|
2176
|
+
NumberTypeAnnotation: 'NumberTypeAnnotation',
|
|
2112
2177
|
ObjectExpression: 'ObjectExpression',
|
|
2113
2178
|
ObjectPattern: 'ObjectPattern',
|
|
2114
2179
|
ObjectTypeAnnotation: 'ObjectTypeAnnotation',
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2180
|
+
ObjectTypeCallProperty: 'ObjectTypeCallProperty',
|
|
2181
|
+
ObjectTypeIndexer: 'ObjectTypeIndexer',
|
|
2182
|
+
ObjectTypeProperty: 'ObjectTypeProperty',
|
|
2118
2183
|
Program: 'Program',
|
|
2119
2184
|
Property: 'Property',
|
|
2185
|
+
QualifiedTypeIdentifier: 'QualifiedTypeIdentifier',
|
|
2120
2186
|
ReturnStatement: 'ReturnStatement',
|
|
2121
2187
|
SequenceExpression: 'SequenceExpression',
|
|
2122
2188
|
SpreadElement: 'SpreadElement',
|
|
2123
2189
|
SpreadProperty: 'SpreadProperty',
|
|
2190
|
+
StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation',
|
|
2191
|
+
StringTypeAnnotation: 'StringTypeAnnotation',
|
|
2124
2192
|
SwitchCase: 'SwitchCase',
|
|
2125
2193
|
SwitchStatement: 'SwitchStatement',
|
|
2126
2194
|
TaggedTemplateExpression: 'TaggedTemplateExpression',
|
|
@@ -2128,10 +2196,15 @@ parseYieldExpression: true
|
|
|
2128
2196
|
TemplateLiteral: 'TemplateLiteral',
|
|
2129
2197
|
ThisExpression: 'ThisExpression',
|
|
2130
2198
|
ThrowStatement: 'ThrowStatement',
|
|
2199
|
+
TupleTypeAnnotation: 'TupleTypeAnnotation',
|
|
2131
2200
|
TryStatement: 'TryStatement',
|
|
2132
|
-
|
|
2201
|
+
TypeAlias: 'TypeAlias',
|
|
2133
2202
|
TypeAnnotation: 'TypeAnnotation',
|
|
2203
|
+
TypeofTypeAnnotation: 'TypeofTypeAnnotation',
|
|
2204
|
+
TypeParameterDeclaration: 'TypeParameterDeclaration',
|
|
2205
|
+
TypeParameterInstantiation: 'TypeParameterInstantiation',
|
|
2134
2206
|
UnaryExpression: 'UnaryExpression',
|
|
2207
|
+
UnionTypeAnnotation: 'UnionTypeAnnotation',
|
|
2135
2208
|
UpdateExpression: 'UpdateExpression',
|
|
2136
2209
|
VariableDeclaration: 'VariableDeclaration',
|
|
2137
2210
|
VariableDeclarator: 'VariableDeclarator',
|
|
@@ -2149,7 +2222,8 @@ parseYieldExpression: true
|
|
|
2149
2222
|
XJSAttribute: 'XJSAttribute',
|
|
2150
2223
|
XJSSpreadAttribute: 'XJSSpreadAttribute',
|
|
2151
2224
|
XJSText: 'XJSText',
|
|
2152
|
-
YieldExpression: 'YieldExpression'
|
|
2225
|
+
YieldExpression: 'YieldExpression',
|
|
2226
|
+
AwaitExpression: 'AwaitExpression'
|
|
2153
2227
|
};
|
|
2154
2228
|
|
|
2155
2229
|
PropertyKind = {
|
|
@@ -2186,7 +2260,6 @@ parseYieldExpression: true
|
|
|
2186
2260
|
IllegalBreak: 'Illegal break statement',
|
|
2187
2261
|
IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition',
|
|
2188
2262
|
IllegalReturn: 'Illegal return statement',
|
|
2189
|
-
IllegalYield: 'Illegal yield expression',
|
|
2190
2263
|
IllegalSpread: 'Illegal spread element',
|
|
2191
2264
|
StrictModeWith: 'Strict mode code may not include a with statement',
|
|
2192
2265
|
StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
|
|
@@ -2209,23 +2282,29 @@ parseYieldExpression: true
|
|
|
2209
2282
|
StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
|
|
2210
2283
|
StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
|
|
2211
2284
|
StrictReservedWord: 'Use of future reserved word in strict mode',
|
|
2212
|
-
|
|
2213
|
-
|
|
2285
|
+
MissingFromClause: 'Missing from clause',
|
|
2286
|
+
NoAsAfterImportNamespace: 'Missing as after import *',
|
|
2214
2287
|
InvalidModuleSpecifier: 'Invalid module specifier',
|
|
2215
|
-
NestedModule: 'Module declaration can not be nested',
|
|
2216
2288
|
NoUnintializedConst: 'Const must be initialized',
|
|
2217
2289
|
ComprehensionRequiresBlock: 'Comprehension must have at least one block',
|
|
2218
2290
|
ComprehensionError: 'Comprehension Error',
|
|
2219
2291
|
EachNotAllowed: 'Each is not supported',
|
|
2220
2292
|
InvalidXJSAttributeValue: 'XJS value should be either an expression or a quoted XJS text',
|
|
2221
2293
|
ExpectedXJSClosingTag: 'Expected corresponding XJS closing tag for %0',
|
|
2222
|
-
AdjacentXJSElements: 'Adjacent XJS elements must be wrapped in an enclosing tag'
|
|
2294
|
+
AdjacentXJSElements: 'Adjacent XJS elements must be wrapped in an enclosing tag',
|
|
2295
|
+
ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' +
|
|
2296
|
+
'you are trying to write a function type, but you ended up ' +
|
|
2297
|
+
'writing a grouped type followed by an =>, which is a syntax ' +
|
|
2298
|
+
'error. Remember, function type parameters are named so function ' +
|
|
2299
|
+
'types look like (name1: type1, name2: type2) => returnType. You ' +
|
|
2300
|
+
'probably wrote (type1) => returnType'
|
|
2223
2301
|
};
|
|
2224
2302
|
|
|
2225
2303
|
// See also tools/generate-unicode-regex.py.
|
|
2226
2304
|
Regex = {
|
|
2227
2305
|
NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
|
|
2228
|
-
NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]')
|
|
2306
|
+
NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
|
|
2307
|
+
LeadingZeros: new RegExp('^0+(?!$)')
|
|
2229
2308
|
};
|
|
2230
2309
|
|
|
2231
2310
|
// Ensure the condition is true, otherwise throw an error.
|
|
@@ -2744,7 +2823,9 @@ parseYieldExpression: true
|
|
|
2744
2823
|
|
|
2745
2824
|
// Other 2-character punctuators: ++ -- << >> && ||
|
|
2746
2825
|
|
|
2747
|
-
|
|
2826
|
+
// Don't match these tokens if we're in a type, since they never can
|
|
2827
|
+
// occur and can mess up types like Map<string, Array<string>>
|
|
2828
|
+
if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0) && !state.inType) {
|
|
2748
2829
|
index += 2;
|
|
2749
2830
|
return {
|
|
2750
2831
|
type: Token.Punctuator,
|
|
@@ -3220,7 +3301,7 @@ parseYieldExpression: true
|
|
|
3220
3301
|
}
|
|
3221
3302
|
|
|
3222
3303
|
function scanRegExp() {
|
|
3223
|
-
var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false;
|
|
3304
|
+
var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false, tmp;
|
|
3224
3305
|
|
|
3225
3306
|
lookahead = null;
|
|
3226
3307
|
skipComment();
|
|
@@ -3296,19 +3377,43 @@ parseYieldExpression: true
|
|
|
3296
3377
|
}
|
|
3297
3378
|
}
|
|
3298
3379
|
|
|
3380
|
+
tmp = pattern;
|
|
3381
|
+
if (flags.indexOf('u') >= 0) {
|
|
3382
|
+
// Replace each astral symbol and every Unicode code point
|
|
3383
|
+
// escape sequence that represents such a symbol with a single
|
|
3384
|
+
// ASCII symbol to avoid throwing on regular expressions that
|
|
3385
|
+
// are only valid in combination with the `/u` flag.
|
|
3386
|
+
tmp = tmp
|
|
3387
|
+
.replace(/\\u\{([0-9a-fA-F]{5,6})\}/g, 'x')
|
|
3388
|
+
.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
|
|
3389
|
+
}
|
|
3390
|
+
|
|
3391
|
+
// First, detect invalid regular expressions.
|
|
3299
3392
|
try {
|
|
3300
|
-
value = new RegExp(
|
|
3393
|
+
value = new RegExp(tmp);
|
|
3301
3394
|
} catch (e) {
|
|
3302
3395
|
throwError({}, Messages.InvalidRegExp);
|
|
3303
3396
|
}
|
|
3304
3397
|
|
|
3305
|
-
|
|
3398
|
+
// Return a regular expression object for this pattern-flag pair, or
|
|
3399
|
+
// `null` in case the current environment doesn't support the flags it
|
|
3400
|
+
// uses.
|
|
3401
|
+
try {
|
|
3402
|
+
value = new RegExp(pattern, flags);
|
|
3403
|
+
} catch (exception) {
|
|
3404
|
+
value = null;
|
|
3405
|
+
}
|
|
3306
3406
|
|
|
3407
|
+
peek();
|
|
3307
3408
|
|
|
3308
3409
|
if (extra.tokenize) {
|
|
3309
3410
|
return {
|
|
3310
3411
|
type: Token.RegularExpression,
|
|
3311
3412
|
value: value,
|
|
3413
|
+
regex: {
|
|
3414
|
+
pattern: pattern,
|
|
3415
|
+
flags: flags
|
|
3416
|
+
},
|
|
3312
3417
|
lineNumber: lineNumber,
|
|
3313
3418
|
lineStart: lineStart,
|
|
3314
3419
|
range: [start, index]
|
|
@@ -3317,6 +3422,10 @@ parseYieldExpression: true
|
|
|
3317
3422
|
return {
|
|
3318
3423
|
literal: str,
|
|
3319
3424
|
value: value,
|
|
3425
|
+
regex: {
|
|
3426
|
+
pattern: pattern,
|
|
3427
|
+
flags: flags
|
|
3428
|
+
},
|
|
3320
3429
|
range: [start, index]
|
|
3321
3430
|
};
|
|
3322
3431
|
}
|
|
@@ -3511,6 +3620,13 @@ parseYieldExpression: true
|
|
|
3511
3620
|
return result;
|
|
3512
3621
|
}
|
|
3513
3622
|
|
|
3623
|
+
function rewind(token) {
|
|
3624
|
+
index = token.range[0];
|
|
3625
|
+
lineNumber = token.lineNumber;
|
|
3626
|
+
lineStart = token.lineStart;
|
|
3627
|
+
lookahead = token;
|
|
3628
|
+
}
|
|
3629
|
+
|
|
3514
3630
|
function markerCreate() {
|
|
3515
3631
|
if (!extra.loc && !extra.range) {
|
|
3516
3632
|
return undefined;
|
|
@@ -3738,8 +3854,8 @@ parseYieldExpression: true
|
|
|
3738
3854
|
},
|
|
3739
3855
|
|
|
3740
3856
|
createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression,
|
|
3741
|
-
returnType,
|
|
3742
|
-
|
|
3857
|
+
isAsync, returnType, typeParameters) {
|
|
3858
|
+
var funDecl = {
|
|
3743
3859
|
type: Syntax.FunctionDeclaration,
|
|
3744
3860
|
id: id,
|
|
3745
3861
|
params: params,
|
|
@@ -3749,13 +3865,19 @@ parseYieldExpression: true
|
|
|
3749
3865
|
generator: generator,
|
|
3750
3866
|
expression: expression,
|
|
3751
3867
|
returnType: returnType,
|
|
3752
|
-
|
|
3868
|
+
typeParameters: typeParameters
|
|
3753
3869
|
};
|
|
3870
|
+
|
|
3871
|
+
if (isAsync) {
|
|
3872
|
+
funDecl.async = true;
|
|
3873
|
+
}
|
|
3874
|
+
|
|
3875
|
+
return funDecl;
|
|
3754
3876
|
},
|
|
3755
3877
|
|
|
3756
3878
|
createFunctionExpression: function (id, params, defaults, body, rest, generator, expression,
|
|
3757
|
-
returnType,
|
|
3758
|
-
|
|
3879
|
+
isAsync, returnType, typeParameters) {
|
|
3880
|
+
var funExpr = {
|
|
3759
3881
|
type: Syntax.FunctionExpression,
|
|
3760
3882
|
id: id,
|
|
3761
3883
|
params: params,
|
|
@@ -3765,8 +3887,14 @@ parseYieldExpression: true
|
|
|
3765
3887
|
generator: generator,
|
|
3766
3888
|
expression: expression,
|
|
3767
3889
|
returnType: returnType,
|
|
3768
|
-
|
|
3890
|
+
typeParameters: typeParameters
|
|
3769
3891
|
};
|
|
3892
|
+
|
|
3893
|
+
if (isAsync) {
|
|
3894
|
+
funExpr.async = true;
|
|
3895
|
+
}
|
|
3896
|
+
|
|
3897
|
+
return funExpr;
|
|
3770
3898
|
},
|
|
3771
3899
|
|
|
3772
3900
|
createIdentifier: function (name) {
|
|
@@ -3778,25 +3906,110 @@ parseYieldExpression: true
|
|
|
3778
3906
|
// are added later (like 'loc' and 'range'). This just helps
|
|
3779
3907
|
// keep the shape of Identifier nodes consistent with everything
|
|
3780
3908
|
// else.
|
|
3781
|
-
typeAnnotation: undefined
|
|
3909
|
+
typeAnnotation: undefined,
|
|
3910
|
+
optional: undefined
|
|
3782
3911
|
};
|
|
3783
3912
|
},
|
|
3784
3913
|
|
|
3785
|
-
createTypeAnnotation: function (
|
|
3914
|
+
createTypeAnnotation: function (typeAnnotation) {
|
|
3786
3915
|
return {
|
|
3787
3916
|
type: Syntax.TypeAnnotation,
|
|
3788
|
-
|
|
3789
|
-
|
|
3917
|
+
typeAnnotation: typeAnnotation
|
|
3918
|
+
};
|
|
3919
|
+
},
|
|
3920
|
+
|
|
3921
|
+
createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
|
|
3922
|
+
return {
|
|
3923
|
+
type: Syntax.FunctionTypeAnnotation,
|
|
3790
3924
|
params: params,
|
|
3791
3925
|
returnType: returnType,
|
|
3792
|
-
|
|
3926
|
+
rest: rest,
|
|
3927
|
+
typeParameters: typeParameters
|
|
3928
|
+
};
|
|
3929
|
+
},
|
|
3930
|
+
|
|
3931
|
+
createFunctionTypeParam: function (name, typeAnnotation, optional) {
|
|
3932
|
+
return {
|
|
3933
|
+
type: Syntax.FunctionTypeParam,
|
|
3934
|
+
name: name,
|
|
3935
|
+
typeAnnotation: typeAnnotation,
|
|
3936
|
+
optional: optional
|
|
3793
3937
|
};
|
|
3794
3938
|
},
|
|
3795
3939
|
|
|
3796
|
-
|
|
3940
|
+
createNullableTypeAnnotation: function (typeAnnotation) {
|
|
3797
3941
|
return {
|
|
3798
|
-
type: Syntax.
|
|
3799
|
-
|
|
3942
|
+
type: Syntax.NullableTypeAnnotation,
|
|
3943
|
+
typeAnnotation: typeAnnotation
|
|
3944
|
+
};
|
|
3945
|
+
},
|
|
3946
|
+
|
|
3947
|
+
createArrayTypeAnnotation: function (elementType) {
|
|
3948
|
+
return {
|
|
3949
|
+
type: Syntax.ArrayTypeAnnotation,
|
|
3950
|
+
elementType: elementType
|
|
3951
|
+
};
|
|
3952
|
+
},
|
|
3953
|
+
|
|
3954
|
+
createGenericTypeAnnotation: function (id, typeParameters) {
|
|
3955
|
+
return {
|
|
3956
|
+
type: Syntax.GenericTypeAnnotation,
|
|
3957
|
+
id: id,
|
|
3958
|
+
typeParameters: typeParameters
|
|
3959
|
+
};
|
|
3960
|
+
},
|
|
3961
|
+
|
|
3962
|
+
createQualifiedTypeIdentifier: function (qualification, id) {
|
|
3963
|
+
return {
|
|
3964
|
+
type: Syntax.QualifiedTypeIdentifier,
|
|
3965
|
+
qualification: qualification,
|
|
3966
|
+
id: id
|
|
3967
|
+
};
|
|
3968
|
+
},
|
|
3969
|
+
|
|
3970
|
+
createTypeParameterDeclaration: function (params) {
|
|
3971
|
+
return {
|
|
3972
|
+
type: Syntax.TypeParameterDeclaration,
|
|
3973
|
+
params: params
|
|
3974
|
+
};
|
|
3975
|
+
},
|
|
3976
|
+
|
|
3977
|
+
createTypeParameterInstantiation: function (params) {
|
|
3978
|
+
return {
|
|
3979
|
+
type: Syntax.TypeParameterInstantiation,
|
|
3980
|
+
params: params
|
|
3981
|
+
};
|
|
3982
|
+
},
|
|
3983
|
+
|
|
3984
|
+
createAnyTypeAnnotation: function () {
|
|
3985
|
+
return {
|
|
3986
|
+
type: Syntax.AnyTypeAnnotation
|
|
3987
|
+
};
|
|
3988
|
+
},
|
|
3989
|
+
|
|
3990
|
+
createBooleanTypeAnnotation: function () {
|
|
3991
|
+
return {
|
|
3992
|
+
type: Syntax.BooleanTypeAnnotation
|
|
3993
|
+
};
|
|
3994
|
+
},
|
|
3995
|
+
|
|
3996
|
+
createNumberTypeAnnotation: function () {
|
|
3997
|
+
return {
|
|
3998
|
+
type: Syntax.NumberTypeAnnotation
|
|
3999
|
+
};
|
|
4000
|
+
},
|
|
4001
|
+
|
|
4002
|
+
createStringTypeAnnotation: function () {
|
|
4003
|
+
return {
|
|
4004
|
+
type: Syntax.StringTypeAnnotation
|
|
4005
|
+
};
|
|
4006
|
+
},
|
|
4007
|
+
|
|
4008
|
+
createStringLiteralTypeAnnotation: function (token) {
|
|
4009
|
+
return {
|
|
4010
|
+
type: Syntax.StringLiteralTypeAnnotation,
|
|
4011
|
+
value: token.value,
|
|
4012
|
+
raw: source.slice(token.range[0], token.range[1])
|
|
3800
4013
|
};
|
|
3801
4014
|
},
|
|
3802
4015
|
|
|
@@ -3806,26 +4019,117 @@ parseYieldExpression: true
|
|
|
3806
4019
|
};
|
|
3807
4020
|
},
|
|
3808
4021
|
|
|
3809
|
-
|
|
4022
|
+
createTypeofTypeAnnotation: function (argument) {
|
|
4023
|
+
return {
|
|
4024
|
+
type: Syntax.TypeofTypeAnnotation,
|
|
4025
|
+
argument: argument
|
|
4026
|
+
};
|
|
4027
|
+
},
|
|
4028
|
+
|
|
4029
|
+
createTupleTypeAnnotation: function (types) {
|
|
4030
|
+
return {
|
|
4031
|
+
type: Syntax.TupleTypeAnnotation,
|
|
4032
|
+
types: types
|
|
4033
|
+
};
|
|
4034
|
+
},
|
|
4035
|
+
|
|
4036
|
+
createObjectTypeAnnotation: function (properties, indexers, callProperties) {
|
|
3810
4037
|
return {
|
|
3811
4038
|
type: Syntax.ObjectTypeAnnotation,
|
|
3812
4039
|
properties: properties,
|
|
3813
|
-
|
|
4040
|
+
indexers: indexers,
|
|
4041
|
+
callProperties: callProperties
|
|
4042
|
+
};
|
|
4043
|
+
},
|
|
4044
|
+
|
|
4045
|
+
createObjectTypeIndexer: function (id, key, value, isStatic) {
|
|
4046
|
+
return {
|
|
4047
|
+
type: Syntax.ObjectTypeIndexer,
|
|
4048
|
+
id: id,
|
|
4049
|
+
key: key,
|
|
4050
|
+
value: value,
|
|
4051
|
+
"static": isStatic
|
|
4052
|
+
};
|
|
4053
|
+
},
|
|
4054
|
+
|
|
4055
|
+
createObjectTypeCallProperty: function (value, isStatic) {
|
|
4056
|
+
return {
|
|
4057
|
+
type: Syntax.ObjectTypeCallProperty,
|
|
4058
|
+
value: value,
|
|
4059
|
+
"static": isStatic
|
|
3814
4060
|
};
|
|
3815
4061
|
},
|
|
3816
4062
|
|
|
3817
|
-
|
|
4063
|
+
createObjectTypeProperty: function (key, value, optional, isStatic) {
|
|
3818
4064
|
return {
|
|
3819
|
-
type: Syntax.
|
|
3820
|
-
|
|
3821
|
-
|
|
4065
|
+
type: Syntax.ObjectTypeProperty,
|
|
4066
|
+
key: key,
|
|
4067
|
+
value: value,
|
|
4068
|
+
optional: optional,
|
|
4069
|
+
"static": isStatic
|
|
4070
|
+
};
|
|
4071
|
+
},
|
|
4072
|
+
|
|
4073
|
+
createUnionTypeAnnotation: function (types) {
|
|
4074
|
+
return {
|
|
4075
|
+
type: Syntax.UnionTypeAnnotation,
|
|
4076
|
+
types: types
|
|
4077
|
+
};
|
|
4078
|
+
},
|
|
4079
|
+
|
|
4080
|
+
createIntersectionTypeAnnotation: function (types) {
|
|
4081
|
+
return {
|
|
4082
|
+
type: Syntax.IntersectionTypeAnnotation,
|
|
4083
|
+
types: types
|
|
4084
|
+
};
|
|
4085
|
+
},
|
|
4086
|
+
|
|
4087
|
+
createTypeAlias: function (id, typeParameters, right) {
|
|
4088
|
+
return {
|
|
4089
|
+
type: Syntax.TypeAlias,
|
|
4090
|
+
id: id,
|
|
4091
|
+
typeParameters: typeParameters,
|
|
4092
|
+
right: right
|
|
4093
|
+
};
|
|
4094
|
+
},
|
|
4095
|
+
|
|
4096
|
+
createInterface: function (id, typeParameters, body, extended) {
|
|
4097
|
+
return {
|
|
4098
|
+
type: Syntax.InterfaceDeclaration,
|
|
4099
|
+
id: id,
|
|
4100
|
+
typeParameters: typeParameters,
|
|
4101
|
+
body: body,
|
|
4102
|
+
"extends": extended
|
|
4103
|
+
};
|
|
4104
|
+
},
|
|
4105
|
+
|
|
4106
|
+
createInterfaceExtends: function (id, typeParameters) {
|
|
4107
|
+
return {
|
|
4108
|
+
type: Syntax.InterfaceExtends,
|
|
4109
|
+
id: id,
|
|
4110
|
+
typeParameters: typeParameters
|
|
4111
|
+
};
|
|
4112
|
+
},
|
|
4113
|
+
|
|
4114
|
+
createDeclareFunction: function (id) {
|
|
4115
|
+
return {
|
|
4116
|
+
type: Syntax.DeclareFunction,
|
|
4117
|
+
id: id
|
|
4118
|
+
};
|
|
4119
|
+
},
|
|
4120
|
+
|
|
4121
|
+
createDeclareVariable: function (id) {
|
|
4122
|
+
return {
|
|
4123
|
+
type: Syntax.DeclareVariable,
|
|
4124
|
+
id: id
|
|
3822
4125
|
};
|
|
3823
4126
|
},
|
|
3824
4127
|
|
|
3825
|
-
|
|
4128
|
+
createDeclareModule: function (id, body) {
|
|
3826
4129
|
return {
|
|
3827
|
-
type: Syntax.
|
|
3828
|
-
id:
|
|
4130
|
+
type: Syntax.DeclareModule,
|
|
4131
|
+
id: id,
|
|
4132
|
+
body: body
|
|
3829
4133
|
};
|
|
3830
4134
|
},
|
|
3831
4135
|
|
|
@@ -3923,11 +4227,15 @@ parseYieldExpression: true
|
|
|
3923
4227
|
},
|
|
3924
4228
|
|
|
3925
4229
|
createLiteral: function (token) {
|
|
3926
|
-
|
|
4230
|
+
var object = {
|
|
3927
4231
|
type: Syntax.Literal,
|
|
3928
4232
|
value: token.value,
|
|
3929
4233
|
raw: source.slice(token.range[0], token.range[1])
|
|
3930
4234
|
};
|
|
4235
|
+
if (token.regex) {
|
|
4236
|
+
object.regex = token.regex;
|
|
4237
|
+
}
|
|
4238
|
+
return object;
|
|
3931
4239
|
},
|
|
3932
4240
|
|
|
3933
4241
|
createMemberExpression: function (accessor, object, property) {
|
|
@@ -4122,8 +4430,8 @@ parseYieldExpression: true
|
|
|
4122
4430
|
};
|
|
4123
4431
|
},
|
|
4124
4432
|
|
|
4125
|
-
createArrowFunctionExpression: function (params, defaults, body, rest, expression) {
|
|
4126
|
-
|
|
4433
|
+
createArrowFunctionExpression: function (params, defaults, body, rest, expression, isAsync) {
|
|
4434
|
+
var arrowExpr = {
|
|
4127
4435
|
type: Syntax.ArrowFunctionExpression,
|
|
4128
4436
|
id: null,
|
|
4129
4437
|
params: params,
|
|
@@ -4133,6 +4441,12 @@ parseYieldExpression: true
|
|
|
4133
4441
|
generator: false,
|
|
4134
4442
|
expression: expression
|
|
4135
4443
|
};
|
|
4444
|
+
|
|
4445
|
+
if (isAsync) {
|
|
4446
|
+
arrowExpr.async = true;
|
|
4447
|
+
}
|
|
4448
|
+
|
|
4449
|
+
return arrowExpr;
|
|
4136
4450
|
},
|
|
4137
4451
|
|
|
4138
4452
|
createMethodDefinition: function (propertyType, kind, key, value) {
|
|
@@ -4145,10 +4459,13 @@ parseYieldExpression: true
|
|
|
4145
4459
|
};
|
|
4146
4460
|
},
|
|
4147
4461
|
|
|
4148
|
-
createClassProperty: function (
|
|
4462
|
+
createClassProperty: function (key, typeAnnotation, computed, isStatic) {
|
|
4149
4463
|
return {
|
|
4150
4464
|
type: Syntax.ClassProperty,
|
|
4151
|
-
|
|
4465
|
+
key: key,
|
|
4466
|
+
typeAnnotation: typeAnnotation,
|
|
4467
|
+
computed: computed,
|
|
4468
|
+
"static": isStatic
|
|
4152
4469
|
};
|
|
4153
4470
|
},
|
|
4154
4471
|
|
|
@@ -4159,24 +4476,43 @@ parseYieldExpression: true
|
|
|
4159
4476
|
};
|
|
4160
4477
|
},
|
|
4161
4478
|
|
|
4162
|
-
|
|
4479
|
+
createClassImplements: function (id, typeParameters) {
|
|
4480
|
+
return {
|
|
4481
|
+
type: Syntax.ClassImplements,
|
|
4482
|
+
id: id,
|
|
4483
|
+
typeParameters: typeParameters
|
|
4484
|
+
};
|
|
4485
|
+
},
|
|
4486
|
+
|
|
4487
|
+
createClassExpression: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
|
|
4163
4488
|
return {
|
|
4164
4489
|
type: Syntax.ClassExpression,
|
|
4165
4490
|
id: id,
|
|
4166
4491
|
superClass: superClass,
|
|
4167
4492
|
body: body,
|
|
4168
|
-
|
|
4493
|
+
typeParameters: typeParameters,
|
|
4494
|
+
superTypeParameters: superTypeParameters,
|
|
4495
|
+
"implements": implemented
|
|
4169
4496
|
};
|
|
4170
4497
|
},
|
|
4171
4498
|
|
|
4172
|
-
createClassDeclaration: function (id, superClass, body,
|
|
4499
|
+
createClassDeclaration: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
|
|
4173
4500
|
return {
|
|
4174
4501
|
type: Syntax.ClassDeclaration,
|
|
4175
4502
|
id: id,
|
|
4176
4503
|
superClass: superClass,
|
|
4177
4504
|
body: body,
|
|
4178
|
-
|
|
4179
|
-
|
|
4505
|
+
typeParameters: typeParameters,
|
|
4506
|
+
superTypeParameters: superTypeParameters,
|
|
4507
|
+
"implements": implemented
|
|
4508
|
+
};
|
|
4509
|
+
},
|
|
4510
|
+
|
|
4511
|
+
createModuleSpecifier: function (token) {
|
|
4512
|
+
return {
|
|
4513
|
+
type: Syntax.ModuleSpecifier,
|
|
4514
|
+
value: token.value,
|
|
4515
|
+
raw: source.slice(token.range[0], token.range[1])
|
|
4180
4516
|
};
|
|
4181
4517
|
},
|
|
4182
4518
|
|
|
@@ -4194,9 +4530,24 @@ parseYieldExpression: true
|
|
|
4194
4530
|
};
|
|
4195
4531
|
},
|
|
4196
4532
|
|
|
4197
|
-
|
|
4533
|
+
createImportDefaultSpecifier: function (id) {
|
|
4534
|
+
return {
|
|
4535
|
+
type: Syntax.ImportDefaultSpecifier,
|
|
4536
|
+
id: id
|
|
4537
|
+
};
|
|
4538
|
+
},
|
|
4539
|
+
|
|
4540
|
+
createImportNamespaceSpecifier: function (id) {
|
|
4541
|
+
return {
|
|
4542
|
+
type: Syntax.ImportNamespaceSpecifier,
|
|
4543
|
+
id: id
|
|
4544
|
+
};
|
|
4545
|
+
},
|
|
4546
|
+
|
|
4547
|
+
createExportDeclaration: function (isDefault, declaration, specifiers, source) {
|
|
4198
4548
|
return {
|
|
4199
4549
|
type: Syntax.ExportDeclaration,
|
|
4550
|
+
'default': !!isDefault,
|
|
4200
4551
|
declaration: declaration,
|
|
4201
4552
|
specifiers: specifiers,
|
|
4202
4553
|
source: source
|
|
@@ -4211,11 +4562,10 @@ parseYieldExpression: true
|
|
|
4211
4562
|
};
|
|
4212
4563
|
},
|
|
4213
4564
|
|
|
4214
|
-
createImportDeclaration: function (specifiers,
|
|
4565
|
+
createImportDeclaration: function (specifiers, source) {
|
|
4215
4566
|
return {
|
|
4216
4567
|
type: Syntax.ImportDeclaration,
|
|
4217
4568
|
specifiers: specifiers,
|
|
4218
|
-
kind: kind,
|
|
4219
4569
|
source: source
|
|
4220
4570
|
};
|
|
4221
4571
|
},
|
|
@@ -4228,12 +4578,10 @@ parseYieldExpression: true
|
|
|
4228
4578
|
};
|
|
4229
4579
|
},
|
|
4230
4580
|
|
|
4231
|
-
|
|
4581
|
+
createAwaitExpression: function (argument) {
|
|
4232
4582
|
return {
|
|
4233
|
-
type: Syntax.
|
|
4234
|
-
|
|
4235
|
-
source: source,
|
|
4236
|
-
body: body
|
|
4583
|
+
type: Syntax.AwaitExpression,
|
|
4584
|
+
argument: argument
|
|
4237
4585
|
};
|
|
4238
4586
|
},
|
|
4239
4587
|
|
|
@@ -4357,13 +4705,21 @@ parseYieldExpression: true
|
|
|
4357
4705
|
// Expect the next token to match the specified keyword.
|
|
4358
4706
|
// If not, an exception will be thrown.
|
|
4359
4707
|
|
|
4360
|
-
function expectKeyword(keyword) {
|
|
4708
|
+
function expectKeyword(keyword, contextual) {
|
|
4361
4709
|
var token = lex();
|
|
4362
|
-
if (token.type !== Token.
|
|
4710
|
+
if (token.type !== (contextual ? Token.Identifier : Token.Keyword) ||
|
|
4711
|
+
token.value !== keyword) {
|
|
4363
4712
|
throwUnexpected(token);
|
|
4364
4713
|
}
|
|
4365
4714
|
}
|
|
4366
4715
|
|
|
4716
|
+
// Expect the next token to match the specified contextual keyword.
|
|
4717
|
+
// If not, an exception will be thrown.
|
|
4718
|
+
|
|
4719
|
+
function expectContextualKeyword(keyword) {
|
|
4720
|
+
return expectKeyword(keyword, true);
|
|
4721
|
+
}
|
|
4722
|
+
|
|
4367
4723
|
// Return true if the next token matches the specified punctuator.
|
|
4368
4724
|
|
|
4369
4725
|
function match(value) {
|
|
@@ -4372,15 +4728,15 @@ parseYieldExpression: true
|
|
|
4372
4728
|
|
|
4373
4729
|
// Return true if the next token matches the specified keyword
|
|
4374
4730
|
|
|
4375
|
-
function matchKeyword(keyword) {
|
|
4376
|
-
|
|
4731
|
+
function matchKeyword(keyword, contextual) {
|
|
4732
|
+
var expectedType = contextual ? Token.Identifier : Token.Keyword;
|
|
4733
|
+
return lookahead.type === expectedType && lookahead.value === keyword;
|
|
4377
4734
|
}
|
|
4378
4735
|
|
|
4379
|
-
|
|
4380
4736
|
// Return true if the next token matches the specified contextual keyword
|
|
4381
4737
|
|
|
4382
4738
|
function matchContextualKeyword(keyword) {
|
|
4383
|
-
return
|
|
4739
|
+
return matchKeyword(keyword, true);
|
|
4384
4740
|
}
|
|
4385
4741
|
|
|
4386
4742
|
// Return true if the next token is an assignment operator
|
|
@@ -4406,6 +4762,30 @@ parseYieldExpression: true
|
|
|
4406
4762
|
op === '|=';
|
|
4407
4763
|
}
|
|
4408
4764
|
|
|
4765
|
+
// Note that 'yield' is treated as a keyword in strict mode, but a
|
|
4766
|
+
// contextual keyword (identifier) in non-strict mode, so we need to
|
|
4767
|
+
// use matchKeyword('yield', false) and matchKeyword('yield', true)
|
|
4768
|
+
// (i.e. matchContextualKeyword) appropriately.
|
|
4769
|
+
function matchYield() {
|
|
4770
|
+
return state.yieldAllowed && matchKeyword('yield', !strict);
|
|
4771
|
+
}
|
|
4772
|
+
|
|
4773
|
+
function matchAsync() {
|
|
4774
|
+
var backtrackToken = lookahead, matches = false;
|
|
4775
|
+
|
|
4776
|
+
if (matchContextualKeyword('async')) {
|
|
4777
|
+
lex(); // Make sure peekLineTerminator() starts after 'async'.
|
|
4778
|
+
matches = !peekLineTerminator();
|
|
4779
|
+
rewind(backtrackToken); // Revert the lex().
|
|
4780
|
+
}
|
|
4781
|
+
|
|
4782
|
+
return matches;
|
|
4783
|
+
}
|
|
4784
|
+
|
|
4785
|
+
function matchAwait() {
|
|
4786
|
+
return state.awaitAllowed && matchContextualKeyword('await');
|
|
4787
|
+
}
|
|
4788
|
+
|
|
4409
4789
|
function consumeSemicolon() {
|
|
4410
4790
|
var line, oldIndex = index, oldLineNumber = lineNumber,
|
|
4411
4791
|
oldLineStart = lineStart, oldLookahead = lookahead;
|
|
@@ -4513,12 +4893,14 @@ parseYieldExpression: true
|
|
|
4513
4893
|
// 11.1.5 Object Initialiser
|
|
4514
4894
|
|
|
4515
4895
|
function parsePropertyFunction(options) {
|
|
4516
|
-
var previousStrict, previousYieldAllowed,
|
|
4517
|
-
marker = markerCreate();
|
|
4896
|
+
var previousStrict, previousYieldAllowed, previousAwaitAllowed,
|
|
4897
|
+
params, defaults, body, marker = markerCreate();
|
|
4518
4898
|
|
|
4519
4899
|
previousStrict = strict;
|
|
4520
4900
|
previousYieldAllowed = state.yieldAllowed;
|
|
4521
4901
|
state.yieldAllowed = options.generator;
|
|
4902
|
+
previousAwaitAllowed = state.awaitAllowed;
|
|
4903
|
+
state.awaitAllowed = options.async;
|
|
4522
4904
|
params = options.params || [];
|
|
4523
4905
|
defaults = options.defaults || [];
|
|
4524
4906
|
|
|
@@ -4528,6 +4910,7 @@ parseYieldExpression: true
|
|
|
4528
4910
|
}
|
|
4529
4911
|
strict = previousStrict;
|
|
4530
4912
|
state.yieldAllowed = previousYieldAllowed;
|
|
4913
|
+
state.awaitAllowed = previousAwaitAllowed;
|
|
4531
4914
|
|
|
4532
4915
|
return markerApply(marker, delegate.createFunctionExpression(
|
|
4533
4916
|
null,
|
|
@@ -4537,8 +4920,9 @@ parseYieldExpression: true
|
|
|
4537
4920
|
options.rest || null,
|
|
4538
4921
|
options.generator,
|
|
4539
4922
|
body.type !== Syntax.BlockStatement,
|
|
4923
|
+
options.async,
|
|
4540
4924
|
options.returnType,
|
|
4541
|
-
options.
|
|
4925
|
+
options.typeParameters
|
|
4542
4926
|
));
|
|
4543
4927
|
}
|
|
4544
4928
|
|
|
@@ -4555,14 +4939,14 @@ parseYieldExpression: true
|
|
|
4555
4939
|
throwErrorTolerant(tmp.stricted, tmp.message);
|
|
4556
4940
|
}
|
|
4557
4941
|
|
|
4558
|
-
|
|
4559
4942
|
method = parsePropertyFunction({
|
|
4560
4943
|
params: tmp.params,
|
|
4561
4944
|
defaults: tmp.defaults,
|
|
4562
4945
|
rest: tmp.rest,
|
|
4563
4946
|
generator: options.generator,
|
|
4947
|
+
async: options.async,
|
|
4564
4948
|
returnType: tmp.returnType,
|
|
4565
|
-
|
|
4949
|
+
typeParameters: options.typeParameters
|
|
4566
4950
|
});
|
|
4567
4951
|
|
|
4568
4952
|
strict = previousStrict;
|
|
@@ -4602,46 +4986,138 @@ parseYieldExpression: true
|
|
|
4602
4986
|
|
|
4603
4987
|
function parseObjectProperty() {
|
|
4604
4988
|
var token, key, id, value, param, expr, computed,
|
|
4605
|
-
marker = markerCreate();
|
|
4989
|
+
marker = markerCreate(), returnType;
|
|
4606
4990
|
|
|
4607
4991
|
token = lookahead;
|
|
4608
4992
|
computed = (token.value === '[');
|
|
4609
4993
|
|
|
4610
|
-
if (token.type === Token.Identifier || computed) {
|
|
4611
|
-
|
|
4994
|
+
if (token.type === Token.Identifier || computed || matchAsync()) {
|
|
4612
4995
|
id = parseObjectPropertyKey();
|
|
4613
4996
|
|
|
4997
|
+
if (match(':')) {
|
|
4998
|
+
lex();
|
|
4999
|
+
|
|
5000
|
+
return markerApply(
|
|
5001
|
+
marker,
|
|
5002
|
+
delegate.createProperty(
|
|
5003
|
+
'init',
|
|
5004
|
+
id,
|
|
5005
|
+
parseAssignmentExpression(),
|
|
5006
|
+
false,
|
|
5007
|
+
false,
|
|
5008
|
+
computed
|
|
5009
|
+
)
|
|
5010
|
+
);
|
|
5011
|
+
}
|
|
5012
|
+
|
|
5013
|
+
if (match('(')) {
|
|
5014
|
+
return markerApply(
|
|
5015
|
+
marker,
|
|
5016
|
+
delegate.createProperty(
|
|
5017
|
+
'init',
|
|
5018
|
+
id,
|
|
5019
|
+
parsePropertyMethodFunction({
|
|
5020
|
+
generator: false,
|
|
5021
|
+
async: false
|
|
5022
|
+
}),
|
|
5023
|
+
true,
|
|
5024
|
+
false,
|
|
5025
|
+
computed
|
|
5026
|
+
)
|
|
5027
|
+
);
|
|
5028
|
+
}
|
|
5029
|
+
|
|
4614
5030
|
// Property Assignment: Getter and Setter.
|
|
4615
5031
|
|
|
4616
|
-
if (token.value === 'get'
|
|
5032
|
+
if (token.value === 'get') {
|
|
4617
5033
|
computed = (lookahead.value === '[');
|
|
4618
5034
|
key = parseObjectPropertyKey();
|
|
5035
|
+
|
|
4619
5036
|
expect('(');
|
|
4620
5037
|
expect(')');
|
|
4621
|
-
|
|
5038
|
+
if (match(':')) {
|
|
5039
|
+
returnType = parseTypeAnnotation();
|
|
5040
|
+
}
|
|
5041
|
+
|
|
5042
|
+
return markerApply(
|
|
5043
|
+
marker,
|
|
5044
|
+
delegate.createProperty(
|
|
5045
|
+
'get',
|
|
5046
|
+
key,
|
|
5047
|
+
parsePropertyFunction({
|
|
5048
|
+
generator: false,
|
|
5049
|
+
async: false,
|
|
5050
|
+
returnType: returnType
|
|
5051
|
+
}),
|
|
5052
|
+
false,
|
|
5053
|
+
false,
|
|
5054
|
+
computed
|
|
5055
|
+
)
|
|
5056
|
+
);
|
|
4622
5057
|
}
|
|
4623
|
-
|
|
5058
|
+
|
|
5059
|
+
if (token.value === 'set') {
|
|
4624
5060
|
computed = (lookahead.value === '[');
|
|
4625
5061
|
key = parseObjectPropertyKey();
|
|
5062
|
+
|
|
4626
5063
|
expect('(');
|
|
4627
5064
|
token = lookahead;
|
|
4628
5065
|
param = [ parseTypeAnnotatableIdentifier() ];
|
|
4629
5066
|
expect(')');
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
return markerApply(
|
|
5067
|
+
if (match(':')) {
|
|
5068
|
+
returnType = parseTypeAnnotation();
|
|
5069
|
+
}
|
|
5070
|
+
|
|
5071
|
+
return markerApply(
|
|
5072
|
+
marker,
|
|
5073
|
+
delegate.createProperty(
|
|
5074
|
+
'set',
|
|
5075
|
+
key,
|
|
5076
|
+
parsePropertyFunction({
|
|
5077
|
+
params: param,
|
|
5078
|
+
generator: false,
|
|
5079
|
+
async: false,
|
|
5080
|
+
name: token,
|
|
5081
|
+
returnType: returnType
|
|
5082
|
+
}),
|
|
5083
|
+
false,
|
|
5084
|
+
false,
|
|
5085
|
+
computed
|
|
5086
|
+
)
|
|
5087
|
+
);
|
|
4635
5088
|
}
|
|
4636
|
-
|
|
4637
|
-
|
|
5089
|
+
|
|
5090
|
+
if (token.value === 'async') {
|
|
5091
|
+
computed = (lookahead.value === '[');
|
|
5092
|
+
key = parseObjectPropertyKey();
|
|
5093
|
+
|
|
5094
|
+
return markerApply(
|
|
5095
|
+
marker,
|
|
5096
|
+
delegate.createProperty(
|
|
5097
|
+
'init',
|
|
5098
|
+
key,
|
|
5099
|
+
parsePropertyMethodFunction({
|
|
5100
|
+
generator: false,
|
|
5101
|
+
async: true
|
|
5102
|
+
}),
|
|
5103
|
+
true,
|
|
5104
|
+
false,
|
|
5105
|
+
computed
|
|
5106
|
+
)
|
|
5107
|
+
);
|
|
4638
5108
|
}
|
|
5109
|
+
|
|
4639
5110
|
if (computed) {
|
|
4640
5111
|
// Computed properties can only be used with full notation.
|
|
4641
5112
|
throwUnexpected(lookahead);
|
|
4642
5113
|
}
|
|
4643
|
-
|
|
5114
|
+
|
|
5115
|
+
return markerApply(
|
|
5116
|
+
marker,
|
|
5117
|
+
delegate.createProperty('init', id, id, false, true, false)
|
|
5118
|
+
);
|
|
4644
5119
|
}
|
|
5120
|
+
|
|
4645
5121
|
if (token.type === Token.EOF || token.type === Token.Punctuator) {
|
|
4646
5122
|
if (!match('*')) {
|
|
4647
5123
|
throwUnexpected(token);
|
|
@@ -4768,6 +5244,18 @@ parseYieldExpression: true
|
|
|
4768
5244
|
return expr;
|
|
4769
5245
|
}
|
|
4770
5246
|
|
|
5247
|
+
function matchAsyncFuncExprOrDecl() {
|
|
5248
|
+
var token;
|
|
5249
|
+
|
|
5250
|
+
if (matchAsync()) {
|
|
5251
|
+
token = lookahead2();
|
|
5252
|
+
if (token.type === Token.Keyword && token.value === 'function') {
|
|
5253
|
+
return true;
|
|
5254
|
+
}
|
|
5255
|
+
}
|
|
5256
|
+
|
|
5257
|
+
return false;
|
|
5258
|
+
}
|
|
4771
5259
|
|
|
4772
5260
|
// 11.1 Primary Expressions
|
|
4773
5261
|
|
|
@@ -5344,13 +5832,15 @@ parseYieldExpression: true
|
|
|
5344
5832
|
}
|
|
5345
5833
|
|
|
5346
5834
|
function parseArrowFunctionExpression(options, marker) {
|
|
5347
|
-
var previousStrict, previousYieldAllowed, body;
|
|
5835
|
+
var previousStrict, previousYieldAllowed, previousAwaitAllowed, body;
|
|
5348
5836
|
|
|
5349
5837
|
expect('=>');
|
|
5350
5838
|
|
|
5351
5839
|
previousStrict = strict;
|
|
5352
5840
|
previousYieldAllowed = state.yieldAllowed;
|
|
5353
5841
|
state.yieldAllowed = false;
|
|
5842
|
+
previousAwaitAllowed = state.awaitAllowed;
|
|
5843
|
+
state.awaitAllowed = !!options.async;
|
|
5354
5844
|
body = parseConciseBody();
|
|
5355
5845
|
|
|
5356
5846
|
if (strict && options.firstRestricted) {
|
|
@@ -5362,30 +5852,47 @@ parseYieldExpression: true
|
|
|
5362
5852
|
|
|
5363
5853
|
strict = previousStrict;
|
|
5364
5854
|
state.yieldAllowed = previousYieldAllowed;
|
|
5855
|
+
state.awaitAllowed = previousAwaitAllowed;
|
|
5365
5856
|
|
|
5366
5857
|
return markerApply(marker, delegate.createArrowFunctionExpression(
|
|
5367
5858
|
options.params,
|
|
5368
5859
|
options.defaults,
|
|
5369
5860
|
body,
|
|
5370
5861
|
options.rest,
|
|
5371
|
-
body.type !== Syntax.BlockStatement
|
|
5862
|
+
body.type !== Syntax.BlockStatement,
|
|
5863
|
+
!!options.async
|
|
5372
5864
|
));
|
|
5373
5865
|
}
|
|
5374
5866
|
|
|
5375
5867
|
function parseAssignmentExpression() {
|
|
5376
|
-
var marker, expr, token, params, oldParenthesizedCount
|
|
5868
|
+
var marker, expr, token, params, oldParenthesizedCount,
|
|
5869
|
+
backtrackToken = lookahead, possiblyAsync = false;
|
|
5377
5870
|
|
|
5378
|
-
|
|
5379
|
-
// contextual keyword (identifier) in non-strict mode, so we need
|
|
5380
|
-
// to use matchKeyword and matchContextualKeyword appropriately.
|
|
5381
|
-
if ((state.yieldAllowed && matchContextualKeyword('yield')) || (strict && matchKeyword('yield'))) {
|
|
5871
|
+
if (matchYield()) {
|
|
5382
5872
|
return parseYieldExpression();
|
|
5383
5873
|
}
|
|
5384
5874
|
|
|
5875
|
+
if (matchAwait()) {
|
|
5876
|
+
return parseAwaitExpression();
|
|
5877
|
+
}
|
|
5878
|
+
|
|
5385
5879
|
oldParenthesizedCount = state.parenthesizedCount;
|
|
5386
5880
|
|
|
5387
5881
|
marker = markerCreate();
|
|
5388
5882
|
|
|
5883
|
+
if (matchAsyncFuncExprOrDecl()) {
|
|
5884
|
+
return parseFunctionExpression();
|
|
5885
|
+
}
|
|
5886
|
+
|
|
5887
|
+
if (matchAsync()) {
|
|
5888
|
+
// We can't be completely sure that this 'async' token is
|
|
5889
|
+
// actually a contextual keyword modifying a function
|
|
5890
|
+
// expression, so we might have to un-lex() it later by
|
|
5891
|
+
// calling rewind(backtrackToken).
|
|
5892
|
+
possiblyAsync = true;
|
|
5893
|
+
lex();
|
|
5894
|
+
}
|
|
5895
|
+
|
|
5389
5896
|
if (match('(')) {
|
|
5390
5897
|
token = lookahead2();
|
|
5391
5898
|
if ((token.type === Token.Punctuator && token.value === ')') || token.value === '...') {
|
|
@@ -5393,11 +5900,21 @@ parseYieldExpression: true
|
|
|
5393
5900
|
if (!match('=>')) {
|
|
5394
5901
|
throwUnexpected(lex());
|
|
5395
5902
|
}
|
|
5903
|
+
params.async = possiblyAsync;
|
|
5396
5904
|
return parseArrowFunctionExpression(params, marker);
|
|
5397
5905
|
}
|
|
5398
5906
|
}
|
|
5399
5907
|
|
|
5400
5908
|
token = lookahead;
|
|
5909
|
+
|
|
5910
|
+
// If the 'async' keyword is not followed by a '(' character or an
|
|
5911
|
+
// identifier, then it can't be an arrow function modifier, and we
|
|
5912
|
+
// should interpret it as a normal identifer.
|
|
5913
|
+
if (possiblyAsync && !match('(') && token.type !== Token.Identifier) {
|
|
5914
|
+
possiblyAsync = false;
|
|
5915
|
+
rewind(backtrackToken);
|
|
5916
|
+
}
|
|
5917
|
+
|
|
5401
5918
|
expr = parseConditionalExpression();
|
|
5402
5919
|
|
|
5403
5920
|
if (match('=>') &&
|
|
@@ -5409,10 +5926,20 @@ parseYieldExpression: true
|
|
|
5409
5926
|
params = reinterpretAsCoverFormalsList(expr.expressions);
|
|
5410
5927
|
}
|
|
5411
5928
|
if (params) {
|
|
5929
|
+
params.async = possiblyAsync;
|
|
5412
5930
|
return parseArrowFunctionExpression(params, marker);
|
|
5413
5931
|
}
|
|
5414
5932
|
}
|
|
5415
5933
|
|
|
5934
|
+
// If we haven't returned by now, then the 'async' keyword was not
|
|
5935
|
+
// a function modifier, and we should rewind and interpret it as a
|
|
5936
|
+
// normal identifier.
|
|
5937
|
+
if (possiblyAsync) {
|
|
5938
|
+
possiblyAsync = false;
|
|
5939
|
+
rewind(backtrackToken);
|
|
5940
|
+
expr = parseConditionalExpression();
|
|
5941
|
+
}
|
|
5942
|
+
|
|
5416
5943
|
if (matchAssign()) {
|
|
5417
5944
|
// 11.13.1
|
|
5418
5945
|
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
|
|
@@ -5518,118 +6045,446 @@ parseYieldExpression: true
|
|
|
5518
6045
|
|
|
5519
6046
|
// 12.2 Variable Statement
|
|
5520
6047
|
|
|
5521
|
-
function
|
|
5522
|
-
var
|
|
5523
|
-
|
|
6048
|
+
function parseTypeParameterDeclaration() {
|
|
6049
|
+
var marker = markerCreate(), paramTypes = [];
|
|
6050
|
+
|
|
6051
|
+
expect('<');
|
|
6052
|
+
while (!match('>')) {
|
|
6053
|
+
paramTypes.push(parseVariableIdentifier());
|
|
6054
|
+
if (!match('>')) {
|
|
6055
|
+
expect(',');
|
|
6056
|
+
}
|
|
6057
|
+
}
|
|
6058
|
+
expect('>');
|
|
6059
|
+
|
|
6060
|
+
return markerApply(marker, delegate.createTypeParameterDeclaration(
|
|
6061
|
+
paramTypes
|
|
6062
|
+
));
|
|
6063
|
+
}
|
|
6064
|
+
|
|
6065
|
+
function parseTypeParameterInstantiation() {
|
|
6066
|
+
var marker = markerCreate(), oldInType = state.inType, paramTypes = [];
|
|
6067
|
+
|
|
6068
|
+
state.inType = true;
|
|
6069
|
+
|
|
6070
|
+
expect('<');
|
|
6071
|
+
while (!match('>')) {
|
|
6072
|
+
paramTypes.push(parseType());
|
|
6073
|
+
if (!match('>')) {
|
|
6074
|
+
expect(',');
|
|
6075
|
+
}
|
|
6076
|
+
}
|
|
6077
|
+
expect('>');
|
|
6078
|
+
|
|
6079
|
+
state.inType = oldInType;
|
|
6080
|
+
|
|
6081
|
+
return markerApply(marker, delegate.createTypeParameterInstantiation(
|
|
6082
|
+
paramTypes
|
|
6083
|
+
));
|
|
6084
|
+
}
|
|
6085
|
+
|
|
6086
|
+
function parseObjectTypeIndexer(marker, isStatic) {
|
|
6087
|
+
var id, key, value;
|
|
6088
|
+
|
|
6089
|
+
expect('[');
|
|
6090
|
+
id = parseObjectPropertyKey();
|
|
6091
|
+
expect(':');
|
|
6092
|
+
key = parseType();
|
|
6093
|
+
expect(']');
|
|
6094
|
+
expect(':');
|
|
6095
|
+
value = parseType();
|
|
6096
|
+
|
|
6097
|
+
return markerApply(marker, delegate.createObjectTypeIndexer(
|
|
6098
|
+
id,
|
|
6099
|
+
key,
|
|
6100
|
+
value,
|
|
6101
|
+
isStatic
|
|
6102
|
+
));
|
|
6103
|
+
}
|
|
6104
|
+
|
|
6105
|
+
function parseObjectTypeMethodish(marker) {
|
|
6106
|
+
var params = [], rest = null, returnType, typeParameters = null;
|
|
6107
|
+
if (match('<')) {
|
|
6108
|
+
typeParameters = parseTypeParameterDeclaration();
|
|
6109
|
+
}
|
|
6110
|
+
|
|
6111
|
+
expect('(');
|
|
6112
|
+
while (lookahead.type === Token.Identifier) {
|
|
6113
|
+
params.push(parseFunctionTypeParam());
|
|
6114
|
+
if (!match(')')) {
|
|
6115
|
+
expect(',');
|
|
6116
|
+
}
|
|
6117
|
+
}
|
|
6118
|
+
|
|
6119
|
+
if (match('...')) {
|
|
6120
|
+
lex();
|
|
6121
|
+
rest = parseFunctionTypeParam();
|
|
6122
|
+
}
|
|
6123
|
+
expect(')');
|
|
6124
|
+
expect(':');
|
|
6125
|
+
returnType = parseType();
|
|
6126
|
+
|
|
6127
|
+
return markerApply(marker, delegate.createFunctionTypeAnnotation(
|
|
6128
|
+
params,
|
|
6129
|
+
returnType,
|
|
6130
|
+
rest,
|
|
6131
|
+
typeParameters
|
|
6132
|
+
));
|
|
6133
|
+
}
|
|
6134
|
+
|
|
6135
|
+
function parseObjectTypeMethod(marker, isStatic, key) {
|
|
6136
|
+
var optional = false, value;
|
|
6137
|
+
value = parseObjectTypeMethodish(marker);
|
|
6138
|
+
|
|
6139
|
+
return markerApply(marker, delegate.createObjectTypeProperty(
|
|
6140
|
+
key,
|
|
6141
|
+
value,
|
|
6142
|
+
optional,
|
|
6143
|
+
isStatic
|
|
6144
|
+
));
|
|
6145
|
+
}
|
|
6146
|
+
|
|
6147
|
+
function parseObjectTypeCallProperty(marker, isStatic) {
|
|
6148
|
+
var valueMarker = markerCreate();
|
|
6149
|
+
return markerApply(marker, delegate.createObjectTypeCallProperty(
|
|
6150
|
+
parseObjectTypeMethodish(valueMarker),
|
|
6151
|
+
isStatic
|
|
6152
|
+
));
|
|
6153
|
+
}
|
|
6154
|
+
|
|
6155
|
+
function parseObjectType(allowStatic) {
|
|
6156
|
+
var callProperties = [], indexers = [], marker, optional = false,
|
|
6157
|
+
properties = [], property, propertyKey, propertyTypeAnnotation,
|
|
6158
|
+
token, isStatic;
|
|
5524
6159
|
|
|
5525
6160
|
expect('{');
|
|
5526
6161
|
|
|
5527
6162
|
while (!match('}')) {
|
|
5528
6163
|
marker = markerCreate();
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
'init',
|
|
5534
|
-
propertyKey,
|
|
5535
|
-
propertyTypeAnnotation,
|
|
5536
|
-
isMethod,
|
|
5537
|
-
false
|
|
5538
|
-
)));
|
|
6164
|
+
if (allowStatic && matchContextualKeyword('static')) {
|
|
6165
|
+
token = lex();
|
|
6166
|
+
isStatic = true;
|
|
6167
|
+
}
|
|
5539
6168
|
|
|
5540
|
-
if (
|
|
5541
|
-
|
|
5542
|
-
|
|
6169
|
+
if (match('[')) {
|
|
6170
|
+
indexers.push(parseObjectTypeIndexer(marker, isStatic));
|
|
6171
|
+
} else if (match('(') || match('<')) {
|
|
6172
|
+
callProperties.push(parseObjectTypeCallProperty(marker, allowStatic));
|
|
6173
|
+
} else {
|
|
6174
|
+
if (isStatic && match(':')) {
|
|
6175
|
+
propertyKey = markerApply(marker, delegate.createIdentifier(token));
|
|
6176
|
+
throwErrorTolerant(token, Messages.StrictReservedWord);
|
|
5543
6177
|
} else {
|
|
5544
|
-
|
|
6178
|
+
propertyKey = parseObjectPropertyKey();
|
|
6179
|
+
}
|
|
6180
|
+
if (match('<') || match('(')) {
|
|
6181
|
+
// This is a method property
|
|
6182
|
+
properties.push(parseObjectTypeMethod(marker, isStatic, propertyKey));
|
|
6183
|
+
} else {
|
|
6184
|
+
if (match('?')) {
|
|
6185
|
+
lex();
|
|
6186
|
+
optional = true;
|
|
6187
|
+
}
|
|
6188
|
+
expect(':');
|
|
6189
|
+
propertyTypeAnnotation = parseType();
|
|
6190
|
+
properties.push(markerApply(marker, delegate.createObjectTypeProperty(
|
|
6191
|
+
propertyKey,
|
|
6192
|
+
propertyTypeAnnotation,
|
|
6193
|
+
optional,
|
|
6194
|
+
isStatic
|
|
6195
|
+
)));
|
|
5545
6196
|
}
|
|
5546
6197
|
}
|
|
6198
|
+
|
|
6199
|
+
if (match(';')) {
|
|
6200
|
+
lex();
|
|
6201
|
+
} else if (!match('}')) {
|
|
6202
|
+
throwUnexpected(lookahead);
|
|
6203
|
+
}
|
|
5547
6204
|
}
|
|
5548
6205
|
|
|
5549
6206
|
expect('}');
|
|
5550
6207
|
|
|
5551
|
-
return delegate.createObjectTypeAnnotation(
|
|
6208
|
+
return delegate.createObjectTypeAnnotation(
|
|
6209
|
+
properties,
|
|
6210
|
+
indexers,
|
|
6211
|
+
callProperties
|
|
6212
|
+
);
|
|
6213
|
+
}
|
|
6214
|
+
|
|
6215
|
+
function parseGenericType() {
|
|
6216
|
+
var marker = markerCreate(), returnType = null,
|
|
6217
|
+
typeParameters = null, typeIdentifier,
|
|
6218
|
+
typeIdentifierMarker = markerCreate;
|
|
6219
|
+
|
|
6220
|
+
typeIdentifier = parseVariableIdentifier();
|
|
6221
|
+
|
|
6222
|
+
while (match('.')) {
|
|
6223
|
+
expect('.');
|
|
6224
|
+
typeIdentifier = markerApply(marker, delegate.createQualifiedTypeIdentifier(
|
|
6225
|
+
typeIdentifier,
|
|
6226
|
+
parseVariableIdentifier()
|
|
6227
|
+
));
|
|
6228
|
+
}
|
|
6229
|
+
|
|
6230
|
+
if (match('<')) {
|
|
6231
|
+
typeParameters = parseTypeParameterInstantiation();
|
|
6232
|
+
}
|
|
6233
|
+
|
|
6234
|
+
return markerApply(marker, delegate.createGenericTypeAnnotation(
|
|
6235
|
+
typeIdentifier,
|
|
6236
|
+
typeParameters
|
|
6237
|
+
));
|
|
5552
6238
|
}
|
|
5553
6239
|
|
|
5554
|
-
function
|
|
6240
|
+
function parseVoidType() {
|
|
5555
6241
|
var marker = markerCreate();
|
|
5556
6242
|
expectKeyword('void');
|
|
5557
6243
|
return markerApply(marker, delegate.createVoidTypeAnnotation());
|
|
5558
6244
|
}
|
|
5559
6245
|
|
|
5560
|
-
function
|
|
5561
|
-
var marker = markerCreate()
|
|
6246
|
+
function parseTypeofType() {
|
|
6247
|
+
var argument, marker = markerCreate();
|
|
6248
|
+
expectKeyword('typeof');
|
|
6249
|
+
argument = parsePrimaryType();
|
|
6250
|
+
return markerApply(marker, delegate.createTypeofTypeAnnotation(
|
|
6251
|
+
argument
|
|
6252
|
+
));
|
|
6253
|
+
}
|
|
6254
|
+
|
|
6255
|
+
function parseTupleType() {
|
|
6256
|
+
var marker = markerCreate(), types = [];
|
|
6257
|
+
expect('[');
|
|
6258
|
+
// We allow trailing commas
|
|
6259
|
+
while (index < length && !match(']')) {
|
|
6260
|
+
types.push(parseType());
|
|
6261
|
+
if (match(']')) {
|
|
6262
|
+
break;
|
|
6263
|
+
}
|
|
6264
|
+
expect(',');
|
|
6265
|
+
}
|
|
6266
|
+
expect(']');
|
|
6267
|
+
return markerApply(marker, delegate.createTupleTypeAnnotation(
|
|
6268
|
+
types
|
|
6269
|
+
));
|
|
6270
|
+
}
|
|
5562
6271
|
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
6272
|
+
function parseFunctionTypeParam() {
|
|
6273
|
+
var marker = markerCreate(), name, optional = false, typeAnnotation;
|
|
6274
|
+
name = parseVariableIdentifier();
|
|
6275
|
+
if (match('?')) {
|
|
6276
|
+
lex();
|
|
6277
|
+
optional = true;
|
|
6278
|
+
}
|
|
6279
|
+
expect(':');
|
|
6280
|
+
typeAnnotation = parseType();
|
|
6281
|
+
return markerApply(marker, delegate.createFunctionTypeParam(
|
|
6282
|
+
name,
|
|
6283
|
+
typeAnnotation,
|
|
6284
|
+
optional
|
|
6285
|
+
));
|
|
6286
|
+
}
|
|
6287
|
+
|
|
6288
|
+
function parseFunctionTypeParams() {
|
|
6289
|
+
var ret = { params: [], rest: null };
|
|
6290
|
+
while (lookahead.type === Token.Identifier) {
|
|
6291
|
+
ret.params.push(parseFunctionTypeParam());
|
|
6292
|
+
if (!match(')')) {
|
|
5567
6293
|
expect(',');
|
|
5568
6294
|
}
|
|
5569
6295
|
}
|
|
5570
|
-
expect('>');
|
|
5571
6296
|
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
6297
|
+
if (match('...')) {
|
|
6298
|
+
lex();
|
|
6299
|
+
ret.rest = parseFunctionTypeParam();
|
|
6300
|
+
}
|
|
6301
|
+
return ret;
|
|
5575
6302
|
}
|
|
5576
6303
|
|
|
5577
|
-
|
|
6304
|
+
// The parsing of types roughly parallels the parsing of expressions, and
|
|
6305
|
+
// primary types are kind of like primary expressions...they're the
|
|
6306
|
+
// primitives with which other types are constructed.
|
|
6307
|
+
function parsePrimaryType() {
|
|
5578
6308
|
var typeIdentifier = null, params = null, returnType = null,
|
|
5579
|
-
|
|
5580
|
-
|
|
6309
|
+
marker = markerCreate(), rest = null, tmp,
|
|
6310
|
+
typeParameters, token, type, isGroupedType = false;
|
|
5581
6311
|
|
|
5582
|
-
|
|
5583
|
-
|
|
6312
|
+
switch (lookahead.type) {
|
|
6313
|
+
case Token.Identifier:
|
|
6314
|
+
switch (lookahead.value) {
|
|
6315
|
+
case 'any':
|
|
6316
|
+
lex();
|
|
6317
|
+
return markerApply(marker, delegate.createAnyTypeAnnotation());
|
|
6318
|
+
case 'bool': // fallthrough
|
|
6319
|
+
case 'boolean':
|
|
6320
|
+
lex();
|
|
6321
|
+
return markerApply(marker, delegate.createBooleanTypeAnnotation());
|
|
6322
|
+
case 'number':
|
|
6323
|
+
lex();
|
|
6324
|
+
return markerApply(marker, delegate.createNumberTypeAnnotation());
|
|
6325
|
+
case 'string':
|
|
6326
|
+
lex();
|
|
6327
|
+
return markerApply(marker, delegate.createStringTypeAnnotation());
|
|
6328
|
+
}
|
|
6329
|
+
return markerApply(marker, parseGenericType());
|
|
6330
|
+
case Token.Punctuator:
|
|
6331
|
+
switch (lookahead.value) {
|
|
6332
|
+
case '{':
|
|
6333
|
+
return markerApply(marker, parseObjectType());
|
|
6334
|
+
case '[':
|
|
6335
|
+
return parseTupleType();
|
|
6336
|
+
case '<':
|
|
6337
|
+
typeParameters = parseTypeParameterDeclaration();
|
|
6338
|
+
expect('(');
|
|
6339
|
+
tmp = parseFunctionTypeParams();
|
|
6340
|
+
params = tmp.params;
|
|
6341
|
+
rest = tmp.rest;
|
|
6342
|
+
expect(')');
|
|
6343
|
+
|
|
6344
|
+
expect('=>');
|
|
6345
|
+
|
|
6346
|
+
returnType = parseType();
|
|
6347
|
+
|
|
6348
|
+
return markerApply(marker, delegate.createFunctionTypeAnnotation(
|
|
6349
|
+
params,
|
|
6350
|
+
returnType,
|
|
6351
|
+
rest,
|
|
6352
|
+
typeParameters
|
|
6353
|
+
));
|
|
6354
|
+
case '(':
|
|
6355
|
+
lex();
|
|
6356
|
+
// Check to see if this is actually a grouped type
|
|
6357
|
+
if (!match(')') && !match('...')) {
|
|
6358
|
+
if (lookahead.type === Token.Identifier) {
|
|
6359
|
+
token = lookahead2();
|
|
6360
|
+
isGroupedType = token.value !== '?' && token.value !== ':';
|
|
6361
|
+
} else {
|
|
6362
|
+
isGroupedType = true;
|
|
6363
|
+
}
|
|
6364
|
+
}
|
|
6365
|
+
|
|
6366
|
+
if (isGroupedType) {
|
|
6367
|
+
type = parseType();
|
|
6368
|
+
expect(')');
|
|
6369
|
+
|
|
6370
|
+
// If we see a => next then someone was probably confused about
|
|
6371
|
+
// function types, so we can provide a better error message
|
|
6372
|
+
if (match('=>')) {
|
|
6373
|
+
throwError({}, Messages.ConfusedAboutFunctionType);
|
|
6374
|
+
}
|
|
6375
|
+
|
|
6376
|
+
return type;
|
|
6377
|
+
}
|
|
6378
|
+
|
|
6379
|
+
tmp = parseFunctionTypeParams();
|
|
6380
|
+
params = tmp.params;
|
|
6381
|
+
rest = tmp.rest;
|
|
6382
|
+
|
|
6383
|
+
expect(')');
|
|
6384
|
+
|
|
6385
|
+
expect('=>');
|
|
6386
|
+
|
|
6387
|
+
returnType = parseType();
|
|
6388
|
+
|
|
6389
|
+
return markerApply(marker, delegate.createFunctionTypeAnnotation(
|
|
6390
|
+
params,
|
|
6391
|
+
returnType,
|
|
6392
|
+
rest,
|
|
6393
|
+
null /* typeParameters */
|
|
6394
|
+
));
|
|
6395
|
+
}
|
|
6396
|
+
break;
|
|
6397
|
+
case Token.Keyword:
|
|
6398
|
+
switch (lookahead.value) {
|
|
6399
|
+
case 'void':
|
|
6400
|
+
return markerApply(marker, parseVoidType());
|
|
6401
|
+
case 'typeof':
|
|
6402
|
+
return markerApply(marker, parseTypeofType());
|
|
6403
|
+
}
|
|
6404
|
+
break;
|
|
6405
|
+
case Token.StringLiteral:
|
|
6406
|
+
token = lex();
|
|
6407
|
+
if (token.octal) {
|
|
6408
|
+
throwError(token, Messages.StrictOctalLiteral);
|
|
6409
|
+
}
|
|
6410
|
+
return markerApply(marker, delegate.createStringLiteralTypeAnnotation(
|
|
6411
|
+
token
|
|
6412
|
+
));
|
|
5584
6413
|
}
|
|
5585
6414
|
|
|
6415
|
+
throwUnexpected(lookahead);
|
|
6416
|
+
}
|
|
6417
|
+
|
|
6418
|
+
function parsePostfixType() {
|
|
6419
|
+
var marker = markerCreate(), t = parsePrimaryType();
|
|
6420
|
+
if (match('[')) {
|
|
6421
|
+
expect('[');
|
|
6422
|
+
expect(']');
|
|
6423
|
+
return markerApply(marker, delegate.createArrayTypeAnnotation(t));
|
|
6424
|
+
}
|
|
6425
|
+
return t;
|
|
6426
|
+
}
|
|
6427
|
+
|
|
6428
|
+
function parsePrefixType() {
|
|
6429
|
+
var marker = markerCreate();
|
|
5586
6430
|
if (match('?')) {
|
|
5587
6431
|
lex();
|
|
5588
|
-
|
|
6432
|
+
return markerApply(marker, delegate.createNullableTypeAnnotation(
|
|
6433
|
+
parsePrefixType()
|
|
6434
|
+
));
|
|
5589
6435
|
}
|
|
6436
|
+
return parsePostfixType();
|
|
6437
|
+
}
|
|
5590
6438
|
|
|
5591
|
-
|
|
5592
|
-
|
|
6439
|
+
|
|
6440
|
+
function parseIntersectionType() {
|
|
6441
|
+
var marker = markerCreate(), type, types;
|
|
6442
|
+
type = parsePrefixType();
|
|
6443
|
+
types = [type];
|
|
6444
|
+
while (match('&')) {
|
|
6445
|
+
lex();
|
|
6446
|
+
types.push(parsePrefixType());
|
|
5593
6447
|
}
|
|
5594
6448
|
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
6449
|
+
return types.length === 1 ?
|
|
6450
|
+
type :
|
|
6451
|
+
markerApply(marker, delegate.createIntersectionTypeAnnotation(
|
|
6452
|
+
types
|
|
6453
|
+
));
|
|
6454
|
+
}
|
|
6455
|
+
|
|
6456
|
+
function parseUnionType() {
|
|
6457
|
+
var marker = markerCreate(), type, types;
|
|
6458
|
+
type = parseIntersectionType();
|
|
6459
|
+
types = [type];
|
|
6460
|
+
while (match('|')) {
|
|
5601
6461
|
lex();
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
6462
|
+
types.push(parseIntersectionType());
|
|
6463
|
+
}
|
|
6464
|
+
return types.length === 1 ?
|
|
6465
|
+
type :
|
|
6466
|
+
markerApply(marker, delegate.createUnionTypeAnnotation(
|
|
6467
|
+
types
|
|
5607
6468
|
));
|
|
5608
|
-
|
|
5609
|
-
expect(',');
|
|
5610
|
-
}
|
|
5611
|
-
}
|
|
5612
|
-
expect(')');
|
|
6469
|
+
}
|
|
5613
6470
|
|
|
5614
|
-
|
|
5615
|
-
|
|
6471
|
+
function parseType() {
|
|
6472
|
+
var oldInType = state.inType, type;
|
|
6473
|
+
state.inType = true;
|
|
5616
6474
|
|
|
5617
|
-
|
|
5618
|
-
} else {
|
|
5619
|
-
if (!matchKeyword('void')) {
|
|
5620
|
-
throwUnexpected(lookahead);
|
|
5621
|
-
} else {
|
|
5622
|
-
return markerApply(marker, parseVoidTypeAnnotation());
|
|
5623
|
-
}
|
|
5624
|
-
}
|
|
6475
|
+
type = parseUnionType();
|
|
5625
6476
|
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
6477
|
+
state.inType = oldInType;
|
|
6478
|
+
return type;
|
|
6479
|
+
}
|
|
6480
|
+
|
|
6481
|
+
function parseTypeAnnotation() {
|
|
6482
|
+
var marker = markerCreate(), type;
|
|
6483
|
+
|
|
6484
|
+
expect(':');
|
|
6485
|
+
type = parseType();
|
|
6486
|
+
|
|
6487
|
+
return markerApply(marker, delegate.createTypeAnnotation(type));
|
|
5633
6488
|
}
|
|
5634
6489
|
|
|
5635
6490
|
function parseVariableIdentifier() {
|
|
@@ -5654,14 +6509,13 @@ parseYieldExpression: true
|
|
|
5654
6509
|
}
|
|
5655
6510
|
|
|
5656
6511
|
if (requireTypeAnnotation || match(':')) {
|
|
5657
|
-
ident =
|
|
5658
|
-
|
|
5659
|
-
parseTypeAnnotation()
|
|
5660
|
-
));
|
|
6512
|
+
ident.typeAnnotation = parseTypeAnnotation();
|
|
6513
|
+
ident = markerApply(marker, ident);
|
|
5661
6514
|
}
|
|
5662
6515
|
|
|
5663
6516
|
if (isOptionalParam) {
|
|
5664
|
-
ident =
|
|
6517
|
+
ident.optional = true;
|
|
6518
|
+
ident = markerApply(marker, ident);
|
|
5665
6519
|
}
|
|
5666
6520
|
|
|
5667
6521
|
return ident;
|
|
@@ -5670,13 +6524,22 @@ parseYieldExpression: true
|
|
|
5670
6524
|
function parseVariableDeclaration(kind) {
|
|
5671
6525
|
var id,
|
|
5672
6526
|
marker = markerCreate(),
|
|
5673
|
-
init = null
|
|
6527
|
+
init = null,
|
|
6528
|
+
typeAnnotationMarker = markerCreate();
|
|
5674
6529
|
if (match('{')) {
|
|
5675
6530
|
id = parseObjectInitialiser();
|
|
5676
6531
|
reinterpretAsAssignmentBindingPattern(id);
|
|
6532
|
+
if (match(':')) {
|
|
6533
|
+
id.typeAnnotation = parseTypeAnnotation();
|
|
6534
|
+
markerApply(typeAnnotationMarker, id);
|
|
6535
|
+
}
|
|
5677
6536
|
} else if (match('[')) {
|
|
5678
6537
|
id = parseArrayInitialiser();
|
|
5679
6538
|
reinterpretAsAssignmentBindingPattern(id);
|
|
6539
|
+
if (match(':')) {
|
|
6540
|
+
id.typeAnnotation = parseTypeAnnotation();
|
|
6541
|
+
markerApply(typeAnnotationMarker, id);
|
|
6542
|
+
}
|
|
5680
6543
|
} else {
|
|
5681
6544
|
id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
|
|
5682
6545
|
// 12.2.1
|
|
@@ -5741,41 +6604,18 @@ parseYieldExpression: true
|
|
|
5741
6604
|
return markerApply(marker, delegate.createVariableDeclaration(declarations, kind));
|
|
5742
6605
|
}
|
|
5743
6606
|
|
|
5744
|
-
//
|
|
5745
|
-
|
|
5746
|
-
function parseModuleDeclaration() {
|
|
5747
|
-
var id, src, body, marker = markerCreate();
|
|
5748
|
-
|
|
5749
|
-
lex(); // 'module'
|
|
5750
|
-
|
|
5751
|
-
if (peekLineTerminator()) {
|
|
5752
|
-
throwError({}, Messages.NewlineAfterModule);
|
|
5753
|
-
}
|
|
5754
|
-
|
|
5755
|
-
switch (lookahead.type) {
|
|
6607
|
+
// people.mozilla.org/~jorendorff/es6-draft.html
|
|
5756
6608
|
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
src = null;
|
|
5761
|
-
break;
|
|
6609
|
+
function parseModuleSpecifier() {
|
|
6610
|
+
var marker = markerCreate(),
|
|
6611
|
+
specifier;
|
|
5762
6612
|
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
body = null;
|
|
5766
|
-
if (!matchContextualKeyword('from')) {
|
|
5767
|
-
throwUnexpected(lex());
|
|
5768
|
-
}
|
|
5769
|
-
lex();
|
|
5770
|
-
src = parsePrimaryExpression();
|
|
5771
|
-
if (src.type !== Syntax.Literal) {
|
|
5772
|
-
throwError({}, Messages.InvalidModuleSpecifier);
|
|
5773
|
-
}
|
|
5774
|
-
break;
|
|
6613
|
+
if (lookahead.type !== Token.StringLiteral) {
|
|
6614
|
+
throwError({}, Messages.InvalidModuleSpecifier);
|
|
5775
6615
|
}
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
return markerApply(marker,
|
|
6616
|
+
specifier = delegate.createModuleSpecifier(lookahead);
|
|
6617
|
+
lex();
|
|
6618
|
+
return markerApply(marker, specifier);
|
|
5779
6619
|
}
|
|
5780
6620
|
|
|
5781
6621
|
function parseExportBatchSpecifier() {
|
|
@@ -5785,9 +6625,14 @@ parseYieldExpression: true
|
|
|
5785
6625
|
}
|
|
5786
6626
|
|
|
5787
6627
|
function parseExportSpecifier() {
|
|
5788
|
-
var id, name = null, marker = markerCreate();
|
|
5789
|
-
|
|
5790
|
-
|
|
6628
|
+
var id, name = null, marker = markerCreate(), from;
|
|
6629
|
+
if (matchKeyword('default')) {
|
|
6630
|
+
lex();
|
|
6631
|
+
id = markerApply(marker, delegate.createIdentifier('default'));
|
|
6632
|
+
// export {default} from "something";
|
|
6633
|
+
} else {
|
|
6634
|
+
id = parseVariableIdentifier();
|
|
6635
|
+
}
|
|
5791
6636
|
if (matchContextualKeyword('as')) {
|
|
5792
6637
|
lex();
|
|
5793
6638
|
name = parseNonComputedProperty();
|
|
@@ -5797,104 +6642,207 @@ parseYieldExpression: true
|
|
|
5797
6642
|
}
|
|
5798
6643
|
|
|
5799
6644
|
function parseExportDeclaration() {
|
|
5800
|
-
var
|
|
6645
|
+
var backtrackToken, id, previousAllowKeyword, declaration = null,
|
|
6646
|
+
isExportFromIdentifier,
|
|
6647
|
+
src = null, specifiers = [],
|
|
5801
6648
|
marker = markerCreate();
|
|
5802
6649
|
|
|
5803
6650
|
expectKeyword('export');
|
|
5804
6651
|
|
|
6652
|
+
if (matchKeyword('default')) {
|
|
6653
|
+
// covers:
|
|
6654
|
+
// export default ...
|
|
6655
|
+
lex();
|
|
6656
|
+
if (matchKeyword('function') || matchKeyword('class')) {
|
|
6657
|
+
backtrackToken = lookahead;
|
|
6658
|
+
lex();
|
|
6659
|
+
if (isIdentifierName(lookahead)) {
|
|
6660
|
+
// covers:
|
|
6661
|
+
// export default function foo () {}
|
|
6662
|
+
// export default class foo {}
|
|
6663
|
+
id = parseNonComputedProperty();
|
|
6664
|
+
rewind(backtrackToken);
|
|
6665
|
+
return markerApply(marker, delegate.createExportDeclaration(true, parseSourceElement(), [id], null));
|
|
6666
|
+
}
|
|
6667
|
+
// covers:
|
|
6668
|
+
// export default function () {}
|
|
6669
|
+
// export default class {}
|
|
6670
|
+
rewind(backtrackToken);
|
|
6671
|
+
switch (lookahead.value) {
|
|
6672
|
+
case 'class':
|
|
6673
|
+
return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null));
|
|
6674
|
+
case 'function':
|
|
6675
|
+
return markerApply(marker, delegate.createExportDeclaration(true, parseFunctionExpression(), [], null));
|
|
6676
|
+
}
|
|
6677
|
+
}
|
|
6678
|
+
|
|
6679
|
+
if (matchContextualKeyword('from')) {
|
|
6680
|
+
throwError({}, Messages.UnexpectedToken, lookahead.value);
|
|
6681
|
+
}
|
|
6682
|
+
|
|
6683
|
+
// covers:
|
|
6684
|
+
// export default {};
|
|
6685
|
+
// export default [];
|
|
6686
|
+
if (match('{')) {
|
|
6687
|
+
declaration = parseObjectInitialiser();
|
|
6688
|
+
} else if (match('[')) {
|
|
6689
|
+
declaration = parseArrayInitialiser();
|
|
6690
|
+
} else {
|
|
6691
|
+
declaration = parseAssignmentExpression();
|
|
6692
|
+
}
|
|
6693
|
+
consumeSemicolon();
|
|
6694
|
+
return markerApply(marker, delegate.createExportDeclaration(true, declaration, [], null));
|
|
6695
|
+
}
|
|
6696
|
+
|
|
6697
|
+
// non-default export
|
|
5805
6698
|
if (lookahead.type === Token.Keyword) {
|
|
6699
|
+
// covers:
|
|
6700
|
+
// export var f = 1;
|
|
5806
6701
|
switch (lookahead.value) {
|
|
5807
6702
|
case 'let':
|
|
5808
6703
|
case 'const':
|
|
5809
6704
|
case 'var':
|
|
5810
6705
|
case 'class':
|
|
5811
6706
|
case 'function':
|
|
5812
|
-
return markerApply(marker, delegate.createExportDeclaration(parseSourceElement(),
|
|
6707
|
+
return markerApply(marker, delegate.createExportDeclaration(false, parseSourceElement(), specifiers, null));
|
|
5813
6708
|
}
|
|
5814
6709
|
}
|
|
5815
6710
|
|
|
5816
|
-
if (
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
6711
|
+
if (match('*')) {
|
|
6712
|
+
// covers:
|
|
6713
|
+
// export * from "foo";
|
|
6714
|
+
specifiers.push(parseExportBatchSpecifier());
|
|
6715
|
+
|
|
6716
|
+
if (!matchContextualKeyword('from')) {
|
|
6717
|
+
throwError({}, lookahead.value ?
|
|
6718
|
+
Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
|
|
6719
|
+
}
|
|
6720
|
+
lex();
|
|
6721
|
+
src = parseModuleSpecifier();
|
|
6722
|
+
consumeSemicolon();
|
|
6723
|
+
|
|
6724
|
+
return markerApply(marker, delegate.createExportDeclaration(false, null, specifiers, src));
|
|
5822
6725
|
}
|
|
5823
6726
|
|
|
5824
|
-
|
|
5825
|
-
|
|
6727
|
+
expect('{');
|
|
6728
|
+
do {
|
|
6729
|
+
isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
|
|
6730
|
+
specifiers.push(parseExportSpecifier());
|
|
6731
|
+
} while (match(',') && lex());
|
|
6732
|
+
expect('}');
|
|
5826
6733
|
|
|
5827
|
-
if (
|
|
5828
|
-
|
|
6734
|
+
if (matchContextualKeyword('from')) {
|
|
6735
|
+
// covering:
|
|
6736
|
+
// export {default} from "foo";
|
|
6737
|
+
// export {foo} from "foo";
|
|
6738
|
+
lex();
|
|
6739
|
+
src = parseModuleSpecifier();
|
|
6740
|
+
consumeSemicolon();
|
|
6741
|
+
} else if (isExportFromIdentifier) {
|
|
6742
|
+
// covering:
|
|
6743
|
+
// export {default}; // missing fromClause
|
|
6744
|
+
throwError({}, lookahead.value ?
|
|
6745
|
+
Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
|
|
5829
6746
|
} else {
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
} while (match(',') && lex());
|
|
5834
|
-
expect('}');
|
|
6747
|
+
// cover
|
|
6748
|
+
// export {foo};
|
|
6749
|
+
consumeSemicolon();
|
|
5835
6750
|
}
|
|
6751
|
+
return markerApply(marker, delegate.createExportDeclaration(false, declaration, specifiers, src));
|
|
6752
|
+
}
|
|
5836
6753
|
|
|
5837
|
-
|
|
6754
|
+
|
|
6755
|
+
function parseImportSpecifier() {
|
|
6756
|
+
// import {<foo as bar>} ...;
|
|
6757
|
+
var id, name = null, marker = markerCreate();
|
|
6758
|
+
|
|
6759
|
+
id = parseNonComputedProperty();
|
|
6760
|
+
if (matchContextualKeyword('as')) {
|
|
5838
6761
|
lex();
|
|
5839
|
-
|
|
5840
|
-
if (src.type !== Syntax.Literal) {
|
|
5841
|
-
throwError({}, Messages.InvalidModuleSpecifier);
|
|
5842
|
-
}
|
|
6762
|
+
name = parseVariableIdentifier();
|
|
5843
6763
|
}
|
|
5844
6764
|
|
|
5845
|
-
|
|
6765
|
+
return markerApply(marker, delegate.createImportSpecifier(id, name));
|
|
6766
|
+
}
|
|
5846
6767
|
|
|
5847
|
-
|
|
6768
|
+
function parseNamedImports() {
|
|
6769
|
+
var specifiers = [];
|
|
6770
|
+
// {foo, bar as bas}
|
|
6771
|
+
expect('{');
|
|
6772
|
+
do {
|
|
6773
|
+
specifiers.push(parseImportSpecifier());
|
|
6774
|
+
} while (match(',') && lex());
|
|
6775
|
+
expect('}');
|
|
6776
|
+
return specifiers;
|
|
6777
|
+
}
|
|
6778
|
+
|
|
6779
|
+
function parseImportDefaultSpecifier() {
|
|
6780
|
+
// import <foo> ...;
|
|
6781
|
+
var id, marker = markerCreate();
|
|
6782
|
+
|
|
6783
|
+
id = parseNonComputedProperty();
|
|
6784
|
+
|
|
6785
|
+
return markerApply(marker, delegate.createImportDefaultSpecifier(id));
|
|
6786
|
+
}
|
|
6787
|
+
|
|
6788
|
+
function parseImportNamespaceSpecifier() {
|
|
6789
|
+
// import <* as foo> ...;
|
|
6790
|
+
var id, marker = markerCreate();
|
|
6791
|
+
|
|
6792
|
+
expect('*');
|
|
6793
|
+
if (!matchContextualKeyword('as')) {
|
|
6794
|
+
throwError({}, Messages.NoAsAfterImportNamespace);
|
|
6795
|
+
}
|
|
6796
|
+
lex();
|
|
6797
|
+
id = parseNonComputedProperty();
|
|
6798
|
+
|
|
6799
|
+
return markerApply(marker, delegate.createImportNamespaceSpecifier(id));
|
|
5848
6800
|
}
|
|
5849
6801
|
|
|
5850
6802
|
function parseImportDeclaration() {
|
|
5851
|
-
var specifiers,
|
|
6803
|
+
var specifiers, src, marker = markerCreate();
|
|
5852
6804
|
|
|
5853
6805
|
expectKeyword('import');
|
|
5854
6806
|
specifiers = [];
|
|
5855
6807
|
|
|
5856
|
-
if (
|
|
5857
|
-
|
|
5858
|
-
|
|
6808
|
+
if (lookahead.type === Token.StringLiteral) {
|
|
6809
|
+
// covers:
|
|
6810
|
+
// import "foo";
|
|
6811
|
+
src = parseModuleSpecifier();
|
|
6812
|
+
consumeSemicolon();
|
|
6813
|
+
return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
|
|
6814
|
+
}
|
|
5859
6815
|
|
|
5860
|
-
|
|
5861
|
-
|
|
6816
|
+
if (!matchKeyword('default') && isIdentifierName(lookahead)) {
|
|
6817
|
+
// covers:
|
|
6818
|
+
// import foo
|
|
6819
|
+
// import foo, ...
|
|
6820
|
+
specifiers.push(parseImportDefaultSpecifier());
|
|
6821
|
+
if (match(',')) {
|
|
6822
|
+
lex();
|
|
5862
6823
|
}
|
|
5863
|
-
|
|
6824
|
+
}
|
|
6825
|
+
if (match('*')) {
|
|
6826
|
+
// covers:
|
|
6827
|
+
// import foo, * as foo
|
|
6828
|
+
// import * as foo
|
|
6829
|
+
specifiers.push(parseImportNamespaceSpecifier());
|
|
5864
6830
|
} else if (match('{')) {
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
} while (match(',') && lex());
|
|
5870
|
-
expect('}');
|
|
5871
|
-
|
|
5872
|
-
if (!matchContextualKeyword('from')) {
|
|
5873
|
-
throwError({}, Messages.NoFromAfterImport);
|
|
5874
|
-
}
|
|
5875
|
-
lex();
|
|
6831
|
+
// covers:
|
|
6832
|
+
// import foo, {bar}
|
|
6833
|
+
// import {bar}
|
|
6834
|
+
specifiers = specifiers.concat(parseNamedImports());
|
|
5876
6835
|
}
|
|
5877
6836
|
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
6837
|
+
if (!matchContextualKeyword('from')) {
|
|
6838
|
+
throwError({}, lookahead.value ?
|
|
6839
|
+
Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
|
|
5881
6840
|
}
|
|
5882
|
-
|
|
6841
|
+
lex();
|
|
6842
|
+
src = parseModuleSpecifier();
|
|
5883
6843
|
consumeSemicolon();
|
|
5884
6844
|
|
|
5885
|
-
return markerApply(marker, delegate.createImportDeclaration(specifiers,
|
|
5886
|
-
}
|
|
5887
|
-
|
|
5888
|
-
function parseImportSpecifier() {
|
|
5889
|
-
var id, name = null, marker = markerCreate();
|
|
5890
|
-
|
|
5891
|
-
id = parseNonComputedProperty();
|
|
5892
|
-
if (matchContextualKeyword('as')) {
|
|
5893
|
-
lex();
|
|
5894
|
-
name = parseVariableIdentifier();
|
|
5895
|
-
}
|
|
5896
|
-
|
|
5897
|
-
return markerApply(marker, delegate.createImportSpecifier(id, name));
|
|
6845
|
+
return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
|
|
5898
6846
|
}
|
|
5899
6847
|
|
|
5900
6848
|
// 12.3 Empty Statement
|
|
@@ -6447,6 +7395,10 @@ parseYieldExpression: true
|
|
|
6447
7395
|
}
|
|
6448
7396
|
}
|
|
6449
7397
|
|
|
7398
|
+
if (matchAsyncFuncExprOrDecl()) {
|
|
7399
|
+
return parseFunctionDeclaration();
|
|
7400
|
+
}
|
|
7401
|
+
|
|
6450
7402
|
marker = markerCreate();
|
|
6451
7403
|
expr = parseExpression();
|
|
6452
7404
|
|
|
@@ -6572,7 +7524,7 @@ parseYieldExpression: true
|
|
|
6572
7524
|
}
|
|
6573
7525
|
|
|
6574
7526
|
function parseParam(options) {
|
|
6575
|
-
var token, rest, param, def;
|
|
7527
|
+
var marker, token, rest, param, def;
|
|
6576
7528
|
|
|
6577
7529
|
token = lookahead;
|
|
6578
7530
|
if (token.value === '...') {
|
|
@@ -6581,19 +7533,31 @@ parseYieldExpression: true
|
|
|
6581
7533
|
}
|
|
6582
7534
|
|
|
6583
7535
|
if (match('[')) {
|
|
7536
|
+
marker = markerCreate();
|
|
6584
7537
|
param = parseArrayInitialiser();
|
|
6585
7538
|
reinterpretAsDestructuredParameter(options, param);
|
|
7539
|
+
if (match(':')) {
|
|
7540
|
+
param.typeAnnotation = parseTypeAnnotation();
|
|
7541
|
+
markerApply(marker, param);
|
|
7542
|
+
}
|
|
6586
7543
|
} else if (match('{')) {
|
|
7544
|
+
marker = markerCreate();
|
|
6587
7545
|
if (rest) {
|
|
6588
7546
|
throwError({}, Messages.ObjectPatternAsRestParameter);
|
|
6589
7547
|
}
|
|
6590
7548
|
param = parseObjectInitialiser();
|
|
6591
7549
|
reinterpretAsDestructuredParameter(options, param);
|
|
7550
|
+
if (match(':')) {
|
|
7551
|
+
param.typeAnnotation = parseTypeAnnotation();
|
|
7552
|
+
markerApply(marker, param);
|
|
7553
|
+
}
|
|
6592
7554
|
} else {
|
|
6593
|
-
// Typing rest params is awkward, so punting on that for now
|
|
6594
7555
|
param =
|
|
6595
7556
|
rest
|
|
6596
|
-
?
|
|
7557
|
+
? parseTypeAnnotatableIdentifier(
|
|
7558
|
+
false, /* requireTypeAnnotation */
|
|
7559
|
+
false /* canBeOptionalParam */
|
|
7560
|
+
)
|
|
6597
7561
|
: parseTypeAnnotatableIdentifier(
|
|
6598
7562
|
false, /* requireTypeAnnotation */
|
|
6599
7563
|
true /* canBeOptionalParam */
|
|
@@ -6661,8 +7625,15 @@ parseYieldExpression: true
|
|
|
6661
7625
|
}
|
|
6662
7626
|
|
|
6663
7627
|
function parseFunctionDeclaration() {
|
|
6664
|
-
var id, body, token, tmp, firstRestricted, message,
|
|
6665
|
-
|
|
7628
|
+
var id, body, token, tmp, firstRestricted, message, generator, isAsync,
|
|
7629
|
+
previousStrict, previousYieldAllowed, previousAwaitAllowed,
|
|
7630
|
+
marker = markerCreate(), typeParameters;
|
|
7631
|
+
|
|
7632
|
+
isAsync = false;
|
|
7633
|
+
if (matchAsync()) {
|
|
7634
|
+
lex();
|
|
7635
|
+
isAsync = true;
|
|
7636
|
+
}
|
|
6666
7637
|
|
|
6667
7638
|
expectKeyword('function');
|
|
6668
7639
|
|
|
@@ -6677,7 +7648,7 @@ parseYieldExpression: true
|
|
|
6677
7648
|
id = parseVariableIdentifier();
|
|
6678
7649
|
|
|
6679
7650
|
if (match('<')) {
|
|
6680
|
-
|
|
7651
|
+
typeParameters = parseTypeParameterDeclaration();
|
|
6681
7652
|
}
|
|
6682
7653
|
|
|
6683
7654
|
if (strict) {
|
|
@@ -6703,6 +7674,8 @@ parseYieldExpression: true
|
|
|
6703
7674
|
previousStrict = strict;
|
|
6704
7675
|
previousYieldAllowed = state.yieldAllowed;
|
|
6705
7676
|
state.yieldAllowed = generator;
|
|
7677
|
+
previousAwaitAllowed = state.awaitAllowed;
|
|
7678
|
+
state.awaitAllowed = isAsync;
|
|
6706
7679
|
|
|
6707
7680
|
body = parseFunctionSourceElements();
|
|
6708
7681
|
|
|
@@ -6714,14 +7687,35 @@ parseYieldExpression: true
|
|
|
6714
7687
|
}
|
|
6715
7688
|
strict = previousStrict;
|
|
6716
7689
|
state.yieldAllowed = previousYieldAllowed;
|
|
7690
|
+
state.awaitAllowed = previousAwaitAllowed;
|
|
6717
7691
|
|
|
6718
|
-
return markerApply(
|
|
6719
|
-
|
|
7692
|
+
return markerApply(
|
|
7693
|
+
marker,
|
|
7694
|
+
delegate.createFunctionDeclaration(
|
|
7695
|
+
id,
|
|
7696
|
+
tmp.params,
|
|
7697
|
+
tmp.defaults,
|
|
7698
|
+
body,
|
|
7699
|
+
tmp.rest,
|
|
7700
|
+
generator,
|
|
7701
|
+
false,
|
|
7702
|
+
isAsync,
|
|
7703
|
+
tmp.returnType,
|
|
7704
|
+
typeParameters
|
|
7705
|
+
)
|
|
7706
|
+
);
|
|
6720
7707
|
}
|
|
6721
7708
|
|
|
6722
7709
|
function parseFunctionExpression() {
|
|
6723
|
-
var token, id = null, firstRestricted, message, tmp, body,
|
|
6724
|
-
|
|
7710
|
+
var token, id = null, firstRestricted, message, tmp, body, generator, isAsync,
|
|
7711
|
+
previousStrict, previousYieldAllowed, previousAwaitAllowed,
|
|
7712
|
+
marker = markerCreate(), typeParameters;
|
|
7713
|
+
|
|
7714
|
+
isAsync = false;
|
|
7715
|
+
if (matchAsync()) {
|
|
7716
|
+
lex();
|
|
7717
|
+
isAsync = true;
|
|
7718
|
+
}
|
|
6725
7719
|
|
|
6726
7720
|
expectKeyword('function');
|
|
6727
7721
|
|
|
@@ -6753,7 +7747,7 @@ parseYieldExpression: true
|
|
|
6753
7747
|
}
|
|
6754
7748
|
|
|
6755
7749
|
if (match('<')) {
|
|
6756
|
-
|
|
7750
|
+
typeParameters = parseTypeParameterDeclaration();
|
|
6757
7751
|
}
|
|
6758
7752
|
}
|
|
6759
7753
|
|
|
@@ -6766,6 +7760,8 @@ parseYieldExpression: true
|
|
|
6766
7760
|
previousStrict = strict;
|
|
6767
7761
|
previousYieldAllowed = state.yieldAllowed;
|
|
6768
7762
|
state.yieldAllowed = generator;
|
|
7763
|
+
previousAwaitAllowed = state.awaitAllowed;
|
|
7764
|
+
state.awaitAllowed = isAsync;
|
|
6769
7765
|
|
|
6770
7766
|
body = parseFunctionSourceElements();
|
|
6771
7767
|
|
|
@@ -6777,20 +7773,29 @@ parseYieldExpression: true
|
|
|
6777
7773
|
}
|
|
6778
7774
|
strict = previousStrict;
|
|
6779
7775
|
state.yieldAllowed = previousYieldAllowed;
|
|
7776
|
+
state.awaitAllowed = previousAwaitAllowed;
|
|
6780
7777
|
|
|
6781
|
-
return markerApply(
|
|
6782
|
-
|
|
7778
|
+
return markerApply(
|
|
7779
|
+
marker,
|
|
7780
|
+
delegate.createFunctionExpression(
|
|
7781
|
+
id,
|
|
7782
|
+
tmp.params,
|
|
7783
|
+
tmp.defaults,
|
|
7784
|
+
body,
|
|
7785
|
+
tmp.rest,
|
|
7786
|
+
generator,
|
|
7787
|
+
false,
|
|
7788
|
+
isAsync,
|
|
7789
|
+
tmp.returnType,
|
|
7790
|
+
typeParameters
|
|
7791
|
+
)
|
|
7792
|
+
);
|
|
6783
7793
|
}
|
|
6784
7794
|
|
|
6785
7795
|
function parseYieldExpression() {
|
|
6786
|
-
var
|
|
6787
|
-
|
|
6788
|
-
yieldToken = lex();
|
|
6789
|
-
assert(yieldToken.value === 'yield', 'Called parseYieldExpression with non-yield lookahead.');
|
|
7796
|
+
var delegateFlag, expr, marker = markerCreate();
|
|
6790
7797
|
|
|
6791
|
-
|
|
6792
|
-
throwErrorTolerant({}, Messages.IllegalYield);
|
|
6793
|
-
}
|
|
7798
|
+
expectKeyword('yield', !strict);
|
|
6794
7799
|
|
|
6795
7800
|
delegateFlag = false;
|
|
6796
7801
|
if (match('*')) {
|
|
@@ -6803,35 +7808,34 @@ parseYieldExpression: true
|
|
|
6803
7808
|
return markerApply(marker, delegate.createYieldExpression(expr, delegateFlag));
|
|
6804
7809
|
}
|
|
6805
7810
|
|
|
7811
|
+
function parseAwaitExpression() {
|
|
7812
|
+
var expr, marker = markerCreate();
|
|
7813
|
+
expectContextualKeyword('await');
|
|
7814
|
+
expr = parseAssignmentExpression();
|
|
7815
|
+
return markerApply(marker, delegate.createAwaitExpression(expr));
|
|
7816
|
+
}
|
|
7817
|
+
|
|
6806
7818
|
// 14 Classes
|
|
6807
7819
|
|
|
6808
|
-
function parseMethodDefinition(existingPropNames) {
|
|
6809
|
-
var token,
|
|
6810
|
-
|
|
6811
|
-
|
|
7820
|
+
function parseMethodDefinition(existingPropNames, key, isStatic, generator, computed) {
|
|
7821
|
+
var token, param, propType, isValidDuplicateProp = false,
|
|
7822
|
+
isAsync, typeParameters, tokenValue, returnType,
|
|
7823
|
+
annotationMarker;
|
|
6812
7824
|
|
|
6813
|
-
|
|
6814
|
-
propType = ClassPropertyType["static"];
|
|
6815
|
-
lex();
|
|
6816
|
-
} else {
|
|
6817
|
-
propType = ClassPropertyType.prototype;
|
|
6818
|
-
}
|
|
7825
|
+
propType = isStatic ? ClassPropertyType["static"] : ClassPropertyType.prototype;
|
|
6819
7826
|
|
|
6820
|
-
if (
|
|
6821
|
-
|
|
6822
|
-
return markerApply(marker, delegate.createMethodDefinition(
|
|
7827
|
+
if (generator) {
|
|
7828
|
+
return delegate.createMethodDefinition(
|
|
6823
7829
|
propType,
|
|
6824
7830
|
'',
|
|
6825
|
-
|
|
7831
|
+
key,
|
|
6826
7832
|
parsePropertyMethodFunction({ generator: true })
|
|
6827
|
-
)
|
|
7833
|
+
);
|
|
6828
7834
|
}
|
|
6829
7835
|
|
|
6830
|
-
|
|
6831
|
-
//parametricTypeMarker = markerCreate();
|
|
6832
|
-
key = parseObjectPropertyKey();
|
|
7836
|
+
tokenValue = key.type === 'Identifier' && key.name;
|
|
6833
7837
|
|
|
6834
|
-
if (
|
|
7838
|
+
if (tokenValue === 'get' && !match('(')) {
|
|
6835
7839
|
key = parseObjectPropertyKey();
|
|
6836
7840
|
|
|
6837
7841
|
// It is a syntax error if any other properties have a name
|
|
@@ -6854,14 +7858,17 @@ parseYieldExpression: true
|
|
|
6854
7858
|
|
|
6855
7859
|
expect('(');
|
|
6856
7860
|
expect(')');
|
|
6857
|
-
|
|
7861
|
+
if (match(':')) {
|
|
7862
|
+
returnType = parseTypeAnnotation();
|
|
7863
|
+
}
|
|
7864
|
+
return delegate.createMethodDefinition(
|
|
6858
7865
|
propType,
|
|
6859
7866
|
'get',
|
|
6860
7867
|
key,
|
|
6861
|
-
parsePropertyFunction({ generator: false })
|
|
6862
|
-
)
|
|
7868
|
+
parsePropertyFunction({ generator: false, returnType: returnType })
|
|
7869
|
+
);
|
|
6863
7870
|
}
|
|
6864
|
-
if (
|
|
7871
|
+
if (tokenValue === 'set' && !match('(')) {
|
|
6865
7872
|
key = parseObjectPropertyKey();
|
|
6866
7873
|
|
|
6867
7874
|
// It is a syntax error if any other properties have a name
|
|
@@ -6886,16 +7893,29 @@ parseYieldExpression: true
|
|
|
6886
7893
|
token = lookahead;
|
|
6887
7894
|
param = [ parseTypeAnnotatableIdentifier() ];
|
|
6888
7895
|
expect(')');
|
|
6889
|
-
|
|
7896
|
+
if (match(':')) {
|
|
7897
|
+
returnType = parseTypeAnnotation();
|
|
7898
|
+
}
|
|
7899
|
+
return delegate.createMethodDefinition(
|
|
6890
7900
|
propType,
|
|
6891
7901
|
'set',
|
|
6892
7902
|
key,
|
|
6893
|
-
parsePropertyFunction({
|
|
6894
|
-
|
|
7903
|
+
parsePropertyFunction({
|
|
7904
|
+
params: param,
|
|
7905
|
+
generator: false,
|
|
7906
|
+
name: token,
|
|
7907
|
+
returnType: returnType
|
|
7908
|
+
})
|
|
7909
|
+
);
|
|
6895
7910
|
}
|
|
6896
7911
|
|
|
6897
7912
|
if (match('<')) {
|
|
6898
|
-
|
|
7913
|
+
typeParameters = parseTypeParameterDeclaration();
|
|
7914
|
+
}
|
|
7915
|
+
|
|
7916
|
+
isAsync = tokenValue === 'async' && !match('(');
|
|
7917
|
+
if (isAsync) {
|
|
7918
|
+
key = parseObjectPropertyKey();
|
|
6899
7919
|
}
|
|
6900
7920
|
|
|
6901
7921
|
// It is a syntax error if any other properties have the same name as a
|
|
@@ -6907,42 +7927,64 @@ parseYieldExpression: true
|
|
|
6907
7927
|
}
|
|
6908
7928
|
existingPropNames[propType][key.name].data = true;
|
|
6909
7929
|
|
|
6910
|
-
return
|
|
7930
|
+
return delegate.createMethodDefinition(
|
|
6911
7931
|
propType,
|
|
6912
7932
|
'',
|
|
6913
7933
|
key,
|
|
6914
7934
|
parsePropertyMethodFunction({
|
|
6915
7935
|
generator: false,
|
|
6916
|
-
|
|
7936
|
+
async: isAsync,
|
|
7937
|
+
typeParameters: typeParameters
|
|
6917
7938
|
})
|
|
6918
|
-
)
|
|
7939
|
+
);
|
|
6919
7940
|
}
|
|
6920
7941
|
|
|
6921
|
-
function parseClassProperty(existingPropNames) {
|
|
6922
|
-
var
|
|
7942
|
+
function parseClassProperty(existingPropNames, key, computed, isStatic) {
|
|
7943
|
+
var typeAnnotation;
|
|
6923
7944
|
|
|
6924
|
-
|
|
7945
|
+
typeAnnotation = parseTypeAnnotation();
|
|
6925
7946
|
expect(';');
|
|
6926
7947
|
|
|
6927
|
-
return
|
|
6928
|
-
|
|
6929
|
-
|
|
7948
|
+
return delegate.createClassProperty(
|
|
7949
|
+
key,
|
|
7950
|
+
typeAnnotation,
|
|
7951
|
+
computed,
|
|
7952
|
+
isStatic
|
|
7953
|
+
);
|
|
6930
7954
|
}
|
|
6931
7955
|
|
|
6932
7956
|
function parseClassElement(existingProps) {
|
|
7957
|
+
var computed, generator = false, key, marker = markerCreate(),
|
|
7958
|
+
isStatic = false;
|
|
6933
7959
|
if (match(';')) {
|
|
6934
7960
|
lex();
|
|
6935
7961
|
return;
|
|
6936
7962
|
}
|
|
6937
7963
|
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
return parseClassProperty(existingProps);
|
|
6942
|
-
}
|
|
7964
|
+
if (lookahead.value === 'static') {
|
|
7965
|
+
lex();
|
|
7966
|
+
isStatic = true;
|
|
6943
7967
|
}
|
|
6944
7968
|
|
|
6945
|
-
|
|
7969
|
+
if (match('*')) {
|
|
7970
|
+
lex();
|
|
7971
|
+
generator = true;
|
|
7972
|
+
}
|
|
7973
|
+
|
|
7974
|
+
computed = (lookahead.value === '[');
|
|
7975
|
+
key = parseObjectPropertyKey();
|
|
7976
|
+
|
|
7977
|
+
if (!generator && lookahead.value === ':') {
|
|
7978
|
+
return markerApply(marker, parseClassProperty(existingProps, key, computed, isStatic));
|
|
7979
|
+
}
|
|
7980
|
+
|
|
7981
|
+
return markerApply(marker, parseMethodDefinition(
|
|
7982
|
+
existingProps,
|
|
7983
|
+
key,
|
|
7984
|
+
isStatic,
|
|
7985
|
+
generator,
|
|
7986
|
+
computed
|
|
7987
|
+
));
|
|
6946
7988
|
}
|
|
6947
7989
|
|
|
6948
7990
|
function parseClassBody() {
|
|
@@ -6969,66 +8011,109 @@ parseYieldExpression: true
|
|
|
6969
8011
|
return markerApply(marker, delegate.createClassBody(classElements));
|
|
6970
8012
|
}
|
|
6971
8013
|
|
|
8014
|
+
function parseClassImplements() {
|
|
8015
|
+
var id, implemented = [], marker, typeParameters;
|
|
8016
|
+
expectContextualKeyword('implements');
|
|
8017
|
+
while (index < length) {
|
|
8018
|
+
marker = markerCreate();
|
|
8019
|
+
id = parseVariableIdentifier();
|
|
8020
|
+
if (match('<')) {
|
|
8021
|
+
typeParameters = parseTypeParameterInstantiation();
|
|
8022
|
+
} else {
|
|
8023
|
+
typeParameters = null;
|
|
8024
|
+
}
|
|
8025
|
+
implemented.push(markerApply(marker, delegate.createClassImplements(
|
|
8026
|
+
id,
|
|
8027
|
+
typeParameters
|
|
8028
|
+
)));
|
|
8029
|
+
if (!match(',')) {
|
|
8030
|
+
break;
|
|
8031
|
+
}
|
|
8032
|
+
expect(',');
|
|
8033
|
+
}
|
|
8034
|
+
return implemented;
|
|
8035
|
+
}
|
|
8036
|
+
|
|
6972
8037
|
function parseClassExpression() {
|
|
6973
|
-
var id, previousYieldAllowed, superClass = null,
|
|
6974
|
-
|
|
8038
|
+
var id, implemented, previousYieldAllowed, superClass = null,
|
|
8039
|
+
superTypeParameters, marker = markerCreate(), typeParameters;
|
|
6975
8040
|
|
|
6976
8041
|
expectKeyword('class');
|
|
6977
8042
|
|
|
6978
|
-
if (!matchKeyword('extends') && !match('{')) {
|
|
8043
|
+
if (!matchKeyword('extends') && !matchContextualKeyword('implements') && !match('{')) {
|
|
6979
8044
|
id = parseVariableIdentifier();
|
|
6980
8045
|
}
|
|
6981
8046
|
|
|
6982
8047
|
if (match('<')) {
|
|
6983
|
-
|
|
8048
|
+
typeParameters = parseTypeParameterDeclaration();
|
|
6984
8049
|
}
|
|
6985
8050
|
|
|
6986
8051
|
if (matchKeyword('extends')) {
|
|
6987
8052
|
expectKeyword('extends');
|
|
6988
8053
|
previousYieldAllowed = state.yieldAllowed;
|
|
6989
8054
|
state.yieldAllowed = false;
|
|
6990
|
-
superClass =
|
|
8055
|
+
superClass = parseLeftHandSideExpressionAllowCall();
|
|
8056
|
+
if (match('<')) {
|
|
8057
|
+
superTypeParameters = parseTypeParameterInstantiation();
|
|
8058
|
+
}
|
|
6991
8059
|
state.yieldAllowed = previousYieldAllowed;
|
|
6992
8060
|
}
|
|
6993
8061
|
|
|
6994
|
-
|
|
8062
|
+
if (matchContextualKeyword('implements')) {
|
|
8063
|
+
implemented = parseClassImplements();
|
|
8064
|
+
}
|
|
8065
|
+
|
|
8066
|
+
return markerApply(marker, delegate.createClassExpression(
|
|
8067
|
+
id,
|
|
8068
|
+
superClass,
|
|
8069
|
+
parseClassBody(),
|
|
8070
|
+
typeParameters,
|
|
8071
|
+
superTypeParameters,
|
|
8072
|
+
implemented
|
|
8073
|
+
));
|
|
6995
8074
|
}
|
|
6996
8075
|
|
|
6997
8076
|
function parseClassDeclaration() {
|
|
6998
|
-
var id, previousYieldAllowed, superClass = null,
|
|
6999
|
-
|
|
8077
|
+
var id, implemented, previousYieldAllowed, superClass = null,
|
|
8078
|
+
superTypeParameters, marker = markerCreate(), typeParameters;
|
|
7000
8079
|
|
|
7001
8080
|
expectKeyword('class');
|
|
7002
8081
|
|
|
7003
8082
|
id = parseVariableIdentifier();
|
|
7004
8083
|
|
|
7005
8084
|
if (match('<')) {
|
|
7006
|
-
|
|
8085
|
+
typeParameters = parseTypeParameterDeclaration();
|
|
7007
8086
|
}
|
|
7008
8087
|
|
|
7009
8088
|
if (matchKeyword('extends')) {
|
|
7010
8089
|
expectKeyword('extends');
|
|
7011
8090
|
previousYieldAllowed = state.yieldAllowed;
|
|
7012
8091
|
state.yieldAllowed = false;
|
|
7013
|
-
superClass =
|
|
8092
|
+
superClass = parseLeftHandSideExpressionAllowCall();
|
|
8093
|
+
if (match('<')) {
|
|
8094
|
+
superTypeParameters = parseTypeParameterInstantiation();
|
|
8095
|
+
}
|
|
7014
8096
|
state.yieldAllowed = previousYieldAllowed;
|
|
7015
8097
|
}
|
|
7016
8098
|
|
|
7017
|
-
|
|
8099
|
+
if (matchContextualKeyword('implements')) {
|
|
8100
|
+
implemented = parseClassImplements();
|
|
8101
|
+
}
|
|
8102
|
+
|
|
8103
|
+
return markerApply(marker, delegate.createClassDeclaration(
|
|
8104
|
+
id,
|
|
8105
|
+
superClass,
|
|
8106
|
+
parseClassBody(),
|
|
8107
|
+
typeParameters,
|
|
8108
|
+
superTypeParameters,
|
|
8109
|
+
implemented
|
|
8110
|
+
));
|
|
7018
8111
|
}
|
|
7019
8112
|
|
|
7020
8113
|
// 15 Program
|
|
7021
8114
|
|
|
7022
|
-
function matchModuleDeclaration() {
|
|
7023
|
-
var id;
|
|
7024
|
-
if (matchContextualKeyword('module')) {
|
|
7025
|
-
id = lookahead2();
|
|
7026
|
-
return id.type === Token.StringLiteral || id.type === Token.Identifier;
|
|
7027
|
-
}
|
|
7028
|
-
return false;
|
|
7029
|
-
}
|
|
7030
|
-
|
|
7031
8115
|
function parseSourceElement() {
|
|
8116
|
+
var token;
|
|
7032
8117
|
if (lookahead.type === Token.Keyword) {
|
|
7033
8118
|
switch (lookahead.value) {
|
|
7034
8119
|
case 'const':
|
|
@@ -7036,17 +8121,36 @@ parseYieldExpression: true
|
|
|
7036
8121
|
return parseConstLetDeclaration(lookahead.value);
|
|
7037
8122
|
case 'function':
|
|
7038
8123
|
return parseFunctionDeclaration();
|
|
7039
|
-
case 'export':
|
|
7040
|
-
return parseExportDeclaration();
|
|
7041
|
-
case 'import':
|
|
7042
|
-
return parseImportDeclaration();
|
|
7043
8124
|
default:
|
|
7044
8125
|
return parseStatement();
|
|
7045
8126
|
}
|
|
7046
8127
|
}
|
|
7047
8128
|
|
|
7048
|
-
if (
|
|
7049
|
-
|
|
8129
|
+
if (matchContextualKeyword('type')
|
|
8130
|
+
&& lookahead2().type === Token.Identifier) {
|
|
8131
|
+
return parseTypeAlias();
|
|
8132
|
+
}
|
|
8133
|
+
|
|
8134
|
+
if (matchContextualKeyword('interface')
|
|
8135
|
+
&& lookahead2().type === Token.Identifier) {
|
|
8136
|
+
return parseInterface();
|
|
8137
|
+
}
|
|
8138
|
+
|
|
8139
|
+
if (matchContextualKeyword('declare')) {
|
|
8140
|
+
token = lookahead2();
|
|
8141
|
+
if (token.type === Token.Keyword) {
|
|
8142
|
+
switch (token.value) {
|
|
8143
|
+
case 'class':
|
|
8144
|
+
return parseDeclareClass();
|
|
8145
|
+
case 'function':
|
|
8146
|
+
return parseDeclareFunction();
|
|
8147
|
+
case 'var':
|
|
8148
|
+
return parseDeclareVariable();
|
|
8149
|
+
}
|
|
8150
|
+
} else if (token.type === Token.Identifier
|
|
8151
|
+
&& token.value === 'module') {
|
|
8152
|
+
return parseDeclareModule();
|
|
8153
|
+
}
|
|
7050
8154
|
}
|
|
7051
8155
|
|
|
7052
8156
|
if (lookahead.type !== Token.EOF) {
|
|
@@ -7064,10 +8168,6 @@ parseYieldExpression: true
|
|
|
7064
8168
|
}
|
|
7065
8169
|
}
|
|
7066
8170
|
|
|
7067
|
-
if (matchModuleDeclaration()) {
|
|
7068
|
-
return parseModuleDeclaration();
|
|
7069
|
-
}
|
|
7070
|
-
|
|
7071
8171
|
return parseSourceElement();
|
|
7072
8172
|
}
|
|
7073
8173
|
|
|
@@ -7109,40 +8209,6 @@ parseYieldExpression: true
|
|
|
7109
8209
|
return sourceElements;
|
|
7110
8210
|
}
|
|
7111
8211
|
|
|
7112
|
-
function parseModuleElement() {
|
|
7113
|
-
return parseSourceElement();
|
|
7114
|
-
}
|
|
7115
|
-
|
|
7116
|
-
function parseModuleElements() {
|
|
7117
|
-
var list = [],
|
|
7118
|
-
statement;
|
|
7119
|
-
|
|
7120
|
-
while (index < length) {
|
|
7121
|
-
if (match('}')) {
|
|
7122
|
-
break;
|
|
7123
|
-
}
|
|
7124
|
-
statement = parseModuleElement();
|
|
7125
|
-
if (typeof statement === 'undefined') {
|
|
7126
|
-
break;
|
|
7127
|
-
}
|
|
7128
|
-
list.push(statement);
|
|
7129
|
-
}
|
|
7130
|
-
|
|
7131
|
-
return list;
|
|
7132
|
-
}
|
|
7133
|
-
|
|
7134
|
-
function parseModuleBlock() {
|
|
7135
|
-
var block, marker = markerCreate();
|
|
7136
|
-
|
|
7137
|
-
expect('{');
|
|
7138
|
-
|
|
7139
|
-
block = parseModuleElements();
|
|
7140
|
-
|
|
7141
|
-
expect('}');
|
|
7142
|
-
|
|
7143
|
-
return markerApply(marker, delegate.createBlockStatement(block));
|
|
7144
|
-
}
|
|
7145
|
-
|
|
7146
8212
|
function parseProgram() {
|
|
7147
8213
|
var body, marker = markerCreate();
|
|
7148
8214
|
strict = false;
|
|
@@ -7613,7 +8679,7 @@ parseYieldExpression: true
|
|
|
7613
8679
|
}
|
|
7614
8680
|
|
|
7615
8681
|
function scanXJSEntity() {
|
|
7616
|
-
var ch, str = '', count = 0,
|
|
8682
|
+
var ch, str = '', start = index, count = 0, code;
|
|
7617
8683
|
ch = source[index];
|
|
7618
8684
|
assert(ch === '&', 'Entity must start with an ampersand');
|
|
7619
8685
|
index++;
|
|
@@ -7625,14 +8691,28 @@ parseYieldExpression: true
|
|
|
7625
8691
|
str += ch;
|
|
7626
8692
|
}
|
|
7627
8693
|
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
8694
|
+
// Well-formed entity (ending was found).
|
|
8695
|
+
if (ch === ';') {
|
|
8696
|
+
// Numeric entity.
|
|
8697
|
+
if (str[0] === '#') {
|
|
8698
|
+
if (str[1] === 'x') {
|
|
8699
|
+
code = +('0' + str.substr(1));
|
|
8700
|
+
} else {
|
|
8701
|
+
// Removing leading zeros in order to avoid treating as octal in old browsers.
|
|
8702
|
+
code = +str.substr(1).replace(Regex.LeadingZeros, '');
|
|
8703
|
+
}
|
|
8704
|
+
|
|
8705
|
+
if (!isNaN(code)) {
|
|
8706
|
+
return String.fromCharCode(code);
|
|
8707
|
+
}
|
|
8708
|
+
} else if (XHTMLEntities[str]) {
|
|
8709
|
+
return XHTMLEntities[str];
|
|
8710
|
+
}
|
|
7634
8711
|
}
|
|
7635
|
-
|
|
8712
|
+
|
|
8713
|
+
// Treat non-entity sequences as regular text.
|
|
8714
|
+
index = start + 1;
|
|
8715
|
+
return '&';
|
|
7636
8716
|
}
|
|
7637
8717
|
|
|
7638
8718
|
function scanXJSText(stopChars) {
|
|
@@ -7959,8 +9039,181 @@ parseYieldExpression: true
|
|
|
7959
9039
|
return markerApply(marker, delegate.createXJSElement(openingElement, closingElement, children));
|
|
7960
9040
|
}
|
|
7961
9041
|
|
|
9042
|
+
function parseTypeAlias() {
|
|
9043
|
+
var id, marker = markerCreate(), typeParameters = null, right;
|
|
9044
|
+
expectContextualKeyword('type');
|
|
9045
|
+
id = parseVariableIdentifier();
|
|
9046
|
+
if (match('<')) {
|
|
9047
|
+
typeParameters = parseTypeParameterDeclaration();
|
|
9048
|
+
}
|
|
9049
|
+
expect('=');
|
|
9050
|
+
right = parseType();
|
|
9051
|
+
consumeSemicolon();
|
|
9052
|
+
return markerApply(marker, delegate.createTypeAlias(id, typeParameters, right));
|
|
9053
|
+
}
|
|
9054
|
+
|
|
9055
|
+
function parseInterfaceExtends() {
|
|
9056
|
+
var marker = markerCreate(), id, typeParameters = null;
|
|
9057
|
+
|
|
9058
|
+
id = parseVariableIdentifier();
|
|
9059
|
+
if (match('<')) {
|
|
9060
|
+
typeParameters = parseTypeParameterInstantiation();
|
|
9061
|
+
}
|
|
9062
|
+
|
|
9063
|
+
return markerApply(marker, delegate.createInterfaceExtends(
|
|
9064
|
+
id,
|
|
9065
|
+
typeParameters
|
|
9066
|
+
));
|
|
9067
|
+
}
|
|
9068
|
+
|
|
9069
|
+
function parseInterfaceish(marker, allowStatic) {
|
|
9070
|
+
var body, bodyMarker, extended = [], id,
|
|
9071
|
+
typeParameters = null;
|
|
9072
|
+
|
|
9073
|
+
id = parseVariableIdentifier();
|
|
9074
|
+
if (match('<')) {
|
|
9075
|
+
typeParameters = parseTypeParameterDeclaration();
|
|
9076
|
+
}
|
|
9077
|
+
|
|
9078
|
+
if (matchKeyword('extends')) {
|
|
9079
|
+
expectKeyword('extends');
|
|
9080
|
+
|
|
9081
|
+
while (index < length) {
|
|
9082
|
+
extended.push(parseInterfaceExtends());
|
|
9083
|
+
if (!match(',')) {
|
|
9084
|
+
break;
|
|
9085
|
+
}
|
|
9086
|
+
expect(',');
|
|
9087
|
+
}
|
|
9088
|
+
}
|
|
9089
|
+
|
|
9090
|
+
bodyMarker = markerCreate();
|
|
9091
|
+
body = markerApply(bodyMarker, parseObjectType(allowStatic));
|
|
9092
|
+
|
|
9093
|
+
return markerApply(marker, delegate.createInterface(
|
|
9094
|
+
id,
|
|
9095
|
+
typeParameters,
|
|
9096
|
+
body,
|
|
9097
|
+
extended
|
|
9098
|
+
));
|
|
9099
|
+
}
|
|
9100
|
+
|
|
9101
|
+
function parseInterface() {
|
|
9102
|
+
var body, bodyMarker, extended = [], id, marker = markerCreate(),
|
|
9103
|
+
typeParameters = null;
|
|
9104
|
+
|
|
9105
|
+
expectContextualKeyword('interface');
|
|
9106
|
+
return parseInterfaceish(marker, /* allowStatic */false);
|
|
9107
|
+
}
|
|
9108
|
+
|
|
9109
|
+
function parseDeclareClass() {
|
|
9110
|
+
var marker = markerCreate(), ret;
|
|
9111
|
+
expectContextualKeyword('declare');
|
|
9112
|
+
expectKeyword('class');
|
|
9113
|
+
|
|
9114
|
+
ret = parseInterfaceish(marker, /* allowStatic */true);
|
|
9115
|
+
ret.type = Syntax.DeclareClass;
|
|
9116
|
+
return ret;
|
|
9117
|
+
}
|
|
9118
|
+
|
|
9119
|
+
function parseDeclareFunction() {
|
|
9120
|
+
var id, idMarker,
|
|
9121
|
+
marker = markerCreate(), params, returnType, rest, tmp,
|
|
9122
|
+
typeParameters = null, value, valueMarker;
|
|
9123
|
+
|
|
9124
|
+
expectContextualKeyword('declare');
|
|
9125
|
+
expectKeyword('function');
|
|
9126
|
+
idMarker = markerCreate();
|
|
9127
|
+
id = parseVariableIdentifier();
|
|
9128
|
+
|
|
9129
|
+
valueMarker = markerCreate();
|
|
9130
|
+
if (match('<')) {
|
|
9131
|
+
typeParameters = parseTypeParameterDeclaration();
|
|
9132
|
+
}
|
|
9133
|
+
expect('(');
|
|
9134
|
+
tmp = parseFunctionTypeParams();
|
|
9135
|
+
params = tmp.params;
|
|
9136
|
+
rest = tmp.rest;
|
|
9137
|
+
expect(')');
|
|
9138
|
+
|
|
9139
|
+
expect(':');
|
|
9140
|
+
returnType = parseType();
|
|
9141
|
+
|
|
9142
|
+
value = markerApply(valueMarker, delegate.createFunctionTypeAnnotation(
|
|
9143
|
+
params,
|
|
9144
|
+
returnType,
|
|
9145
|
+
rest,
|
|
9146
|
+
typeParameters
|
|
9147
|
+
));
|
|
9148
|
+
|
|
9149
|
+
id.typeAnnotation = markerApply(valueMarker, delegate.createTypeAnnotation(
|
|
9150
|
+
value
|
|
9151
|
+
));
|
|
9152
|
+
markerApply(idMarker, id);
|
|
9153
|
+
|
|
9154
|
+
consumeSemicolon();
|
|
9155
|
+
|
|
9156
|
+
return markerApply(marker, delegate.createDeclareFunction(
|
|
9157
|
+
id
|
|
9158
|
+
));
|
|
9159
|
+
}
|
|
9160
|
+
|
|
9161
|
+
function parseDeclareVariable() {
|
|
9162
|
+
var id, marker = markerCreate();
|
|
9163
|
+
expectContextualKeyword('declare');
|
|
9164
|
+
expectKeyword('var');
|
|
9165
|
+
id = parseTypeAnnotatableIdentifier();
|
|
9166
|
+
|
|
9167
|
+
consumeSemicolon();
|
|
9168
|
+
|
|
9169
|
+
return markerApply(marker, delegate.createDeclareVariable(
|
|
9170
|
+
id
|
|
9171
|
+
));
|
|
9172
|
+
}
|
|
9173
|
+
|
|
9174
|
+
function parseDeclareModule() {
|
|
9175
|
+
var body = [], bodyMarker, id, idMarker, marker = markerCreate(), token;
|
|
9176
|
+
expectContextualKeyword('declare');
|
|
9177
|
+
expectContextualKeyword('module');
|
|
9178
|
+
|
|
9179
|
+
if (lookahead.type === Token.StringLiteral) {
|
|
9180
|
+
if (strict && lookahead.octal) {
|
|
9181
|
+
throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
|
|
9182
|
+
}
|
|
9183
|
+
idMarker = markerCreate();
|
|
9184
|
+
id = markerApply(idMarker, delegate.createLiteral(lex()));
|
|
9185
|
+
} else {
|
|
9186
|
+
id = parseVariableIdentifier();
|
|
9187
|
+
}
|
|
9188
|
+
|
|
9189
|
+
bodyMarker = markerCreate();
|
|
9190
|
+
expect('{');
|
|
9191
|
+
while (index < length && !match('}')) {
|
|
9192
|
+
token = lookahead2();
|
|
9193
|
+
switch (token.value) {
|
|
9194
|
+
case 'class':
|
|
9195
|
+
body.push(parseDeclareClass());
|
|
9196
|
+
break;
|
|
9197
|
+
case 'function':
|
|
9198
|
+
body.push(parseDeclareFunction());
|
|
9199
|
+
break;
|
|
9200
|
+
case 'var':
|
|
9201
|
+
body.push(parseDeclareVariable());
|
|
9202
|
+
break;
|
|
9203
|
+
default:
|
|
9204
|
+
throwUnexpected(lookahead);
|
|
9205
|
+
}
|
|
9206
|
+
}
|
|
9207
|
+
expect('}');
|
|
9208
|
+
|
|
9209
|
+
return markerApply(marker, delegate.createDeclareModule(
|
|
9210
|
+
id,
|
|
9211
|
+
markerApply(bodyMarker, delegate.createBlockStatement(body))
|
|
9212
|
+
));
|
|
9213
|
+
}
|
|
9214
|
+
|
|
7962
9215
|
function collectToken() {
|
|
7963
|
-
var start, loc, token, range, value;
|
|
9216
|
+
var start, loc, token, range, value, entry;
|
|
7964
9217
|
|
|
7965
9218
|
if (!state.inXJSChild) {
|
|
7966
9219
|
skipComment();
|
|
@@ -7983,12 +9236,19 @@ parseYieldExpression: true
|
|
|
7983
9236
|
if (token.type !== Token.EOF) {
|
|
7984
9237
|
range = [token.range[0], token.range[1]];
|
|
7985
9238
|
value = source.slice(token.range[0], token.range[1]);
|
|
7986
|
-
|
|
9239
|
+
entry = {
|
|
7987
9240
|
type: TokenName[token.type],
|
|
7988
9241
|
value: value,
|
|
7989
9242
|
range: range,
|
|
7990
9243
|
loc: loc
|
|
7991
|
-
}
|
|
9244
|
+
};
|
|
9245
|
+
if (token.regex) {
|
|
9246
|
+
entry.regex = {
|
|
9247
|
+
pattern: token.regex.pattern,
|
|
9248
|
+
flags: token.regex.flags
|
|
9249
|
+
};
|
|
9250
|
+
}
|
|
9251
|
+
extra.tokens.push(entry);
|
|
7992
9252
|
}
|
|
7993
9253
|
|
|
7994
9254
|
return token;
|
|
@@ -8027,6 +9287,7 @@ parseYieldExpression: true
|
|
|
8027
9287
|
extra.tokens.push({
|
|
8028
9288
|
type: 'RegularExpression',
|
|
8029
9289
|
value: regex.literal,
|
|
9290
|
+
regex: regex.regex,
|
|
8030
9291
|
range: [pos, index],
|
|
8031
9292
|
loc: loc
|
|
8032
9293
|
});
|
|
@@ -8044,6 +9305,12 @@ parseYieldExpression: true
|
|
|
8044
9305
|
type: entry.type,
|
|
8045
9306
|
value: entry.value
|
|
8046
9307
|
};
|
|
9308
|
+
if (entry.regex) {
|
|
9309
|
+
token.regex = {
|
|
9310
|
+
pattern: entry.regex.pattern,
|
|
9311
|
+
flags: entry.regex.flags
|
|
9312
|
+
};
|
|
9313
|
+
}
|
|
8047
9314
|
if (extra.range) {
|
|
8048
9315
|
token.range = entry.range;
|
|
8049
9316
|
}
|
|
@@ -8230,8 +9497,10 @@ parseYieldExpression: true
|
|
|
8230
9497
|
inSwitch: false,
|
|
8231
9498
|
inXJSChild: false,
|
|
8232
9499
|
inXJSTag: false,
|
|
9500
|
+
inType: false,
|
|
8233
9501
|
lastCommentStart: -1,
|
|
8234
|
-
yieldAllowed: false
|
|
9502
|
+
yieldAllowed: false,
|
|
9503
|
+
awaitAllowed: false
|
|
8235
9504
|
};
|
|
8236
9505
|
|
|
8237
9506
|
extra = {};
|
|
@@ -8302,7 +9571,7 @@ parseYieldExpression: true
|
|
|
8302
9571
|
}
|
|
8303
9572
|
|
|
8304
9573
|
// Sync with *.json manifests.
|
|
8305
|
-
exports.version = '
|
|
9574
|
+
exports.version = '8001.1001.0-dev-harmony-fb';
|
|
8306
9575
|
|
|
8307
9576
|
exports.tokenize = tokenize;
|
|
8308
9577
|
|
|
@@ -8332,34 +9601,6 @@ parseYieldExpression: true
|
|
|
8332
9601
|
}));
|
|
8333
9602
|
/* vim: set sw=4 ts=4 et tw=80 : */
|
|
8334
9603
|
|
|
8335
|
-
},{}],9:[function(_dereq_,module,exports){
|
|
8336
|
-
var Base62 = (function (my) {
|
|
8337
|
-
my.chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
|
|
8338
|
-
|
|
8339
|
-
my.encode = function(i){
|
|
8340
|
-
if (i === 0) {return '0'}
|
|
8341
|
-
var s = ''
|
|
8342
|
-
while (i > 0) {
|
|
8343
|
-
s = this.chars[i % 62] + s
|
|
8344
|
-
i = Math.floor(i/62)
|
|
8345
|
-
}
|
|
8346
|
-
return s
|
|
8347
|
-
};
|
|
8348
|
-
my.decode = function(a,b,c,d){
|
|
8349
|
-
for (
|
|
8350
|
-
b = c = (
|
|
8351
|
-
a === (/\W|_|^$/.test(a += "") || a)
|
|
8352
|
-
) - 1;
|
|
8353
|
-
d = a.charCodeAt(c++);
|
|
8354
|
-
)
|
|
8355
|
-
b = b * 62 + d - [, 48, 29, 87][d >> 5];
|
|
8356
|
-
return b
|
|
8357
|
-
};
|
|
8358
|
-
|
|
8359
|
-
return my;
|
|
8360
|
-
}({}));
|
|
8361
|
-
|
|
8362
|
-
module.exports = Base62
|
|
8363
9604
|
},{}],10:[function(_dereq_,module,exports){
|
|
8364
9605
|
/*
|
|
8365
9606
|
* Copyright 2009-2011 Mozilla Foundation and contributors
|
|
@@ -10632,7 +11873,6 @@ function _nodeIsBlockScopeBoundary(node, parentNode) {
|
|
|
10632
11873
|
|
|
10633
11874
|
/**
|
|
10634
11875
|
* @param {object} node
|
|
10635
|
-
* @param {function} visitor
|
|
10636
11876
|
* @param {array} path
|
|
10637
11877
|
* @param {object} state
|
|
10638
11878
|
*/
|
|
@@ -10830,7 +12070,7 @@ function transform(visitors, source, options) {
|
|
|
10830
12070
|
exports.transform = transform;
|
|
10831
12071
|
exports.Syntax = Syntax;
|
|
10832
12072
|
|
|
10833
|
-
},{"./utils":22,"esprima-fb":
|
|
12073
|
+
},{"./utils":22,"esprima-fb":9,"source-map":10}],22:[function(_dereq_,module,exports){
|
|
10834
12074
|
/**
|
|
10835
12075
|
* Copyright 2013 Facebook, Inc.
|
|
10836
12076
|
*
|
|
@@ -11281,8 +12521,8 @@ function initScopeMetadata(boundaryNode, path, node) {
|
|
|
11281
12521
|
function declareIdentInLocalScope(identName, metaData, state) {
|
|
11282
12522
|
state.localScope.identifiers[identName] = {
|
|
11283
12523
|
boundaryNode: metaData.boundaryNode,
|
|
11284
|
-
path: metaData.
|
|
11285
|
-
node: metaData.
|
|
12524
|
+
path: metaData.bindingPath,
|
|
12525
|
+
node: metaData.bindingNode,
|
|
11286
12526
|
state: Object.create(state)
|
|
11287
12527
|
};
|
|
11288
12528
|
}
|
|
@@ -11299,7 +12539,6 @@ function getLexicalBindingMetadata(identName, state) {
|
|
|
11299
12539
|
* @param {function} analyzer
|
|
11300
12540
|
* @param {function} traverser
|
|
11301
12541
|
* @param {object} node
|
|
11302
|
-
* @param {function} visitor
|
|
11303
12542
|
* @param {array} path
|
|
11304
12543
|
* @param {object} state
|
|
11305
12544
|
*/
|
|
@@ -11376,16 +12615,22 @@ function enqueueNodeWithStartIndex(queue, node) {
|
|
|
11376
12615
|
* @param {string} type - node type to lookup.
|
|
11377
12616
|
*/
|
|
11378
12617
|
function containsChildOfType(node, type) {
|
|
12618
|
+
return containsChildMatching(node, function(node) {
|
|
12619
|
+
return node.type === type;
|
|
12620
|
+
});
|
|
12621
|
+
}
|
|
12622
|
+
|
|
12623
|
+
function containsChildMatching(node, matcher) {
|
|
11379
12624
|
var foundMatchingChild = false;
|
|
11380
12625
|
function nodeTypeAnalyzer(node) {
|
|
11381
|
-
if (node
|
|
12626
|
+
if (matcher(node) === true) {
|
|
11382
12627
|
foundMatchingChild = true;
|
|
11383
12628
|
return false;
|
|
11384
12629
|
}
|
|
11385
12630
|
}
|
|
11386
12631
|
function nodeTypeTraverser(child, path, state) {
|
|
11387
12632
|
if (!foundMatchingChild) {
|
|
11388
|
-
foundMatchingChild =
|
|
12633
|
+
foundMatchingChild = containsChildMatching(child, matcher);
|
|
11389
12634
|
}
|
|
11390
12635
|
}
|
|
11391
12636
|
analyzeAndTraverse(
|
|
@@ -11414,11 +12659,20 @@ function getBoundaryNode(path) {
|
|
|
11414
12659
|
);
|
|
11415
12660
|
}
|
|
11416
12661
|
|
|
12662
|
+
function getTempVar(tempVarIndex) {
|
|
12663
|
+
return '$__' + tempVarIndex;
|
|
12664
|
+
}
|
|
12665
|
+
|
|
12666
|
+
function getTempVarWithValue(tempVarIndex, tempVarValue) {
|
|
12667
|
+
return getTempVar(tempVarIndex) + '=' + tempVarValue;
|
|
12668
|
+
}
|
|
12669
|
+
|
|
11417
12670
|
exports.append = append;
|
|
11418
12671
|
exports.catchup = catchup;
|
|
11419
12672
|
exports.catchupWhiteOut = catchupWhiteOut;
|
|
11420
12673
|
exports.catchupWhiteSpace = catchupWhiteSpace;
|
|
11421
12674
|
exports.catchupNewlines = catchupNewlines;
|
|
12675
|
+
exports.containsChildMatching = containsChildMatching;
|
|
11422
12676
|
exports.containsChildOfType = containsChildOfType;
|
|
11423
12677
|
exports.createState = createState;
|
|
11424
12678
|
exports.declareIdentInLocalScope = declareIdentInLocalScope;
|
|
@@ -11436,8 +12690,10 @@ exports.updateState = updateState;
|
|
|
11436
12690
|
exports.analyzeAndTraverse = analyzeAndTraverse;
|
|
11437
12691
|
exports.getOrderedChildren = getOrderedChildren;
|
|
11438
12692
|
exports.getNodeSourceText = getNodeSourceText;
|
|
12693
|
+
exports.getTempVar = getTempVar;
|
|
12694
|
+
exports.getTempVarWithValue = getTempVarWithValue;
|
|
11439
12695
|
|
|
11440
|
-
},{"./docblock":20,"esprima-fb":
|
|
12696
|
+
},{"./docblock":20,"esprima-fb":9}],23:[function(_dereq_,module,exports){
|
|
11441
12697
|
/**
|
|
11442
12698
|
* Copyright 2013 Facebook, Inc.
|
|
11443
12699
|
*
|
|
@@ -11512,7 +12768,14 @@ function visitArrowFunction(traverse, node, path, state) {
|
|
|
11512
12768
|
|
|
11513
12769
|
// Bind the function only if `this` value is used
|
|
11514
12770
|
// inside it or inside any sub-expression.
|
|
11515
|
-
|
|
12771
|
+
var containsBindingSyntax =
|
|
12772
|
+
utils.containsChildMatching(node.body, function(node) {
|
|
12773
|
+
return node.type === Syntax.ThisExpression
|
|
12774
|
+
|| (node.type === Syntax.Identifier
|
|
12775
|
+
&& node.name === "super");
|
|
12776
|
+
});
|
|
12777
|
+
|
|
12778
|
+
if (containsBindingSyntax) {
|
|
11516
12779
|
utils.append('.bind(this)', state);
|
|
11517
12780
|
}
|
|
11518
12781
|
|
|
@@ -11553,7 +12816,7 @@ function renderExpressionBody(traverse, node, path, state) {
|
|
|
11553
12816
|
// Special handling of rest param.
|
|
11554
12817
|
if (node.rest) {
|
|
11555
12818
|
utils.append(
|
|
11556
|
-
restParamVisitors.renderRestParamSetup(node),
|
|
12819
|
+
restParamVisitors.renderRestParamSetup(node, state),
|
|
11557
12820
|
state
|
|
11558
12821
|
);
|
|
11559
12822
|
}
|
|
@@ -11590,7 +12853,7 @@ exports.visitorList = [
|
|
|
11590
12853
|
];
|
|
11591
12854
|
|
|
11592
12855
|
|
|
11593
|
-
},{"../src/utils":22,"./es6-destructuring-visitors":25,"./es6-rest-param-visitors":28,"esprima-fb":
|
|
12856
|
+
},{"../src/utils":22,"./es6-destructuring-visitors":25,"./es6-rest-param-visitors":28,"esprima-fb":9}],24:[function(_dereq_,module,exports){
|
|
11594
12857
|
/**
|
|
11595
12858
|
* Copyright 2013 Facebook, Inc.
|
|
11596
12859
|
*
|
|
@@ -11821,7 +13084,7 @@ function visitClassFunctionExpression(traverse, node, path, state) {
|
|
|
11821
13084
|
|
|
11822
13085
|
var params = node.params;
|
|
11823
13086
|
if (params.length > 0) {
|
|
11824
|
-
utils.
|
|
13087
|
+
utils.catchupNewlines(params[0].range[0], state);
|
|
11825
13088
|
for (var i = 0; i < params.length; i++) {
|
|
11826
13089
|
utils.catchup(node.params[i].range[0], state);
|
|
11827
13090
|
path.unshift(node);
|
|
@@ -12159,7 +13422,7 @@ exports.visitorList = [
|
|
|
12159
13422
|
visitSuperMemberExpression
|
|
12160
13423
|
];
|
|
12161
13424
|
|
|
12162
|
-
},{"../src/utils":22,"./reserved-words-helper":32,"base62":
|
|
13425
|
+
},{"../src/utils":22,"./reserved-words-helper":32,"base62":8,"esprima-fb":9}],25:[function(_dereq_,module,exports){
|
|
12163
13426
|
/**
|
|
12164
13427
|
* Copyright 2014 Facebook, Inc.
|
|
12165
13428
|
*
|
|
@@ -12215,7 +13478,7 @@ var restPropertyHelpers = _dereq_('./es7-rest-property-helpers');
|
|
|
12215
13478
|
|
|
12216
13479
|
function visitStructuredVariable(traverse, node, path, state) {
|
|
12217
13480
|
// Allocate new temp for the pattern.
|
|
12218
|
-
utils.append(
|
|
13481
|
+
utils.append(utils.getTempVar(state.localScope.tempVarIndex) + '=', state);
|
|
12219
13482
|
// Skip the pattern and assign the init to the temp.
|
|
12220
13483
|
utils.catchupWhiteSpace(node.init.range[0], state);
|
|
12221
13484
|
traverse(node.init, path, state);
|
|
@@ -12255,14 +13518,14 @@ function getDestructuredComponents(node, state) {
|
|
|
12255
13518
|
// and also for function param patterns: [x, ...xs, y]
|
|
12256
13519
|
components.push(item.argument.name +
|
|
12257
13520
|
'=Array.prototype.slice.call(' +
|
|
12258
|
-
|
|
13521
|
+
utils.getTempVar(tmpIndex) + ',' + idx + ')'
|
|
12259
13522
|
);
|
|
12260
13523
|
continue;
|
|
12261
13524
|
}
|
|
12262
13525
|
|
|
12263
13526
|
if (item.type === Syntax.SpreadProperty) {
|
|
12264
13527
|
var restExpression = restPropertyHelpers.renderRestExpression(
|
|
12265
|
-
|
|
13528
|
+
utils.getTempVar(tmpIndex),
|
|
12266
13529
|
patternItems
|
|
12267
13530
|
);
|
|
12268
13531
|
components.push(item.argument.name + '=' + restExpression);
|
|
@@ -12281,8 +13544,8 @@ function getDestructuredComponents(node, state) {
|
|
|
12281
13544
|
} else {
|
|
12282
13545
|
// Complex sub-structure.
|
|
12283
13546
|
components.push(
|
|
12284
|
-
|
|
12285
|
-
getDestructuredComponents(value, state)
|
|
13547
|
+
utils.getTempVarWithValue(++state.localScope.tempVarIndex, accessor) +
|
|
13548
|
+
',' + getDestructuredComponents(value, state)
|
|
12286
13549
|
);
|
|
12287
13550
|
}
|
|
12288
13551
|
}
|
|
@@ -12295,14 +13558,16 @@ function getPatternItems(node) {
|
|
|
12295
13558
|
}
|
|
12296
13559
|
|
|
12297
13560
|
function getPatternItemAccessor(node, patternItem, tmpIndex, idx) {
|
|
12298
|
-
var tmpName =
|
|
13561
|
+
var tmpName = utils.getTempVar(tmpIndex);
|
|
12299
13562
|
if (node.type === Syntax.ObjectPattern) {
|
|
12300
13563
|
if (reservedWordsHelper.isReservedWord(patternItem.key.name)) {
|
|
12301
13564
|
return tmpName + '["' + patternItem.key.name + '"]';
|
|
12302
|
-
} else {
|
|
13565
|
+
} else if (patternItem.key.type === Syntax.Literal) {
|
|
13566
|
+
return tmpName + '[' + JSON.stringify(patternItem.key.value) + ']';
|
|
13567
|
+
} else if (patternItem.key.type === Syntax.Identifier) {
|
|
12303
13568
|
return tmpName + '.' + patternItem.key.name;
|
|
12304
13569
|
}
|
|
12305
|
-
} else {
|
|
13570
|
+
} else if (node.type === Syntax.ArrayPattern) {
|
|
12306
13571
|
return tmpName + '[' + idx + ']';
|
|
12307
13572
|
}
|
|
12308
13573
|
}
|
|
@@ -12313,14 +13578,6 @@ function getPatternItemValue(node, patternItem) {
|
|
|
12313
13578
|
: patternItem;
|
|
12314
13579
|
}
|
|
12315
13580
|
|
|
12316
|
-
function getInitialValue(index, value) {
|
|
12317
|
-
return getTmpVar(index) + '=' + value;
|
|
12318
|
-
}
|
|
12319
|
-
|
|
12320
|
-
function getTmpVar(index) {
|
|
12321
|
-
return '$__' + index;
|
|
12322
|
-
}
|
|
12323
|
-
|
|
12324
13581
|
// -------------------------------------------------------
|
|
12325
13582
|
// 2. Assignment expression.
|
|
12326
13583
|
//
|
|
@@ -12330,14 +13587,14 @@ function getTmpVar(index) {
|
|
|
12330
13587
|
|
|
12331
13588
|
function visitStructuredAssignment(traverse, node, path, state) {
|
|
12332
13589
|
var exprNode = node.expression;
|
|
12333
|
-
utils.append('var ' +
|
|
13590
|
+
utils.append('var ' + utils.getTempVar(state.localScope.tempVarIndex) + '=', state);
|
|
12334
13591
|
|
|
12335
13592
|
utils.catchupWhiteSpace(exprNode.right.range[0], state);
|
|
12336
13593
|
traverse(exprNode.right, path, state);
|
|
12337
13594
|
utils.catchup(exprNode.right.range[1], state);
|
|
12338
13595
|
|
|
12339
13596
|
utils.append(
|
|
12340
|
-
'
|
|
13597
|
+
';' + getDestructuredComponents(exprNode.left, state) + ';',
|
|
12341
13598
|
state
|
|
12342
13599
|
);
|
|
12343
13600
|
|
|
@@ -12362,7 +13619,7 @@ visitStructuredAssignment.test = function(node, path, state) {
|
|
|
12362
13619
|
// -------------------------------------------------------
|
|
12363
13620
|
|
|
12364
13621
|
function visitStructuredParameter(traverse, node, path, state) {
|
|
12365
|
-
utils.append(
|
|
13622
|
+
utils.append(utils.getTempVar(getParamIndex(node, path)), state);
|
|
12366
13623
|
utils.catchupWhiteSpace(node.range[1], state);
|
|
12367
13624
|
return true;
|
|
12368
13625
|
}
|
|
@@ -12407,7 +13664,7 @@ function visitFunctionBodyForStructuredParameter(traverse, node, path, state) {
|
|
|
12407
13664
|
|
|
12408
13665
|
if (funcNode.rest) {
|
|
12409
13666
|
utils.append(
|
|
12410
|
-
restParamVisitors.renderRestParamSetup(funcNode),
|
|
13667
|
+
restParamVisitors.renderRestParamSetup(funcNode, state),
|
|
12411
13668
|
state
|
|
12412
13669
|
);
|
|
12413
13670
|
}
|
|
@@ -12447,7 +13704,7 @@ exports.visitorList = [
|
|
|
12447
13704
|
exports.renderDestructuredComponents = renderDestructuredComponents;
|
|
12448
13705
|
|
|
12449
13706
|
|
|
12450
|
-
},{"../src/utils":22,"./es6-rest-param-visitors":28,"./es7-rest-property-helpers":30,"./reserved-words-helper":32,"esprima-fb":
|
|
13707
|
+
},{"../src/utils":22,"./es6-rest-param-visitors":28,"./es7-rest-property-helpers":30,"./reserved-words-helper":32,"esprima-fb":9}],26:[function(_dereq_,module,exports){
|
|
12451
13708
|
/**
|
|
12452
13709
|
* Copyright 2013 Facebook, Inc.
|
|
12453
13710
|
*
|
|
@@ -12518,7 +13775,7 @@ exports.visitorList = [
|
|
|
12518
13775
|
visitObjectConciseMethod
|
|
12519
13776
|
];
|
|
12520
13777
|
|
|
12521
|
-
},{"../src/utils":22,"./reserved-words-helper":32,"esprima-fb":
|
|
13778
|
+
},{"../src/utils":22,"./reserved-words-helper":32,"esprima-fb":9}],27:[function(_dereq_,module,exports){
|
|
12522
13779
|
/**
|
|
12523
13780
|
* Copyright 2013 Facebook, Inc.
|
|
12524
13781
|
*
|
|
@@ -12545,7 +13802,7 @@ exports.visitorList = [
|
|
|
12545
13802
|
* return {x, y}; // {x: x, y: y}
|
|
12546
13803
|
* };
|
|
12547
13804
|
*
|
|
12548
|
-
* //
|
|
13805
|
+
* // Destructuring.
|
|
12549
13806
|
* function init({port, ip, coords: {x, y}}) { ... }
|
|
12550
13807
|
*
|
|
12551
13808
|
*/
|
|
@@ -12573,7 +13830,7 @@ exports.visitorList = [
|
|
|
12573
13830
|
];
|
|
12574
13831
|
|
|
12575
13832
|
|
|
12576
|
-
},{"../src/utils":22,"esprima-fb":
|
|
13833
|
+
},{"../src/utils":22,"esprima-fb":9}],28:[function(_dereq_,module,exports){
|
|
12577
13834
|
/**
|
|
12578
13835
|
* Copyright 2013 Facebook, Inc.
|
|
12579
13836
|
*
|
|
@@ -12593,16 +13850,20 @@ exports.visitorList = [
|
|
|
12593
13850
|
/*jslint node:true*/
|
|
12594
13851
|
|
|
12595
13852
|
/**
|
|
12596
|
-
* Desugars ES6 rest parameters into ES3 arguments
|
|
13853
|
+
* Desugars ES6 rest parameters into an ES3 arguments array.
|
|
12597
13854
|
*
|
|
12598
13855
|
* function printf(template, ...args) {
|
|
12599
13856
|
* args.forEach(...);
|
|
12600
|
-
* }
|
|
13857
|
+
* }
|
|
13858
|
+
*
|
|
13859
|
+
* We could use `Array.prototype.slice.call`, but that usage of arguments causes
|
|
13860
|
+
* functions to be deoptimized in V8, so instead we use a for-loop.
|
|
12601
13861
|
*
|
|
12602
13862
|
* function printf(template) {
|
|
12603
|
-
* var args = []
|
|
13863
|
+
* for (var args = [], $__0 = 1, $__1 = arguments.length; $__0 < $__1; $__0++)
|
|
13864
|
+
* args.push(arguments[$__0]);
|
|
12604
13865
|
* args.forEach(...);
|
|
12605
|
-
* }
|
|
13866
|
+
* }
|
|
12606
13867
|
*
|
|
12607
13868
|
*/
|
|
12608
13869
|
var Syntax = _dereq_('esprima-fb').Syntax;
|
|
@@ -12647,17 +13908,22 @@ visitFunctionParamsWithRestParam.test = function(node, path, state) {
|
|
|
12647
13908
|
return _nodeIsFunctionWithRestParam(node);
|
|
12648
13909
|
};
|
|
12649
13910
|
|
|
12650
|
-
function renderRestParamSetup(functionNode) {
|
|
12651
|
-
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
13911
|
+
function renderRestParamSetup(functionNode, state) {
|
|
13912
|
+
var idx = state.localScope.tempVarIndex++;
|
|
13913
|
+
var len = state.localScope.tempVarIndex++;
|
|
13914
|
+
|
|
13915
|
+
return 'for (var ' + functionNode.rest.name + '=[],' +
|
|
13916
|
+
utils.getTempVarWithValue(idx, functionNode.params.length) + ',' +
|
|
13917
|
+
utils.getTempVarWithValue(len, 'arguments.length') + ';' +
|
|
13918
|
+
utils.getTempVar(idx) + '<' + utils.getTempVar(len) + ';' +
|
|
13919
|
+
utils.getTempVar(idx) + '++) ' +
|
|
13920
|
+
functionNode.rest.name + '.push(arguments[' + utils.getTempVar(idx) + ']);';
|
|
12655
13921
|
}
|
|
12656
13922
|
|
|
12657
13923
|
function visitFunctionBodyWithRestParam(traverse, node, path, state) {
|
|
12658
13924
|
utils.catchup(node.range[0] + 1, state);
|
|
12659
13925
|
var parentNode = path[0];
|
|
12660
|
-
utils.append(renderRestParamSetup(parentNode), state);
|
|
13926
|
+
utils.append(renderRestParamSetup(parentNode, state), state);
|
|
12661
13927
|
return true;
|
|
12662
13928
|
}
|
|
12663
13929
|
|
|
@@ -12672,7 +13938,7 @@ exports.visitorList = [
|
|
|
12672
13938
|
visitFunctionBodyWithRestParam
|
|
12673
13939
|
];
|
|
12674
13940
|
|
|
12675
|
-
},{"../src/utils":22,"esprima-fb":
|
|
13941
|
+
},{"../src/utils":22,"esprima-fb":9}],29:[function(_dereq_,module,exports){
|
|
12676
13942
|
/**
|
|
12677
13943
|
* Copyright 2013 Facebook, Inc.
|
|
12678
13944
|
*
|
|
@@ -12830,7 +14096,7 @@ exports.visitorList = [
|
|
|
12830
14096
|
visitTaggedTemplateExpression
|
|
12831
14097
|
];
|
|
12832
14098
|
|
|
12833
|
-
},{"../src/utils":22,"esprima-fb":
|
|
14099
|
+
},{"../src/utils":22,"esprima-fb":9}],30:[function(_dereq_,module,exports){
|
|
12834
14100
|
/**
|
|
12835
14101
|
* Copyright 2013 Facebook, Inc.
|
|
12836
14102
|
*
|
|
@@ -12913,7 +14179,7 @@ function renderRestExpression(accessorExpression, excludedProperties) {
|
|
|
12913
14179
|
|
|
12914
14180
|
exports.renderRestExpression = renderRestExpression;
|
|
12915
14181
|
|
|
12916
|
-
},{"../src/utils":22,"esprima-fb":
|
|
14182
|
+
},{"../src/utils":22,"esprima-fb":9}],31:[function(_dereq_,module,exports){
|
|
12917
14183
|
/**
|
|
12918
14184
|
* Copyright 2004-present Facebook. All Rights Reserved.
|
|
12919
14185
|
*/
|
|
@@ -12985,7 +14251,11 @@ function visitObjectLiteralSpread(traverse, node, path, state) {
|
|
|
12985
14251
|
}
|
|
12986
14252
|
}
|
|
12987
14253
|
|
|
12988
|
-
|
|
14254
|
+
// Strip any non-whitespace between the last item and the end.
|
|
14255
|
+
// We only catch up on whitespace so that we ignore any trailing commas which
|
|
14256
|
+
// are stripped out for IE8 support. Unfortunately, this also strips out any
|
|
14257
|
+
// trailing comments.
|
|
14258
|
+
utils.catchupWhiteSpace(node.range[1] - 1, state);
|
|
12989
14259
|
|
|
12990
14260
|
// Skip the trailing }
|
|
12991
14261
|
utils.move(node.range[1], state);
|
|
@@ -13019,7 +14289,7 @@ exports.visitorList = [
|
|
|
13019
14289
|
visitObjectLiteralSpread
|
|
13020
14290
|
];
|
|
13021
14291
|
|
|
13022
|
-
},{"../src/utils":22,"esprima-fb":
|
|
14292
|
+
},{"../src/utils":22,"esprima-fb":9}],32:[function(_dereq_,module,exports){
|
|
13023
14293
|
/**
|
|
13024
14294
|
* Copyright 2014 Facebook, Inc.
|
|
13025
14295
|
*
|
|
@@ -13061,7 +14331,7 @@ var RESERVED_WORDS = [].concat(
|
|
|
13061
14331
|
LITERALS
|
|
13062
14332
|
);
|
|
13063
14333
|
|
|
13064
|
-
var reservedWordsMap =
|
|
14334
|
+
var reservedWordsMap = Object.create(null);
|
|
13065
14335
|
RESERVED_WORDS.forEach(function(k) {
|
|
13066
14336
|
reservedWordsMap[k] = true;
|
|
13067
14337
|
});
|
|
@@ -13072,7 +14342,7 @@ exports.isReservedWord = function(word) {
|
|
|
13072
14342
|
|
|
13073
14343
|
},{}],33:[function(_dereq_,module,exports){
|
|
13074
14344
|
var esprima = _dereq_('esprima-fb');
|
|
13075
|
-
var utils = _dereq_('
|
|
14345
|
+
var utils = _dereq_('../src/utils');
|
|
13076
14346
|
|
|
13077
14347
|
var Syntax = esprima.Syntax;
|
|
13078
14348
|
|
|
@@ -13083,6 +14353,7 @@ function _isFunctionNode(node) {
|
|
|
13083
14353
|
}
|
|
13084
14354
|
|
|
13085
14355
|
function visitClassProperty(traverse, node, path, state) {
|
|
14356
|
+
utils.catchup(node.range[0], state);
|
|
13086
14357
|
utils.catchupWhiteOut(node.range[1], state);
|
|
13087
14358
|
return false;
|
|
13088
14359
|
}
|
|
@@ -13090,18 +14361,50 @@ visitClassProperty.test = function(node, path, state) {
|
|
|
13090
14361
|
return node.type === Syntax.ClassProperty;
|
|
13091
14362
|
};
|
|
13092
14363
|
|
|
14364
|
+
function visitTypeAlias(traverse, node, path, state) {
|
|
14365
|
+
utils.catchupWhiteOut(node.range[1], state);
|
|
14366
|
+
return false;
|
|
14367
|
+
}
|
|
14368
|
+
visitTypeAlias.test = function(node, path, state) {
|
|
14369
|
+
return node.type === Syntax.TypeAlias;
|
|
14370
|
+
};
|
|
14371
|
+
|
|
14372
|
+
function visitInterfaceDeclaration(traverse, node, path, state) {
|
|
14373
|
+
utils.catchupWhiteOut(node.range[1], state);
|
|
14374
|
+
return false;
|
|
14375
|
+
}
|
|
14376
|
+
visitInterfaceDeclaration.test = function(node, path, state) {
|
|
14377
|
+
return node.type === Syntax.InterfaceDeclaration;
|
|
14378
|
+
};
|
|
14379
|
+
|
|
14380
|
+
function visitDeclare(traverse, node, path, state) {
|
|
14381
|
+
utils.catchupWhiteOut(node.range[1], state);
|
|
14382
|
+
return false;
|
|
14383
|
+
}
|
|
14384
|
+
visitDeclare.test = function(node, path, state) {
|
|
14385
|
+
switch (node.type) {
|
|
14386
|
+
case Syntax.DeclareVariable:
|
|
14387
|
+
case Syntax.DeclareFunction:
|
|
14388
|
+
case Syntax.DeclareClass:
|
|
14389
|
+
case Syntax.DeclareModule: return true
|
|
14390
|
+
}
|
|
14391
|
+
return false;
|
|
14392
|
+
}
|
|
14393
|
+
|
|
13093
14394
|
function visitFunctionParametricAnnotation(traverse, node, path, state) {
|
|
14395
|
+
utils.catchup(node.range[0], state);
|
|
13094
14396
|
utils.catchupWhiteOut(node.range[1], state);
|
|
13095
14397
|
return false;
|
|
13096
14398
|
}
|
|
13097
14399
|
visitFunctionParametricAnnotation.test = function(node, path, state) {
|
|
13098
|
-
return node.type === Syntax.
|
|
14400
|
+
return node.type === Syntax.TypeParameterDeclaration
|
|
13099
14401
|
&& path[0]
|
|
13100
14402
|
&& _isFunctionNode(path[0])
|
|
13101
|
-
&& node === path[0].
|
|
14403
|
+
&& node === path[0].typeParameters;
|
|
13102
14404
|
};
|
|
13103
14405
|
|
|
13104
14406
|
function visitFunctionReturnAnnotation(traverse, node, path, state) {
|
|
14407
|
+
utils.catchup(node.range[0], state);
|
|
13105
14408
|
utils.catchupWhiteOut(node.range[1], state);
|
|
13106
14409
|
return false;
|
|
13107
14410
|
}
|
|
@@ -13110,38 +14413,83 @@ visitFunctionReturnAnnotation.test = function(node, path, state) {
|
|
|
13110
14413
|
};
|
|
13111
14414
|
|
|
13112
14415
|
function visitOptionalFunctionParameterAnnotation(traverse, node, path, state) {
|
|
13113
|
-
|
|
13114
|
-
traverse(node.id, path, state);
|
|
13115
|
-
path.shift();
|
|
13116
|
-
utils.catchup(node.id.range[1], state);
|
|
14416
|
+
utils.catchup(node.range[0] + node.name.length, state);
|
|
13117
14417
|
utils.catchupWhiteOut(node.range[1], state);
|
|
13118
14418
|
return false;
|
|
13119
14419
|
}
|
|
13120
14420
|
visitOptionalFunctionParameterAnnotation.test = function(node, path, state) {
|
|
13121
|
-
return node.type === Syntax.
|
|
14421
|
+
return node.type === Syntax.Identifier
|
|
14422
|
+
&& node.optional
|
|
13122
14423
|
&& path[0]
|
|
13123
14424
|
&& _isFunctionNode(path[0]);
|
|
13124
14425
|
};
|
|
13125
14426
|
|
|
13126
14427
|
function visitTypeAnnotatedIdentifier(traverse, node, path, state) {
|
|
13127
|
-
|
|
13128
|
-
utils.
|
|
13129
|
-
utils.catchupWhiteOut(node.range[1], state);
|
|
14428
|
+
utils.catchup(node.typeAnnotation.range[0], state);
|
|
14429
|
+
utils.catchupWhiteOut(node.typeAnnotation.range[1], state);
|
|
13130
14430
|
return false;
|
|
13131
14431
|
}
|
|
13132
14432
|
visitTypeAnnotatedIdentifier.test = function(node, path, state) {
|
|
13133
|
-
return node.type === Syntax.
|
|
14433
|
+
return node.type === Syntax.Identifier && node.typeAnnotation;
|
|
14434
|
+
};
|
|
14435
|
+
|
|
14436
|
+
function visitTypeAnnotatedObjectOrArrayPattern(traverse, node, path, state) {
|
|
14437
|
+
utils.catchup(node.typeAnnotation.range[0], state);
|
|
14438
|
+
utils.catchupWhiteOut(node.typeAnnotation.range[1], state);
|
|
14439
|
+
return false;
|
|
14440
|
+
}
|
|
14441
|
+
visitTypeAnnotatedObjectOrArrayPattern.test = function(node, path, state) {
|
|
14442
|
+
var rightType = node.type === Syntax.ObjectPattern
|
|
14443
|
+
|| node.type === Syntax.ArrayPattern;
|
|
14444
|
+
return rightType && node.typeAnnotation;
|
|
14445
|
+
};
|
|
14446
|
+
|
|
14447
|
+
/**
|
|
14448
|
+
* Methods cause trouble, since esprima parses them as a key/value pair, where
|
|
14449
|
+
* the location of the value starts at the method body. For example
|
|
14450
|
+
* { bar(x:number,...y:Array<number>):number {} }
|
|
14451
|
+
* is parsed as
|
|
14452
|
+
* { bar: function(x: number, ...y:Array<number>): number {} }
|
|
14453
|
+
* except that the location of the FunctionExpression value is 40-something,
|
|
14454
|
+
* which is the location of the function body. This means that by the time we
|
|
14455
|
+
* visit the params, rest param, and return type organically, we've already
|
|
14456
|
+
* catchup()'d passed them.
|
|
14457
|
+
*/
|
|
14458
|
+
function visitMethod(traverse, node, path, state) {
|
|
14459
|
+
path.unshift(node);
|
|
14460
|
+
traverse(node.key, path, state);
|
|
14461
|
+
|
|
14462
|
+
path.unshift(node.value);
|
|
14463
|
+
traverse(node.value.params, path, state);
|
|
14464
|
+
node.value.rest && traverse(node.value.rest, path, state);
|
|
14465
|
+
node.value.returnType && traverse(node.value.returnType, path, state);
|
|
14466
|
+
traverse(node.value.body, path, state);
|
|
14467
|
+
|
|
14468
|
+
path.shift();
|
|
14469
|
+
|
|
14470
|
+
path.shift();
|
|
14471
|
+
return false;
|
|
14472
|
+
}
|
|
14473
|
+
|
|
14474
|
+
visitMethod.test = function(node, path, state) {
|
|
14475
|
+
return (node.type === "Property" && (node.method || node.kind === "set" || node.kind === "get"))
|
|
14476
|
+
|| (node.type === "MethodDefinition");
|
|
13134
14477
|
};
|
|
13135
14478
|
|
|
13136
14479
|
exports.visitorList = [
|
|
13137
14480
|
visitClassProperty,
|
|
14481
|
+
visitDeclare,
|
|
14482
|
+
visitInterfaceDeclaration,
|
|
13138
14483
|
visitFunctionParametricAnnotation,
|
|
13139
14484
|
visitFunctionReturnAnnotation,
|
|
14485
|
+
visitMethod,
|
|
13140
14486
|
visitOptionalFunctionParameterAnnotation,
|
|
13141
|
-
|
|
14487
|
+
visitTypeAlias,
|
|
14488
|
+
visitTypeAnnotatedIdentifier,
|
|
14489
|
+
visitTypeAnnotatedObjectOrArrayPattern
|
|
13142
14490
|
];
|
|
13143
14491
|
|
|
13144
|
-
},{"
|
|
14492
|
+
},{"../src/utils":22,"esprima-fb":9}],34:[function(_dereq_,module,exports){
|
|
13145
14493
|
/**
|
|
13146
14494
|
* Copyright 2013-2014, Facebook, Inc.
|
|
13147
14495
|
* All rights reserved.
|
|
@@ -13153,7 +14501,7 @@ exports.visitorList = [
|
|
|
13153
14501
|
/*global exports:true*/
|
|
13154
14502
|
"use strict";
|
|
13155
14503
|
|
|
13156
|
-
var Syntax = _dereq_('
|
|
14504
|
+
var Syntax = _dereq_('jstransform').Syntax;
|
|
13157
14505
|
var utils = _dereq_('jstransform/src/utils');
|
|
13158
14506
|
|
|
13159
14507
|
var FALLBACK_TAGS = _dereq_('./xjs').knownTags;
|
|
@@ -13396,7 +14744,7 @@ exports.visitorList = [
|
|
|
13396
14744
|
visitReactTag
|
|
13397
14745
|
];
|
|
13398
14746
|
|
|
13399
|
-
},{"./xjs":36,"
|
|
14747
|
+
},{"./xjs":36,"jstransform":21,"jstransform/src/utils":22}],35:[function(_dereq_,module,exports){
|
|
13400
14748
|
/**
|
|
13401
14749
|
* Copyright 2013-2014, Facebook, Inc.
|
|
13402
14750
|
* All rights reserved.
|
|
@@ -13408,7 +14756,7 @@ exports.visitorList = [
|
|
|
13408
14756
|
/*global exports:true*/
|
|
13409
14757
|
"use strict";
|
|
13410
14758
|
|
|
13411
|
-
var Syntax = _dereq_('
|
|
14759
|
+
var Syntax = _dereq_('jstransform').Syntax;
|
|
13412
14760
|
var utils = _dereq_('jstransform/src/utils');
|
|
13413
14761
|
|
|
13414
14762
|
function addDisplayName(displayName, object, state) {
|
|
@@ -13432,7 +14780,7 @@ function addDisplayName(displayName, object, state) {
|
|
|
13432
14780
|
|
|
13433
14781
|
if (safe) {
|
|
13434
14782
|
utils.catchup(object['arguments'][0].range[0] + 1, state);
|
|
13435
|
-
utils.append(
|
|
14783
|
+
utils.append('displayName: "' + displayName + '",', state);
|
|
13436
14784
|
}
|
|
13437
14785
|
}
|
|
13438
14786
|
}
|
|
@@ -13491,7 +14839,7 @@ exports.visitorList = [
|
|
|
13491
14839
|
visitReactDisplayName
|
|
13492
14840
|
];
|
|
13493
14841
|
|
|
13494
|
-
},{"
|
|
14842
|
+
},{"jstransform":21,"jstransform/src/utils":22}],36:[function(_dereq_,module,exports){
|
|
13495
14843
|
/**
|
|
13496
14844
|
* Copyright 2013-2014, Facebook, Inc.
|
|
13497
14845
|
* All rights reserved.
|
|
@@ -13502,7 +14850,7 @@ exports.visitorList = [
|
|
|
13502
14850
|
*/
|
|
13503
14851
|
/*global exports:true*/
|
|
13504
14852
|
"use strict";
|
|
13505
|
-
var Syntax = _dereq_('
|
|
14853
|
+
var Syntax = _dereq_('jstransform').Syntax;
|
|
13506
14854
|
var utils = _dereq_('jstransform/src/utils');
|
|
13507
14855
|
|
|
13508
14856
|
var knownTags = {
|
|
@@ -13708,6 +15056,7 @@ function renderXJSLiteral(object, isLast, state, start, end) {
|
|
|
13708
15056
|
function renderXJSExpressionContainer(traverse, object, isLast, path, state) {
|
|
13709
15057
|
// Plus 1 to skip `{`.
|
|
13710
15058
|
utils.move(object.range[0] + 1, state);
|
|
15059
|
+
utils.catchup(object.expression.range[0], state);
|
|
13711
15060
|
traverse(object.expression, path, state);
|
|
13712
15061
|
|
|
13713
15062
|
if (!isLast && object.expression.type !== Syntax.XJSEmptyExpression) {
|
|
@@ -13725,7 +15074,7 @@ function renderXJSExpressionContainer(traverse, object, isLast, path, state) {
|
|
|
13725
15074
|
function quoteAttrName(attr) {
|
|
13726
15075
|
// Quote invalid JS identifiers.
|
|
13727
15076
|
if (!/^[a-z_$][a-z\d_$]*$/i.test(attr)) {
|
|
13728
|
-
return "'
|
|
15077
|
+
return '"' + attr + '"';
|
|
13729
15078
|
}
|
|
13730
15079
|
return attr;
|
|
13731
15080
|
}
|
|
@@ -13740,7 +15089,7 @@ exports.renderXJSLiteral = renderXJSLiteral;
|
|
|
13740
15089
|
exports.quoteAttrName = quoteAttrName;
|
|
13741
15090
|
exports.trimLeft = trimLeft;
|
|
13742
15091
|
|
|
13743
|
-
},{"
|
|
15092
|
+
},{"jstransform":21,"jstransform/src/utils":22}],37:[function(_dereq_,module,exports){
|
|
13744
15093
|
/*global exports:true*/
|
|
13745
15094
|
var es6ArrowFunctions = _dereq_('jstransform/visitors/es6-arrow-function-visitors');
|
|
13746
15095
|
var es6Classes = _dereq_('jstransform/visitors/es6-class-visitors');
|
|
@@ -13752,7 +15101,6 @@ var es6Templates = _dereq_('jstransform/visitors/es6-template-visitors');
|
|
|
13752
15101
|
var es7SpreadProperty = _dereq_('jstransform/visitors/es7-spread-property-visitors');
|
|
13753
15102
|
var react = _dereq_('./transforms/react');
|
|
13754
15103
|
var reactDisplayName = _dereq_('./transforms/reactDisplayName');
|
|
13755
|
-
var typesSyntax = _dereq_('jstransform/visitors/type-syntax');
|
|
13756
15104
|
|
|
13757
15105
|
/**
|
|
13758
15106
|
* Map from transformName => orderedListOfVisitors.
|
|
@@ -13766,8 +15114,7 @@ var transformVisitors = {
|
|
|
13766
15114
|
'es6-rest-params': es6RestParameters.visitorList,
|
|
13767
15115
|
'es6-templates': es6Templates.visitorList,
|
|
13768
15116
|
'es7-spread-property': es7SpreadProperty.visitorList,
|
|
13769
|
-
'react': react.visitorList.concat(reactDisplayName.visitorList)
|
|
13770
|
-
'types': typesSyntax.visitorList
|
|
15117
|
+
'react': react.visitorList.concat(reactDisplayName.visitorList)
|
|
13771
15118
|
};
|
|
13772
15119
|
|
|
13773
15120
|
var transformSets = {
|
|
@@ -13783,9 +15130,6 @@ var transformSets = {
|
|
|
13783
15130
|
],
|
|
13784
15131
|
'react': [
|
|
13785
15132
|
'react'
|
|
13786
|
-
],
|
|
13787
|
-
'type-annotations': [
|
|
13788
|
-
'types'
|
|
13789
15133
|
]
|
|
13790
15134
|
};
|
|
13791
15135
|
|
|
@@ -13793,7 +15137,6 @@ var transformSets = {
|
|
|
13793
15137
|
* Specifies the order in which each transform should run.
|
|
13794
15138
|
*/
|
|
13795
15139
|
var transformRunOrder = [
|
|
13796
|
-
'types',
|
|
13797
15140
|
'es6-arrow-functions',
|
|
13798
15141
|
'es6-object-concise-method',
|
|
13799
15142
|
'es6-object-short-notation',
|
|
@@ -13854,5 +15197,5 @@ exports.getVisitorsBySet = getVisitorsBySet;
|
|
|
13854
15197
|
exports.getAllVisitors = getAllVisitors;
|
|
13855
15198
|
exports.transformVisitors = transformVisitors;
|
|
13856
15199
|
|
|
13857
|
-
},{"./transforms/react":34,"./transforms/reactDisplayName":35,"jstransform/visitors/es6-arrow-function-visitors":23,"jstransform/visitors/es6-class-visitors":24,"jstransform/visitors/es6-destructuring-visitors":25,"jstransform/visitors/es6-object-concise-method-visitors":26,"jstransform/visitors/es6-object-short-notation-visitors":27,"jstransform/visitors/es6-rest-param-visitors":28,"jstransform/visitors/es6-template-visitors":29,"jstransform/visitors/es7-spread-property-visitors":31
|
|
15200
|
+
},{"./transforms/react":34,"./transforms/reactDisplayName":35,"jstransform/visitors/es6-arrow-function-visitors":23,"jstransform/visitors/es6-class-visitors":24,"jstransform/visitors/es6-destructuring-visitors":25,"jstransform/visitors/es6-object-concise-method-visitors":26,"jstransform/visitors/es6-object-short-notation-visitors":27,"jstransform/visitors/es6-rest-param-visitors":28,"jstransform/visitors/es6-template-visitors":29,"jstransform/visitors/es7-spread-property-visitors":31}]},{},[1])(1)
|
|
13858
15201
|
});
|