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 %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_SPEC_FUNCTION(adder)) { |
28 throw MakeTypeError('property_not_function', ['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('iterator_value_not_an_object', [nextItem]); | 32 throw MakeTypeError('iterator_value_not_an_object', [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 } |
38 | 38 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 function WeakSetConstructor(iterable) { | 109 function WeakSetConstructor(iterable) { |
110 if (!%_IsConstructCall()) { | 110 if (!%_IsConstructCall()) { |
111 throw MakeTypeError('constructor_not_function', ['WeakSet']); | 111 throw MakeTypeError('constructor_not_function', ['WeakSet']); |
112 } | 112 } |
113 | 113 |
114 %WeakCollectionInitialize(this); | 114 %WeakCollectionInitialize(this); |
115 | 115 |
116 if (!IS_NULL_OR_UNDEFINED(iterable)) { | 116 if (!IS_NULL_OR_UNDEFINED(iterable)) { |
117 var adder = this.add; | 117 var adder = this.add; |
118 if (!IS_SPEC_FUNCTION(adder)) { | 118 if (!IS_SPEC_FUNCTION(adder)) { |
119 throw MakeTypeError('property_not_function', ['add', this]); | 119 throw MakeTypeError(kPropertyNotFunction, ['add', this]); |
120 } | 120 } |
121 for (var value of iterable) { | 121 for (var value of iterable) { |
122 %_CallFunction(this, value, adder); | 122 %_CallFunction(this, value, adder); |
123 } | 123 } |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 | 127 |
128 function WeakSetAdd(value) { | 128 function WeakSetAdd(value) { |
129 if (!IS_WEAKSET(this)) { | 129 if (!IS_WEAKSET(this)) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 // Set up the non-enumerable functions on the WeakSet prototype object. | 172 // Set up the non-enumerable functions on the WeakSet prototype object. |
173 InstallFunctions($WeakSet.prototype, DONT_ENUM, [ | 173 InstallFunctions($WeakSet.prototype, DONT_ENUM, [ |
174 "add", WeakSetAdd, | 174 "add", WeakSetAdd, |
175 "has", WeakSetHas, | 175 "has", WeakSetHas, |
176 "delete", WeakSetDelete | 176 "delete", WeakSetDelete |
177 ]); | 177 ]); |
178 } | 178 } |
179 | 179 |
180 SetUpWeakSet(); | 180 SetUpWeakSet(); |
OLD | NEW |