| 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 "use strict"; | 5 "use strict"; |
| 6 | 6 |
| 7 // This file relies on the fact that the following declaration has been made | 7 // This file relies on the fact that the following declaration has been made |
| 8 // in runtime.js: | 8 // in runtime.js: |
| 9 // var $Array = global.Array; | 9 // var $Array = global.Array; |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 throw MakeTypeError('incompatible_method_receiver', | 99 throw MakeTypeError('incompatible_method_receiver', |
| 100 ['Set.prototype.forEach', this]); | 100 ['Set.prototype.forEach', this]); |
| 101 } | 101 } |
| 102 | 102 |
| 103 if (!IS_SPEC_FUNCTION(f)) { | 103 if (!IS_SPEC_FUNCTION(f)) { |
| 104 throw MakeTypeError('called_non_callable', [f]); | 104 throw MakeTypeError('called_non_callable', [f]); |
| 105 } | 105 } |
| 106 | 106 |
| 107 var iterator = %SetCreateIterator(this, ITERATOR_KIND_VALUES); | 107 var iterator = %SetCreateIterator(this, ITERATOR_KIND_VALUES); |
| 108 var entry; | 108 var entry; |
| 109 try { | 109 while (!(entry = %SetIteratorNext(iterator)).done) { |
| 110 while (!(entry = %SetIteratorNext(iterator)).done) { | 110 %_CallFunction(receiver, entry.value, entry.value, this, f); |
| 111 %_CallFunction(receiver, entry.value, entry.value, this, f); | |
| 112 } | |
| 113 } finally { | |
| 114 %SetIteratorClose(iterator); | |
| 115 } | 111 } |
| 116 } | 112 } |
| 117 | 113 |
| 118 | 114 |
| 119 // ------------------------------------------------------------------- | 115 // ------------------------------------------------------------------- |
| 120 | 116 |
| 121 function SetUpSet() { | 117 function SetUpSet() { |
| 122 %CheckIsBootstrapping(); | 118 %CheckIsBootstrapping(); |
| 123 | 119 |
| 124 %SetCode($Set, SetConstructor); | 120 %SetCode($Set, SetConstructor); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 throw MakeTypeError('incompatible_method_receiver', | 208 throw MakeTypeError('incompatible_method_receiver', |
| 213 ['Map.prototype.forEach', this]); | 209 ['Map.prototype.forEach', this]); |
| 214 } | 210 } |
| 215 | 211 |
| 216 if (!IS_SPEC_FUNCTION(f)) { | 212 if (!IS_SPEC_FUNCTION(f)) { |
| 217 throw MakeTypeError('called_non_callable', [f]); | 213 throw MakeTypeError('called_non_callable', [f]); |
| 218 } | 214 } |
| 219 | 215 |
| 220 var iterator = %MapCreateIterator(this, ITERATOR_KIND_ENTRIES); | 216 var iterator = %MapCreateIterator(this, ITERATOR_KIND_ENTRIES); |
| 221 var entry; | 217 var entry; |
| 222 try { | 218 while (!(entry = %MapIteratorNext(iterator)).done) { |
| 223 while (!(entry = %MapIteratorNext(iterator)).done) { | 219 %_CallFunction(receiver, entry.value[1], entry.value[0], this, f); |
| 224 %_CallFunction(receiver, entry.value[1], entry.value[0], this, f); | |
| 225 } | |
| 226 } finally { | |
| 227 %MapIteratorClose(iterator); | |
| 228 } | 220 } |
| 229 } | 221 } |
| 230 | 222 |
| 231 | 223 |
| 232 // ------------------------------------------------------------------- | 224 // ------------------------------------------------------------------- |
| 233 | 225 |
| 234 function SetUpMap() { | 226 function SetUpMap() { |
| 235 %CheckIsBootstrapping(); | 227 %CheckIsBootstrapping(); |
| 236 | 228 |
| 237 %SetCode($Map, MapConstructor); | 229 %SetCode($Map, MapConstructor); |
| 238 %FunctionSetPrototype($Map, new $Object()); | 230 %FunctionSetPrototype($Map, new $Object()); |
| 239 %SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM); | 231 %SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM); |
| 240 | 232 |
| 241 %FunctionSetLength(MapForEach, 1); | 233 %FunctionSetLength(MapForEach, 1); |
| 242 | 234 |
| 243 // Set up the non-enumerable functions on the Map prototype object. | 235 // Set up the non-enumerable functions on the Map prototype object. |
| 244 InstallGetter($Map.prototype, "size", MapGetSize); | 236 InstallGetter($Map.prototype, "size", MapGetSize); |
| 245 InstallFunctions($Map.prototype, DONT_ENUM, $Array( | 237 InstallFunctions($Map.prototype, DONT_ENUM, $Array( |
| 246 "get", MapGet, | 238 "get", MapGet, |
| 247 "set", MapSet, | 239 "set", MapSet, |
| 248 "has", MapHas, | 240 "has", MapHas, |
| 249 "delete", MapDelete, | 241 "delete", MapDelete, |
| 250 "clear", MapClear, | 242 "clear", MapClear, |
| 251 "forEach", MapForEach | 243 "forEach", MapForEach |
| 252 )); | 244 )); |
| 253 } | 245 } |
| 254 | 246 |
| 255 SetUpMap(); | 247 SetUpMap(); |
| OLD | NEW |