Index: src/accessors.cc |
diff --git a/src/accessors.cc b/src/accessors.cc |
index a5164a2fff5b5166ae2c814818c6a45bb40fb442..7563256a39118e464ad40b5e4931b6763f20dd2f 100644 |
--- a/src/accessors.cc |
+++ b/src/accessors.cc |
@@ -1385,9 +1385,8 @@ Handle<AccessorInfo> Accessors::FunctionCallerInfo( |
// Accessors::MakeModuleExport |
// |
-static void ModuleGetExport( |
- v8::Local<v8::String> property, |
- const v8::PropertyCallbackInfo<v8::Value>& info) { |
+static void ModuleGetExport(v8::Local<v8::Name> property, |
+ const v8::PropertyCallbackInfo<v8::Value>& info) { |
JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); |
Context* context = Context::cast(instance->context()); |
DCHECK(context->IsModuleContext()); |
@@ -1396,7 +1395,7 @@ static void ModuleGetExport( |
->Int32Value(info.GetIsolate()->GetCurrentContext()) |
.FromMaybe(-1); |
if (slot < 0 || slot >= context->length()) { |
- Handle<String> name = v8::Utils::OpenHandle(*property); |
+ Handle<Name> name = v8::Utils::OpenHandle(*property); |
Handle<Object> exception = isolate->factory()->NewReferenceError( |
MessageTemplate::kNotDefined, name); |
@@ -1405,7 +1404,7 @@ static void ModuleGetExport( |
} |
Object* value = context->get(slot); |
if (value->IsTheHole()) { |
- Handle<String> name = v8::Utils::OpenHandle(*property); |
+ Handle<Name> name = v8::Utils::OpenHandle(*property); |
Handle<Object> exception = isolate->factory()->NewReferenceError( |
MessageTemplate::kNotDefined, name); |
@@ -1416,33 +1415,14 @@ static void ModuleGetExport( |
} |
-static void ModuleSetExport( |
- v8::Local<v8::String> property, |
- v8::Local<v8::Value> value, |
- const v8::PropertyCallbackInfo<v8::Value>& info) { |
- JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); |
- Context* context = Context::cast(instance->context()); |
- DCHECK(context->IsModuleContext()); |
- Isolate* isolate = instance->GetIsolate(); |
- int slot = info.Data() |
- ->Int32Value(info.GetIsolate()->GetCurrentContext()) |
- .FromMaybe(-1); |
- if (slot < 0 || slot >= context->length()) { |
- Handle<String> name = v8::Utils::OpenHandle(*property); |
- Handle<Object> exception = isolate->factory()->NewReferenceError( |
- MessageTemplate::kNotDefined, name); |
- isolate->ScheduleThrow(*exception); |
- return; |
- } |
- Object* old_value = context->get(slot); |
- if (old_value->IsTheHole()) { |
- Handle<String> name = v8::Utils::OpenHandle(*property); |
- Handle<Object> exception = isolate->factory()->NewReferenceError( |
- MessageTemplate::kNotDefined, name); |
- isolate->ScheduleThrow(*exception); |
- return; |
- } |
- context->set(slot, *v8::Utils::OpenHandle(*value)); |
+static void ModuleSetExport(v8::Local<v8::Name> property, |
+ v8::Local<v8::Value> value, |
+ const v8::PropertyCallbackInfo<void>& info) { |
+ Handle<Name> name = v8::Utils::OpenHandle(*property); |
+ Isolate* isolate = name->GetIsolate(); |
+ Handle<Object> exception = |
+ isolate->factory()->NewTypeError(MessageTemplate::kNotDefined, name); |
+ isolate->ScheduleThrow(*exception); |
} |
@@ -1451,17 +1431,9 @@ Handle<AccessorInfo> Accessors::MakeModuleExport( |
int index, |
PropertyAttributes attributes) { |
Isolate* isolate = name->GetIsolate(); |
- Factory* factory = isolate->factory(); |
- Handle<AccessorInfo> info = factory->NewAccessorInfo(); |
- info->set_property_attributes(attributes); |
- info->set_all_can_read(true); |
- info->set_all_can_write(true); |
- info->set_name(*name); |
+ Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport, |
+ &ModuleSetExport, attributes); |
info->set_data(Smi::FromInt(index)); |
- Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
- Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
- info->set_getter(*getter); |
- if (!(attributes & ReadOnly)) info->set_setter(*setter); |
return info; |
} |