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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 557 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
558 Object::ToName(isolate, key)); | 558 Object::ToName(isolate, key)); |
559 | 559 |
560 // Lookup the {name} on {receiver}. | 560 // Lookup the {name} on {receiver}. |
561 Maybe<bool> maybe = JSReceiver::HasProperty(receiver, name); | 561 Maybe<bool> maybe = JSReceiver::HasProperty(receiver, name); |
562 if (!maybe.IsJust()) return isolate->heap()->exception(); | 562 if (!maybe.IsJust()) return isolate->heap()->exception(); |
563 return isolate->heap()->ToBoolean(maybe.FromJust()); | 563 return isolate->heap()->ToBoolean(maybe.FromJust()); |
564 } | 564 } |
565 | 565 |
566 | 566 |
567 RUNTIME_FUNCTION(Runtime_PropertyIsEnumerable) { | |
568 HandleScope scope(isolate); | |
569 DCHECK(args.length() == 2); | |
570 | |
571 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | |
572 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | |
573 | |
574 Maybe<PropertyAttributes> maybe = | |
575 JSReceiver::GetOwnPropertyAttributes(object, key); | |
576 if (!maybe.IsJust()) return isolate->heap()->exception(); | |
577 if (maybe.FromJust() == ABSENT) return isolate->heap()->false_value(); | |
578 return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0); | |
579 } | |
580 | |
581 | |
582 RUNTIME_FUNCTION(Runtime_GetOwnPropertyKeys) { | 567 RUNTIME_FUNCTION(Runtime_GetOwnPropertyKeys) { |
583 HandleScope scope(isolate); | 568 HandleScope scope(isolate); |
584 DCHECK(args.length() == 2); | 569 DCHECK(args.length() == 2); |
585 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 570 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
586 CONVERT_SMI_ARG_CHECKED(filter_value, 1); | 571 CONVERT_SMI_ARG_CHECKED(filter_value, 1); |
587 PropertyFilter filter = static_cast<PropertyFilter>(filter_value); | 572 PropertyFilter filter = static_cast<PropertyFilter>(filter_value); |
588 | 573 |
589 Handle<FixedArray> keys; | 574 Handle<FixedArray> keys; |
590 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 575 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
591 isolate, keys, | 576 isolate, keys, |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 | 846 |
862 RUNTIME_FUNCTION(Runtime_ToPrimitive_Number) { | 847 RUNTIME_FUNCTION(Runtime_ToPrimitive_Number) { |
863 HandleScope scope(isolate); | 848 HandleScope scope(isolate); |
864 DCHECK_EQ(1, args.length()); | 849 DCHECK_EQ(1, args.length()); |
865 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 850 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
866 RETURN_RESULT_OR_FAILURE( | 851 RETURN_RESULT_OR_FAILURE( |
867 isolate, Object::ToPrimitive(input, ToPrimitiveHint::kNumber)); | 852 isolate, Object::ToPrimitive(input, ToPrimitiveHint::kNumber)); |
868 } | 853 } |
869 | 854 |
870 | 855 |
871 RUNTIME_FUNCTION(Runtime_ToPrimitive_String) { | |
872 HandleScope scope(isolate); | |
873 DCHECK_EQ(1, args.length()); | |
874 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | |
875 RETURN_RESULT_OR_FAILURE( | |
876 isolate, Object::ToPrimitive(input, ToPrimitiveHint::kString)); | |
877 } | |
878 | |
879 | |
880 RUNTIME_FUNCTION(Runtime_ToNumber) { | 856 RUNTIME_FUNCTION(Runtime_ToNumber) { |
881 HandleScope scope(isolate); | 857 HandleScope scope(isolate); |
882 DCHECK_EQ(1, args.length()); | 858 DCHECK_EQ(1, args.length()); |
883 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 859 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
884 RETURN_RESULT_OR_FAILURE(isolate, Object::ToNumber(input)); | 860 RETURN_RESULT_OR_FAILURE(isolate, Object::ToNumber(input)); |
885 } | 861 } |
886 | 862 |
887 | 863 |
888 RUNTIME_FUNCTION(Runtime_ToInteger) { | 864 RUNTIME_FUNCTION(Runtime_ToInteger) { |
889 HandleScope scope(isolate); | 865 HandleScope scope(isolate); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 isolate, o, key, &success, LookupIterator::OWN); | 981 isolate, o, key, &success, LookupIterator::OWN); |
1006 if (!success) return isolate->heap()->exception(); | 982 if (!success) return isolate->heap()->exception(); |
1007 MAYBE_RETURN( | 983 MAYBE_RETURN( |
1008 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 984 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
1009 isolate->heap()->exception()); | 985 isolate->heap()->exception()); |
1010 return *value; | 986 return *value; |
1011 } | 987 } |
1012 | 988 |
1013 } // namespace internal | 989 } // namespace internal |
1014 } // namespace v8 | 990 } // namespace v8 |
OLD | NEW |