| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/scopeinfo.h" | 9 #include "src/scopeinfo.h" |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 &result->maybe_assigned_flag); | 47 &result->maybe_assigned_flag); |
| 48 | 48 |
| 49 if (slot_index >= 0 && result->location == VariableLocation::CONTEXT) { | 49 if (slot_index >= 0 && result->location == VariableLocation::CONTEXT) { |
| 50 result->context_index = i; | 50 result->context_index = i; |
| 51 result->slot_index = slot_index; | 51 result->slot_index = slot_index; |
| 52 return true; | 52 return true; |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 | |
| 58 | |
| 59 bool ScriptContextTable::LookupLexical(Handle<ScriptContextTable> table, | |
| 60 Handle<String> name) { | |
| 61 for (int i = 0; i < table->used(); i++) { | |
| 62 Handle<Context> context = GetContext(table, i); | |
| 63 DCHECK(context->IsScriptContext()); | |
| 64 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); | |
| 65 int slot_index = ScopeInfo::LexicalContextSlotIndex(scope_info, name); | |
| 66 if (slot_index >= 0) return true; | |
| 67 } | |
| 68 return false; | |
| 69 } | |
| 70 | 57 |
| 71 | 58 |
| 72 Context* Context::declaration_context() { | 59 Context* Context::declaration_context() { |
| 73 Context* current = this; | 60 Context* current = this; |
| 74 while (!current->IsFunctionContext() && !current->IsNativeContext() && | 61 while (!current->IsFunctionContext() && !current->IsNativeContext() && |
| 75 !current->IsScriptContext()) { | 62 !current->IsScriptContext()) { |
| 76 current = current->previous(); | 63 current = current->previous(); |
| 77 DCHECK(current->closure() == closure()); | 64 DCHECK(current->closure() == closure()); |
| 78 } | 65 } |
| 79 return current; | 66 return current; |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 // During bootstrapping we allow all objects to pass as global | 511 // During bootstrapping we allow all objects to pass as global |
| 525 // objects. This is necessary to fix circular dependencies. | 512 // objects. This is necessary to fix circular dependencies. |
| 526 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || | 513 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || |
| 527 isolate->bootstrapper()->IsActive() || | 514 isolate->bootstrapper()->IsActive() || |
| 528 object->IsGlobalObject(); | 515 object->IsGlobalObject(); |
| 529 } | 516 } |
| 530 #endif | 517 #endif |
| 531 | 518 |
| 532 } // namespace internal | 519 } // namespace internal |
| 533 } // namespace v8 | 520 } // namespace v8 |
| OLD | NEW |