Index: src/ast/scopes.cc |
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
index a1d31c6005222910b545b46417ddd30b093ca196..bc3a285ed2acb3075bb99802614c25c9a54c8dde 100644 |
--- a/src/ast/scopes.cc |
+++ b/src/ast/scopes.cc |
@@ -77,14 +77,20 @@ void SloppyBlockFunctionMap::Declare(Zone* zone, const AstRawString* name, |
// ---------------------------------------------------------------------------- |
// Implementation of Scope |
-Scope::Scope(Zone* zone) |
+Scope::Scope(Zone* zone, ScopeType scope_type) |
: zone_(zone), |
outer_scope_(nullptr), |
variables_(zone), |
ordered_variables_(4, zone), |
decls_(4, zone), |
- scope_type_(SCRIPT_SCOPE) { |
+ scope_type_(scope_type) { |
+ DCHECK(scope_type == SCRIPT_SCOPE || scope_type == WITH_SCOPE); |
SetDefaults(); |
+#ifdef DEBUG |
+ if (scope_type == WITH_SCOPE) { |
+ already_resolved_ = true; |
+ } |
+#endif |
} |
Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type) |
@@ -146,17 +152,14 @@ Scope::Scope(Zone* zone, Scope* inner_scope, ScopeType scope_type, |
decls_(0, zone), |
scope_info_(scope_info), |
scope_type_(scope_type) { |
+ DCHECK(!scope_info.is_null()); |
SetDefaults(); |
#ifdef DEBUG |
already_resolved_ = true; |
#endif |
- if (scope_type == WITH_SCOPE) { |
- DCHECK(scope_info.is_null()); |
- } else { |
- if (scope_info->CallsEval()) RecordEvalCall(); |
- set_language_mode(scope_info->language_mode()); |
- num_heap_slots_ = scope_info->ContextLength(); |
- } |
+ if (scope_info->CallsEval()) RecordEvalCall(); |
+ set_language_mode(scope_info->language_mode()); |
+ num_heap_slots_ = scope_info->ContextLength(); |
DCHECK_LE(Context::MIN_CONTEXT_SLOTS, num_heap_slots_); |
if (inner_scope != nullptr) AddInnerScope(inner_scope); |
@@ -264,8 +267,11 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, |
while (!context->IsNativeContext()) { |
if (context->IsWithContext() || context->IsDebugEvaluateContext()) { |
// For scope analysis, debug-evaluate is equivalent to a with scope. |
- Scope* with_scope = new (zone) |
- Scope(zone, current_scope, WITH_SCOPE, Handle<ScopeInfo>()); |
+ Scope* with_scope = new (zone) Scope(zone, WITH_SCOPE); |
+ if (current_scope != nullptr) { |
+ with_scope->AddInnerScope(current_scope); |
Toon Verwaest
2016/08/23 12:33:27
Perhaps we should just pull this out of the other
|
+ } |
+ |
// TODO(yangguo): Remove once debug-evaluate properly keeps track of the |
// function scope in which we are evaluating. |
if (context->IsDebugEvaluateContext()) { |