| 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 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
| 14 | 15 |
| 15 // ------------------------------------------------------------------- | 16 // ------------------------------------------------------------------- |
| 16 // Harmony WeakMap | 17 // Harmony WeakMap |
| 17 | 18 |
| 18 function WeakMapConstructor(iterable) { | 19 function WeakMapConstructor(iterable) { |
| 19 if (!%_IsConstructCall()) { | 20 if (!%_IsConstructCall()) { |
| 20 throw MakeTypeError(kConstructorNotFunction, "WeakMap"); | 21 throw MakeTypeError(kConstructorNotFunction, "WeakMap"); |
| 21 } | 22 } |
| 22 | 23 |
| 23 %WeakCollectionInitialize(this); | 24 %WeakCollectionInitialize(this); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 84 } |
| 84 | 85 |
| 85 | 86 |
| 86 // ------------------------------------------------------------------- | 87 // ------------------------------------------------------------------- |
| 87 | 88 |
| 88 %SetCode(GlobalWeakMap, WeakMapConstructor); | 89 %SetCode(GlobalWeakMap, WeakMapConstructor); |
| 89 %FunctionSetLength(GlobalWeakMap, 0); | 90 %FunctionSetLength(GlobalWeakMap, 0); |
| 90 %FunctionSetPrototype(GlobalWeakMap, new GlobalObject()); | 91 %FunctionSetPrototype(GlobalWeakMap, new GlobalObject()); |
| 91 %AddNamedProperty(GlobalWeakMap.prototype, "constructor", GlobalWeakMap, | 92 %AddNamedProperty(GlobalWeakMap.prototype, "constructor", GlobalWeakMap, |
| 92 DONT_ENUM); | 93 DONT_ENUM); |
| 93 %AddNamedProperty(GlobalWeakMap.prototype, symbolToStringTag, "WeakMap", | 94 %AddNamedProperty(GlobalWeakMap.prototype, toStringTagSymbol, "WeakMap", |
| 94 DONT_ENUM | READ_ONLY); | 95 DONT_ENUM | READ_ONLY); |
| 95 | 96 |
| 96 // Set up the non-enumerable functions on the WeakMap prototype object. | 97 // Set up the non-enumerable functions on the WeakMap prototype object. |
| 97 utils.InstallFunctions(GlobalWeakMap.prototype, DONT_ENUM, [ | 98 utils.InstallFunctions(GlobalWeakMap.prototype, DONT_ENUM, [ |
| 98 "get", WeakMapGet, | 99 "get", WeakMapGet, |
| 99 "set", WeakMapSet, | 100 "set", WeakMapSet, |
| 100 "has", WeakMapHas, | 101 "has", WeakMapHas, |
| 101 "delete", WeakMapDelete | 102 "delete", WeakMapDelete |
| 102 ]); | 103 ]); |
| 103 | 104 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 158 } |
| 158 | 159 |
| 159 | 160 |
| 160 // ------------------------------------------------------------------- | 161 // ------------------------------------------------------------------- |
| 161 | 162 |
| 162 %SetCode(GlobalWeakSet, WeakSetConstructor); | 163 %SetCode(GlobalWeakSet, WeakSetConstructor); |
| 163 %FunctionSetLength(GlobalWeakSet, 0); | 164 %FunctionSetLength(GlobalWeakSet, 0); |
| 164 %FunctionSetPrototype(GlobalWeakSet, new GlobalObject()); | 165 %FunctionSetPrototype(GlobalWeakSet, new GlobalObject()); |
| 165 %AddNamedProperty(GlobalWeakSet.prototype, "constructor", GlobalWeakSet, | 166 %AddNamedProperty(GlobalWeakSet.prototype, "constructor", GlobalWeakSet, |
| 166 DONT_ENUM); | 167 DONT_ENUM); |
| 167 %AddNamedProperty(GlobalWeakSet.prototype, symbolToStringTag, "WeakSet", | 168 %AddNamedProperty(GlobalWeakSet.prototype, toStringTagSymbol, "WeakSet", |
| 168 DONT_ENUM | READ_ONLY); | 169 DONT_ENUM | READ_ONLY); |
| 169 | 170 |
| 170 // Set up the non-enumerable functions on the WeakSet prototype object. | 171 // Set up the non-enumerable functions on the WeakSet prototype object. |
| 171 utils.InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ | 172 utils.InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ |
| 172 "add", WeakSetAdd, | 173 "add", WeakSetAdd, |
| 173 "has", WeakSetHas, | 174 "has", WeakSetHas, |
| 174 "delete", WeakSetDelete | 175 "delete", WeakSetDelete |
| 175 ]); | 176 ]); |
| 176 | 177 |
| 177 }) | 178 }) |
| OLD | NEW |