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

Side by Side Diff: src/accessors.cc

Issue 2388153003: [modules] Implement namespace imports. (Closed)
Patch Set: Extend a test. Created 4 years, 2 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/accessors.h" 5 #include "src/accessors.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/contexts.h" 8 #include "src/contexts.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 195
196 Handle<AccessorInfo> Accessors::ArrayLengthInfo( 196 Handle<AccessorInfo> Accessors::ArrayLengthInfo(
197 Isolate* isolate, PropertyAttributes attributes) { 197 Isolate* isolate, PropertyAttributes attributes) {
198 return MakeAccessor(isolate, 198 return MakeAccessor(isolate,
199 isolate->factory()->length_string(), 199 isolate->factory()->length_string(),
200 &ArrayLengthGetter, 200 &ArrayLengthGetter,
201 &ArrayLengthSetter, 201 &ArrayLengthSetter,
202 attributes); 202 attributes);
203 } 203 }
204 204
205 //
206 // Accessors::ModuleNamespaceToStringTag
207 //
208
209 void Accessors::ModuleNamespaceToStringTagGetter(
210 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
211 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
212 info.GetReturnValue().Set(
213 Utils::ToLocal(isolate->factory()->NewStringFromAsciiChecked("Module")));
214 }
215
216 Handle<AccessorInfo> Accessors::ModuleNamespaceToStringTagInfo(
217 Isolate* isolate, PropertyAttributes attributes) {
218 Handle<Name> name = isolate->factory()->to_string_tag_symbol();
219 return MakeAccessor(isolate, name, &ModuleNamespaceToStringTagGetter, nullptr,
220 attributes);
221 }
222
223 //
224 // Accessors::ModuleNamespaceEntry
225 //
226
227 void Accessors::ModuleNamespaceEntryGetter(
228 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
229 DisallowHeapAllocation no_allocation;
230 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
231 HandleScope scope(isolate);
232 JSModuleNamespace* holder =
233 JSModuleNamespace::cast(*Utils::OpenHandle(*info.Holder()));
234 Object* result =
235 holder->GetExport(Handle<String>::cast(Utils::OpenHandle(*name)));
236 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate)));
237 }
238
239 void Accessors::ModuleNamespaceEntrySetter(
240 v8::Local<v8::Name> name, v8::Local<v8::Value> val,
241 const v8::PropertyCallbackInfo<void>& info) {
242 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
243 HandleScope scope(isolate);
244 Factory* factory = isolate->factory();
245 Handle<JSModuleNamespace> holder =
246 Handle<JSModuleNamespace>::cast(Utils::OpenHandle(*info.Holder()));
247
248 if (info.ShouldThrowOnError()) {
249 isolate->Throw(*factory->NewTypeError(
250 MessageTemplate::kStrictReadOnlyProperty, Utils::OpenHandle(*name),
251 i::Object::TypeOf(isolate, holder), holder));
252 isolate->OptionalRescheduleException(false);
253 } else {
254 info.GetReturnValue().Set(Utils::ToLocal(factory->ToBoolean(false)));
255 }
256 }
257
258 Handle<AccessorInfo> Accessors::ModuleNamespaceEntryInfo(
259 Isolate* isolate, Handle<String> name, PropertyAttributes attributes) {
260 return MakeAccessor(isolate, name, &ModuleNamespaceEntryGetter,
261 &ModuleNamespaceEntrySetter, attributes);
262 }
263
205 264
206 // 265 //
207 // Accessors::StringLength 266 // Accessors::StringLength
208 // 267 //
209 268
210 void Accessors::StringLengthGetter( 269 void Accessors::StringLengthGetter(
211 v8::Local<v8::Name> name, 270 v8::Local<v8::Name> name,
212 const v8::PropertyCallbackInfo<v8::Value>& info) { 271 const v8::PropertyCallbackInfo<v8::Value>& info) {
213 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 272 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
214 DisallowHeapAllocation no_allocation; 273 DisallowHeapAllocation no_allocation;
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, 1286 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate,
1228 PropertyAttributes attributes) { 1287 PropertyAttributes attributes) {
1229 Handle<AccessorInfo> info = 1288 Handle<AccessorInfo> info =
1230 MakeAccessor(isolate, isolate->factory()->stack_string(), 1289 MakeAccessor(isolate, isolate->factory()->stack_string(),
1231 &ErrorStackGetter, &ErrorStackSetter, attributes); 1290 &ErrorStackGetter, &ErrorStackSetter, attributes);
1232 return info; 1291 return info;
1233 } 1292 }
1234 1293
1235 } // namespace internal 1294 } // namespace internal
1236 } // namespace v8 1295 } // namespace v8
OLDNEW
« no previous file with comments | « src/accessors.h ('k') | src/ast/ast-types.cc » ('j') | src/interpreter/bytecode-generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698