Huáng Jùnliàng da0af5fd99 V8intrinsic syntax plugin (#10148)
* feat: v8intrinsic syntax plugin

Implement V8 Intrinsic Syntax Extension. Here we check the execution branch inside the parseSubscript to make sure the V8IntrinsicIdentifier is immediately followed by a call expression.

* feat: disable combining placeholders and v8intrisic

per https://github.com/babel/babel/issues/10104#issuecomment-506950969

* test: add more error cases

* refactor: parse v8 intrinsic in parseExprAtom

This approach is identical to V8’s implementation. Move the test cases as the behaviour changes.

* fix: plugin-name typo

* test: add yield-expression test case

* feat: require startsExpr on modulo for v8intrinsic

* perf: skip eof and braceR check as they must return false

* Print V8IntrinsicIdentifier

* feat: add v8intrinsic to parser typings

* Add generated type helpers

* fix: incorrect type definition

* fix: allow V8IntrinsicIdentifier to be callee
2019-09-06 17:43:19 +02:00

191 lines
4.9 KiB
JSON

{
"type": "File",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 47
}
},
"program": {
"type": "Program",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 47
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 47
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 47
}
},
"id": null,
"generator": false,
"async": true,
"params": [],
"body": {
"type": "BlockStatement",
"start": 12,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 47
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 14,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 45
}
},
"expression": {
"type": "AwaitExpression",
"start": 14,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 45
}
},
"argument": {
"type": "CallExpression",
"start": 20,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 45
}
},
"callee": {
"type": "V8IntrinsicIdentifier",
"start": 20,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 35
},
"identifierName": "StringParseInt"
},
"name": "StringParseInt"
},
"arguments": [
{
"type": "StringLiteral",
"start": 36,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 36
},
"end": {
"line": 1,
"column": 40
}
},
"extra": {
"rawValue": "42",
"raw": "\"42\""
},
"value": "42"
},
{
"type": "NumericLiteral",
"start": 42,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 42
},
"end": {
"line": 1,
"column": 44
}
},
"extra": {
"rawValue": 10,
"raw": "10"
},
"value": 10
}
]
}
}
}
],
"directives": []
}
}
}
],
"directives": []
}
}