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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 82 |
83 JSObject* Context::extension_object() { | 83 JSObject* Context::extension_object() { |
84 DCHECK(IsNativeContext() || IsFunctionContext() || IsBlockContext()); | 84 DCHECK(IsNativeContext() || IsFunctionContext() || IsBlockContext()); |
85 Object* object = extension(); | 85 HeapObject* object = extension(); |
86 if (object == nullptr) return nullptr; | 86 if (object->IsTheHole()) return nullptr; |
87 if (IsBlockContext()) { | 87 if (IsBlockContext()) { |
88 if (!object->IsSloppyBlockWithEvalContextExtension()) return nullptr; | 88 if (!object->IsSloppyBlockWithEvalContextExtension()) return nullptr; |
89 object = SloppyBlockWithEvalContextExtension::cast(object)->extension(); | 89 object = SloppyBlockWithEvalContextExtension::cast(object)->extension(); |
90 } | 90 } |
91 DCHECK(object->IsJSContextExtensionObject() || | 91 DCHECK(object->IsJSContextExtensionObject() || |
92 (IsNativeContext() && object->IsJSGlobalObject())); | 92 (IsNativeContext() && object->IsJSGlobalObject())); |
93 return JSObject::cast(object); | 93 return JSObject::cast(object); |
94 } | 94 } |
95 | 95 |
96 | 96 |
97 JSReceiver* Context::extension_receiver() { | 97 JSReceiver* Context::extension_receiver() { |
98 DCHECK(IsNativeContext() || IsWithContext() || | 98 DCHECK(IsNativeContext() || IsWithContext() || |
99 IsFunctionContext() || IsBlockContext()); | 99 IsFunctionContext() || IsBlockContext()); |
100 return IsWithContext() ? JSReceiver::cast(extension()) : extension_object(); | 100 return IsWithContext() ? JSReceiver::cast(extension()) : extension_object(); |
101 } | 101 } |
102 | 102 |
103 | 103 |
104 ScopeInfo* Context::scope_info() { | 104 ScopeInfo* Context::scope_info() { |
105 DCHECK(IsModuleContext() || IsScriptContext() || IsBlockContext()); | 105 DCHECK(IsModuleContext() || IsScriptContext() || IsBlockContext()); |
106 Object* object = extension(); | 106 HeapObject* object = extension(); |
107 if (object->IsSloppyBlockWithEvalContextExtension()) { | 107 if (object->IsSloppyBlockWithEvalContextExtension()) { |
108 DCHECK(IsBlockContext()); | 108 DCHECK(IsBlockContext()); |
109 object = SloppyBlockWithEvalContextExtension::cast(object)->scope_info(); | 109 object = SloppyBlockWithEvalContextExtension::cast(object)->scope_info(); |
110 } | 110 } |
111 return ScopeInfo::cast(object); | 111 return ScopeInfo::cast(object); |
112 } | 112 } |
113 | 113 |
114 | 114 |
115 String* Context::catch_name() { | 115 String* Context::catch_name() { |
116 DCHECK(IsCatchContext()); | 116 DCHECK(IsCatchContext()); |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 | 579 |
580 int previous_value = errors_thrown()->value(); | 580 int previous_value = errors_thrown()->value(); |
581 set_errors_thrown(Smi::FromInt(previous_value + 1)); | 581 set_errors_thrown(Smi::FromInt(previous_value + 1)); |
582 } | 582 } |
583 | 583 |
584 | 584 |
585 int Context::GetErrorsThrown() { return errors_thrown()->value(); } | 585 int Context::GetErrorsThrown() { return errors_thrown()->value(); } |
586 | 586 |
587 } // namespace internal | 587 } // namespace internal |
588 } // namespace v8 | 588 } // namespace v8 |
OLD | NEW |