Don't make immediately resolved proxies unresolved
BUG=v8:5209 Review-Url: https://codereview.chromium.org/2349193002 Cr-Commit-Position: refs/heads/master@{#39514}
This commit is contained in:
parent
ce03778926
commit
58507b719e
@ -478,7 +478,7 @@ void DeclarationScope::HoistSloppyBlockFunctions(AstNodeFactory* factory) {
|
||||
// Declare a var-style binding for the function in the outer scope
|
||||
if (!var_created) {
|
||||
var_created = true;
|
||||
VariableProxy* proxy = NewUnresolved(factory, name);
|
||||
VariableProxy* proxy = factory->NewVariableProxy(name, NORMAL_VARIABLE);
|
||||
Declaration* declaration =
|
||||
factory->NewVariableDeclaration(proxy, this, kNoSourcePosition);
|
||||
// Based on the preceding check, it doesn't matter what we pass as
|
||||
@ -1490,14 +1490,8 @@ Variable* Scope::LookupRecursive(VariableProxy* proxy, Scope* outer_scope_end) {
|
||||
|
||||
void Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy) {
|
||||
DCHECK(info->script_scope()->is_script_scope());
|
||||
|
||||
// If the proxy is already resolved there's nothing to do
|
||||
// (functions and consts may be resolved by the parser).
|
||||
if (proxy->is_resolved()) return;
|
||||
|
||||
// Otherwise, try to resolve the variable.
|
||||
DCHECK(!proxy->is_resolved());
|
||||
Variable* var = LookupRecursive(proxy, nullptr);
|
||||
|
||||
ResolveTo(info, proxy, var);
|
||||
}
|
||||
|
||||
@ -1549,7 +1543,7 @@ VariableProxy* Scope::FetchFreeVariables(DeclarationScope* max_outer_scope,
|
||||
for (VariableProxy *proxy = unresolved_, *next = nullptr; proxy != nullptr;
|
||||
proxy = next) {
|
||||
next = proxy->next_unresolved();
|
||||
if (proxy->is_resolved()) continue;
|
||||
DCHECK(!proxy->is_resolved());
|
||||
Variable* var = LookupRecursive(proxy, max_outer_scope->outer_scope());
|
||||
if (var == nullptr) {
|
||||
proxy->set_next_unresolved(stack);
|
||||
|
@ -1485,11 +1485,9 @@ Declaration* Parser::DeclareVariable(const AstRawString* name,
|
||||
VariableMode mode, InitializationFlag init,
|
||||
int pos, bool* ok) {
|
||||
DCHECK_NOT_NULL(name);
|
||||
Scope* scope =
|
||||
IsLexicalVariableMode(mode) ? this->scope() : GetDeclarationScope();
|
||||
VariableProxy* proxy =
|
||||
scope->NewUnresolved(factory(), name, scanner()->location().beg_pos,
|
||||
scanner()->location().end_pos);
|
||||
VariableProxy* proxy = factory()->NewVariableProxy(
|
||||
name, NORMAL_VARIABLE, scanner()->location().beg_pos,
|
||||
scanner()->location().end_pos);
|
||||
Declaration* declaration =
|
||||
factory()->NewVariableDeclaration(proxy, this->scope(), pos);
|
||||
Declare(declaration, DeclarationDescriptor::NORMAL, mode, init, CHECK_OK);
|
||||
@ -1656,7 +1654,8 @@ Statement* Parser::DeclareFunction(const AstRawString* variable_name,
|
||||
VariableMode mode =
|
||||
(!scope()->is_declaration_scope() || scope()->is_module_scope()) ? LET
|
||||
: VAR;
|
||||
VariableProxy* proxy = NewUnresolved(variable_name);
|
||||
VariableProxy* proxy =
|
||||
factory()->NewVariableProxy(variable_name, NORMAL_VARIABLE);
|
||||
Declaration* declaration =
|
||||
factory()->NewFunctionDeclaration(proxy, function, scope(), pos);
|
||||
Declare(declaration, DeclarationDescriptor::NORMAL, mode, kCreatedInitialized,
|
||||
@ -3857,7 +3856,7 @@ Expression* Parser::ParseClassLiteral(const AstRawString* name,
|
||||
|
||||
VariableProxy* proxy = nullptr;
|
||||
if (name != nullptr) {
|
||||
proxy = NewUnresolved(name);
|
||||
proxy = factory()->NewVariableProxy(name, NORMAL_VARIABLE);
|
||||
// TODO(verwaest): declare via block_state.
|
||||
Declaration* declaration =
|
||||
factory()->NewVariableDeclaration(proxy, block_state.scope(), pos);
|
||||
@ -3941,7 +3940,8 @@ Expression* Parser::ParseClassLiteral(const AstRawString* name,
|
||||
//}
|
||||
const AstRawString* name = ClassFieldVariableName(
|
||||
true, ast_value_factory(), instance_field_initializers->length());
|
||||
VariableProxy* name_proxy = NewUnresolved(name);
|
||||
VariableProxy* name_proxy =
|
||||
factory()->NewVariableProxy(name, NORMAL_VARIABLE);
|
||||
Declaration* name_declaration = factory()->NewVariableDeclaration(
|
||||
name_proxy, scope(), kNoSourcePosition);
|
||||
Variable* name_var =
|
||||
@ -4022,7 +4022,8 @@ Expression* Parser::ParseClassLiteral(const AstRawString* name,
|
||||
for (int i = 0; i < instance_field_initializers->length(); ++i) {
|
||||
const AstRawString* function_name =
|
||||
ClassFieldVariableName(false, ast_value_factory(), i);
|
||||
VariableProxy* function_proxy = NewUnresolved(function_name);
|
||||
VariableProxy* function_proxy =
|
||||
factory()->NewVariableProxy(function_name, NORMAL_VARIABLE);
|
||||
Declaration* function_declaration = factory()->NewVariableDeclaration(
|
||||
function_proxy, scope(), kNoSourcePosition);
|
||||
Variable* function_var =
|
||||
|
@ -141,8 +141,8 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
|
||||
// an initial value in the declaration (because they are initialized upon
|
||||
// entering the function).
|
||||
const AstRawString* name = pattern->raw_name();
|
||||
VariableProxy* proxy = descriptor_->scope->NewUnresolved(
|
||||
factory(), name, parser_->scanner()->location().beg_pos,
|
||||
VariableProxy* proxy = factory()->NewVariableProxy(
|
||||
name, NORMAL_VARIABLE, parser_->scanner()->location().beg_pos,
|
||||
parser_->scanner()->location().end_pos);
|
||||
Declaration* declaration = factory()->NewVariableDeclaration(
|
||||
proxy, descriptor_->scope, descriptor_->declaration_pos);
|
||||
|
Loading…
Reference in New Issue
Block a user