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 "use strict"; | 5 "use strict"; |
6 | 6 |
7 // This file relies on the fact that the following declaration has been made | 7 // This file relies on the fact that the following declaration has been made |
8 // in runtime.js: | 8 // in runtime.js: |
9 // var $Array = global.Array; | 9 // var $Array = global.Array; |
10 | 10 |
11 var $WeakMap = global.WeakMap; | 11 var $WeakMap = global.WeakMap; |
12 var $WeakSet = global.WeakSet; | 12 var $WeakSet = global.WeakSet; |
13 | 13 |
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('constructor_not_function', ['WeakMap']); | 20 throw MakeTypeError('constructor_not_function', ['WeakMap']); |
21 } | 21 } |
22 | 22 |
23 var iter, adder; | 23 var iter, adder; |
24 | 24 |
25 if (!IS_NULL_OR_UNDEFINED(iterable)) { | 25 if (!IS_NULL_OR_UNDEFINED(iterable)) { |
26 iter = GetIterator(iterable); | |
27 adder = this.set; | 26 adder = this.set; |
28 if (!IS_SPEC_FUNCTION(adder)) { | 27 if (!IS_SPEC_FUNCTION(adder)) { |
29 throw MakeTypeError('property_not_function', ['set', this]); | 28 throw MakeTypeError('property_not_function', ['set', this]); |
30 } | 29 } |
| 30 iter = GetIterator(iterable); |
31 } | 31 } |
32 | 32 |
33 %WeakCollectionInitialize(this); | 33 %WeakCollectionInitialize(this); |
34 | 34 |
35 if (IS_UNDEFINED(iter)) return; | 35 if (IS_UNDEFINED(iter)) return; |
36 | 36 |
37 var next, done, nextItem; | 37 var next, done, nextItem; |
38 while (!(next = iter.next()).done) { | 38 while (!(next = iter.next()).done) { |
39 if (!IS_SPEC_OBJECT(next)) { | 39 if (!IS_SPEC_OBJECT(next)) { |
40 throw MakeTypeError('iterator_result_not_an_object', [next]); | 40 throw MakeTypeError('iterator_result_not_an_object', [next]); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // Harmony WeakSet | 123 // Harmony WeakSet |
124 | 124 |
125 function WeakSetConstructor(iterable) { | 125 function WeakSetConstructor(iterable) { |
126 if (!%_IsConstructCall()) { | 126 if (!%_IsConstructCall()) { |
127 throw MakeTypeError('constructor_not_function', ['WeakSet']); | 127 throw MakeTypeError('constructor_not_function', ['WeakSet']); |
128 } | 128 } |
129 | 129 |
130 var iter, adder; | 130 var iter, adder; |
131 | 131 |
132 if (!IS_NULL_OR_UNDEFINED(iterable)) { | 132 if (!IS_NULL_OR_UNDEFINED(iterable)) { |
133 iter = GetIterator(iterable); | |
134 adder = this.add; | 133 adder = this.add; |
135 if (!IS_SPEC_FUNCTION(adder)) { | 134 if (!IS_SPEC_FUNCTION(adder)) { |
136 throw MakeTypeError('property_not_function', ['add', this]); | 135 throw MakeTypeError('property_not_function', ['add', this]); |
137 } | 136 } |
| 137 iter = GetIterator(iterable); |
138 } | 138 } |
139 | 139 |
140 %WeakCollectionInitialize(this); | 140 %WeakCollectionInitialize(this); |
141 | 141 |
142 if (IS_UNDEFINED(iter)) return; | 142 if (IS_UNDEFINED(iter)) return; |
143 | 143 |
144 var next, done; | 144 var next, done; |
145 while (!(next = iter.next()).done) { | 145 while (!(next = iter.next()).done) { |
146 if (!IS_SPEC_OBJECT(next)) { | 146 if (!IS_SPEC_OBJECT(next)) { |
147 throw MakeTypeError('iterator_result_not_an_object', [next]); | 147 throw MakeTypeError('iterator_result_not_an_object', [next]); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 200 |
201 // Set up the non-enumerable functions on the WeakSet prototype object. | 201 // Set up the non-enumerable functions on the WeakSet prototype object. |
202 InstallFunctions($WeakSet.prototype, DONT_ENUM, $Array( | 202 InstallFunctions($WeakSet.prototype, DONT_ENUM, $Array( |
203 "add", WeakSetAdd, | 203 "add", WeakSetAdd, |
204 "has", WeakSetHas, | 204 "has", WeakSetHas, |
205 "delete", WeakSetDelete | 205 "delete", WeakSetDelete |
206 )); | 206 )); |
207 } | 207 } |
208 | 208 |
209 SetUpWeakSet(); | 209 SetUpWeakSet(); |
OLD | NEW |