| 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 <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 int start_position, int end_position) { | 87 int start_position, int end_position) { |
| 88 Handle<Object> prototype_parent; | 88 Handle<Object> prototype_parent; |
| 89 Handle<Object> constructor_parent; | 89 Handle<Object> constructor_parent; |
| 90 | 90 |
| 91 if (super_class->IsTheHole()) { | 91 if (super_class->IsTheHole()) { |
| 92 prototype_parent = isolate->initial_object_prototype(); | 92 prototype_parent = isolate->initial_object_prototype(); |
| 93 } else { | 93 } else { |
| 94 if (super_class->IsNull()) { | 94 if (super_class->IsNull()) { |
| 95 prototype_parent = isolate->factory()->null_value(); | 95 prototype_parent = isolate->factory()->null_value(); |
| 96 } else if (super_class->IsConstructor()) { | 96 } else if (super_class->IsConstructor()) { |
| 97 if (super_class->IsJSFunction() && | 97 DCHECK(!super_class->IsJSFunction() || |
| 98 Handle<JSFunction>::cast(super_class)->shared()->is_generator()) { | 98 !Handle<JSFunction>::cast(super_class)->shared()->is_resumable()); |
| 99 THROW_NEW_ERROR( | |
| 100 isolate, | |
| 101 NewTypeError(MessageTemplate::kExtendsValueGenerator, super_class), | |
| 102 Object); | |
| 103 } | |
| 104 ASSIGN_RETURN_ON_EXCEPTION( | 99 ASSIGN_RETURN_ON_EXCEPTION( |
| 105 isolate, prototype_parent, | 100 isolate, prototype_parent, |
| 106 Runtime::GetObjectProperty(isolate, super_class, | 101 Runtime::GetObjectProperty(isolate, super_class, |
| 107 isolate->factory()->prototype_string()), | 102 isolate->factory()->prototype_string()), |
| 108 Object); | 103 Object); |
| 109 if (!prototype_parent->IsNull() && !prototype_parent->IsJSReceiver()) { | 104 if (!prototype_parent->IsNull() && !prototype_parent->IsJSReceiver()) { |
| 110 THROW_NEW_ERROR( | 105 THROW_NEW_ERROR( |
| 111 isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject, | 106 isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject, |
| 112 prototype_parent), | 107 prototype_parent), |
| 113 Object); | 108 Object); |
| 114 } | 109 } |
| 115 constructor_parent = super_class; | 110 constructor_parent = super_class; |
| 116 } else { | 111 } else { |
| 117 THROW_NEW_ERROR( | 112 THROW_NEW_ERROR(isolate, |
| 118 isolate, | 113 NewTypeError(MessageTemplate::kExtendsValueNotConstructor, |
| 119 NewTypeError(MessageTemplate::kExtendsValueNotFunction, super_class), | 114 super_class), |
| 120 Object); | 115 Object); |
| 121 } | 116 } |
| 122 } | 117 } |
| 123 | 118 |
| 124 Handle<Map> map = | 119 Handle<Map> map = |
| 125 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 120 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 126 map->set_is_prototype_map(true); | 121 map->set_is_prototype_map(true); |
| 127 Map::SetPrototype(map, prototype_parent); | 122 Map::SetPrototype(map, prototype_parent); |
| 128 map->SetConstructor(*constructor); | 123 map->SetConstructor(*constructor); |
| 129 Handle<JSObject> prototype = isolate->factory()->NewJSObjectFromMap(map); | 124 Handle<JSObject> prototype = isolate->factory()->NewJSObjectFromMap(map); |
| 130 | 125 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 | 389 |
| 395 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { | 390 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { |
| 396 SealHandleScope shs(isolate); | 391 SealHandleScope shs(isolate); |
| 397 DCHECK_EQ(1, args.length()); | 392 DCHECK_EQ(1, args.length()); |
| 398 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); | 393 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); |
| 399 return active_function->map()->prototype(); | 394 return active_function->map()->prototype(); |
| 400 } | 395 } |
| 401 | 396 |
| 402 } // namespace internal | 397 } // namespace internal |
| 403 } // namespace v8 | 398 } // namespace v8 |
| OLD | NEW |