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/contexts.h" | 5 #include "src/contexts.h" |
6 | 6 |
7 #include "src/ast/scopeinfo.h" | 7 #include "src/ast/scopeinfo.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 Context* Context::declaration_context() { | 73 Context* Context::declaration_context() { |
74 Context* current = this; | 74 Context* current = this; |
75 while (!current->is_declaration_context()) { | 75 while (!current->is_declaration_context()) { |
76 current = current->previous(); | 76 current = current->previous(); |
77 DCHECK(current->closure() == closure()); | 77 DCHECK(current->closure() == closure()); |
78 } | 78 } |
79 return current; | 79 return current; |
80 } | 80 } |
81 | 81 |
| 82 Context* Context::local_context() { |
| 83 Context* current = this; |
| 84 while (!current->IsFunctionContext() && !current->IsScriptContext() && |
| 85 !current->IsNativeContext()) { |
| 86 current = current->previous(); |
| 87 DCHECK(current->closure() == closure()); |
| 88 } |
| 89 return current; |
| 90 } |
82 | 91 |
83 JSObject* Context::extension_object() { | 92 JSObject* Context::extension_object() { |
84 DCHECK(IsNativeContext() || IsFunctionContext() || IsBlockContext()); | 93 DCHECK(IsNativeContext() || IsFunctionContext() || IsBlockContext()); |
85 HeapObject* object = extension(); | 94 HeapObject* object = extension(); |
86 if (object->IsTheHole()) return nullptr; | 95 if (object->IsTheHole()) return nullptr; |
87 if (IsBlockContext()) { | 96 if (IsBlockContext()) { |
88 if (!object->IsSloppyBlockWithEvalContextExtension()) return nullptr; | 97 if (!object->IsSloppyBlockWithEvalContextExtension()) return nullptr; |
89 object = SloppyBlockWithEvalContextExtension::cast(object)->extension(); | 98 object = SloppyBlockWithEvalContextExtension::cast(object)->extension(); |
90 } | 99 } |
91 DCHECK(object->IsJSContextExtensionObject() || | 100 DCHECK(object->IsJSContextExtensionObject() || |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 | 580 |
572 int previous_value = errors_thrown()->value(); | 581 int previous_value = errors_thrown()->value(); |
573 set_errors_thrown(Smi::FromInt(previous_value + 1)); | 582 set_errors_thrown(Smi::FromInt(previous_value + 1)); |
574 } | 583 } |
575 | 584 |
576 | 585 |
577 int Context::GetErrorsThrown() { return errors_thrown()->value(); } | 586 int Context::GetErrorsThrown() { return errors_thrown()->value(); } |
578 | 587 |
579 } // namespace internal | 588 } // namespace internal |
580 } // namespace v8 | 589 } // namespace v8 |
OLD | NEW |