add function.sent
This commit is contained in:
@@ -28,7 +28,7 @@ const pp = Parser.prototype;
|
||||
// strict mode, init properties are also not allowed to be repeated.
|
||||
|
||||
pp.checkPropClash = function (prop, propHash) {
|
||||
if (prop.computed || prop.method) return;
|
||||
if (prop.computed) return;
|
||||
|
||||
let key = prop.key;
|
||||
let name;
|
||||
@@ -459,9 +459,7 @@ pp.parseExprAtom = function (refShorthandDefaultPos) {
|
||||
return this.parseObj(false, refShorthandDefaultPos);
|
||||
|
||||
case tt._function:
|
||||
node = this.startNode();
|
||||
this.next();
|
||||
return this.parseFunction(node, false);
|
||||
return this.parseFunctionExpression();
|
||||
|
||||
case tt.at:
|
||||
this.parseDecorators();
|
||||
@@ -493,6 +491,27 @@ pp.parseExprAtom = function (refShorthandDefaultPos) {
|
||||
}
|
||||
};
|
||||
|
||||
pp.parseFunctionExpression = function () {
|
||||
let node = this.startNode();
|
||||
let meta = this.parseIdentifier(true);
|
||||
if (this.state.inGenerator && this.eat(tt.dot) && this.hasPlugin("functionSent")) {
|
||||
return this.parseMetaProperty(node, meta, "sent");
|
||||
} else {
|
||||
return this.parseFunction(node, false);
|
||||
}
|
||||
};
|
||||
|
||||
pp.parseMetaProperty = function (node, meta, propertyName) {
|
||||
node.meta = meta;
|
||||
node.property = this.parseIdentifier(true);
|
||||
|
||||
if (node.property.name !== propertyName) {
|
||||
this.raise(node.property.start, `The only valid meta property for new is ${meta.name}.${propertyName}`);
|
||||
}
|
||||
|
||||
return this.finishNode(node, "MetaProperty");
|
||||
};
|
||||
|
||||
pp.parseLiteral = function (value, type) {
|
||||
let node = this.startNode();
|
||||
this.addExtra(node, "rawValue", value);
|
||||
@@ -592,14 +611,7 @@ pp.parseNew = function () {
|
||||
let meta = this.parseIdentifier(true);
|
||||
|
||||
if (this.eat(tt.dot)) {
|
||||
node.meta = meta;
|
||||
node.property = this.parseIdentifier(true);
|
||||
|
||||
if (node.property.name !== "target") {
|
||||
this.raise(node.property.start, "The only valid meta property for new is new.target");
|
||||
}
|
||||
|
||||
return this.finishNode(node, "MetaProperty");
|
||||
return this.parseMetaProperty(node, meta, "target");
|
||||
}
|
||||
|
||||
node.callee = this.parseNoCallExpr();
|
||||
|
||||
Reference in New Issue
Block a user