| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 throw MakeTypeError('incompatible_method_receiver', | 288 throw MakeTypeError('incompatible_method_receiver', |
| 289 ['WeakMap.prototype.delete', this]); | 289 ['WeakMap.prototype.delete', this]); |
| 290 } | 290 } |
| 291 if (!(IS_SPEC_OBJECT(key) || IS_SYMBOL(key))) { | 291 if (!(IS_SPEC_OBJECT(key) || IS_SYMBOL(key))) { |
| 292 throw %MakeTypeError('invalid_weakmap_key', [this, key]); | 292 throw %MakeTypeError('invalid_weakmap_key', [this, key]); |
| 293 } | 293 } |
| 294 return %WeakMapDelete(this, key); | 294 return %WeakMapDelete(this, key); |
| 295 } | 295 } |
| 296 | 296 |
| 297 | 297 |
| 298 function WeakMapClear() { |
| 299 if (!IS_WEAKMAP(this)) { |
| 300 throw MakeTypeError('incompatible_method_receiver', |
| 301 ['WeakMap.prototype.clear', this]); |
| 302 } |
| 303 // Replace the internal table with a new empty table. |
| 304 %WeakMapInitialize(this); |
| 305 } |
| 306 |
| 307 |
| 298 // ------------------------------------------------------------------- | 308 // ------------------------------------------------------------------- |
| 299 | 309 |
| 300 function SetUpWeakMap() { | 310 function SetUpWeakMap() { |
| 301 %CheckIsBootstrapping(); | 311 %CheckIsBootstrapping(); |
| 302 | 312 |
| 303 %SetCode($WeakMap, WeakMapConstructor); | 313 %SetCode($WeakMap, WeakMapConstructor); |
| 304 %FunctionSetPrototype($WeakMap, new $Object()); | 314 %FunctionSetPrototype($WeakMap, new $Object()); |
| 305 %SetProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM); | 315 %SetProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM); |
| 306 | 316 |
| 307 // Set up the non-enumerable functions on the WeakMap prototype object. | 317 // Set up the non-enumerable functions on the WeakMap prototype object. |
| 308 InstallFunctions($WeakMap.prototype, DONT_ENUM, $Array( | 318 InstallFunctions($WeakMap.prototype, DONT_ENUM, $Array( |
| 309 "get", WeakMapGet, | 319 "get", WeakMapGet, |
| 310 "set", WeakMapSet, | 320 "set", WeakMapSet, |
| 311 "has", WeakMapHas, | 321 "has", WeakMapHas, |
| 312 "delete", WeakMapDelete | 322 "delete", WeakMapDelete, |
| 323 "clear", WeakMapClear |
| 313 )); | 324 )); |
| 314 } | 325 } |
| 315 | 326 |
| 316 SetUpWeakMap(); | 327 SetUpWeakMap(); |
| OLD | NEW |