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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 Handle<Object> key, | 132 Handle<Object> key, |
133 LanguageMode language_mode) { | 133 LanguageMode language_mode) { |
134 bool success = false; | 134 bool success = false; |
135 LookupIterator it = LookupIterator::PropertyOrElement( | 135 LookupIterator it = LookupIterator::PropertyOrElement( |
136 isolate, receiver, key, &success, LookupIterator::OWN); | 136 isolate, receiver, key, &success, LookupIterator::OWN); |
137 if (!success) return Nothing<bool>(); | 137 if (!success) return Nothing<bool>(); |
138 | 138 |
139 return JSReceiver::DeleteProperty(&it, language_mode); | 139 return JSReceiver::DeleteProperty(&it, language_mode); |
140 } | 140 } |
141 | 141 |
| 142 // ES #sec-object.keys |
| 143 RUNTIME_FUNCTION(Runtime_ObjectKeys) { |
| 144 HandleScope scope(isolate); |
| 145 Handle<Object> object = args.at(0); |
| 146 |
| 147 // Convert the {object} to a proper {receiver}. |
| 148 Handle<JSReceiver> receiver; |
| 149 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
| 150 Object::ToObject(isolate, object)); |
| 151 |
| 152 // Collect the own keys for the {receiver}. |
| 153 Handle<FixedArray> keys; |
| 154 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 155 isolate, keys, |
| 156 KeyAccumulator::GetKeys(receiver, KeyCollectionMode::kOwnOnly, |
| 157 ENUMERABLE_STRINGS, |
| 158 GetKeysConversion::kConvertToString)); |
| 159 return *keys; |
| 160 } |
| 161 |
142 // ES6 19.1.3.2 | 162 // ES6 19.1.3.2 |
143 RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) { | 163 RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) { |
144 HandleScope scope(isolate); | 164 HandleScope scope(isolate); |
145 Handle<Object> property = args.at(1); | 165 Handle<Object> property = args.at(1); |
146 | 166 |
147 Handle<Name> key; | 167 Handle<Name> key; |
148 uint32_t index; | 168 uint32_t index; |
149 bool key_is_array_index = property->ToArrayIndex(&index); | 169 bool key_is_array_index = property->ToArrayIndex(&index); |
150 | 170 |
151 if (!key_is_array_index) { | 171 if (!key_is_array_index) { |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 // While iteration alone may not have observable side-effects, calling | 1057 // While iteration alone may not have observable side-effects, calling |
1038 // toNumber on an object will. Make sure the arg is not an array of objects. | 1058 // toNumber on an object will. Make sure the arg is not an array of objects. |
1039 ElementsKind kind = JSObject::cast(*obj)->GetElementsKind(); | 1059 ElementsKind kind = JSObject::cast(*obj)->GetElementsKind(); |
1040 if (!IsFastNumberElementsKind(kind)) return isolate->heap()->ToBoolean(false); | 1060 if (!IsFastNumberElementsKind(kind)) return isolate->heap()->ToBoolean(false); |
1041 | 1061 |
1042 return isolate->heap()->ToBoolean(!obj->IterationHasObservableEffects()); | 1062 return isolate->heap()->ToBoolean(!obj->IterationHasObservableEffects()); |
1043 } | 1063 } |
1044 | 1064 |
1045 } // namespace internal | 1065 } // namespace internal |
1046 } // namespace v8 | 1066 } // namespace v8 |
OLD | NEW |