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

Unified Diff: src/accessors.cc

Issue 2388153003: [modules] Implement namespace imports. (Closed)
Patch Set: Fix verifier. 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
Index: src/accessors.cc
diff --git a/src/accessors.cc b/src/accessors.cc
index da44151b3edbdd6d4b517e14936aacc83bd0b6fc..a22f3ceac1a148ed721c79635f6c64127c7769e3 100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -202,6 +202,64 @@ 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) {
+ DisallowHeapAllocation no_allocation;
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
+ HandleScope scope(isolate);
+ JSModuleNamespace* holder =
+ JSModuleNamespace::cast(*Utils::OpenHandle(*info.Holder()));
+ Object* result = holder->Get(Handle<String>::cast(Utils::OpenHandle(*name)));
+ info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate)));
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698