| 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 2801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2812 v8::Utils::ToLocal(key), | 2812 v8::Utils::ToLocal(key), |
| 2813 v8::Utils::ToLocal(value)); | 2813 v8::Utils::ToLocal(value)); |
| 2814 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 2814 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 2815 return value; | 2815 return value; |
| 2816 } | 2816 } |
| 2817 | 2817 |
| 2818 if (structure->IsAccessorPair()) { | 2818 if (structure->IsAccessorPair()) { |
| 2819 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 2819 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); |
| 2820 if (setter->IsSpecFunction()) { | 2820 if (setter->IsSpecFunction()) { |
| 2821 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 2821 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
| 2822 CALL_HEAP_FUNCTION(isolate, | 2822 return SetPropertyWithDefinedSetter( |
| 2823 object->SetPropertyWithDefinedSetter( | 2823 object, Handle<JSReceiver>::cast(setter), value); |
| 2824 JSReceiver::cast(*setter), *value), | |
| 2825 Object); | |
| 2826 } else { | 2824 } else { |
| 2827 if (strict_mode == kNonStrictMode) { | 2825 if (strict_mode == kNonStrictMode) { |
| 2828 return value; | 2826 return value; |
| 2829 } | 2827 } |
| 2830 Handle<Object> args[2] = { name, holder }; | 2828 Handle<Object> args[2] = { name, holder }; |
| 2831 Handle<Object> error = | 2829 Handle<Object> error = |
| 2832 isolate->factory()->NewTypeError("no_setter_in_callback", | 2830 isolate->factory()->NewTypeError("no_setter_in_callback", |
| 2833 HandleVector(args, 2)); | 2831 HandleVector(args, 2)); |
| 2834 isolate->Throw(*error); | 2832 isolate->Throw(*error); |
| 2835 return Handle<Object>(); | 2833 return Handle<Object>(); |
| 2836 } | 2834 } |
| 2837 } | 2835 } |
| 2838 | 2836 |
| 2839 // TODO(dcarney): Handle correctly. | 2837 // TODO(dcarney): Handle correctly. |
| 2840 if (structure->IsDeclaredAccessorInfo()) { | 2838 if (structure->IsDeclaredAccessorInfo()) { |
| 2841 return value; | 2839 return value; |
| 2842 } | 2840 } |
| 2843 | 2841 |
| 2844 UNREACHABLE(); | 2842 UNREACHABLE(); |
| 2845 return Handle<Object>(); | 2843 return Handle<Object>(); |
| 2846 } | 2844 } |
| 2847 | 2845 |
| 2848 | 2846 |
| 2849 MaybeObject* JSReceiver::SetPropertyWithDefinedSetter(JSReceiver* setter, | 2847 Handle<Object> JSReceiver::SetPropertyWithDefinedSetter( |
| 2850 Object* value) { | 2848 Handle<JSReceiver> object, |
| 2851 Isolate* isolate = GetIsolate(); | 2849 Handle<JSReceiver> setter, |
| 2852 Handle<Object> value_handle(value, isolate); | 2850 Handle<Object> value) { |
| 2853 Handle<JSReceiver> fun(setter, isolate); | 2851 Isolate* isolate = object->GetIsolate(); |
| 2854 Handle<JSReceiver> self(this, isolate); | 2852 |
| 2855 #ifdef ENABLE_DEBUGGER_SUPPORT | 2853 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 2856 Debug* debug = isolate->debug(); | 2854 Debug* debug = isolate->debug(); |
| 2857 // Handle stepping into a setter if step into is active. | 2855 // Handle stepping into a setter if step into is active. |
| 2858 // TODO(rossberg): should this apply to getters that are function proxies? | 2856 // TODO(rossberg): should this apply to getters that are function proxies? |
| 2859 if (debug->StepInActive() && fun->IsJSFunction()) { | 2857 if (debug->StepInActive() && setter->IsJSFunction()) { |
| 2860 debug->HandleStepIn( | 2858 debug->HandleStepIn( |
| 2861 Handle<JSFunction>::cast(fun), Handle<Object>::null(), 0, false); | 2859 Handle<JSFunction>::cast(setter), Handle<Object>::null(), 0, false); |
| 2862 } | 2860 } |
| 2863 #endif | 2861 #endif |
| 2864 bool has_pending_exception; | 2862 bool has_pending_exception; |
| 2865 Handle<Object> argv[] = { value_handle }; | 2863 Handle<Object> argv[] = { value }; |
| 2866 Execution::Call( | 2864 Execution::Call( |
| 2867 isolate, fun, self, ARRAY_SIZE(argv), argv, &has_pending_exception); | 2865 isolate, setter, object, ARRAY_SIZE(argv), argv, &has_pending_exception); |
| 2868 // Check for pending exception and return the result. | 2866 // Check for pending exception and return the result. |
| 2869 if (has_pending_exception) return Failure::Exception(); | 2867 if (has_pending_exception) return Handle<Object>(); |
| 2870 return *value_handle; | 2868 return value; |
| 2871 } | 2869 } |
| 2872 | 2870 |
| 2873 | 2871 |
| 2874 MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes( | 2872 MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes( |
| 2875 uint32_t index, | 2873 uint32_t index, |
| 2876 Object* value, | 2874 Object* value, |
| 2877 bool* found, | 2875 bool* found, |
| 2878 StrictModeFlag strict_mode) { | 2876 StrictModeFlag strict_mode) { |
| 2879 Heap* heap = GetHeap(); | 2877 Heap* heap = GetHeap(); |
| 2880 for (Object* pt = GetPrototype(); | 2878 for (Object* pt = GetPrototype(); |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3533 return Handle<Object>(); | 3531 return Handle<Object>(); |
| 3534 } | 3532 } |
| 3535 | 3533 |
| 3536 // We have an AccessorDescriptor. | 3534 // We have an AccessorDescriptor. |
| 3537 Handle<String> set_name = isolate->factory()->InternalizeOneByteString( | 3535 Handle<String> set_name = isolate->factory()->InternalizeOneByteString( |
| 3538 STATIC_ASCII_VECTOR("set_")); | 3536 STATIC_ASCII_VECTOR("set_")); |
| 3539 Handle<Object> setter(v8::internal::GetProperty(isolate, desc, set_name)); | 3537 Handle<Object> setter(v8::internal::GetProperty(isolate, desc, set_name)); |
| 3540 ASSERT(!isolate->has_pending_exception()); | 3538 ASSERT(!isolate->has_pending_exception()); |
| 3541 if (!setter->IsUndefined()) { | 3539 if (!setter->IsUndefined()) { |
| 3542 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 3540 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
| 3543 CALL_HEAP_FUNCTION(isolate, | 3541 return SetPropertyWithDefinedSetter( |
| 3544 receiver->SetPropertyWithDefinedSetter( | 3542 receiver, Handle<JSReceiver>::cast(setter), value); |
| 3545 JSReceiver::cast(*setter), *value), | |
| 3546 Object); | |
| 3547 } | 3543 } |
| 3548 | 3544 |
| 3549 if (strict_mode == kNonStrictMode) return value; | 3545 if (strict_mode == kNonStrictMode) return value; |
| 3550 Handle<Object> args2[] = { name, proxy }; | 3546 Handle<Object> args2[] = { name, proxy }; |
| 3551 Handle<Object> error = isolate->factory()->NewTypeError( | 3547 Handle<Object> error = isolate->factory()->NewTypeError( |
| 3552 "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2))); | 3548 "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2))); |
| 3553 isolate->Throw(*error); | 3549 isolate->Throw(*error); |
| 3554 return Handle<Object>(); | 3550 return Handle<Object>(); |
| 3555 } | 3551 } |
| 3556 | 3552 |
| (...skipping 8152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11709 v8::Utils::ToLocal(key), | 11705 v8::Utils::ToLocal(key), |
| 11710 v8::Utils::ToLocal(value)); | 11706 v8::Utils::ToLocal(value)); |
| 11711 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 11707 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 11712 return value; | 11708 return value; |
| 11713 } | 11709 } |
| 11714 | 11710 |
| 11715 if (structure->IsAccessorPair()) { | 11711 if (structure->IsAccessorPair()) { |
| 11716 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 11712 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); |
| 11717 if (setter->IsSpecFunction()) { | 11713 if (setter->IsSpecFunction()) { |
| 11718 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 11714 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
| 11719 CALL_HEAP_FUNCTION(isolate, | 11715 return SetPropertyWithDefinedSetter( |
| 11720 object->SetPropertyWithDefinedSetter( | 11716 object, Handle<JSReceiver>::cast(setter), value); |
| 11721 JSReceiver::cast(*setter), *value), | |
| 11722 Object); | |
| 11723 } else { | 11717 } else { |
| 11724 if (strict_mode == kNonStrictMode) { | 11718 if (strict_mode == kNonStrictMode) { |
| 11725 return value; | 11719 return value; |
| 11726 } | 11720 } |
| 11727 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); | 11721 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); |
| 11728 Handle<Object> args[2] = { key, holder }; | 11722 Handle<Object> args[2] = { key, holder }; |
| 11729 Handle<Object> error = isolate->factory()->NewTypeError( | 11723 Handle<Object> error = isolate->factory()->NewTypeError( |
| 11730 "no_setter_in_callback", HandleVector(args, 2)); | 11724 "no_setter_in_callback", HandleVector(args, 2)); |
| 11731 isolate->Throw(*error); | 11725 isolate->Throw(*error); |
| 11732 return Handle<Object>(); | 11726 return Handle<Object>(); |
| (...skipping 4371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16104 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16098 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16105 static const char* error_messages_[] = { | 16099 static const char* error_messages_[] = { |
| 16106 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16100 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16107 }; | 16101 }; |
| 16108 #undef ERROR_MESSAGES_TEXTS | 16102 #undef ERROR_MESSAGES_TEXTS |
| 16109 return error_messages_[reason]; | 16103 return error_messages_[reason]; |
| 16110 } | 16104 } |
| 16111 | 16105 |
| 16112 | 16106 |
| 16113 } } // namespace v8::internal | 16107 } } // namespace v8::internal |
| OLD | NEW |