Commit 4943f722 authored by verwaest's avatar verwaest Committed by Commit bot

Remove bool result from analyze since it's always true

This also gets rid of the pending_error_handler field on DeclarationScope which wasn't actually used.

BUG=v8:5209

Review-Url: https://codereview.chromium.org/2218083002
Cr-Commit-Position: refs/heads/master@{#38400}
parent 6c44ab30
......@@ -373,7 +373,7 @@ int Scope::num_parameters() const {
return is_declaration_scope() ? AsDeclarationScope()->num_parameters() : 0;
}
bool Scope::Analyze(ParseInfo* info) {
void Scope::Analyze(ParseInfo* info) {
DCHECK(info->literal() != NULL);
DeclarationScope* scope = info->literal()->scope();
DeclarationScope* top = scope;
......@@ -390,7 +390,7 @@ bool Scope::Analyze(ParseInfo* info) {
// Allocate the variables.
{
AstNodeFactory ast_node_factory(info->ast_value_factory());
if (!top->AllocateVariables(info, &ast_node_factory)) return false;
top->AllocateVariables(info, &ast_node_factory);
}
#ifdef DEBUG
......@@ -401,8 +401,6 @@ bool Scope::Analyze(ParseInfo* info) {
scope->CheckScopePositions();
scope->CheckZones();
#endif
return true;
}
void DeclarationScope::DeclareThis(AstValueFactory* ast_value_factory) {
......@@ -871,7 +869,7 @@ void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals,
}
}
bool DeclarationScope::AllocateVariables(ParseInfo* info,
void DeclarationScope::AllocateVariables(ParseInfo* info,
AstNodeFactory* factory) {
// 1) Propagate scope information.
bool outer_scope_calls_sloppy_eval = false;
......@@ -883,16 +881,10 @@ bool DeclarationScope::AllocateVariables(ParseInfo* info,
PropagateScopeInfo(outer_scope_calls_sloppy_eval);
// 2) Resolve variables.
if (!ResolveVariablesRecursively(info, factory)) {
DCHECK(pending_error_handler_.has_pending_error());
pending_error_handler_.ThrowPendingError(info->isolate(), info->script());
return false;
}
ResolveVariablesRecursively(info, factory);
// 3) Allocate variables.
AllocateVariablesRecursively(info->ast_value_factory());
return true;
}
......@@ -1362,14 +1354,13 @@ Variable* Scope::LookupRecursive(VariableProxy* proxy,
return var;
}
bool Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy,
void Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy,
AstNodeFactory* factory) {
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 true;
if (proxy->is_resolved()) return;
// Otherwise, try to resolve the variable.
BindingKind binding_kind;
......@@ -1436,27 +1427,22 @@ bool Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy,
if (proxy->is_assigned()) var->set_maybe_assigned();
proxy->BindTo(var);
return true;
}
bool Scope::ResolveVariablesRecursively(ParseInfo* info,
void Scope::ResolveVariablesRecursively(ParseInfo* info,
AstNodeFactory* factory) {
DCHECK(info->script_scope()->is_script_scope());
// Resolve unresolved variables for this scope.
for (VariableProxy* proxy = unresolved_; proxy != nullptr;
proxy = proxy->next_unresolved()) {
if (!ResolveVariable(info, proxy, factory)) return false;
ResolveVariable(info, proxy, factory);
}
// Resolve unresolved variables for inner scopes.
for (Scope* scope = inner_scope_; scope != nullptr; scope = scope->sibling_) {
if (!scope->ResolveVariablesRecursively(info, factory)) return false;
scope->ResolveVariablesRecursively(info, factory);
}
return true;
}
void Scope::MigrateUnresolvableLocals(DeclarationScope* migrate_to,
......
......@@ -8,7 +8,6 @@
#include "src/ast/ast.h"
#include "src/base/hashmap.h"
#include "src/globals.h"
#include "src/pending-compilation-error-handler.h"
#include "src/zone.h"
namespace v8 {
......@@ -127,7 +126,7 @@ class Scope: public ZoneObject {
// Compute top scope and allocate variables. For lazy compilation the top
// scope only contains the single lazily compiled function, so this
// doesn't re-allocate variables repeatedly.
static bool Analyze(ParseInfo* info);
static void Analyze(ParseInfo* info);
enum class DeserializationMode { kDeserializeOffHeap, kKeepScopeInfo };
......@@ -596,11 +595,9 @@ class Scope: public ZoneObject {
Variable* LookupRecursive(VariableProxy* proxy, BindingKind* binding_kind,
AstNodeFactory* factory,
Scope* max_outer_scope = nullptr);
MUST_USE_RESULT
bool ResolveVariable(ParseInfo* info, VariableProxy* proxy,
void ResolveVariable(ParseInfo* info, VariableProxy* proxy,
AstNodeFactory* factory);
MUST_USE_RESULT
bool ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory);
void ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory);
// Tries to resolve local variables inside max_outer_scope; migrates those
// which cannot be resolved into migrate_to.
......@@ -850,8 +847,7 @@ class DeclarationScope : public Scope {
// In the case of code compiled and run using 'eval', the context
// parameter is the context in which eval was called. In all other
// cases the context parameter is an empty handle.
MUST_USE_RESULT
bool AllocateVariables(ParseInfo* info, AstNodeFactory* factory);
void AllocateVariables(ParseInfo* info, AstNodeFactory* factory);
// To be called during parsing. Do just enough scope analysis that we can
// discard the Scope for lazily compiled functions. In particular, this
......@@ -903,7 +899,6 @@ class DeclarationScope : public Scope {
Variable* this_function_;
// Module descriptor; module scopes only.
ModuleDescriptor* module_descriptor_;
PendingCompilationErrorHandler pending_error_handler_;
};
} // namespace internal
......
......@@ -1193,7 +1193,7 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
bool Compiler::Analyze(ParseInfo* info) {
DCHECK_NOT_NULL(info->literal());
if (!Rewriter::Rewrite(info)) return false;
if (!Scope::Analyze(info)) return false;
Scope::Analyze(info);
if (!Renumber(info)) return false;
DCHECK_NOT_NULL(info->scope());
return true;
......
......@@ -35,7 +35,7 @@ struct TestHelper : public HandleAndZoneScope {
CHECK(Parser::ParseStatic(&parse_info));
CHECK(Rewriter::Rewrite(&parse_info));
CHECK(Scope::Analyze(&parse_info));
Scope::Analyze(&parse_info);
DeclarationScope* scope = info.literal()->scope();
AstValueFactory* factory = parse_info.ast_value_factory();
......
......@@ -1117,7 +1117,7 @@ TEST(ScopeUsesArgumentsSuperThis) {
info.set_global();
CHECK(parser.Parse(&info));
CHECK(i::Rewriter::Rewrite(&info));
CHECK(i::Scope::Analyze(&info));
i::Scope::Analyze(&info);
CHECK(info.literal() != NULL);
i::DeclarationScope* script_scope = info.literal()->scope();
......
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