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 var $getHash; | 5 var $getHash; |
6 var $getExistingHash; | 6 var $getExistingHash; |
| 7 var $mapFromArray; |
| 8 var $setFromArray; |
7 | 9 |
8 (function(global, utils) { | 10 (function(global, utils) { |
9 "use strict"; | 11 "use strict"; |
10 | 12 |
11 %CheckIsBootstrapping(); | 13 %CheckIsBootstrapping(); |
12 | 14 |
13 // ------------------------------------------------------------------- | 15 // ------------------------------------------------------------------- |
14 // Imports | 16 // Imports |
15 | 17 |
16 var GlobalMap = global.Map; | 18 var GlobalMap = global.Map; |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 "has", MapHas, | 475 "has", MapHas, |
474 "delete", MapDelete, | 476 "delete", MapDelete, |
475 "clear", MapClearJS, | 477 "clear", MapClearJS, |
476 "forEach", MapForEach | 478 "forEach", MapForEach |
477 ]); | 479 ]); |
478 | 480 |
479 // Expose to the global scope. | 481 // Expose to the global scope. |
480 $getHash = GetHash; | 482 $getHash = GetHash; |
481 $getExistingHash = GetExistingHash; | 483 $getExistingHash = GetExistingHash; |
482 | 484 |
| 485 $mapFromArray = function(array) { |
| 486 var map = new GlobalMap; |
| 487 var length = array.length; |
| 488 for (var i = 0; i < length; ++i) { |
| 489 var entry = array[i]; |
| 490 %_CallFunction(map, entry[0], entry[1], MapSet); |
| 491 } |
| 492 return map; |
| 493 }; |
| 494 |
| 495 $setFromArray = function(array) { |
| 496 var set = new GlobalSet; |
| 497 var length = array.length; |
| 498 for (var i = 0; i < length; ++i) { |
| 499 %_CallFunction(set, array[i], SetAdd); |
| 500 } |
| 501 return set; |
| 502 }; |
| 503 |
483 }) | 504 }) |
OLD | NEW |