[parser cleanup] Unify implementation of CheckPossibleEvalCall
Besides reducing code duplication, this makes it easier to change the implementation, which may be necessary to properly support eval calls in arrow function parameter initializers. Review URL: https://codereview.chromium.org/1573363002 Cr-Commit-Position: refs/heads/master@{#33219}
This commit is contained in:
parent
95145fa826
commit
1be3c3a2ae
@ -830,6 +830,17 @@ class ParserBase : public Traits {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Keep track of eval() calls since they disable all local variable
|
||||
// optimizations. This checks if expression is an eval call, and if yes,
|
||||
// forwards the information to scope.
|
||||
void CheckPossibleEvalCall(ExpressionT expression, Scope* scope) {
|
||||
if (Traits::IsIdentifier(expression) &&
|
||||
Traits::IsEval(Traits::AsIdentifier(expression))) {
|
||||
scope->DeclarationScope()->RecordEvalCall();
|
||||
scope->RecordEvalCall();
|
||||
}
|
||||
}
|
||||
|
||||
// Used to validate property names in object literals and class literals
|
||||
enum PropertyKind {
|
||||
kAccessorProperty,
|
||||
|
@ -375,17 +375,6 @@ void ParserTraits::CheckAssigningFunctionLiteralToProperty(Expression* left,
|
||||
}
|
||||
|
||||
|
||||
void ParserTraits::CheckPossibleEvalCall(Expression* expression,
|
||||
Scope* scope) {
|
||||
VariableProxy* callee = expression->AsVariableProxy();
|
||||
if (callee != NULL &&
|
||||
callee->raw_name() == parser_->ast_value_factory()->eval_string()) {
|
||||
scope->DeclarationScope()->RecordEvalCall();
|
||||
scope->RecordEvalCall();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Expression* ParserTraits::MarkExpressionAsAssigned(Expression* expression) {
|
||||
VariableProxy* proxy =
|
||||
expression != NULL ? expression->AsVariableProxy() : NULL;
|
||||
|
@ -416,11 +416,6 @@ class ParserTraits {
|
||||
static void CheckAssigningFunctionLiteralToProperty(Expression* left,
|
||||
Expression* right);
|
||||
|
||||
// Keep track of eval() calls since they disable all local variable
|
||||
// optimizations. This checks if expression is an eval call, and if yes,
|
||||
// forwards the information to scope.
|
||||
void CheckPossibleEvalCall(Expression* expression, Scope* scope);
|
||||
|
||||
// Determine if the expression is a variable proxy and mark it as being used
|
||||
// in an assignment or with a increment/decrement operator.
|
||||
static Expression* MarkExpressionAsAssigned(Expression* expression);
|
||||
|
@ -692,14 +692,6 @@ class PreParserTraits {
|
||||
static void CheckAssigningFunctionLiteralToProperty(
|
||||
PreParserExpression left, PreParserExpression right) {}
|
||||
|
||||
static void CheckPossibleEvalCall(PreParserExpression expression,
|
||||
Scope* scope) {
|
||||
if (IsIdentifier(expression) && IsEval(AsIdentifier(expression))) {
|
||||
scope->DeclarationScope()->RecordEvalCall();
|
||||
scope->RecordEvalCall();
|
||||
}
|
||||
}
|
||||
|
||||
static PreParserExpression MarkExpressionAsAssigned(
|
||||
PreParserExpression expression) {
|
||||
// TODO(marja): To be able to produce the same errors, the preparser needs
|
||||
|
Loading…
Reference in New Issue
Block a user