| 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 "use strict"; | 6 "use strict"; |
| 7 | 7 |
| 8 %CheckIsBootstrapping(); | 8 %CheckIsBootstrapping(); |
| 9 | 9 |
| 10 // ------------------------------------------------------------------- | 10 // ------------------------------------------------------------------- |
| 11 // Imports | 11 // Imports |
| 12 | 12 |
| 13 var GlobalMap = global.Map; | 13 var GlobalMap = global.Map; |
| 14 var GlobalObject = global.Object; | 14 var GlobalObject = global.Object; |
| 15 var GlobalSet = global.Set; | 15 var GlobalSet = global.Set; |
| 16 var hashCodeSymbol = utils.ImportNow("hash_code_symbol"); | 16 var hashCodeSymbol = utils.ImportNow("hash_code_symbol"); |
| 17 var IntRandom; | 17 var IntRandom; |
| 18 var MakeTypeError; | 18 var MakeTypeError; |
| 19 var MapIterator; | 19 var MapIterator; |
| 20 var NumberIsNaN; | 20 var NumberIsNaN; |
| 21 var SetIterator; | 21 var SetIterator; |
| 22 var speciesSymbol = utils.ImportNow("species_symbol"); |
| 22 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 23 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
| 23 | 24 |
| 24 utils.Import(function(from) { | 25 utils.Import(function(from) { |
| 25 IntRandom = from.IntRandom; | 26 IntRandom = from.IntRandom; |
| 26 MakeTypeError = from.MakeTypeError; | 27 MakeTypeError = from.MakeTypeError; |
| 27 MapIterator = from.MapIterator; | 28 MapIterator = from.MapIterator; |
| 28 NumberIsNaN = from.NumberIsNaN; | 29 NumberIsNaN = from.NumberIsNaN; |
| 29 SetIterator = from.SetIterator; | 30 SetIterator = from.SetIterator; |
| 30 }); | 31 }); |
| 31 | 32 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 249 |
| 249 var iterator = new SetIterator(this, ITERATOR_KIND_VALUES); | 250 var iterator = new SetIterator(this, ITERATOR_KIND_VALUES); |
| 250 var key; | 251 var key; |
| 251 var value_array = [UNDEFINED]; | 252 var value_array = [UNDEFINED]; |
| 252 while (%SetIteratorNext(iterator, value_array)) { | 253 while (%SetIteratorNext(iterator, value_array)) { |
| 253 key = value_array[0]; | 254 key = value_array[0]; |
| 254 %_Call(f, receiver, key, key, this); | 255 %_Call(f, receiver, key, key, this); |
| 255 } | 256 } |
| 256 } | 257 } |
| 257 | 258 |
| 259 |
| 260 function SetSpecies() { |
| 261 return this; |
| 262 } |
| 263 |
| 264 |
| 258 // ------------------------------------------------------------------- | 265 // ------------------------------------------------------------------- |
| 259 | 266 |
| 260 %SetCode(GlobalSet, SetConstructor); | 267 %SetCode(GlobalSet, SetConstructor); |
| 261 %FunctionSetLength(GlobalSet, 0); | 268 %FunctionSetLength(GlobalSet, 0); |
| 262 %FunctionSetPrototype(GlobalSet, new GlobalObject()); | 269 %FunctionSetPrototype(GlobalSet, new GlobalObject()); |
| 263 %AddNamedProperty(GlobalSet.prototype, "constructor", GlobalSet, DONT_ENUM); | 270 %AddNamedProperty(GlobalSet.prototype, "constructor", GlobalSet, DONT_ENUM); |
| 264 %AddNamedProperty(GlobalSet.prototype, toStringTagSymbol, "Set", | 271 %AddNamedProperty(GlobalSet.prototype, toStringTagSymbol, "Set", |
| 265 DONT_ENUM | READ_ONLY); | 272 DONT_ENUM | READ_ONLY); |
| 266 | 273 |
| 267 %FunctionSetLength(SetForEach, 1); | 274 %FunctionSetLength(SetForEach, 1); |
| 268 | 275 |
| 276 utils.InstallGetter(GlobalSet, speciesSymbol, SetSpecies); |
| 277 |
| 269 // Set up the non-enumerable functions on the Set prototype object. | 278 // Set up the non-enumerable functions on the Set prototype object. |
| 270 utils.InstallGetter(GlobalSet.prototype, "size", SetGetSize); | 279 utils.InstallGetter(GlobalSet.prototype, "size", SetGetSize); |
| 271 utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [ | 280 utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [ |
| 272 "add", SetAdd, | 281 "add", SetAdd, |
| 273 "has", SetHas, | 282 "has", SetHas, |
| 274 "delete", SetDelete, | 283 "delete", SetDelete, |
| 275 "clear", SetClearJS, | 284 "clear", SetClearJS, |
| 276 "forEach", SetForEach | 285 "forEach", SetForEach |
| 277 ]); | 286 ]); |
| 278 | 287 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 437 |
| 429 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); | 438 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 430 | 439 |
| 431 var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES); | 440 var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES); |
| 432 var value_array = [UNDEFINED, UNDEFINED]; | 441 var value_array = [UNDEFINED, UNDEFINED]; |
| 433 while (%MapIteratorNext(iterator, value_array)) { | 442 while (%MapIteratorNext(iterator, value_array)) { |
| 434 %_Call(f, receiver, value_array[1], value_array[0], this); | 443 %_Call(f, receiver, value_array[1], value_array[0], this); |
| 435 } | 444 } |
| 436 } | 445 } |
| 437 | 446 |
| 447 |
| 448 function MapSpecies() { |
| 449 return this; |
| 450 } |
| 451 |
| 438 // ------------------------------------------------------------------- | 452 // ------------------------------------------------------------------- |
| 439 | 453 |
| 440 %SetCode(GlobalMap, MapConstructor); | 454 %SetCode(GlobalMap, MapConstructor); |
| 441 %FunctionSetLength(GlobalMap, 0); | 455 %FunctionSetLength(GlobalMap, 0); |
| 442 %FunctionSetPrototype(GlobalMap, new GlobalObject()); | 456 %FunctionSetPrototype(GlobalMap, new GlobalObject()); |
| 443 %AddNamedProperty(GlobalMap.prototype, "constructor", GlobalMap, DONT_ENUM); | 457 %AddNamedProperty(GlobalMap.prototype, "constructor", GlobalMap, DONT_ENUM); |
| 444 %AddNamedProperty( | 458 %AddNamedProperty( |
| 445 GlobalMap.prototype, toStringTagSymbol, "Map", DONT_ENUM | READ_ONLY); | 459 GlobalMap.prototype, toStringTagSymbol, "Map", DONT_ENUM | READ_ONLY); |
| 446 | 460 |
| 447 %FunctionSetLength(MapForEach, 1); | 461 %FunctionSetLength(MapForEach, 1); |
| 448 | 462 |
| 463 utils.InstallGetter(GlobalMap, speciesSymbol, MapSpecies); |
| 464 |
| 449 // Set up the non-enumerable functions on the Map prototype object. | 465 // Set up the non-enumerable functions on the Map prototype object. |
| 450 utils.InstallGetter(GlobalMap.prototype, "size", MapGetSize); | 466 utils.InstallGetter(GlobalMap.prototype, "size", MapGetSize); |
| 451 utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [ | 467 utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [ |
| 452 "get", MapGet, | 468 "get", MapGet, |
| 453 "set", MapSet, | 469 "set", MapSet, |
| 454 "has", MapHas, | 470 "has", MapHas, |
| 455 "delete", MapDelete, | 471 "delete", MapDelete, |
| 456 "clear", MapClearJS, | 472 "clear", MapClearJS, |
| 457 "forEach", MapForEach | 473 "forEach", MapForEach |
| 458 ]); | 474 ]); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 469 "set_has", SetHas, | 485 "set_has", SetHas, |
| 470 "set_delete", SetDelete, | 486 "set_delete", SetDelete, |
| 471 ]); | 487 ]); |
| 472 | 488 |
| 473 utils.Export(function(to) { | 489 utils.Export(function(to) { |
| 474 to.GetExistingHash = GetExistingHash; | 490 to.GetExistingHash = GetExistingHash; |
| 475 to.GetHash = GetHash; | 491 to.GetHash = GetHash; |
| 476 }); | 492 }); |
| 477 | 493 |
| 478 }) | 494 }) |
| OLD | NEW |