}
-Object* Accessors::FunctionGetArguments(Isolate* isolate,
- Object* object,
- void*) {
+void Accessors::FunctionArgumentsGetter(
+ v8::Local<v8::String> name,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
HandleScope scope(isolate);
- Handle<JSFunction> function;
+ Handle<Object> object = Utils::OpenHandle(*info.This());
+ MaybeHandle<JSFunction> maybe_function;
+
{
DisallowHeapAllocation no_allocation;
- JSFunction* holder = FindInstanceOf<JSFunction>(isolate, object);
- if (holder == NULL) return isolate->heap()->undefined_value();
- function = Handle<JSFunction>(holder, isolate);
+ JSFunction* function = FindInstanceOf<JSFunction>(isolate, *object);
+ if (function != NULL) maybe_function = Handle<JSFunction>(function);
+ }
+
+ Handle<JSFunction> function;
+ Handle<Object> result;
+ if (maybe_function.ToHandle(&function)) {
+ result = GetFunctionArguments(isolate, function);
+ } else {
+ result = isolate->factory()->undefined_value();
}
- return *GetFunctionArguments(isolate, function);
+ info.GetReturnValue().Set(Utils::ToLocal(result));
}
-const AccessorDescriptor Accessors::FunctionArguments = {
- FunctionGetArguments,
- ReadOnlySetAccessor,
- 0
-};
+void Accessors::FunctionArgumentsSetter(
+ v8::Local<v8::String> name,
+ v8::Local<v8::Value> val,
+ const v8::PropertyCallbackInfo<void>& info) {
+ // Do nothing.
+}
+
+
+Handle<AccessorInfo> Accessors::FunctionArgumentsInfo(
+ Isolate* isolate, PropertyAttributes attributes) {
+ return MakeAccessor(isolate,
+ isolate->factory()->arguments_string(),
+ &FunctionArgumentsGetter,
+ &FunctionArgumentsSetter,
+ attributes);
+}
//
// The list of accessor descriptors. This is a second-order macro
// taking a macro to be applied to all accessor descriptor names.
#define ACCESSOR_DESCRIPTOR_LIST(V) \
- V(FunctionArguments) \
V(FunctionCaller) \
V(ArrayLength)
#define ACCESSOR_INFO_LIST(V) \
+ V(FunctionArguments) \
V(FunctionName) \
V(FunctionLength) \
V(FunctionPrototype) \
int* object_offset);
private:
- // Accessor functions only used through the descriptor.
- static Object* FunctionSetPrototype(Isolate* isolate,
- JSObject* object,
- Object*,
- void*);
- static Object* FunctionGetPrototype(Isolate* isolate,
- Object* object,
- void*);
- static Object* FunctionGetLength(Isolate* isolate,
- Object* object,
- void*);
- static Object* FunctionGetName(Isolate* isolate, Object* object, void*);
- static Object* FunctionGetArguments(Isolate* isolate,
- Object* object,
- void*);
static Object* FunctionGetCaller(Isolate* isolate,
Object* object,
void*);
int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
Map::EnsureDescriptorSlack(map, size);
- Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments));
Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller));
PropertyAttributes attribs = static_cast<PropertyAttributes>(
DONT_ENUM | DONT_DELETE | READ_ONLY);
name, attribs);
map->AppendDescriptor(&d);
}
+ Handle<AccessorInfo> args =
+ Accessors::FunctionArgumentsInfo(isolate(), attribs);
{ // Add arguments.
- CallbacksDescriptor d(factory()->arguments_string(), args, attribs);
+ CallbacksDescriptor d(Handle<Name>(Name::cast(args->name())),
+ args, attribs);
map->AppendDescriptor(&d);
}
{ // Add caller.