Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 49591df299c1a126173eb99febf61eca68194d60..ba6f33c5313ed589930c4808fb00553383aeca3b 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -4927,6 +4927,37 @@ static bool IsValidAccessor(Handle<Object> obj) { |
} |
+// Transform getter or setter into something DefineAccessor can handle. |
+static Handle<Object> InstantiateAccessorComponent(Isolate* isolate, |
+ Handle<Object> component) { |
+ if (component->IsUndefined()) return isolate->factory()->null_value(); |
+ Handle<FunctionTemplateInfo> info = |
+ Handle<FunctionTemplateInfo>::cast(component); |
+ return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); |
+} |
+ |
+ |
+RUNTIME_FUNCTION(Runtime_DefineApiAccessorProperty) { |
+ HandleScope scope(isolate); |
+ ASSERT(args.length() == 5); |
+ 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); |
+ RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo()); |
+ RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo()); |
+ RUNTIME_ASSERT(PropertyDetails::AttributesField::is_valid( |
+ static_cast<PropertyAttributes>(attribute))); |
+ RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, JSObject::DefineAccessor( |
+ object, name, InstantiateAccessorComponent(isolate, getter), |
+ InstantiateAccessorComponent(isolate, setter), |
+ static_cast<PropertyAttributes>(attribute))); |
+ return isolate->heap()->undefined_value(); |
+} |
+ |
+ |
// Implements part of 8.12.9 DefineOwnProperty. |
// There are 3 cases that lead here: |
// Step 4b - define a new accessor property. |