Commit a63185a6 authored by adamk's avatar adamk Committed by Commit bot

Remove vestigial legacy const handling from parser

R=littledan@chromium.org

Review URL: https://codereview.chromium.org/1836183002

Cr-Commit-Position: refs/heads/master@{#35459}
parent c09792bf
...@@ -1972,14 +1972,6 @@ Variable* Parser::Declare(Declaration* declaration, ...@@ -1972,14 +1972,6 @@ Variable* Parser::Declare(Declaration* declaration,
// RuntimeHidden_DeclareLookupSlot calls. // RuntimeHidden_DeclareLookupSlot calls.
declaration_scope->AddDeclaration(declaration); declaration_scope->AddDeclaration(declaration);
if (mode == CONST_LEGACY && declaration_scope->is_script_scope()) {
// For global const variables we bind the proxy to a variable.
DCHECK(resolve); // should be set by all callers
Variable::Kind kind = Variable::NORMAL;
var = new (zone()) Variable(declaration_scope, name, mode, kind,
kNeedsInitialization, kNotAssigned);
}
// If requested and we have a local variable, bind the proxy to the variable // If requested and we have a local variable, bind the proxy to the variable
// at parse-time. This is used for functions (and consts) declared inside // at parse-time. This is used for functions (and consts) declared inside
// statements: the corresponding function (or const) variable must be in the // statements: the corresponding function (or const) variable must be in the
...@@ -2344,9 +2336,8 @@ Block* Parser::ParseVariableDeclarations( ...@@ -2344,9 +2336,8 @@ Block* Parser::ParseVariableDeclarations(
return nullptr; return nullptr;
} }
// 'let x' and (legacy) 'const x' initialize 'x' to undefined. // 'let x' initializes 'x' to undefined.
if (parsing_result->descriptor.mode == LET || if (parsing_result->descriptor.mode == LET) {
parsing_result->descriptor.mode == CONST_LEGACY) {
value = GetLiteralUndefined(position()); value = GetLiteralUndefined(position());
} }
} }
......
...@@ -272,15 +272,9 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) { ...@@ -272,15 +272,9 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
factory()->NewExpressionStatement(initialize, initialize->position()), factory()->NewExpressionStatement(initialize, initialize->position()),
zone()); zone());
} }
} else if (value != nullptr && (descriptor_->mode == CONST_LEGACY || } else if (value != nullptr && IsLexicalVariableMode(descriptor_->mode)) {
IsLexicalVariableMode(descriptor_->mode))) { // For 'let' and 'const' declared variables the initialization always
// Constant initializations always assign to the declared constant which // assigns to the declared variable.
// is always at the function scope level. This is only relevant for
// dynamically looked-up variables and constants (the
// start context for constant lookups is always the function context,
// while it is the top context for var declared variables). Sigh...
// For 'let' and 'const' declared variables in harmony mode the
// initialization also always assigns to the declared variable.
DCHECK_NOT_NULL(proxy); DCHECK_NOT_NULL(proxy);
DCHECK_NOT_NULL(proxy->var()); DCHECK_NOT_NULL(proxy->var());
DCHECK_NOT_NULL(value); DCHECK_NOT_NULL(value);
......
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