Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: src/contexts.cc

Issue 2328283002: Revert of [modules] Basic support of exports (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/contexts.h ('k') | src/debug/debug-scopes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 57
58 58
59 bool Context::is_declaration_context() { 59 bool Context::is_declaration_context() {
60 if (IsFunctionContext() || IsNativeContext() || IsScriptContext() || 60 if (IsFunctionContext() || IsNativeContext() || IsScriptContext()) {
61 IsModuleContext()) {
62 return true; 61 return true;
63 } 62 }
64 if (!IsBlockContext()) return false; 63 if (!IsBlockContext()) return false;
65 Object* ext = extension(); 64 Object* ext = extension();
66 // If we have the special extension, we immediately know it must be a 65 // If we have the special extension, we immediately know it must be a
67 // declaration scope. That's just a small performance shortcut. 66 // declaration scope. That's just a small performance shortcut.
68 return ext->IsContextExtension() || 67 return ext->IsContextExtension() ||
69 ScopeInfo::cast(ext)->is_declaration_scope(); 68 ScopeInfo::cast(ext)->is_declaration_scope();
70 } 69 }
71 70
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 116 }
118 HeapObject* object = extension(); 117 HeapObject* object = extension();
119 if (object->IsContextExtension()) { 118 if (object->IsContextExtension()) {
120 DCHECK(IsBlockContext() || IsCatchContext() || IsWithContext() || 119 DCHECK(IsBlockContext() || IsCatchContext() || IsWithContext() ||
121 IsDebugEvaluateContext()); 120 IsDebugEvaluateContext());
122 object = ContextExtension::cast(object)->scope_info(); 121 object = ContextExtension::cast(object)->scope_info();
123 } 122 }
124 return ScopeInfo::cast(object); 123 return ScopeInfo::cast(object);
125 } 124 }
126 125
127 JSModule* Context::module() {
128 Context* current = this;
129 while (!current->IsModuleContext()) {
130 current = current->previous();
131 }
132 return JSModule::cast(current->extension());
133 }
134 126
135 String* Context::catch_name() { 127 String* Context::catch_name() {
136 DCHECK(IsCatchContext()); 128 DCHECK(IsCatchContext());
137 return String::cast(ContextExtension::cast(extension())->extension()); 129 return String::cast(ContextExtension::cast(extension())->extension());
138 } 130 }
139 131
140 132
141 JSGlobalObject* Context::global_object() { 133 JSGlobalObject* Context::global_object() {
142 return JSGlobalObject::cast(native_context()->extension()); 134 return JSGlobalObject::cast(native_context()->extension());
143 } 135 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 182
191 static PropertyAttributes GetAttributesForMode(VariableMode mode) { 183 static PropertyAttributes GetAttributesForMode(VariableMode mode) {
192 DCHECK(IsDeclaredVariableMode(mode)); 184 DCHECK(IsDeclaredVariableMode(mode));
193 return mode == CONST ? READ_ONLY : NONE; 185 return mode == CONST ? READ_ONLY : NONE;
194 } 186 }
195 187
196 Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags, 188 Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
197 int* index, PropertyAttributes* attributes, 189 int* index, PropertyAttributes* attributes,
198 InitializationFlag* init_flag, 190 InitializationFlag* init_flag,
199 VariableMode* variable_mode) { 191 VariableMode* variable_mode) {
200 DCHECK(!IsModuleContext());
201 Isolate* isolate = GetIsolate(); 192 Isolate* isolate = GetIsolate();
202 Handle<Context> context(this, isolate); 193 Handle<Context> context(this, isolate);
203 194
204 bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0; 195 bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0;
205 bool failed_whitelist = false; 196 bool failed_whitelist = false;
206 *index = kNotFound; 197 *index = kNotFound;
207 *attributes = ABSENT; 198 *attributes = ABSENT;
208 *init_flag = kCreatedInitialized; 199 *init_flag = kCreatedInitialized;
209 *variable_mode = VAR; 200 *variable_mode = VAR;
210 201
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 562
572 int previous_value = errors_thrown()->value(); 563 int previous_value = errors_thrown()->value();
573 set_errors_thrown(Smi::FromInt(previous_value + 1)); 564 set_errors_thrown(Smi::FromInt(previous_value + 1));
574 } 565 }
575 566
576 567
577 int Context::GetErrorsThrown() { return errors_thrown()->value(); } 568 int Context::GetErrorsThrown() { return errors_thrown()->value(); }
578 569
579 } // namespace internal 570 } // namespace internal
580 } // namespace v8 571 } // namespace v8
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | src/debug/debug-scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698