| 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 "use strict"; | 7 "use strict"; |
| 8 | 8 |
| 9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
| 10 | 10 |
| 11 var GlobalObject = global.Object; | 11 var GlobalObject = global.Object; |
| 12 var GlobalWeakMap = global.WeakMap; | 12 var GlobalWeakMap = global.WeakMap; |
| 13 var GlobalWeakSet = global.WeakSet; | 13 var GlobalWeakSet = global.WeakSet; |
| 14 | 14 |
| 15 // ------------------------------------------------------------------- | 15 // ------------------------------------------------------------------- |
| 16 // Harmony WeakMap | 16 // Harmony WeakMap |
| 17 | 17 |
| 18 function WeakMapConstructor(iterable) { | 18 function WeakMapConstructor(iterable) { |
| 19 if (!%_IsConstructCall()) { | 19 if (!%_IsConstructCall()) { |
| 20 throw MakeTypeError(kConstructorNotFunction, "WeakMap"); | 20 throw MakeTypeError(kConstructorNotFunction, "WeakMap"); |
| 21 } | 21 } |
| 22 | 22 |
| 23 %WeakCollectionInitialize(this); | 23 %WeakCollectionInitialize(this); |
| 24 | 24 |
| 25 if (!IS_NULL_OR_UNDEFINED(iterable)) { | 25 if (!IS_NULL_OR_UNDEFINED(iterable)) { |
| 26 var adder = this.set; | 26 var adder = this.set; |
| 27 if (!IS_SPEC_FUNCTION(adder)) { | 27 if (!IS_CALLABLE(adder)) { |
| 28 throw MakeTypeError(kPropertyNotFunction, 'set', this); | 28 throw MakeTypeError(kPropertyNotFunction, 'set', this); |
| 29 } | 29 } |
| 30 for (var nextItem of iterable) { | 30 for (var nextItem of iterable) { |
| 31 if (!IS_SPEC_OBJECT(nextItem)) { | 31 if (!IS_SPEC_OBJECT(nextItem)) { |
| 32 throw MakeTypeError(kIteratorValueNotAnObject, nextItem); | 32 throw MakeTypeError(kIteratorValueNotAnObject, nextItem); |
| 33 } | 33 } |
| 34 %_CallFunction(this, nextItem[0], nextItem[1], adder); | 34 %_CallFunction(this, nextItem[0], nextItem[1], adder); |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 } | 37 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 function WeakSetConstructor(iterable) { | 107 function WeakSetConstructor(iterable) { |
| 108 if (!%_IsConstructCall()) { | 108 if (!%_IsConstructCall()) { |
| 109 throw MakeTypeError(kConstructorNotFunction, "WeakSet"); | 109 throw MakeTypeError(kConstructorNotFunction, "WeakSet"); |
| 110 } | 110 } |
| 111 | 111 |
| 112 %WeakCollectionInitialize(this); | 112 %WeakCollectionInitialize(this); |
| 113 | 113 |
| 114 if (!IS_NULL_OR_UNDEFINED(iterable)) { | 114 if (!IS_NULL_OR_UNDEFINED(iterable)) { |
| 115 var adder = this.add; | 115 var adder = this.add; |
| 116 if (!IS_SPEC_FUNCTION(adder)) { | 116 if (!IS_CALLABLE(adder)) { |
| 117 throw MakeTypeError(kPropertyNotFunction, 'add', this); | 117 throw MakeTypeError(kPropertyNotFunction, 'add', this); |
| 118 } | 118 } |
| 119 for (var value of iterable) { | 119 for (var value of iterable) { |
| 120 %_CallFunction(this, value, adder); | 120 %_CallFunction(this, value, adder); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 | 125 |
| 126 function WeakSetAdd(value) { | 126 function WeakSetAdd(value) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 DONT_ENUM | READ_ONLY); | 168 DONT_ENUM | READ_ONLY); |
| 169 | 169 |
| 170 // Set up the non-enumerable functions on the WeakSet prototype object. | 170 // Set up the non-enumerable functions on the WeakSet prototype object. |
| 171 utils.InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ | 171 utils.InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ |
| 172 "add", WeakSetAdd, | 172 "add", WeakSetAdd, |
| 173 "has", WeakSetHas, | 173 "has", WeakSetHas, |
| 174 "delete", WeakSetDelete | 174 "delete", WeakSetDelete |
| 175 ]); | 175 ]); |
| 176 | 176 |
| 177 }) | 177 }) |
| OLD | NEW |