Commit 9b6c5704 authored by adamk's avatar adamk Committed by Commit bot

Clean up and simplify Parser::Declare

This removes the "resolve" parameter from Declare, since there's no case
where Scope analysis wouldn't make the same resolution decision the
parser can make here.

Other cleanup includes:
  - Replace some if statements with DCHECKS where they could never be hit
  - After the above, reordered some conditions for clarity
  - Remove or edit down old comments

Should be no change in behavior.

R=neis@chromium.org

Review-Url: https://codereview.chromium.org/2217973003
Cr-Commit-Position: refs/heads/master@{#38454}
parent 5afd1f30
This diff is collapsed.
......@@ -1082,8 +1082,8 @@ class Parser : public ParserBase<ParserTraits> {
// Parser support
VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode);
Variable* Declare(Declaration* declaration,
DeclarationDescriptor::Kind declaration_kind, bool resolve,
bool* ok, Scope* declaration_scope = nullptr);
DeclarationDescriptor::Kind declaration_kind, bool* ok,
Scope* declaration_scope = nullptr);
void DeclareConstVariable(const AstRawString* name, InitializationFlag init,
int pos, bool* ok);
......
......@@ -151,9 +151,8 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
Declaration* declaration = factory()->NewVariableDeclaration(
proxy, descriptor_->mode, descriptor_->scope,
descriptor_->declaration_pos);
Variable* var =
parser_->Declare(declaration, descriptor_->declaration_kind,
descriptor_->mode != VAR, ok_, descriptor_->hoist_scope);
Variable* var = parser_->Declare(declaration, descriptor_->declaration_kind,
ok_, descriptor_->hoist_scope);
if (!*ok_) return;
DCHECK_NOT_NULL(var);
DCHECK(!proxy->is_resolved() || proxy->var() == var);
......
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