| Index: src/accessors.cc
|
| diff --git a/src/accessors.cc b/src/accessors.cc
|
| index 8048738b28e487b40971a7e302176a6248c7395c..f4fefff71329289cf3a2d4d2c92e9bc775a5f51f 100644
|
| --- a/src/accessors.cc
|
| +++ b/src/accessors.cc
|
| @@ -802,4 +802,69 @@ const AccessorDescriptor Accessors::ObjectPrototype = {
|
| 0
|
| };
|
|
|
| +
|
| +//
|
| +// Accessors::MakeModuleExport
|
| +//
|
| +
|
| +static v8::Handle<v8::Value> ModuleGetExport(
|
| + v8::Local<v8::String> property,
|
| + const v8::AccessorInfo& info) {
|
| + JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder()));
|
| + Context* context = Context::cast(instance->context());
|
| + ASSERT(context->IsModuleContext());
|
| + int slot = info.Data()->Int32Value();
|
| + Object* value = context->get(slot);
|
| + if (value->IsTheHole()) {
|
| + Handle<String> name = v8::Utils::OpenHandle(*property);
|
| + Isolate* isolate = instance->GetIsolate();
|
| + isolate->ScheduleThrow(
|
| + *isolate->factory()->NewReferenceError("not_defined",
|
| + HandleVector(&name, 1)));
|
| + return v8::Handle<v8::Value>();
|
| + }
|
| + return v8::Utils::ToLocal(Handle<Object>(value));
|
| +}
|
| +
|
| +
|
| +static void ModuleSetExport(
|
| + v8::Local<v8::String> property,
|
| + v8::Local<v8::Value> value,
|
| + const v8::AccessorInfo& info) {
|
| + JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder()));
|
| + Context* context = Context::cast(instance->context());
|
| + ASSERT(context->IsModuleContext());
|
| + int slot = info.Data()->Int32Value();
|
| + Object* old_value = context->get(slot);
|
| + if (old_value->IsTheHole()) {
|
| + Handle<String> name = v8::Utils::OpenHandle(*property);
|
| + Isolate* isolate = instance->GetIsolate();
|
| + isolate->ScheduleThrow(
|
| + *isolate->factory()->NewReferenceError("not_defined",
|
| + HandleVector(&name, 1)));
|
| + return;
|
| + }
|
| + context->set(slot, *v8::Utils::OpenHandle(*value));
|
| +}
|
| +
|
| +
|
| +Handle<AccessorInfo> Accessors::MakeModuleExport(
|
| + Handle<String> name,
|
| + int index,
|
| + PropertyAttributes attributes) {
|
| + Factory* factory = name->GetIsolate()->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);
|
| + info->set_data(Smi::FromInt(index));
|
| + v8::AccessorGetter getter = &ModuleGetExport;
|
| + v8::AccessorSetter setter = &ModuleSetExport;
|
| + info->set_getter(*v8::FromCData(getter));
|
| + if (!(attributes & ReadOnly)) info->set_setter(*v8::FromCData(setter));
|
| + return info;
|
| +}
|
| +
|
| +
|
| } } // namespace v8::internal
|
|
|