Changeset 46963 in webkit
- Timestamp:
- Aug 9, 2009 3:33:57 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r46933 r46963 1 2009-08-08 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Eric Seidel and Sam Weinig. 4 5 [ES5] Implement Object.getPrototypeOf 6 https://bugs.webkit.org/show_bug.cgi?id=28114 7 8 Implement getPrototypeOf 9 10 * runtime/CommonIdentifiers.h: 11 * runtime/JSGlobalObject.cpp: 12 (JSC::JSGlobalObject::reset): 13 * runtime/ObjectConstructor.cpp: 14 (JSC::ObjectConstructor::ObjectConstructor): 15 (JSC::objectConsGetPrototypeOf): 16 * runtime/ObjectConstructor.h: 17 1 18 2009-08-07 Zoltan Horvath <hzoltan@inf.u-szeged.hu> 2 19 -
trunk/JavaScriptCore/runtime/CommonIdentifiers.h
r45891 r46963 43 43 macro(fromCharCode) \ 44 44 macro(global) \ 45 macro(getPrototypeOf) \ 45 46 macro(hasOwnProperty) \ 46 47 macro(ignoreCase) \ -
trunk/JavaScriptCore/runtime/JSGlobalObject.cpp
r44550 r46963 257 257 // Constructors 258 258 259 JSCell* objectConstructor = new (exec) ObjectConstructor(exec, ObjectConstructor::createStructure(d()->functionPrototype), d()->objectPrototype );259 JSCell* objectConstructor = new (exec) ObjectConstructor(exec, ObjectConstructor::createStructure(d()->functionPrototype), d()->objectPrototype, d()->prototypeFunctionStructure.get()); 260 260 JSCell* functionConstructor = new (exec) FunctionConstructor(exec, FunctionConstructor::createStructure(d()->functionPrototype), d()->functionPrototype); 261 261 JSCell* arrayConstructor = new (exec) ArrayConstructor(exec, ArrayConstructor::createStructure(d()->functionPrototype), d()->arrayPrototype); -
trunk/JavaScriptCore/runtime/ObjectConstructor.cpp
r43372 r46963 30 30 ASSERT_CLASS_FITS_IN_CELL(ObjectConstructor); 31 31 32 ObjectConstructor::ObjectConstructor(ExecState* exec, PassRefPtr<Structure> structure, ObjectPrototype* objectPrototype) 32 static JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState*, JSObject*, JSValue, const ArgList&); 33 34 ObjectConstructor::ObjectConstructor(ExecState* exec, PassRefPtr<Structure> structure, ObjectPrototype* objectPrototype, Structure* prototypeFunctionStructure) 33 35 : InternalFunction(&exec->globalData(), structure, Identifier(exec, "Object")) 34 36 { … … 38 40 // no. of arguments for constructor 39 41 putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete); 42 43 putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().getPrototypeOf, objectConstructorGetPrototypeOf), DontEnum); 40 44 } 41 45 … … 71 75 } 72 76 77 JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState* exec, JSObject*, JSValue, const ArgList& args) 78 { 79 if (!args.at(0).isObject()) 80 return throwError(exec, TypeError, "Requested prototype of a value that is not an object."); 81 return asObject(args.at(0))->prototype(); 82 } 83 73 84 } // namespace JSC -
trunk/JavaScriptCore/runtime/ObjectConstructor.h
r38440 r46963 30 30 class ObjectConstructor : public InternalFunction { 31 31 public: 32 ObjectConstructor(ExecState*, PassRefPtr<Structure>, ObjectPrototype* );32 ObjectConstructor(ExecState*, PassRefPtr<Structure>, ObjectPrototype*, Structure* prototypeFunctionStructure); 33 33 34 34 private: -
trunk/LayoutTests/ChangeLog
r46960 r46963 1 2009-08-08 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Eric Seidel and Sam Weinig. 4 5 [ES5] Implement Object.getPrototypeOf 6 https://bugs.webkit.org/show_bug.cgi?id=28114 7 8 Add tests for getPrototypeOf 9 10 * fast/js/prototypes-expected.txt: 11 * fast/js/resources/prototypes.js: 12 1 13 2009-08-08 Jan Michael Alonzo <jmalonzo@webkit.org> 2 14 -
trunk/LayoutTests/fast/js/prototypes-expected.txt
r43506 r46963 1 Test protot oypes of various objects.1 Test prototypes of various objects and the various means to access them. 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". … … 21 21 PASS Number.__proto__ is Object.__proto__ 22 22 PASS String.__proto__ is Object.__proto__ 23 PASS Object.getPrototypeOf('') threw exception TypeError: Requested prototype of a value that is not an object.. 24 PASS Object.getPrototypeOf(0) threw exception TypeError: Requested prototype of a value that is not an object.. 25 PASS Object.getPrototypeOf([]) is Array.prototype 26 PASS Object.getPrototypeOf({}) is Object.prototype 27 PASS Object.getPrototypeOf(new Date) is Date.prototype 28 PASS Object.getPrototypeOf(new Number) is Number.prototype 29 PASS Object.getPrototypeOf(new Object) is Object.prototype 30 PASS Object.getPrototypeOf(new String) is String.prototype 31 PASS Object.getPrototypeOf(Array.prototype) is Object.prototype 32 PASS Object.getPrototypeOf(Date.prototype) is Object.prototype 33 PASS Object.getPrototypeOf(Number.prototype) is Object.prototype 34 PASS Object.getPrototypeOf(Object.prototype) is null 35 PASS Object.getPrototypeOf(String.prototype) is Object.prototype 36 PASS Object.getPrototypeOf(Array) is Object.__proto__ 37 PASS Object.getPrototypeOf(Date) is Object.__proto__ 38 PASS Object.getPrototypeOf(Number) is Object.__proto__ 39 PASS Object.getPrototypeOf(String) is Object.__proto__ 40 PASS String.prototype.isPrototypeOf('') is false 41 PASS Number.prototype.isPrototypeOf(0) is false 42 PASS Array.prototype.isPrototypeOf([]) is true 43 PASS Object.prototype.isPrototypeOf({}) is true 44 PASS Date.prototype.isPrototypeOf(new Date) is true 45 PASS Number.prototype.isPrototypeOf(new Number) is true 46 PASS Object.prototype.isPrototypeOf(new Object) is true 47 PASS String.prototype.isPrototypeOf(new String) is true 48 PASS Object.prototype.isPrototypeOf(Array.prototype) is true 49 PASS Object.prototype.isPrototypeOf(Date.prototype) is true 50 PASS Object.prototype.isPrototypeOf(Number.prototype) is true 51 PASS Object.prototype.isPrototypeOf(String.prototype) is true 52 PASS Object.__proto__.isPrototypeOf(Array) is true 53 PASS Object.__proto__.isPrototypeOf(Date) is true 54 PASS Object.__proto__.isPrototypeOf(Number) is true 55 PASS Object.__proto__.isPrototypeOf(String) is true 23 56 PASS successfullyParsed is true 24 57 -
trunk/LayoutTests/fast/js/resources/prototypes.js
r43506 r46963 1 1 description( 2 'Test protot oypes of various objects.'2 'Test prototypes of various objects and the various means to access them.' 3 3 ); 4 4 … … 21 21 shouldBe("String.__proto__", "Object.__proto__"); 22 22 23 shouldThrow("Object.getPrototypeOf('')"); 24 shouldThrow("Object.getPrototypeOf(0)"); 25 shouldBe("Object.getPrototypeOf([])", "Array.prototype"); 26 shouldBe("Object.getPrototypeOf({})", "Object.prototype"); 27 shouldBe("Object.getPrototypeOf(new Date)", "Date.prototype"); 28 shouldBe("Object.getPrototypeOf(new Number)", "Number.prototype"); 29 shouldBe("Object.getPrototypeOf(new Object)", "Object.prototype"); 30 shouldBe("Object.getPrototypeOf(new String)", "String.prototype"); 31 shouldBe("Object.getPrototypeOf(Array.prototype)", "Object.prototype"); 32 shouldBe("Object.getPrototypeOf(Date.prototype)", "Object.prototype"); 33 shouldBe("Object.getPrototypeOf(Number.prototype)", "Object.prototype"); 34 shouldBe("Object.getPrototypeOf(Object.prototype)", "null"); 35 shouldBe("Object.getPrototypeOf(String.prototype)", "Object.prototype"); 36 shouldBe("Object.getPrototypeOf(Array)", "Object.__proto__"); 37 shouldBe("Object.getPrototypeOf(Date)", "Object.__proto__"); 38 shouldBe("Object.getPrototypeOf(Number)", "Object.__proto__"); 39 shouldBe("Object.getPrototypeOf(String)", "Object.__proto__"); 40 41 shouldBeFalse("String.prototype.isPrototypeOf('')"); 42 shouldBeFalse("Number.prototype.isPrototypeOf(0)"); 43 shouldBeTrue("Array.prototype.isPrototypeOf([])"); 44 shouldBeTrue("Object.prototype.isPrototypeOf({})"); 45 shouldBeTrue("Date.prototype.isPrototypeOf(new Date)"); 46 shouldBeTrue("Number.prototype.isPrototypeOf(new Number)"); 47 shouldBeTrue("Object.prototype.isPrototypeOf(new Object)"); 48 shouldBeTrue("String.prototype.isPrototypeOf(new String)"); 49 shouldBeTrue("Object.prototype.isPrototypeOf(Array.prototype)"); 50 shouldBeTrue("Object.prototype.isPrototypeOf(Date.prototype)"); 51 shouldBeTrue("Object.prototype.isPrototypeOf(Number.prototype)"); 52 shouldBeTrue("Object.prototype.isPrototypeOf(String.prototype)"); 53 shouldBeTrue("Object.__proto__.isPrototypeOf(Array)"); 54 shouldBeTrue("Object.__proto__.isPrototypeOf(Date)"); 55 shouldBeTrue("Object.__proto__.isPrototypeOf(Number)"); 56 shouldBeTrue("Object.__proto__.isPrototypeOf(String)"); 57 23 58 var successfullyParsed = true;
Note: See TracChangeset
for help on using the changeset viewer.