Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 057e268f7ad0e6ec9f830b449b7963a5eda30934..0ce62905412f424ea1fd64ebffe8d70c8695fe72 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -1664,6 +1664,14 @@ static bool CheckAccessException(Object* callback, |
(access_type == v8::ACCESS_GET && info->all_can_read()) || |
(access_type == v8::ACCESS_SET && info->all_can_write()); |
} |
+ if (callback->IsAccessorPair()) { |
+ AccessorPair* info = AccessorPair::cast(callback); |
+ return |
+ (access_type == v8::ACCESS_HAS && |
+ (info->all_can_read() || info->all_can_write())) || |
+ (access_type == v8::ACCESS_GET && info->all_can_read()) || |
+ (access_type == v8::ACCESS_SET && info->all_can_write()); |
+ } |
return false; |
} |
@@ -1945,6 +1953,41 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { |
} |
+RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAccessorProperty) { |
+ HandleScope scope(isolate); |
+ ASSERT(args.length() == 6); |
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); |
+ CONVERT_SMI_ARG_CHECKED(attribute, 4); |
+ CONVERT_SMI_ARG_CHECKED(access_control, 5); |
+ // Transform getter into something DefineAccessor can handle. |
+ if (getter->IsUndefined()) { |
Sven Panne
2013/08/22 08:52:51
Tiny nit: Can we extract this if/then/else into a
|
+ getter = isolate->factory()->null_value(); |
+ } else { |
+ Handle<FunctionTemplateInfo> info = |
+ Handle<FunctionTemplateInfo>::cast(getter); |
+ getter = Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); |
+ } |
+ // Transform getter into something DefineAccessor can handle. |
+ if (setter->IsUndefined()) { |
+ setter = isolate->factory()->null_value(); |
+ } else { |
+ Handle<FunctionTemplateInfo> info = |
+ Handle<FunctionTemplateInfo>::cast(setter); |
+ setter = Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); |
+ } |
+ JSObject::DefineAccessor(object, |
+ name, |
+ getter, |
+ setter, |
+ static_cast<PropertyAttributes>(attribute), |
+ static_cast<v8::AccessControl>(access_control)); |
+ return isolate->heap()->undefined_value(); |
+} |
+ |
+ |
static Failure* ThrowRedeclarationError(Isolate* isolate, |
const char* type, |
Handle<String> name) { |