| Index: src/execution.cc
|
| diff --git a/src/execution.cc b/src/execution.cc
|
| index eb26438fe87af6a1d264b3b9ad32ad0efab6e8e8..850dec561f8151b66abd818831964c939e176a3e 100644
|
| --- a/src/execution.cc
|
| +++ b/src/execution.cc
|
| @@ -234,6 +234,30 @@ Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) {
|
| }
|
|
|
|
|
| +Handle<Object> Execution::TryGetFunctionDelegate(Handle<Object> object,
|
| + bool* has_pending_exception) {
|
| + ASSERT(!object->IsJSFunction());
|
| + Isolate* isolate = Isolate::Current();
|
| +
|
| + // Objects created through the API can have an instance-call handler
|
| + // that should be used when calling the object as a function.
|
| + if (object->IsHeapObject() &&
|
| + HeapObject::cast(*object)->map()->has_instance_call_handler()) {
|
| + return Handle<JSFunction>(
|
| + isolate->global_context()->call_as_function_delegate());
|
| + }
|
| +
|
| + // If the Object doesn't have an instance-call handler we should
|
| + // throw a non-callable exception.
|
| + i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError(
|
| + "called_non_callable", i::HandleVector<i::Object>(&object, 1));
|
| + isolate->Throw(*error_obj);
|
| + *has_pending_exception = true;
|
| +
|
| + return isolate->factory()->undefined_value();
|
| +}
|
| +
|
| +
|
| Handle<Object> Execution::GetConstructorDelegate(Handle<Object> object) {
|
| ASSERT(!object->IsJSFunction());
|
| Isolate* isolate = Isolate::Current();
|
|
|