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

Side by Side Diff: src/contexts.cc

Issue 2302783002: [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
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 104
105 JSReceiver* Context::extension_receiver() { 105 JSReceiver* Context::extension_receiver() {
106 DCHECK(IsNativeContext() || IsWithContext() || 106 DCHECK(IsNativeContext() || IsWithContext() ||
107 IsFunctionContext() || IsBlockContext()); 107 IsFunctionContext() || IsBlockContext());
108 return IsWithContext() ? JSReceiver::cast(extension()) : extension_object(); 108 return IsWithContext() ? JSReceiver::cast(extension()) : extension_object();
109 } 109 }
110 110
111 111
112 ScopeInfo* Context::scope_info() { 112 ScopeInfo* Context::scope_info() {
113 DCHECK(IsModuleContext() || IsScriptContext() || IsBlockContext()); 113 DCHECK(IsScriptContext() || IsBlockContext());
114 HeapObject* object = extension(); 114 HeapObject* object = extension();
115 if (object->IsSloppyBlockWithEvalContextExtension()) { 115 if (object->IsSloppyBlockWithEvalContextExtension()) {
116 DCHECK(IsBlockContext()); 116 DCHECK(IsBlockContext());
117 object = SloppyBlockWithEvalContextExtension::cast(object)->scope_info(); 117 object = SloppyBlockWithEvalContextExtension::cast(object)->scope_info();
118 } 118 }
119 return ScopeInfo::cast(object); 119 return ScopeInfo::cast(object);
120 } 120 }
121 121
122 122
123 JSModule* Context::module() {
124 Context* current = this;
125 while (!current->IsModuleContext()) {
126 current = current->previous();
127 DCHECK_NOT_NULL(current); // XXX
adamk 2016/09/01 23:13:34 In our offline discussion I said this was a bit bo
neis 2016/09/02 11:32:58 Done.
128 }
129 return JSModule::cast(current->extension());
130 }
131
132
123 String* Context::catch_name() { 133 String* Context::catch_name() {
124 DCHECK(IsCatchContext()); 134 DCHECK(IsCatchContext());
125 return String::cast(extension()); 135 return String::cast(extension());
126 } 136 }
127 137
128 138
129 JSGlobalObject* Context::global_object() { 139 JSGlobalObject* Context::global_object() {
130 return JSGlobalObject::cast(native_context()->extension()); 140 return JSGlobalObject::cast(native_context()->extension());
131 } 141 }
132 142
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 188
179 static PropertyAttributes GetAttributesForMode(VariableMode mode) { 189 static PropertyAttributes GetAttributesForMode(VariableMode mode) {
180 DCHECK(IsDeclaredVariableMode(mode)); 190 DCHECK(IsDeclaredVariableMode(mode));
181 return mode == CONST ? READ_ONLY : NONE; 191 return mode == CONST ? READ_ONLY : NONE;
182 } 192 }
183 193
184 Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags, 194 Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
185 int* index, PropertyAttributes* attributes, 195 int* index, PropertyAttributes* attributes,
186 InitializationFlag* init_flag, 196 InitializationFlag* init_flag,
187 VariableMode* variable_mode) { 197 VariableMode* variable_mode) {
198 DCHECK(!IsModuleContext());
188 Isolate* isolate = GetIsolate(); 199 Isolate* isolate = GetIsolate();
189 Handle<Context> context(this, isolate); 200 Handle<Context> context(this, isolate);
190 201
191 bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0; 202 bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0;
192 bool failed_whitelist = false; 203 bool failed_whitelist = false;
193 *index = kNotFound; 204 *index = kNotFound;
194 *attributes = ABSENT; 205 *attributes = ABSENT;
195 *init_flag = kCreatedInitialized; 206 *init_flag = kCreatedInitialized;
196 *variable_mode = VAR; 207 *variable_mode = VAR;
197 208
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 566
556 int previous_value = errors_thrown()->value(); 567 int previous_value = errors_thrown()->value();
557 set_errors_thrown(Smi::FromInt(previous_value + 1)); 568 set_errors_thrown(Smi::FromInt(previous_value + 1));
558 } 569 }
559 570
560 571
561 int Context::GetErrorsThrown() { return errors_thrown()->value(); } 572 int Context::GetErrorsThrown() { return errors_thrown()->value(); }
562 573
563 } // namespace internal 574 } // namespace internal
564 } // namespace v8 575 } // namespace v8
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | src/debug/debug-scopes.cc » ('j') | src/factory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698