Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: src/v8natives.js

Issue 141913002: ES6: Implement Object.setPrototypeOf (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 1008
1009 1009
1010 // ES5 section 15.2.3.2. 1010 // ES5 section 15.2.3.2.
1011 function ObjectGetPrototypeOf(obj) { 1011 function ObjectGetPrototypeOf(obj) {
1012 if (!IS_SPEC_OBJECT(obj)) { 1012 if (!IS_SPEC_OBJECT(obj)) {
1013 throw MakeTypeError("called_on_non_object", ["Object.getPrototypeOf"]); 1013 throw MakeTypeError("called_on_non_object", ["Object.getPrototypeOf"]);
1014 } 1014 }
1015 return %GetPrototype(obj); 1015 return %GetPrototype(obj);
1016 } 1016 }
1017 1017
1018 // ES6 section 19.1.2.19.
1019 function ObjectSetPrototypeOf(obj, proto) {
1020 if (IS_NULL_OR_UNDEFINED(obj) && !IS_UNDETECTABLE(obj)) {
arv (Not doing code reviews) 2014/01/17 17:43:23 The ES6 spec uses CheckObjectCoercible. It comes u
Dmitry Lomov (no reviews) 2014/01/17 20:17:36 Agreed, good idea.
1021 throw MakeTypeError("called_on_null_or_undefined",
1022 ["Object.setPrototypeOf"]);
1023 }
1024
1025 if (proto !== null && !IS_SPEC_OBJECT(proto)) {
1026 throw MakeTypeError("proto_object_or_null", [proto]);
1027 }
1028
1029 if (IS_SPEC_OBJECT(obj)) {
1030 %SetPrototype(obj, proto);
1031 }
1032
1033 return obj;
1034 }
1035
1018 1036
1019 // ES5 section 15.2.3.3 1037 // ES5 section 15.2.3.3
1020 function ObjectGetOwnPropertyDescriptor(obj, p) { 1038 function ObjectGetOwnPropertyDescriptor(obj, p) {
1021 if (!IS_SPEC_OBJECT(obj)) { 1039 if (!IS_SPEC_OBJECT(obj)) {
1022 throw MakeTypeError("called_on_non_object", 1040 throw MakeTypeError("called_on_non_object",
1023 ["Object.getOwnPropertyDescriptor"]); 1041 ["Object.getOwnPropertyDescriptor"]);
1024 } 1042 }
1025 var desc = GetOwnProperty(obj, p); 1043 var desc = GetOwnProperty(obj, p);
1026 return FromPropertyDescriptor(desc); 1044 return FromPropertyDescriptor(desc);
1027 } 1045 }
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 ObjectGetProto, ObjectSetProto); 1454 ObjectGetProto, ObjectSetProto);
1437 1455
1438 // Set up non-enumerable functions in the Object object. 1456 // Set up non-enumerable functions in the Object object.
1439 InstallFunctions($Object, DONT_ENUM, $Array( 1457 InstallFunctions($Object, DONT_ENUM, $Array(
1440 "keys", ObjectKeys, 1458 "keys", ObjectKeys,
1441 "create", ObjectCreate, 1459 "create", ObjectCreate,
1442 "defineProperty", ObjectDefineProperty, 1460 "defineProperty", ObjectDefineProperty,
1443 "defineProperties", ObjectDefineProperties, 1461 "defineProperties", ObjectDefineProperties,
1444 "freeze", ObjectFreeze, 1462 "freeze", ObjectFreeze,
1445 "getPrototypeOf", ObjectGetPrototypeOf, 1463 "getPrototypeOf", ObjectGetPrototypeOf,
1464 "setPrototypeOf", ObjectSetPrototypeOf,
1446 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, 1465 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
1447 "getOwnPropertyNames", ObjectGetOwnPropertyNames, 1466 "getOwnPropertyNames", ObjectGetOwnPropertyNames,
1448 // getOwnPropertySymbols is added in symbol.js. 1467 // getOwnPropertySymbols is added in symbol.js.
1449 "is", ObjectIs, 1468 "is", ObjectIs,
1450 "isExtensible", ObjectIsExtensible, 1469 "isExtensible", ObjectIsExtensible,
1451 "isFrozen", ObjectIsFrozen, 1470 "isFrozen", ObjectIsFrozen,
1452 "isSealed", ObjectIsSealed, 1471 "isSealed", ObjectIsSealed,
1453 "preventExtensions", ObjectPreventExtension, 1472 "preventExtensions", ObjectPreventExtension,
1454 "seal", ObjectSeal 1473 "seal", ObjectSeal
1455 // deliverChangeRecords, getNotifier, observe and unobserve are added 1474 // deliverChangeRecords, getNotifier, observe and unobserve are added
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 // Eventually, we should move to a real event queue that allows to maintain 1907 // Eventually, we should move to a real event queue that allows to maintain
1889 // relative ordering of different kinds of tasks. 1908 // relative ordering of different kinds of tasks.
1890 1909
1891 RunMicrotasks.runners = new InternalArray; 1910 RunMicrotasks.runners = new InternalArray;
1892 1911
1893 function RunMicrotasks() { 1912 function RunMicrotasks() {
1894 while (%SetMicrotaskPending(false)) { 1913 while (%SetMicrotaskPending(false)) {
1895 for (var i in RunMicrotasks.runners) RunMicrotasks.runners[i](); 1914 for (var i in RunMicrotasks.runners) RunMicrotasks.runners[i]();
1896 } 1915 }
1897 } 1916 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698