| 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 (function(global, utils) { | 5 (function(global, utils) { |
| 6 | 6 |
| 7 %CheckIsBootstrapping(); | 7 %CheckIsBootstrapping(); |
| 8 | 8 |
| 9 // ---------------------------------------------------------------------------- | 9 // ---------------------------------------------------------------------------- |
| 10 // Imports | 10 // Imports |
| (...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 return %IsExtensible(obj); | 1255 return %IsExtensible(obj); |
| 1256 } | 1256 } |
| 1257 | 1257 |
| 1258 | 1258 |
| 1259 // ECMA-262, Edition 6, section 19.1.2.10 | 1259 // ECMA-262, Edition 6, section 19.1.2.10 |
| 1260 function ObjectIs(obj1, obj2) { | 1260 function ObjectIs(obj1, obj2) { |
| 1261 return $sameValue(obj1, obj2); | 1261 return $sameValue(obj1, obj2); |
| 1262 } | 1262 } |
| 1263 | 1263 |
| 1264 | 1264 |
| 1265 // ECMA-262, Edition 6, section 19.1.2.1 |
| 1266 function ObjectAssign(target, sources) { |
| 1267 // TODO(bmeurer): Move this to toplevel. |
| 1268 "use strict"; |
| 1269 var to = TO_OBJECT(target); |
| 1270 var argsLen = %_ArgumentsLength(); |
| 1271 if (argsLen < 2) return to; |
| 1272 |
| 1273 for (var i = 1; i < argsLen; ++i) { |
| 1274 var nextSource = %_Arguments(i); |
| 1275 if (IS_NULL_OR_UNDEFINED(nextSource)) { |
| 1276 continue; |
| 1277 } |
| 1278 |
| 1279 var from = TO_OBJECT(nextSource); |
| 1280 var keys = OwnPropertyKeys(from); |
| 1281 var len = keys.length; |
| 1282 |
| 1283 for (var j = 0; j < len; ++j) { |
| 1284 var key = keys[j]; |
| 1285 if (%IsPropertyEnumerable(from, key)) { |
| 1286 var propValue = from[key]; |
| 1287 to[key] = propValue; |
| 1288 } |
| 1289 } |
| 1290 } |
| 1291 return to; |
| 1292 } |
| 1293 |
| 1294 |
| 1265 // ECMA-262, Edition 6, section B.2.2.1.1 | 1295 // ECMA-262, Edition 6, section B.2.2.1.1 |
| 1266 function ObjectGetProto() { | 1296 function ObjectGetProto() { |
| 1267 return %_GetPrototype(TO_OBJECT(this)); | 1297 return %_GetPrototype(TO_OBJECT(this)); |
| 1268 } | 1298 } |
| 1269 | 1299 |
| 1270 | 1300 |
| 1271 // ECMA-262, Edition 6, section B.2.2.1.2 | 1301 // ECMA-262, Edition 6, section B.2.2.1.2 |
| 1272 function ObjectSetProto(proto) { | 1302 function ObjectSetProto(proto) { |
| 1273 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__"); | 1303 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__"); |
| 1274 | 1304 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 "__defineGetter__", ObjectDefineGetter, | 1339 "__defineGetter__", ObjectDefineGetter, |
| 1310 "__lookupGetter__", ObjectLookupGetter, | 1340 "__lookupGetter__", ObjectLookupGetter, |
| 1311 "__defineSetter__", ObjectDefineSetter, | 1341 "__defineSetter__", ObjectDefineSetter, |
| 1312 "__lookupSetter__", ObjectLookupSetter | 1342 "__lookupSetter__", ObjectLookupSetter |
| 1313 ]); | 1343 ]); |
| 1314 utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto, | 1344 utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto, |
| 1315 ObjectSetProto); | 1345 ObjectSetProto); |
| 1316 | 1346 |
| 1317 // Set up non-enumerable functions in the Object object. | 1347 // Set up non-enumerable functions in the Object object. |
| 1318 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ | 1348 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ |
| 1349 "assign", ObjectAssign, |
| 1319 "keys", ObjectKeys, | 1350 "keys", ObjectKeys, |
| 1320 "create", ObjectCreate, | 1351 "create", ObjectCreate, |
| 1321 "defineProperty", ObjectDefineProperty, | 1352 "defineProperty", ObjectDefineProperty, |
| 1322 "defineProperties", ObjectDefineProperties, | 1353 "defineProperties", ObjectDefineProperties, |
| 1323 "freeze", ObjectFreezeJS, | 1354 "freeze", ObjectFreezeJS, |
| 1324 "getPrototypeOf", ObjectGetPrototypeOf, | 1355 "getPrototypeOf", ObjectGetPrototypeOf, |
| 1325 "setPrototypeOf", ObjectSetPrototypeOf, | 1356 "setPrototypeOf", ObjectSetPrototypeOf, |
| 1326 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, | 1357 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, |
| 1327 "getOwnPropertyNames", ObjectGetOwnPropertyNames, | 1358 "getOwnPropertyNames", ObjectGetOwnPropertyNames, |
| 1328 // getOwnPropertySymbols is added in symbol.js. | 1359 // getOwnPropertySymbols is added in symbol.js. |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 to.NewFunctionString = NewFunctionString; | 1832 to.NewFunctionString = NewFunctionString; |
| 1802 to.NumberIsNaN = NumberIsNaN; | 1833 to.NumberIsNaN = NumberIsNaN; |
| 1803 to.ObjectDefineProperties = ObjectDefineProperties; | 1834 to.ObjectDefineProperties = ObjectDefineProperties; |
| 1804 to.ObjectDefineProperty = ObjectDefineProperty; | 1835 to.ObjectDefineProperty = ObjectDefineProperty; |
| 1805 to.ObjectFreeze = ObjectFreezeJS; | 1836 to.ObjectFreeze = ObjectFreezeJS; |
| 1806 to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys; | 1837 to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys; |
| 1807 to.ObjectHasOwnProperty = ObjectHasOwnProperty; | 1838 to.ObjectHasOwnProperty = ObjectHasOwnProperty; |
| 1808 to.ObjectIsFrozen = ObjectIsFrozen; | 1839 to.ObjectIsFrozen = ObjectIsFrozen; |
| 1809 to.ObjectIsSealed = ObjectIsSealed; | 1840 to.ObjectIsSealed = ObjectIsSealed; |
| 1810 to.ObjectToString = ObjectToString; | 1841 to.ObjectToString = ObjectToString; |
| 1811 to.OwnPropertyKeys = OwnPropertyKeys; | |
| 1812 to.ToNameArray = ToNameArray; | 1842 to.ToNameArray = ToNameArray; |
| 1813 }); | 1843 }); |
| 1814 | 1844 |
| 1815 %InstallToContext([ | 1845 %InstallToContext([ |
| 1816 "global_eval_fun", GlobalEval, | 1846 "global_eval_fun", GlobalEval, |
| 1817 "object_define_own_property", DefineOwnPropertyFromAPI, | 1847 "object_define_own_property", DefineOwnPropertyFromAPI, |
| 1818 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor, | 1848 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor, |
| 1819 "to_complete_property_descriptor", ToCompletePropertyDescriptor, | 1849 "to_complete_property_descriptor", ToCompletePropertyDescriptor, |
| 1820 ]); | 1850 ]); |
| 1821 | 1851 |
| 1822 }) | 1852 }) |
| OLD | NEW |