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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 static MaybeHandle<Object> DefineClass(Isolate* isolate, | 84 static MaybeHandle<Object> DefineClass(Isolate* isolate, |
85 Handle<Object> super_class, | 85 Handle<Object> super_class, |
86 Handle<JSFunction> constructor, | 86 Handle<JSFunction> constructor, |
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(isolate)) { | 91 if (super_class->IsTheHole(isolate)) { |
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(isolate)) { |
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 DCHECK(!super_class->IsJSFunction() || | 97 DCHECK(!super_class->IsJSFunction() || |
98 !Handle<JSFunction>::cast(super_class)->shared()->is_resumable()); | 98 !Handle<JSFunction>::cast(super_class)->shared()->is_resumable()); |
99 ASSIGN_RETURN_ON_EXCEPTION( | 99 ASSIGN_RETURN_ON_EXCEPTION( |
100 isolate, prototype_parent, | 100 isolate, prototype_parent, |
101 Runtime::GetObjectProperty(isolate, super_class, | 101 Runtime::GetObjectProperty(isolate, super_class, |
102 isolate->factory()->prototype_string()), | 102 isolate->factory()->prototype_string()), |
103 Object); | 103 Object); |
104 if (!prototype_parent->IsNull() && !prototype_parent->IsJSReceiver()) { | 104 if (!prototype_parent->IsNull(isolate) && |
| 105 !prototype_parent->IsJSReceiver()) { |
105 THROW_NEW_ERROR( | 106 THROW_NEW_ERROR( |
106 isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject, | 107 isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject, |
107 prototype_parent), | 108 prototype_parent), |
108 Object); | 109 Object); |
109 } | 110 } |
110 constructor_parent = super_class; | 111 constructor_parent = super_class; |
111 } else { | 112 } else { |
112 THROW_NEW_ERROR(isolate, | 113 THROW_NEW_ERROR(isolate, |
113 NewTypeError(MessageTemplate::kExtendsValueNotConstructor, | 114 NewTypeError(MessageTemplate::kExtendsValueNotConstructor, |
114 super_class), | 115 super_class), |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 390 |
390 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { | 391 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { |
391 SealHandleScope shs(isolate); | 392 SealHandleScope shs(isolate); |
392 DCHECK_EQ(1, args.length()); | 393 DCHECK_EQ(1, args.length()); |
393 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); | 394 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); |
394 return active_function->map()->prototype(); | 395 return active_function->map()->prototype(); |
395 } | 396 } |
396 | 397 |
397 } // namespace internal | 398 } // namespace internal |
398 } // namespace v8 | 399 } // namespace v8 |
OLD | NEW |