Commit 1be3c3a2 authored by adamk's avatar adamk Committed by Commit bot

[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}
parent 95145fa8
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment