| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/debug/debug-scopes.h" | 5 #include "src/debug/debug-scopes.h" |
| 6 | 6 |
| 7 #include "src/debug/debug.h" | 7 #include "src/debug/debug.h" |
| 8 #include "src/frames-inl.h" | 8 #include "src/frames-inl.h" |
| 9 #include "src/globals.h" | 9 #include "src/globals.h" |
| 10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 if (ignore_nested_scopes) { | 70 if (ignore_nested_scopes) { |
| 71 if (scope_info->HasContext()) { | 71 if (scope_info->HasContext()) { |
| 72 context_ = Handle<Context>(context_->declaration_context(), isolate_); | 72 context_ = Handle<Context>(context_->declaration_context(), isolate_); |
| 73 } else { | 73 } else { |
| 74 while (context_->closure() == *function) { | 74 while (context_->closure() == *function) { |
| 75 context_ = Handle<Context>(context_->previous(), isolate_); | 75 context_ = Handle<Context>(context_->previous(), isolate_); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 if (scope_info->scope_type() == FUNCTION_SCOPE || | 78 if (scope_info->scope_type() == FUNCTION_SCOPE) { |
| 79 scope_info->scope_type() == ARROW_SCOPE) { | |
| 80 nested_scope_chain_.Add(scope_info); | 79 nested_scope_chain_.Add(scope_info); |
| 81 } | 80 } |
| 82 } else { | 81 } else { |
| 83 // Reparse the code and analyze the scopes. | 82 // Reparse the code and analyze the scopes. |
| 84 Handle<Script> script(Script::cast(shared_info->script())); | 83 Handle<Script> script(Script::cast(shared_info->script())); |
| 85 Scope* scope = NULL; | 84 Scope* scope = NULL; |
| 86 | 85 |
| 87 // Check whether we are in global, eval or function code. | 86 // Check whether we are in global, eval or function code. |
| 88 Zone zone; | 87 Zone zone; |
| 89 if (scope_info->scope_type() != FUNCTION_SCOPE && | 88 if (scope_info->scope_type() != FUNCTION_SCOPE) { |
| 90 scope_info->scope_type() != ARROW_SCOPE) { | |
| 91 // Global or eval code. | 89 // Global or eval code. |
| 92 ParseInfo info(&zone, script); | 90 ParseInfo info(&zone, script); |
| 93 if (scope_info->scope_type() == SCRIPT_SCOPE) { | 91 if (scope_info->scope_type() == SCRIPT_SCOPE) { |
| 94 info.set_global(); | 92 info.set_global(); |
| 95 } else { | 93 } else { |
| 96 DCHECK(scope_info->scope_type() == EVAL_SCOPE); | 94 DCHECK(scope_info->scope_type() == EVAL_SCOPE); |
| 97 info.set_eval(); | 95 info.set_eval(); |
| 98 info.set_context(Handle<Context>(function->context())); | 96 info.set_context(Handle<Context>(function->context())); |
| 99 } | 97 } |
| 100 if (Parser::ParseStatic(&info) && Scope::Analyze(&info)) { | 98 if (Parser::ParseStatic(&info) && Scope::Analyze(&info)) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 174 } |
| 177 | 175 |
| 178 | 176 |
| 179 // Return the type of the current scope. | 177 // Return the type of the current scope. |
| 180 ScopeIterator::ScopeType ScopeIterator::Type() { | 178 ScopeIterator::ScopeType ScopeIterator::Type() { |
| 181 DCHECK(!failed_); | 179 DCHECK(!failed_); |
| 182 if (!nested_scope_chain_.is_empty()) { | 180 if (!nested_scope_chain_.is_empty()) { |
| 183 Handle<ScopeInfo> scope_info = nested_scope_chain_.last(); | 181 Handle<ScopeInfo> scope_info = nested_scope_chain_.last(); |
| 184 switch (scope_info->scope_type()) { | 182 switch (scope_info->scope_type()) { |
| 185 case FUNCTION_SCOPE: | 183 case FUNCTION_SCOPE: |
| 186 case ARROW_SCOPE: | |
| 187 DCHECK(context_->IsFunctionContext() || !scope_info->HasContext()); | 184 DCHECK(context_->IsFunctionContext() || !scope_info->HasContext()); |
| 188 return ScopeTypeLocal; | 185 return ScopeTypeLocal; |
| 189 case MODULE_SCOPE: | 186 case MODULE_SCOPE: |
| 190 DCHECK(context_->IsModuleContext()); | 187 DCHECK(context_->IsModuleContext()); |
| 191 return ScopeTypeModule; | 188 return ScopeTypeModule; |
| 192 case SCRIPT_SCOPE: | 189 case SCRIPT_SCOPE: |
| 193 DCHECK(context_->IsScriptContext() || context_->IsNativeContext()); | 190 DCHECK(context_->IsScriptContext() || context_->IsNativeContext()); |
| 194 return ScopeTypeScript; | 191 return ScopeTypeScript; |
| 195 case WITH_SCOPE: | 192 case WITH_SCOPE: |
| 196 DCHECK(context_->IsWithContext()); | 193 DCHECK(context_->IsWithContext()); |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 isolate_, value, Object::GetPropertyOrElement(extension, key), false); | 782 isolate_, value, Object::GetPropertyOrElement(extension, key), false); |
| 786 RETURN_ON_EXCEPTION_VALUE( | 783 RETURN_ON_EXCEPTION_VALUE( |
| 787 isolate_, JSObject::SetOwnPropertyIgnoreAttributes( | 784 isolate_, JSObject::SetOwnPropertyIgnoreAttributes( |
| 788 scope_object, key, value, NONE), false); | 785 scope_object, key, value, NONE), false); |
| 789 } | 786 } |
| 790 return true; | 787 return true; |
| 791 } | 788 } |
| 792 | 789 |
| 793 } // namespace internal | 790 } // namespace internal |
| 794 } // namespace v8 | 791 } // namespace v8 |
| OLD | NEW |