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() { |
| 6 |
5 "use strict"; | 7 "use strict"; |
6 | 8 |
7 // This file relies on the fact that the following declaration has been made | |
8 // in runtime.js: | |
9 // var $Array = global.Array; | |
10 | |
11 var $Set = global.Set; | |
12 var $Map = global.Map; | |
13 | |
14 | |
15 (function() { | |
16 | |
17 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
18 | 10 |
| 11 var GlobalMap = global.Map; |
| 12 var GlobalObject = global.Object; |
| 13 var GlobalSet = global.Set; |
| 14 |
| 15 // ------------------------------------------------------------------- |
19 | 16 |
20 function HashToEntry(table, hash, numBuckets) { | 17 function HashToEntry(table, hash, numBuckets) { |
21 var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets); | 18 var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets); |
22 return ORDERED_HASH_TABLE_BUCKET_AT(table, bucket); | 19 return ORDERED_HASH_TABLE_BUCKET_AT(table, bucket); |
23 } | 20 } |
24 %SetInlineBuiltinFlag(HashToEntry); | 21 %SetInlineBuiltinFlag(HashToEntry); |
25 | 22 |
26 | 23 |
27 function SetFindEntry(table, numBuckets, key, hash) { | 24 function SetFindEntry(table, numBuckets, key, hash) { |
28 var keyIsNaN = NumberIsNaN(key); | 25 var keyIsNaN = NumberIsNaN(key); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 224 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
228 var value_array = [UNDEFINED]; | 225 var value_array = [UNDEFINED]; |
229 while (%SetIteratorNext(iterator, value_array)) { | 226 while (%SetIteratorNext(iterator, value_array)) { |
230 if (stepping) %DebugPrepareStepInIfStepping(f); | 227 if (stepping) %DebugPrepareStepInIfStepping(f); |
231 key = value_array[0]; | 228 key = value_array[0]; |
232 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; | 229 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; |
233 %_CallFunction(new_receiver, key, key, this, f); | 230 %_CallFunction(new_receiver, key, key, this, f); |
234 } | 231 } |
235 } | 232 } |
236 | 233 |
| 234 // ------------------------------------------------------------------- |
237 | 235 |
238 %SetCode($Set, SetConstructor); | 236 %SetCode(GlobalSet, SetConstructor); |
239 %FunctionSetLength($Set, 0); | 237 %FunctionSetLength(GlobalSet, 0); |
240 %FunctionSetPrototype($Set, new $Object()); | 238 %FunctionSetPrototype(GlobalSet, new GlobalObject()); |
241 %AddNamedProperty($Set.prototype, "constructor", $Set, DONT_ENUM); | 239 %AddNamedProperty(GlobalSet.prototype, "constructor", GlobalSet, DONT_ENUM); |
242 %AddNamedProperty( | 240 %AddNamedProperty(GlobalSet.prototype, symbolToStringTag, "Set", |
243 $Set.prototype, symbolToStringTag, "Set", DONT_ENUM | READ_ONLY); | 241 DONT_ENUM | READ_ONLY); |
244 | 242 |
245 %FunctionSetLength(SetForEach, 1); | 243 %FunctionSetLength(SetForEach, 1); |
246 | 244 |
247 // Set up the non-enumerable functions on the Set prototype object. | 245 // Set up the non-enumerable functions on the Set prototype object. |
248 InstallGetter($Set.prototype, "size", SetGetSize); | 246 InstallGetter(GlobalSet.prototype, "size", SetGetSize); |
249 InstallFunctions($Set.prototype, DONT_ENUM, [ | 247 InstallFunctions(GlobalSet.prototype, DONT_ENUM, [ |
250 "add", SetAdd, | 248 "add", SetAdd, |
251 "has", SetHas, | 249 "has", SetHas, |
252 "delete", SetDelete, | 250 "delete", SetDelete, |
253 "clear", SetClearJS, | 251 "clear", SetClearJS, |
254 "forEach", SetForEach | 252 "forEach", SetForEach |
255 ]); | 253 ]); |
256 | 254 |
257 | 255 |
258 // ------------------------------------------------------------------- | 256 // ------------------------------------------------------------------- |
259 // Harmony Map | 257 // Harmony Map |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES); | 414 var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES); |
417 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 415 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
418 var value_array = [UNDEFINED, UNDEFINED]; | 416 var value_array = [UNDEFINED, UNDEFINED]; |
419 while (%MapIteratorNext(iterator, value_array)) { | 417 while (%MapIteratorNext(iterator, value_array)) { |
420 if (stepping) %DebugPrepareStepInIfStepping(f); | 418 if (stepping) %DebugPrepareStepInIfStepping(f); |
421 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; | 419 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; |
422 %_CallFunction(new_receiver, value_array[1], value_array[0], this, f); | 420 %_CallFunction(new_receiver, value_array[1], value_array[0], this, f); |
423 } | 421 } |
424 } | 422 } |
425 | 423 |
| 424 // ------------------------------------------------------------------- |
426 | 425 |
427 %SetCode($Map, MapConstructor); | 426 %SetCode(GlobalMap, MapConstructor); |
428 %FunctionSetLength($Map, 0); | 427 %FunctionSetLength(GlobalMap, 0); |
429 %FunctionSetPrototype($Map, new $Object()); | 428 %FunctionSetPrototype(GlobalMap, new GlobalObject()); |
430 %AddNamedProperty($Map.prototype, "constructor", $Map, DONT_ENUM); | 429 %AddNamedProperty(GlobalMap.prototype, "constructor", GlobalMap, DONT_ENUM); |
431 %AddNamedProperty( | 430 %AddNamedProperty( |
432 $Map.prototype, symbolToStringTag, "Map", DONT_ENUM | READ_ONLY); | 431 GlobalMap.prototype, symbolToStringTag, "Map", DONT_ENUM | READ_ONLY); |
433 | 432 |
434 %FunctionSetLength(MapForEach, 1); | 433 %FunctionSetLength(MapForEach, 1); |
435 | 434 |
436 // Set up the non-enumerable functions on the Map prototype object. | 435 // Set up the non-enumerable functions on the Map prototype object. |
437 InstallGetter($Map.prototype, "size", MapGetSize); | 436 InstallGetter(GlobalMap.prototype, "size", MapGetSize); |
438 InstallFunctions($Map.prototype, DONT_ENUM, [ | 437 InstallFunctions(GlobalMap.prototype, DONT_ENUM, [ |
439 "get", MapGet, | 438 "get", MapGet, |
440 "set", MapSet, | 439 "set", MapSet, |
441 "has", MapHas, | 440 "has", MapHas, |
442 "delete", MapDelete, | 441 "delete", MapDelete, |
443 "clear", MapClearJS, | 442 "clear", MapClearJS, |
444 "forEach", MapForEach | 443 "forEach", MapForEach |
445 ]); | 444 ]); |
446 | 445 |
447 })(); | 446 })(); |
OLD | NEW |