Chromium Code Reviews| 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/accessors.h" | 10 #include "src/accessors.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 | 160 |
| 161 JSFunction::SetPrototype(constructor, prototype); | 161 JSFunction::SetPrototype(constructor, prototype); |
| 162 PropertyAttributes attribs = | 162 PropertyAttributes attribs = |
| 163 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 163 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 164 RETURN_ON_EXCEPTION(isolate, | 164 RETURN_ON_EXCEPTION(isolate, |
| 165 JSObject::SetOwnPropertyIgnoreAttributes( | 165 JSObject::SetOwnPropertyIgnoreAttributes( |
| 166 constructor, isolate->factory()->prototype_string(), | 166 constructor, isolate->factory()->prototype_string(), |
| 167 prototype, attribs), | 167 prototype, attribs), |
| 168 Object); | 168 Object); |
| 169 | 169 |
| 170 // TODO(arv): Only do this conditionally. | |
|
arv (Not doing code reviews)
2017/01/05 05:18:43
Thanks
| |
| 171 Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol()); | |
| 172 RETURN_ON_EXCEPTION( | |
| 173 isolate, JSObject::SetOwnPropertyIgnoreAttributes( | |
| 174 constructor, home_object_symbol, prototype, DONT_ENUM), | |
| 175 Object); | |
| 176 | |
| 177 if (!constructor_parent.is_null()) { | 170 if (!constructor_parent.is_null()) { |
| 178 MAYBE_RETURN_NULL(JSObject::SetPrototype(constructor, constructor_parent, | 171 MAYBE_RETURN_NULL(JSObject::SetPrototype(constructor, constructor_parent, |
| 179 false, Object::THROW_ON_ERROR)); | 172 false, Object::THROW_ON_ERROR)); |
| 180 } | 173 } |
| 181 | 174 |
| 182 JSObject::AddProperty(prototype, isolate->factory()->constructor_string(), | 175 JSObject::AddProperty(prototype, isolate->factory()->constructor_string(), |
| 183 constructor, DONT_ENUM); | 176 constructor, DONT_ENUM); |
| 184 | 177 |
| 185 // Install private properties that are used to construct the FunctionToString. | 178 // Install private properties that are used to construct the FunctionToString. |
| 186 RETURN_ON_EXCEPTION( | 179 RETURN_ON_EXCEPTION( |
| 187 isolate, | 180 isolate, |
| 188 Object::SetProperty( | 181 Object::SetProperty( |
| 189 constructor, isolate->factory()->class_start_position_symbol(), | 182 constructor, isolate->factory()->class_start_position_symbol(), |
| 190 handle(Smi::FromInt(start_position), isolate), STRICT), | 183 handle(Smi::FromInt(start_position), isolate), STRICT), |
| 191 Object); | 184 Object); |
| 192 RETURN_ON_EXCEPTION( | 185 RETURN_ON_EXCEPTION( |
| 193 isolate, Object::SetProperty( | 186 isolate, Object::SetProperty( |
| 194 constructor, isolate->factory()->class_end_position_symbol(), | 187 constructor, isolate->factory()->class_end_position_symbol(), |
| 195 handle(Smi::FromInt(end_position), isolate), STRICT), | 188 handle(Smi::FromInt(end_position), isolate), STRICT), |
| 196 Object); | 189 Object); |
| 197 | 190 |
| 198 return constructor; | 191 // Caller already has access to constructor, so return the prototype. |
| 192 return prototype; | |
| 199 } | 193 } |
| 200 | 194 |
| 201 | 195 |
| 202 RUNTIME_FUNCTION(Runtime_DefineClass) { | 196 RUNTIME_FUNCTION(Runtime_DefineClass) { |
| 203 HandleScope scope(isolate); | 197 HandleScope scope(isolate); |
| 204 DCHECK(args.length() == 4); | 198 DCHECK(args.length() == 4); |
| 205 CONVERT_ARG_HANDLE_CHECKED(Object, super_class, 0); | 199 CONVERT_ARG_HANDLE_CHECKED(Object, super_class, 0); |
| 206 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 1); | 200 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 1); |
| 207 CONVERT_SMI_ARG_CHECKED(start_position, 2); | 201 CONVERT_SMI_ARG_CHECKED(start_position, 2); |
| 208 CONVERT_SMI_ARG_CHECKED(end_position, 3); | 202 CONVERT_SMI_ARG_CHECKED(end_position, 3); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 510 } | 504 } |
| 511 | 505 |
| 512 // Call the constructor. | 506 // Call the constructor. |
| 513 RETURN_RESULT_OR_FAILURE( | 507 RETURN_RESULT_OR_FAILURE( |
| 514 isolate, Execution::New(isolate, constructor, new_target, result_length, | 508 isolate, Execution::New(isolate, constructor, new_target, result_length, |
| 515 construct_args.start())); | 509 construct_args.start())); |
| 516 } | 510 } |
| 517 | 511 |
| 518 } // namespace internal | 512 } // namespace internal |
| 519 } // namespace v8 | 513 } // namespace v8 |
| OLD | NEW |