| 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() { | 5 (function() { |
| 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('constructor_not_function', ['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_SPEC_FUNCTION(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('iterator_value_not_an_object', [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 } |
| 38 | 38 |
| 39 | 39 |
| 40 function WeakMapGet(key) { | 40 function WeakMapGet(key) { |
| 41 if (!IS_WEAKMAP(this)) { | 41 if (!IS_WEAKMAP(this)) { |
| 42 throw MakeTypeError(kIncompatibleMethodReceiver, | 42 throw MakeTypeError(kIncompatibleMethodReceiver, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 "set", WeakMapSet, | 95 "set", WeakMapSet, |
| 96 "has", WeakMapHas, | 96 "has", WeakMapHas, |
| 97 "delete", WeakMapDelete | 97 "delete", WeakMapDelete |
| 98 ]); | 98 ]); |
| 99 | 99 |
| 100 // ------------------------------------------------------------------- | 100 // ------------------------------------------------------------------- |
| 101 // Harmony WeakSet | 101 // Harmony WeakSet |
| 102 | 102 |
| 103 function WeakSetConstructor(iterable) { | 103 function WeakSetConstructor(iterable) { |
| 104 if (!%_IsConstructCall()) { | 104 if (!%_IsConstructCall()) { |
| 105 throw MakeTypeError('constructor_not_function', ['WeakSet']); | 105 throw MakeTypeError(kConstructorNotFunction, "WeakSet"); |
| 106 } | 106 } |
| 107 | 107 |
| 108 %WeakCollectionInitialize(this); | 108 %WeakCollectionInitialize(this); |
| 109 | 109 |
| 110 if (!IS_NULL_OR_UNDEFINED(iterable)) { | 110 if (!IS_NULL_OR_UNDEFINED(iterable)) { |
| 111 var adder = this.add; | 111 var adder = this.add; |
| 112 if (!IS_SPEC_FUNCTION(adder)) { | 112 if (!IS_SPEC_FUNCTION(adder)) { |
| 113 throw MakeTypeError(kPropertyNotFunction, 'add', this); | 113 throw MakeTypeError(kPropertyNotFunction, 'add', this); |
| 114 } | 114 } |
| 115 for (var value of iterable) { | 115 for (var value of iterable) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 DONT_ENUM | READ_ONLY); | 162 DONT_ENUM | READ_ONLY); |
| 163 | 163 |
| 164 // Set up the non-enumerable functions on the WeakSet prototype object. | 164 // Set up the non-enumerable functions on the WeakSet prototype object. |
| 165 InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ | 165 InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ |
| 166 "add", WeakSetAdd, | 166 "add", WeakSetAdd, |
| 167 "has", WeakSetHas, | 167 "has", WeakSetHas, |
| 168 "delete", WeakSetDelete | 168 "delete", WeakSetDelete |
| 169 ]); | 169 ]); |
| 170 | 170 |
| 171 })(); | 171 })(); |
| OLD | NEW |