Index: src/ast/scopes.cc |
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
index 1eb5b66a9377df597dca77325581b715479281c1..e8b526e147e616f41e459b7a8ba1349d076c05ef 100644 |
--- a/src/ast/scopes.cc |
+++ b/src/ast/scopes.cc |
@@ -132,8 +132,8 @@ Scope::Scope(Zone* zone, Scope* inner_scope, ScopeType scope_type, |
num_heap_slots_ = scope_info_->ContextLength(); |
} |
// Ensure at least MIN_CONTEXT_SLOTS to indicate a materialized context. |
- num_heap_slots_ = Max(num_heap_slots_, |
- static_cast<int>(Context::MIN_CONTEXT_SLOTS)); |
+ num_heap_slots_ = |
+ Max(num_heap_slots_, static_cast<int>(Context::MIN_CONTEXT_SLOTS)); |
AddInnerScope(inner_scope); |
} |
@@ -157,11 +157,8 @@ Scope::Scope(Zone* zone, Scope* inner_scope, |
AddInnerScope(inner_scope); |
++num_var_or_const_; |
num_heap_slots_ = Context::MIN_CONTEXT_SLOTS; |
- Variable* variable = variables_.Declare(this, |
- catch_variable_name, |
- VAR, |
- Variable::NORMAL, |
- kCreatedInitialized); |
+ Variable* variable = variables_.Declare( |
+ this, catch_variable_name, VAR, Variable::NORMAL, kCreatedInitialized); |
AllocateHeapSlot(variable); |
} |
@@ -171,9 +168,8 @@ void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope, |
FunctionKind function_kind) { |
outer_scope_ = outer_scope; |
scope_type_ = scope_type; |
- is_declaration_scope_ = |
- is_eval_scope() || is_function_scope() || |
- is_module_scope() || is_script_scope(); |
+ is_declaration_scope_ = is_eval_scope() || is_function_scope() || |
+ is_module_scope() || is_script_scope(); |
function_kind_ = function_kind; |
scope_name_ = ast_value_factory_->empty_string(); |
dynamics_ = nullptr; |
@@ -197,7 +193,8 @@ void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope, |
scope_nonlinear_ = false; |
force_eager_compilation_ = false; |
force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) |
- ? outer_scope->has_forced_context_allocation() : false; |
+ ? outer_scope->has_forced_context_allocation() |
+ : false; |
num_var_or_const_ = 0; |
num_stack_slots_ = 0; |
num_heap_slots_ = 0; |
@@ -291,8 +288,7 @@ bool Scope::Analyze(ParseInfo* info) { |
// Traverse the scope tree up to the first unresolved scope or the global |
// scope and start scope resolution and variable allocation from that scope. |
- while (!top->is_script_scope() && |
- !top->outer_scope()->already_resolved()) { |
+ while (!top->is_script_scope() && !top->outer_scope()->already_resolved()) { |
top = top->outer_scope(); |
} |
@@ -497,9 +493,7 @@ Variable* Scope::LookupFunctionVar(const AstRawString* name, |
Variable* Scope::Lookup(const AstRawString* name) { |
- for (Scope* scope = this; |
- scope != NULL; |
- scope = scope->outer_scope()) { |
+ for (Scope* scope = this; scope != NULL; scope = scope->outer_scope()) { |
Variable* var = scope->LookupLocal(name); |
if (var != NULL) return var; |
} |
@@ -507,9 +501,9 @@ Variable* Scope::Lookup(const AstRawString* name) { |
} |
-Variable* Scope::DeclareParameter( |
- const AstRawString* name, VariableMode mode, |
- bool is_optional, bool is_rest, bool* is_duplicate) { |
+Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode, |
+ bool is_optional, bool is_rest, |
+ bool* is_duplicate) { |
DCHECK(!already_resolved()); |
DCHECK(is_function_scope()); |
DCHECK(!is_optional || !is_rest); |
@@ -552,10 +546,7 @@ Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode, |
Variable* Scope::DeclareDynamicGlobal(const AstRawString* name) { |
DCHECK(is_script_scope()); |
- return variables_.Declare(this, |
- name, |
- DYNAMIC_GLOBAL, |
- Variable::NORMAL, |
+ return variables_.Declare(this, name, DYNAMIC_GLOBAL, Variable::NORMAL, |
kCreatedInitialized); |
} |
@@ -576,11 +567,8 @@ bool Scope::RemoveUnresolved(VariableProxy* var) { |
Variable* Scope::NewTemporary(const AstRawString* name) { |
DCHECK(!already_resolved()); |
Scope* scope = this->ClosureScope(); |
- Variable* var = new(zone()) Variable(scope, |
- name, |
- TEMPORARY, |
- Variable::NORMAL, |
- kCreatedInitialized); |
+ Variable* var = new (zone()) |
+ Variable(scope, name, TEMPORARY, Variable::NORMAL, kCreatedInitialized); |
scope->temps_.Add(var, zone()); |
return var; |
} |
@@ -641,7 +629,7 @@ Declaration* Scope::CheckConflictingVarDeclarations() { |
class VarAndOrder { |
public: |
- VarAndOrder(Variable* var, int order) : var_(var), order_(order) { } |
+ VarAndOrder(Variable* var, int order) : var_(var), order_(order) {} |
Variable* var() const { return var_; } |
int order() const { return order_; } |
static int Compare(const VarAndOrder* a, const VarAndOrder* b) { |
@@ -680,8 +668,7 @@ void Scope::CollectStackAndContextLocals( |
// Collect declared local variables. |
ZoneList<VarAndOrder> vars(variables_.occupancy(), zone()); |
- for (VariableMap::Entry* p = variables_.Start(); |
- p != NULL; |
+ for (VariableMap::Entry* p = variables_.Start(); p != NULL; |
p = variables_.Next(p)) { |
Variable* var = reinterpret_cast<Variable*>(p->value); |
if (strong_mode_free_variables && var->has_strong_mode_reference() && |
@@ -830,7 +817,6 @@ Scope* Scope::ReceiverScope() { |
} |
- |
Handle<ScopeInfo> Scope::GetScopeInfo(Isolate* isolate) { |
if (scope_info_.is_null()) { |
scope_info_ = ScopeInfo::Create(isolate, zone(), this); |
@@ -875,24 +861,28 @@ void Scope::ReportMessage(int start_position, int end_position, |
static const char* Header(ScopeType scope_type, FunctionKind function_kind, |
bool is_declaration_scope) { |
switch (scope_type) { |
- case EVAL_SCOPE: return "eval"; |
+ case EVAL_SCOPE: |
+ return "eval"; |
// TODO(adamk): Should we print concise method scopes specially? |
case FUNCTION_SCOPE: |
return IsArrowFunction(function_kind) ? "arrow" : "function"; |
- case MODULE_SCOPE: return "module"; |
- case SCRIPT_SCOPE: return "global"; |
- case CATCH_SCOPE: return "catch"; |
- case BLOCK_SCOPE: return is_declaration_scope ? "varblock" : "block"; |
- case WITH_SCOPE: return "with"; |
+ case MODULE_SCOPE: |
+ return "module"; |
+ case SCRIPT_SCOPE: |
+ return "global"; |
+ case CATCH_SCOPE: |
+ return "catch"; |
+ case BLOCK_SCOPE: |
+ return is_declaration_scope ? "varblock" : "block"; |
+ case WITH_SCOPE: |
+ return "with"; |
} |
UNREACHABLE(); |
return NULL; |
} |
-static void Indent(int n, const char* str) { |
- PrintF("%*s%s", n, "", str); |
-} |
+static void Indent(int n, const char* str) { PrintF("%*s%s", n, "", str); } |
static void PrintName(const AstRawString* name) { |
@@ -1067,13 +1057,9 @@ Variable* Scope::NonLocal(const AstRawString* name, VariableMode mode) { |
Variable* var = map->Lookup(name); |
if (var == NULL) { |
// Declare a new non-local. |
- InitializationFlag init_flag = (mode == VAR) |
- ? kCreatedInitialized : kNeedsInitialization; |
- var = map->Declare(NULL, |
- name, |
- mode, |
- Variable::NORMAL, |
- init_flag); |
+ InitializationFlag init_flag = |
+ (mode == VAR) ? kCreatedInitialized : kNeedsInitialization; |
+ var = map->Declare(NULL, name, mode, Variable::NORMAL, init_flag); |
// Allocate it by giving it a dynamic lookup. |
var->AllocateTo(VariableLocation::LOOKUP, -1); |
} |
@@ -1343,7 +1329,7 @@ bool Scope::ResolveVariablesRecursively(ParseInfo* info, |
} |
-void Scope::PropagateScopeInfo(bool outer_scope_calls_sloppy_eval ) { |
+void Scope::PropagateScopeInfo(bool outer_scope_calls_sloppy_eval) { |
if (outer_scope_calls_sloppy_eval) { |
outer_scope_calls_sloppy_eval_ = true; |
} |
@@ -1396,10 +1382,8 @@ bool Scope::MustAllocateInContext(Variable* var) { |
if (var->mode() == TEMPORARY) return false; |
if (is_catch_scope() || is_module_scope()) return true; |
if (is_script_scope() && IsLexicalVariableMode(var->mode())) return true; |
- return var->has_forced_context_allocation() || |
- scope_calls_eval_ || |
- inner_scope_calls_eval_ || |
- scope_contains_with_; |
+ return var->has_forced_context_allocation() || scope_calls_eval_ || |
+ inner_scope_calls_eval_ || scope_contains_with_; |
} |
@@ -1551,8 +1535,7 @@ void Scope::AllocateNonParameterLocalsAndDeclaredGlobals(Isolate* isolate) { |
} |
ZoneList<VarAndOrder> vars(variables_.occupancy(), zone()); |
- for (VariableMap::Entry* p = variables_.Start(); |
- p != NULL; |
+ for (VariableMap::Entry* p = variables_.Start(); p != NULL; |
p = variables_.Next(p)) { |
Variable* var = reinterpret_cast<Variable*>(p->value); |
vars.Add(VarAndOrder(var, p->order), zone()); |
@@ -1655,7 +1638,8 @@ void Scope::AllocateModules() { |
int Scope::StackLocalCount() const { |
return num_stack_slots() - |
- (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); |
+ (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 |
+ : 0); |
} |