OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 4); | 641 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 4); |
642 | 642 |
643 RETURN_FAILURE_ON_EXCEPTION( | 643 RETURN_FAILURE_ON_EXCEPTION( |
644 isolate, JSObject::DefineAccessor(obj, name, getter, setter, attrs)); | 644 isolate, JSObject::DefineAccessor(obj, name, getter, setter, attrs)); |
645 return isolate->heap()->undefined_value(); | 645 return isolate->heap()->undefined_value(); |
646 } | 646 } |
647 | 647 |
648 | 648 |
649 RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) { | 649 RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) { |
650 HandleScope scope(isolate); | 650 HandleScope scope(isolate); |
651 DCHECK(args.length() == 5); | 651 DCHECK(args.length() == 4); |
652 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 652 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
653 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 653 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
654 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 654 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
655 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 655 CONVERT_SMI_ARG_CHECKED(flag, 3); |
656 CONVERT_SMI_ARG_CHECKED(set_function_name, 4); | |
657 | 656 |
658 if (set_function_name) { | 657 DataPropertyInLiteralFlags flags = |
| 658 static_cast<DataPropertyInLiteralFlag>(flag); |
| 659 |
| 660 PropertyAttributes attrs = (flags & DataPropertyInLiteralFlag::kDontEnum) |
| 661 ? PropertyAttributes::DONT_ENUM |
| 662 : PropertyAttributes::NONE; |
| 663 |
| 664 if (flags & DataPropertyInLiteralFlag::kSetFunctionName) { |
659 DCHECK(value->IsJSFunction()); | 665 DCHECK(value->IsJSFunction()); |
660 JSFunction::SetName(Handle<JSFunction>::cast(value), name, | 666 JSFunction::SetName(Handle<JSFunction>::cast(value), name, |
661 isolate->factory()->empty_string()); | 667 isolate->factory()->empty_string()); |
662 } | 668 } |
663 | 669 |
664 LookupIterator it = LookupIterator::PropertyOrElement( | 670 LookupIterator it = LookupIterator::PropertyOrElement( |
665 isolate, object, name, object, LookupIterator::OWN); | 671 isolate, object, name, object, LookupIterator::OWN); |
666 // Cannot fail since this should only be called when | 672 // Cannot fail since this should only be called when |
667 // creating an object literal. | 673 // creating an object literal. |
668 CHECK(JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs, | 674 CHECK(JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs, |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 if (!success) return isolate->heap()->exception(); | 931 if (!success) return isolate->heap()->exception(); |
926 MAYBE_RETURN( | 932 MAYBE_RETURN( |
927 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 933 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
928 isolate->heap()->exception()); | 934 isolate->heap()->exception()); |
929 return *value; | 935 return *value; |
930 } | 936 } |
931 | 937 |
932 | 938 |
933 } // namespace internal | 939 } // namespace internal |
934 } // namespace v8 | 940 } // namespace v8 |
OLD | NEW |