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

Unified Diff: src/accessors.cc

Issue 2388153003: [modules] Implement namespace imports. (Closed)
Patch Set: Add comment on VisitModuleNamespaceImports. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/accessors.h ('k') | src/ast/ast-types.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/accessors.cc
diff --git a/src/accessors.cc b/src/accessors.cc
index da44151b3edbdd6d4b517e14936aacc83bd0b6fc..e9674b97934ad0b68feb7d9e60da2490b1f39693 100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -202,6 +202,68 @@ Handle<AccessorInfo> Accessors::ArrayLengthInfo(
attributes);
}
+//
+// Accessors::ModuleNamespaceToStringTag
+//
+
+void Accessors::ModuleNamespaceToStringTagGetter(
+ v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
+ info.GetReturnValue().Set(
+ Utils::ToLocal(isolate->factory()->NewStringFromAsciiChecked("Module")));
+}
+
+Handle<AccessorInfo> Accessors::ModuleNamespaceToStringTagInfo(
+ Isolate* isolate, PropertyAttributes attributes) {
+ Handle<Name> name = isolate->factory()->to_string_tag_symbol();
+ return MakeAccessor(isolate, name, &ModuleNamespaceToStringTagGetter, nullptr,
+ attributes);
+}
+
+//
+// Accessors::ModuleNamespaceEntry
+//
+
+void Accessors::ModuleNamespaceEntryGetter(
+ v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
+ HandleScope scope(isolate);
+ JSModuleNamespace* holder =
+ JSModuleNamespace::cast(*Utils::OpenHandle(*info.Holder()));
+ Handle<Object> result;
+ if (!holder->GetExport(Handle<String>::cast(Utils::OpenHandle(*name)))
+ .ToHandle(&result)) {
+ isolate->OptionalRescheduleException(false);
+ } else {
+ info.GetReturnValue().Set(Utils::ToLocal(result));
+ }
+}
+
+void Accessors::ModuleNamespaceEntrySetter(
+ v8::Local<v8::Name> name, v8::Local<v8::Value> val,
+ const v8::PropertyCallbackInfo<void>& info) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
+ HandleScope scope(isolate);
+ Factory* factory = isolate->factory();
+ Handle<JSModuleNamespace> holder =
+ Handle<JSModuleNamespace>::cast(Utils::OpenHandle(*info.Holder()));
+
+ if (info.ShouldThrowOnError()) {
+ isolate->Throw(*factory->NewTypeError(
+ MessageTemplate::kStrictReadOnlyProperty, Utils::OpenHandle(*name),
+ i::Object::TypeOf(isolate, holder), holder));
+ isolate->OptionalRescheduleException(false);
+ } else {
+ info.GetReturnValue().Set(Utils::ToLocal(factory->ToBoolean(false)));
+ }
+}
+
+Handle<AccessorInfo> Accessors::ModuleNamespaceEntryInfo(
+ Isolate* isolate, Handle<String> name, PropertyAttributes attributes) {
+ return MakeAccessor(isolate, name, &ModuleNamespaceEntryGetter,
+ &ModuleNamespaceEntrySetter, attributes);
+}
+
//
// Accessors::StringLength
« no previous file with comments | « src/accessors.h ('k') | src/ast/ast-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698