Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index a69ab75ebdffaff2e3ee76339b7a4ed38fe7bdad..c2f84e8749d1f724dc394a0179160dc1b72abb4f 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -1605,6 +1605,55 @@ bool Object::SameValueZero(Object* other) { |
| } |
| +MaybeHandle<Object> Object::ArraySpeciesConstructor( |
| + Isolate* isolate, Handle<Object> original_array) { |
| + Handle<Context> native_context = isolate->native_context(); |
| + if (!FLAG_harmony_species) { |
| + return Handle<Object>(native_context->array_function(), isolate); |
| + } |
| + Handle<Object> constructor = isolate->factory()->undefined_value(); |
| + Maybe<bool> is_array = Object::IsArray(original_array); |
| + MAYBE_RETURN_NULL(is_array); |
| + if (is_array.FromJust()) { |
| + ASSIGN_RETURN_ON_EXCEPTION( |
| + isolate, constructor, |
| + Object::GetProperty(original_array, |
| + isolate->factory()->constructor_string()), |
| + Object); |
| + if (constructor->IsConstructor()) { |
| + Handle<Context> constructor_context; |
| + ASSIGN_RETURN_ON_EXCEPTION( |
| + isolate, constructor_context, |
| + JSReceiver::GetFunctionRealm(Handle<JSReceiver>::cast(constructor)), |
|
adamk
2016/01/07 01:11:04
Did this need changing to make proxies work? Can y
Dan Ehrenberg
2016/01/07 01:35:17
Yeah, you caught me. I couldn't think of a great t
adamk
2016/01/07 01:38:30
Not crashing is sufficient to allay my fears.
|
| + Object); |
| + if (*constructor_context != *native_context && |
| + *constructor == constructor_context->array_function()) { |
| + constructor = isolate->factory()->undefined_value(); |
| + } |
| + } |
| + if (constructor->IsJSReceiver()) { |
| + ASSIGN_RETURN_ON_EXCEPTION( |
| + isolate, constructor, |
| + Object::GetProperty(constructor, |
| + isolate->factory()->species_symbol()), |
| + Object); |
| + if (constructor->IsNull()) { |
| + constructor = isolate->factory()->undefined_value(); |
| + } |
| + } |
| + } |
| + if (constructor->IsUndefined()) { |
| + return Handle<Object>(native_context->array_function(), isolate); |
| + } else { |
| + if (!constructor->IsConstructor()) { |
| + return isolate->Throw<Object>(isolate->factory()->NewTypeError( |
|
adamk
2016/01/07 01:11:04
Looks like there's a macro for this:
THROW_NEW_ER
Dan Ehrenberg
2016/01/07 01:35:17
OK, sure.
adamk
2016/01/07 01:38:30
Sorry, it's the week of macros!
|
| + MessageTemplate::kSpeciesNotConstructor)); |
| + } |
| + return constructor; |
| + } |
| +} |
| + |
| + |
| void Object::ShortPrint(FILE* out) { |
| OFStream os(out); |
| os << Brief(this); |