OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2324 } else { | 2324 } else { |
2325 if (!constructor->IsConstructor()) { | 2325 if (!constructor->IsConstructor()) { |
2326 THROW_NEW_ERROR(isolate, | 2326 THROW_NEW_ERROR(isolate, |
2327 NewTypeError(MessageTemplate::kSpeciesNotConstructor), | 2327 NewTypeError(MessageTemplate::kSpeciesNotConstructor), |
2328 Object); | 2328 Object); |
2329 } | 2329 } |
2330 return constructor; | 2330 return constructor; |
2331 } | 2331 } |
2332 } | 2332 } |
2333 | 2333 |
| 2334 // ES6 section 7.3.20 SpeciesConstructor ( O, defaultConstructor ) |
| 2335 MUST_USE_RESULT MaybeHandle<Object> Object::SpeciesConstructor( |
| 2336 Isolate* isolate, Handle<JSReceiver> recv, |
| 2337 Handle<JSFunction> default_ctor) { |
| 2338 Handle<Object> ctor_obj; |
| 2339 ASSIGN_RETURN_ON_EXCEPTION( |
| 2340 isolate, ctor_obj, |
| 2341 JSObject::GetProperty(recv, isolate->factory()->constructor_string()), |
| 2342 Object); |
| 2343 |
| 2344 if (ctor_obj->IsUndefined(isolate)) return default_ctor; |
| 2345 |
| 2346 if (!ctor_obj->IsJSReceiver()) { |
| 2347 THROW_NEW_ERROR(isolate, |
| 2348 NewTypeError(MessageTemplate::kConstructorNotReceiver), |
| 2349 Object); |
| 2350 } |
| 2351 |
| 2352 Handle<JSReceiver> ctor = Handle<JSReceiver>::cast(ctor_obj); |
| 2353 |
| 2354 Handle<Object> species; |
| 2355 ASSIGN_RETURN_ON_EXCEPTION( |
| 2356 isolate, species, |
| 2357 JSObject::GetProperty(ctor, isolate->factory()->species_symbol()), |
| 2358 Object); |
| 2359 |
| 2360 if (species->IsNullOrUndefined(isolate)) { |
| 2361 return default_ctor; |
| 2362 } |
| 2363 |
| 2364 if (species->IsConstructor()) return species; |
| 2365 |
| 2366 THROW_NEW_ERROR( |
| 2367 isolate, NewTypeError(MessageTemplate::kSpeciesNotConstructor), Object); |
| 2368 } |
| 2369 |
2334 bool Object::IterationHasObservableEffects() { | 2370 bool Object::IterationHasObservableEffects() { |
2335 // Check that this object is an array. | 2371 // Check that this object is an array. |
2336 if (!IsJSArray()) return true; | 2372 if (!IsJSArray()) return true; |
2337 JSArray* spread_array = JSArray::cast(this); | 2373 JSArray* spread_array = JSArray::cast(this); |
2338 Isolate* isolate = spread_array->GetIsolate(); | 2374 Isolate* isolate = spread_array->GetIsolate(); |
2339 | 2375 |
2340 // Check that we have the original ArrayPrototype. | 2376 // Check that we have the original ArrayPrototype. |
2341 JSObject* array_proto = JSObject::cast(spread_array->map()->prototype()); | 2377 JSObject* array_proto = JSObject::cast(spread_array->map()->prototype()); |
2342 if (!isolate->is_initial_array_prototype(array_proto)) return true; | 2378 if (!isolate->is_initial_array_prototype(array_proto)) return true; |
2343 | 2379 |
(...skipping 17877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20221 // depend on this. | 20257 // depend on this. |
20222 return DICTIONARY_ELEMENTS; | 20258 return DICTIONARY_ELEMENTS; |
20223 } | 20259 } |
20224 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20260 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20225 return kind; | 20261 return kind; |
20226 } | 20262 } |
20227 } | 20263 } |
20228 | 20264 |
20229 } // namespace internal | 20265 } // namespace internal |
20230 } // namespace v8 | 20266 } // namespace v8 |
OLD | NEW |