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 |
(...skipping 20 matching lines...) Expand all Loading... |
31 function WeakMapConstructor(iterable) { | 31 function WeakMapConstructor(iterable) { |
32 if (IS_UNDEFINED(new.target)) { | 32 if (IS_UNDEFINED(new.target)) { |
33 throw MakeTypeError(kConstructorNotFunction, "WeakMap"); | 33 throw MakeTypeError(kConstructorNotFunction, "WeakMap"); |
34 } | 34 } |
35 | 35 |
36 %WeakCollectionInitialize(this); | 36 %WeakCollectionInitialize(this); |
37 | 37 |
38 if (!IS_NULL_OR_UNDEFINED(iterable)) { | 38 if (!IS_NULL_OR_UNDEFINED(iterable)) { |
39 var adder = this.set; | 39 var adder = this.set; |
40 if (!IS_CALLABLE(adder)) { | 40 if (!IS_CALLABLE(adder)) { |
41 throw MakeTypeError(kPropertyNotFunction, 'set', this); | 41 throw MakeTypeError(kPropertyNotFunction, adder, 'set', this); |
42 } | 42 } |
43 for (var nextItem of iterable) { | 43 for (var nextItem of iterable) { |
44 if (!IS_SPEC_OBJECT(nextItem)) { | 44 if (!IS_SPEC_OBJECT(nextItem)) { |
45 throw MakeTypeError(kIteratorValueNotAnObject, nextItem); | 45 throw MakeTypeError(kIteratorValueNotAnObject, nextItem); |
46 } | 46 } |
47 %_Call(adder, this, nextItem[0], nextItem[1]); | 47 %_Call(adder, this, nextItem[0], nextItem[1]); |
48 } | 48 } |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 function WeakSetConstructor(iterable) { | 120 function WeakSetConstructor(iterable) { |
121 if (IS_UNDEFINED(new.target)) { | 121 if (IS_UNDEFINED(new.target)) { |
122 throw MakeTypeError(kConstructorNotFunction, "WeakSet"); | 122 throw MakeTypeError(kConstructorNotFunction, "WeakSet"); |
123 } | 123 } |
124 | 124 |
125 %WeakCollectionInitialize(this); | 125 %WeakCollectionInitialize(this); |
126 | 126 |
127 if (!IS_NULL_OR_UNDEFINED(iterable)) { | 127 if (!IS_NULL_OR_UNDEFINED(iterable)) { |
128 var adder = this.add; | 128 var adder = this.add; |
129 if (!IS_CALLABLE(adder)) { | 129 if (!IS_CALLABLE(adder)) { |
130 throw MakeTypeError(kPropertyNotFunction, 'add', this); | 130 throw MakeTypeError(kPropertyNotFunction, adder, 'add', this); |
131 } | 131 } |
132 for (var value of iterable) { | 132 for (var value of iterable) { |
133 %_Call(adder, this, value); | 133 %_Call(adder, this, value); |
134 } | 134 } |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 | 138 |
139 function WeakSetAdd(value) { | 139 function WeakSetAdd(value) { |
140 if (!IS_WEAKSET(this)) { | 140 if (!IS_WEAKSET(this)) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 DONT_ENUM | READ_ONLY); | 181 DONT_ENUM | READ_ONLY); |
182 | 182 |
183 // Set up the non-enumerable functions on the WeakSet prototype object. | 183 // Set up the non-enumerable functions on the WeakSet prototype object. |
184 utils.InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ | 184 utils.InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ |
185 "add", WeakSetAdd, | 185 "add", WeakSetAdd, |
186 "has", WeakSetHas, | 186 "has", WeakSetHas, |
187 "delete", WeakSetDelete | 187 "delete", WeakSetDelete |
188 ]); | 188 ]); |
189 | 189 |
190 }) | 190 }) |
OLD | NEW |