implement annotations (#4763)
This commit is contained in:
28
lib/parse.js
28
lib/parse.js
@@ -1758,7 +1758,6 @@ function parse($TEXT, options) {
|
||||
args : args,
|
||||
end : prev()
|
||||
});
|
||||
mark_pure(call);
|
||||
return subscripts(call, allow_calls);
|
||||
};
|
||||
|
||||
@@ -1840,7 +1839,6 @@ function parse($TEXT, options) {
|
||||
end.comments_after.length = 0;
|
||||
end.comments_after = ex.end.comments_after;
|
||||
ex.end = end;
|
||||
if (ex instanceof AST_Call) mark_pure(ex);
|
||||
if (is("punc", "=>")) return arrow(ex instanceof AST_Sequence ? ex.expressions : [ ex ], start);
|
||||
return subscripts(ex, allow_calls);
|
||||
case "[":
|
||||
@@ -2217,19 +2215,6 @@ function parse($TEXT, options) {
|
||||
});
|
||||
}
|
||||
|
||||
function mark_pure(call) {
|
||||
var start = call.start;
|
||||
var comments = start.comments_before;
|
||||
var i = HOP(start, "comments_before_length") ? start.comments_before_length : comments.length;
|
||||
while (--i >= 0) {
|
||||
var comment = comments[i];
|
||||
if (/[@#]__PURE__/.test(comment.value)) {
|
||||
call.pure = comment;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function template(tag) {
|
||||
var read = S.input.context().read_template;
|
||||
var strings = [];
|
||||
@@ -2277,7 +2262,6 @@ function parse($TEXT, options) {
|
||||
args : expr_list(")", !options.strict),
|
||||
end : prev()
|
||||
});
|
||||
mark_pure(call);
|
||||
return subscripts(call, true);
|
||||
}
|
||||
if (is("punc", "`")) {
|
||||
@@ -2286,6 +2270,18 @@ function parse($TEXT, options) {
|
||||
tmpl.end = prev();
|
||||
return subscripts(tmpl, allow_calls);
|
||||
}
|
||||
if (expr instanceof AST_Call && !expr.pure) {
|
||||
var start = expr.start;
|
||||
var comments = start.comments_before;
|
||||
var i = HOP(start, "comments_before_length") ? start.comments_before_length : comments.length;
|
||||
while (--i >= 0) {
|
||||
var match = /[@#]__PURE__/.exec(comments[i].value);
|
||||
if (match) {
|
||||
expr.pure = match[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return expr;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user