| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 <stdlib.h> | 5 #include <stdlib.h> | 
| 6 #include <limits> | 6 #include <limits> | 
| 7 | 7 | 
| 8 #include "src/v8.h" | 8 #include "src/v8.h" | 
| 9 | 9 | 
| 10 #include "src/accessors.h" | 10 #include "src/accessors.h" | 
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 354   DCHECK(args.length() == 4); | 354   DCHECK(args.length() == 4); | 
| 355   CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 355   CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 
| 356   CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 356   CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 
| 357   CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 357   CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 
| 358   CONVERT_ARG_HANDLE_CHECKED(Name, name, 3); | 358   CONVERT_ARG_HANDLE_CHECKED(Name, name, 3); | 
| 359 | 359 | 
| 360   return StoreToSuper(isolate, home_object, receiver, name, value, SLOPPY); | 360   return StoreToSuper(isolate, home_object, receiver, name, value, SLOPPY); | 
| 361 } | 361 } | 
| 362 | 362 | 
| 363 | 363 | 
|  | 364 RUNTIME_FUNCTION(Runtime_DefineClass) { | 
|  | 365   HandleScope scope(isolate); | 
|  | 366   DCHECK(args.length() == 3); | 
|  | 367   CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 
|  | 368   CONVERT_ARG_HANDLE_CHECKED(Object, super_class, 1); | 
|  | 369   CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 2); | 
|  | 370 | 
|  | 371   Handle<Object> prototype_parent; | 
|  | 372   Handle<Object> constructor_parent; | 
|  | 373   bool has_constructor_parent = false; | 
|  | 374 | 
|  | 375   if (super_class->IsTheHole()) { | 
|  | 376     prototype_parent = isolate->initial_object_prototype(); | 
|  | 377   } else { | 
|  | 378     if (super_class->IsNull()) { | 
|  | 379       prototype_parent = isolate->factory()->null_value(); | 
|  | 380     } else if (!super_class->IsSpecFunction()) { | 
|  | 381       // TODO(arv): Should be IsConstructor. | 
|  | 382       Handle<Object> args[1] = {super_class}; | 
|  | 383       THROW_NEW_ERROR_RETURN_FAILURE( | 
|  | 384           isolate, | 
|  | 385           NewTypeError("extends_value_not_a_function", HandleVector(args, 1))); | 
|  | 386     } else { | 
|  | 387       ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 
|  | 388           isolate, prototype_parent, | 
|  | 389           Runtime::GetObjectProperty(isolate, super_class, | 
|  | 390                                      isolate->factory()->prototype_string())); | 
|  | 391       if (!prototype_parent->IsNull() && !prototype_parent->IsSpecObject()) { | 
|  | 392         Handle<Object> args[1] = {prototype_parent}; | 
|  | 393         THROW_NEW_ERROR_RETURN_FAILURE( | 
|  | 394             isolate, NewTypeError("prototype_parent_not_an_object", | 
|  | 395                                   HandleVector(args, 1))); | 
|  | 396       } | 
|  | 397       constructor_parent = super_class; | 
|  | 398       has_constructor_parent = true; | 
|  | 399     } | 
|  | 400   } | 
|  | 401 | 
|  | 402   Handle<JSObject> prototype = | 
|  | 403       isolate->factory()->NewJSObject(isolate->object_function()); | 
|  | 404   JSObject::SetPrototype(prototype, prototype_parent, false).Assert(); | 
|  | 405 | 
|  | 406   Handle<String> name_string = name->IsString() | 
|  | 407                                    ? Handle<String>::cast(name) | 
|  | 408                                    : isolate->factory()->empty_string(); | 
|  | 409 | 
|  | 410   Handle<JSFunction> ctor; | 
|  | 411   if (constructor->IsUndefined()) { | 
|  | 412     // TODO(arv): This should not use an empty function but a function that | 
|  | 413     // calls super. | 
|  | 414     Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); | 
|  | 415     ctor = isolate->factory()->NewFunction(name_string, code, prototype, true); | 
|  | 416   } else { | 
|  | 417     ctor = Handle<JSFunction>::cast(constructor); | 
|  | 418     JSFunction::SetPrototype(ctor, prototype); | 
|  | 419     PropertyAttributes attribs = | 
|  | 420         static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 
|  | 421     JSObject::SetOwnPropertyIgnoreAttributes( | 
|  | 422         ctor, isolate->factory()->prototype_string(), prototype, attribs) | 
|  | 423         .Assert(); | 
|  | 424   } | 
|  | 425 | 
|  | 426   Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol()); | 
|  | 427   JSObject::SetOwnPropertyIgnoreAttributes(ctor, home_object_symbol, prototype, | 
|  | 428                                            DONT_ENUM).Assert(); | 
|  | 429 | 
|  | 430   if (has_constructor_parent) { | 
|  | 431     JSObject::SetPrototype(ctor, constructor_parent, false).Assert(); | 
|  | 432   } | 
|  | 433 | 
|  | 434   JSObject::AddProperty(prototype, isolate->factory()->constructor_string(), | 
|  | 435                         ctor, DONT_ENUM); | 
|  | 436 | 
|  | 437   return *ctor; | 
|  | 438 } | 
|  | 439 | 
|  | 440 | 
| 364 RUNTIME_FUNCTION(Runtime_IsExtensible) { | 441 RUNTIME_FUNCTION(Runtime_IsExtensible) { | 
| 365   SealHandleScope shs(isolate); | 442   SealHandleScope shs(isolate); | 
| 366   DCHECK(args.length() == 1); | 443   DCHECK(args.length() == 1); | 
| 367   CONVERT_ARG_CHECKED(JSObject, obj, 0); | 444   CONVERT_ARG_CHECKED(JSObject, obj, 0); | 
| 368   if (obj->IsJSGlobalProxy()) { | 445   if (obj->IsJSGlobalProxy()) { | 
| 369     PrototypeIterator iter(isolate, obj); | 446     PrototypeIterator iter(isolate, obj); | 
| 370     if (iter.IsAtEnd()) return isolate->heap()->false_value(); | 447     if (iter.IsAtEnd()) return isolate->heap()->false_value(); | 
| 371     DCHECK(iter.GetCurrent()->IsJSGlobalObject()); | 448     DCHECK(iter.GetCurrent()->IsJSGlobalObject()); | 
| 372     obj = JSObject::cast(iter.GetCurrent()); | 449     obj = JSObject::cast(iter.GetCurrent()); | 
| 373   } | 450   } | 
| (...skipping 3060 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3434   } | 3511   } | 
| 3435   return NULL; | 3512   return NULL; | 
| 3436 } | 3513 } | 
| 3437 | 3514 | 
| 3438 | 3515 | 
| 3439 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 3516 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 
| 3440   return &(kIntrinsicFunctions[static_cast<int>(id)]); | 3517   return &(kIntrinsicFunctions[static_cast<int>(id)]); | 
| 3441 } | 3518 } | 
| 3442 } | 3519 } | 
| 3443 }  // namespace v8::internal | 3520 }  // namespace v8::internal | 
| OLD | NEW | 
|---|