| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 445 |
| 446 MaybeObject* JSProxy::GetElementWithHandler(Object* receiver, | 446 MaybeObject* JSProxy::GetElementWithHandler(Object* receiver, |
| 447 uint32_t index) { | 447 uint32_t index) { |
| 448 String* name; | 448 String* name; |
| 449 MaybeObject* maybe = GetHeap()->Uint32ToString(index); | 449 MaybeObject* maybe = GetHeap()->Uint32ToString(index); |
| 450 if (!maybe->To<String>(&name)) return maybe; | 450 if (!maybe->To<String>(&name)) return maybe; |
| 451 return GetPropertyWithHandler(receiver, name); | 451 return GetPropertyWithHandler(receiver, name); |
| 452 } | 452 } |
| 453 | 453 |
| 454 | 454 |
| 455 MaybeObject* JSProxy::SetElementWithHandler(JSReceiver* receiver, | 455 Handle<Object> JSProxy::SetElementWithHandler(Handle<JSProxy> proxy, |
| 456 uint32_t index, | 456 Handle<JSReceiver> receiver, |
| 457 Object* value, | 457 uint32_t index, |
| 458 StrictModeFlag strict_mode) { | 458 Handle<Object> value, |
| 459 String* name; | 459 StrictModeFlag strict_mode) { |
| 460 MaybeObject* maybe = GetHeap()->Uint32ToString(index); | 460 Isolate* isolate = proxy->GetIsolate(); |
| 461 if (!maybe->To<String>(&name)) return maybe; | 461 Handle<String> name = isolate->factory()->Uint32ToString(index); |
| 462 return SetPropertyWithHandler(receiver, name, value, NONE, strict_mode); | 462 CALL_HEAP_FUNCTION(isolate, |
| 463 proxy->SetPropertyWithHandler( |
| 464 *receiver, *name, *value, NONE, strict_mode), |
| 465 Object); |
| 463 } | 466 } |
| 464 | 467 |
| 465 | 468 |
| 466 bool JSProxy::HasElementWithHandler(uint32_t index) { | 469 bool JSProxy::HasElementWithHandler(uint32_t index) { |
| 467 String* name; | 470 String* name; |
| 468 MaybeObject* maybe = GetHeap()->Uint32ToString(index); | 471 MaybeObject* maybe = GetHeap()->Uint32ToString(index); |
| 469 if (!maybe->To<String>(&name)) return maybe; | 472 if (!maybe->To<String>(&name)) return maybe; |
| 470 return HasPropertyWithHandler(name); | 473 return HasPropertyWithHandler(name); |
| 471 } | 474 } |
| 472 | 475 |
| (...skipping 3061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3534 | 3537 |
| 3535 if (strict_mode == kNonStrictMode) return *value; | 3538 if (strict_mode == kNonStrictMode) return *value; |
| 3536 Handle<Object> args2[] = { name, proxy }; | 3539 Handle<Object> args2[] = { name, proxy }; |
| 3537 Handle<Object> error = isolate->factory()->NewTypeError( | 3540 Handle<Object> error = isolate->factory()->NewTypeError( |
| 3538 "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2))); | 3541 "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2))); |
| 3539 return isolate->Throw(*error); | 3542 return isolate->Throw(*error); |
| 3540 } | 3543 } |
| 3541 | 3544 |
| 3542 | 3545 |
| 3543 Handle<Object> JSProxy::DeletePropertyWithHandler( | 3546 Handle<Object> JSProxy::DeletePropertyWithHandler( |
| 3544 Handle<JSProxy> object, Handle<Name> name, DeleteMode mode) { | 3547 Handle<JSProxy> proxy, Handle<Name> name, DeleteMode mode) { |
| 3545 Isolate* isolate = object->GetIsolate(); | 3548 Isolate* isolate = proxy->GetIsolate(); |
| 3546 | 3549 |
| 3547 // TODO(rossberg): adjust once there is a story for symbols vs proxies. | 3550 // TODO(rossberg): adjust once there is a story for symbols vs proxies. |
| 3548 if (name->IsSymbol()) return isolate->factory()->false_value(); | 3551 if (name->IsSymbol()) return isolate->factory()->false_value(); |
| 3549 | 3552 |
| 3550 Handle<Object> args[] = { name }; | 3553 Handle<Object> args[] = { name }; |
| 3551 Handle<Object> result = object->CallTrap( | 3554 Handle<Object> result = proxy->CallTrap( |
| 3552 "delete", Handle<Object>(), ARRAY_SIZE(args), args); | 3555 "delete", Handle<Object>(), ARRAY_SIZE(args), args); |
| 3553 if (isolate->has_pending_exception()) return Handle<Object>(); | 3556 if (isolate->has_pending_exception()) return Handle<Object>(); |
| 3554 | 3557 |
| 3555 bool result_bool = result->BooleanValue(); | 3558 bool result_bool = result->BooleanValue(); |
| 3556 if (mode == STRICT_DELETION && !result_bool) { | 3559 if (mode == STRICT_DELETION && !result_bool) { |
| 3557 Handle<Object> handler(object->handler(), isolate); | 3560 Handle<Object> handler(proxy->handler(), isolate); |
| 3558 Handle<String> trap_name = isolate->factory()->InternalizeOneByteString( | 3561 Handle<String> trap_name = isolate->factory()->InternalizeOneByteString( |
| 3559 STATIC_ASCII_VECTOR("delete")); | 3562 STATIC_ASCII_VECTOR("delete")); |
| 3560 Handle<Object> args[] = { handler, trap_name }; | 3563 Handle<Object> args[] = { handler, trap_name }; |
| 3561 Handle<Object> error = isolate->factory()->NewTypeError( | 3564 Handle<Object> error = isolate->factory()->NewTypeError( |
| 3562 "handler_failed", HandleVector(args, ARRAY_SIZE(args))); | 3565 "handler_failed", HandleVector(args, ARRAY_SIZE(args))); |
| 3563 isolate->Throw(*error); | 3566 isolate->Throw(*error); |
| 3564 return Handle<Object>(); | 3567 return Handle<Object>(); |
| 3565 } | 3568 } |
| 3566 return isolate->factory()->ToBoolean(result_bool); | 3569 return isolate->factory()->ToBoolean(result_bool); |
| 3567 } | 3570 } |
| 3568 | 3571 |
| 3569 | 3572 |
| 3570 Handle<Object> JSProxy::DeleteElementWithHandler( | 3573 Handle<Object> JSProxy::DeleteElementWithHandler( |
| 3571 Handle<JSProxy> object, uint32_t index, DeleteMode mode) { | 3574 Handle<JSProxy> proxy, uint32_t index, DeleteMode mode) { |
| 3572 Isolate* isolate = object->GetIsolate(); | 3575 Isolate* isolate = proxy->GetIsolate(); |
| 3573 Handle<String> name = isolate->factory()->Uint32ToString(index); | 3576 Handle<String> name = isolate->factory()->Uint32ToString(index); |
| 3574 return JSProxy::DeletePropertyWithHandler(object, name, mode); | 3577 return JSProxy::DeletePropertyWithHandler(proxy, name, mode); |
| 3575 } | 3578 } |
| 3576 | 3579 |
| 3577 | 3580 |
| 3578 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( | 3581 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( |
| 3579 JSReceiver* receiver_raw, | 3582 JSReceiver* receiver_raw, |
| 3580 Name* name_raw) { | 3583 Name* name_raw) { |
| 3581 Isolate* isolate = GetIsolate(); | 3584 Isolate* isolate = GetIsolate(); |
| 3582 HandleScope scope(isolate); | 3585 HandleScope scope(isolate); |
| 3583 Handle<JSProxy> proxy(this); | 3586 Handle<JSProxy> proxy(this); |
| 3584 Handle<Object> handler(this->handler(), isolate); // Trap might morph proxy. | 3587 Handle<Object> handler(this->handler(), isolate); // Trap might morph proxy. |
| (...skipping 8519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12104 ASSERT(elements()->IsFixedDoubleArray()); | 12107 ASSERT(elements()->IsFixedDoubleArray()); |
| 12105 Object* obj; | 12108 Object* obj; |
| 12106 { MaybeObject* maybe_obj = NormalizeElements(); | 12109 { MaybeObject* maybe_obj = NormalizeElements(); |
| 12107 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 12110 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 12108 } | 12111 } |
| 12109 ASSERT(HasDictionaryElements()); | 12112 ASSERT(HasDictionaryElements()); |
| 12110 return SetElement(index, value, NONE, strict_mode, check_prototype); | 12113 return SetElement(index, value, NONE, strict_mode, check_prototype); |
| 12111 } | 12114 } |
| 12112 | 12115 |
| 12113 | 12116 |
| 12114 MaybeObject* JSReceiver::SetElement(uint32_t index, | 12117 Handle<Object> JSReceiver::SetElement(Handle<JSReceiver> object, |
| 12115 Object* value, | 12118 uint32_t index, |
| 12116 PropertyAttributes attributes, | 12119 Handle<Object> value, |
| 12117 StrictModeFlag strict_mode, | 12120 PropertyAttributes attributes, |
| 12118 bool check_proto) { | 12121 StrictModeFlag strict_mode) { |
| 12119 if (IsJSProxy()) { | 12122 if (object->IsJSProxy()) { |
| 12120 return JSProxy::cast(this)->SetElementWithHandler( | 12123 return JSProxy::SetElementWithHandler( |
| 12121 this, index, value, strict_mode); | 12124 Handle<JSProxy>::cast(object), object, index, value, strict_mode); |
| 12122 } else { | |
| 12123 return JSObject::cast(this)->SetElement( | |
| 12124 index, value, attributes, strict_mode, check_proto); | |
| 12125 } | 12125 } |
| 12126 return JSObject::SetElement( |
| 12127 Handle<JSObject>::cast(object), index, value, attributes, strict_mode); |
| 12126 } | 12128 } |
| 12127 | 12129 |
| 12128 | 12130 |
| 12129 Handle<Object> JSObject::SetOwnElement(Handle<JSObject> object, | 12131 Handle<Object> JSObject::SetOwnElement(Handle<JSObject> object, |
| 12130 uint32_t index, | 12132 uint32_t index, |
| 12131 Handle<Object> value, | 12133 Handle<Object> value, |
| 12132 StrictModeFlag strict_mode) { | 12134 StrictModeFlag strict_mode) { |
| 12133 ASSERT(!object->HasExternalArrayElements()); | 12135 ASSERT(!object->HasExternalArrayElements()); |
| 12134 CALL_HEAP_FUNCTION( | 12136 CALL_HEAP_FUNCTION( |
| 12135 object->GetIsolate(), | 12137 object->GetIsolate(), |
| (...skipping 3856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15992 #define ERROR_MESSAGES_TEXTS(C, T) T, | 15994 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 15993 static const char* error_messages_[] = { | 15995 static const char* error_messages_[] = { |
| 15994 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 15996 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 15995 }; | 15997 }; |
| 15996 #undef ERROR_MESSAGES_TEXTS | 15998 #undef ERROR_MESSAGES_TEXTS |
| 15997 return error_messages_[reason]; | 15999 return error_messages_[reason]; |
| 15998 } | 16000 } |
| 15999 | 16001 |
| 16000 | 16002 |
| 16001 } } // namespace v8::internal | 16003 } } // namespace v8::internal |
| OLD | NEW |