OLD | NEW |
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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 if (IS_UNDEFINED(desc)) return desc; | 381 if (IS_UNDEFINED(desc)) return desc; |
382 | 382 |
383 if (IsDataDescriptor(desc)) { | 383 if (IsDataDescriptor(desc)) { |
384 return { value: desc.getValue(), | 384 return { value: desc.getValue(), |
385 writable: desc.isWritable(), | 385 writable: desc.isWritable(), |
386 enumerable: desc.isEnumerable(), | 386 enumerable: desc.isEnumerable(), |
387 configurable: desc.isConfigurable() }; | 387 configurable: desc.isConfigurable() }; |
388 } | 388 } |
389 // Must be an AccessorDescriptor then. We never return a generic descriptor. | 389 // Must be an AccessorDescriptor then. We never return a generic descriptor. |
390 return { get: desc.getGet(), | 390 return { get: desc.getGet(), |
391 set: desc.getSet() === ObjectSetProto ? ObjectPoisonProto | 391 set: desc.getSet(), |
392 : desc.getSet(), | |
393 enumerable: desc.isEnumerable(), | 392 enumerable: desc.isEnumerable(), |
394 configurable: desc.isConfigurable() }; | 393 configurable: desc.isConfigurable() }; |
395 } | 394 } |
396 | 395 |
397 | 396 |
398 // Harmony Proxies | 397 // Harmony Proxies |
399 function FromGenericPropertyDescriptor(desc) { | 398 function FromGenericPropertyDescriptor(desc) { |
400 if (IS_UNDEFINED(desc)) return desc; | 399 if (IS_UNDEFINED(desc)) return desc; |
401 var obj = new $Object(); | 400 var obj = new $Object(); |
402 | 401 |
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 return %GetPrototype(this); | 1354 return %GetPrototype(this); |
1356 } | 1355 } |
1357 | 1356 |
1358 | 1357 |
1359 // Harmony __proto__ setter. | 1358 // Harmony __proto__ setter. |
1360 function ObjectSetProto(obj) { | 1359 function ObjectSetProto(obj) { |
1361 return %SetPrototype(this, obj); | 1360 return %SetPrototype(this, obj); |
1362 } | 1361 } |
1363 | 1362 |
1364 | 1363 |
1365 // Harmony __proto__ poison pill. | |
1366 function ObjectPoisonProto(obj) { | |
1367 throw MakeTypeError("proto_poison_pill", []); | |
1368 } | |
1369 | |
1370 | |
1371 function ObjectConstructor(x) { | 1364 function ObjectConstructor(x) { |
1372 if (%_IsConstructCall()) { | 1365 if (%_IsConstructCall()) { |
1373 if (x == null) return this; | 1366 if (x == null) return this; |
1374 return ToObject(x); | 1367 return ToObject(x); |
1375 } else { | 1368 } else { |
1376 if (x == null) return { }; | 1369 if (x == null) return { }; |
1377 return ToObject(x); | 1370 return ToObject(x); |
1378 } | 1371 } |
1379 } | 1372 } |
1380 | 1373 |
1381 | 1374 |
1382 // ---------------------------------------------------------------------------- | 1375 // ---------------------------------------------------------------------------- |
1383 // Object | 1376 // Object |
1384 | 1377 |
1385 function SetUpObject() { | 1378 function SetUpObject() { |
1386 %CheckIsBootstrapping(); | 1379 %CheckIsBootstrapping(); |
1387 | 1380 |
1388 %SetNativeFlag($Object); | 1381 %SetNativeFlag($Object); |
1389 %SetCode($Object, ObjectConstructor); | 1382 %SetCode($Object, ObjectConstructor); |
1390 %FunctionSetName(ObjectPoisonProto, "__proto__"); | |
1391 %FunctionRemovePrototype(ObjectPoisonProto); | |
1392 %SetExpectedNumberOfProperties($Object, 4); | 1383 %SetExpectedNumberOfProperties($Object, 4); |
1393 | 1384 |
1394 %SetProperty($Object.prototype, "constructor", $Object, DONT_ENUM); | 1385 %SetProperty($Object.prototype, "constructor", $Object, DONT_ENUM); |
1395 | 1386 |
1396 // Set up non-enumerable functions on the Object.prototype object. | 1387 // Set up non-enumerable functions on the Object.prototype object. |
1397 InstallFunctions($Object.prototype, DONT_ENUM, $Array( | 1388 InstallFunctions($Object.prototype, DONT_ENUM, $Array( |
1398 "toString", ObjectToString, | 1389 "toString", ObjectToString, |
1399 "toLocaleString", ObjectToLocaleString, | 1390 "toLocaleString", ObjectToLocaleString, |
1400 "valueOf", ObjectValueOf, | 1391 "valueOf", ObjectValueOf, |
1401 "hasOwnProperty", ObjectHasOwnProperty, | 1392 "hasOwnProperty", ObjectHasOwnProperty, |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1844 // Eventually, we should move to a real event queue that allows to maintain | 1835 // Eventually, we should move to a real event queue that allows to maintain |
1845 // relative ordering of different kinds of tasks. | 1836 // relative ordering of different kinds of tasks. |
1846 | 1837 |
1847 RunMicrotasks.runners = new InternalArray; | 1838 RunMicrotasks.runners = new InternalArray; |
1848 | 1839 |
1849 function RunMicrotasks() { | 1840 function RunMicrotasks() { |
1850 while (%SetMicrotaskPending(false)) { | 1841 while (%SetMicrotaskPending(false)) { |
1851 for (var i in RunMicrotasks.runners) RunMicrotasks.runners[i](); | 1842 for (var i in RunMicrotasks.runners) RunMicrotasks.runners[i](); |
1852 } | 1843 } |
1853 } | 1844 } |
OLD | NEW |