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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (!IS_SET(this)) { | 122 if (!IS_SET(this)) { |
123 throw MakeTypeError('incompatible_method_receiver', | 123 throw MakeTypeError('incompatible_method_receiver', |
124 ['Set.prototype.forEach', this]); | 124 ['Set.prototype.forEach', this]); |
125 } | 125 } |
126 | 126 |
127 if (!IS_SPEC_FUNCTION(f)) { | 127 if (!IS_SPEC_FUNCTION(f)) { |
128 throw MakeTypeError('called_non_callable', [f]); | 128 throw MakeTypeError('called_non_callable', [f]); |
129 } | 129 } |
130 | 130 |
131 var iterator = new SetIterator(this, ITERATOR_KIND_VALUES); | 131 var iterator = new SetIterator(this, ITERATOR_KIND_VALUES); |
132 var entry; | 132 var key; |
133 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 133 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
134 while (!(entry = %SetIteratorNext(iterator)).done) { | 134 var value_array = [UNDEFINED]; |
| 135 while (%SetIteratorNext(iterator, value_array)) { |
135 if (stepping) %DebugPrepareStepInIfStepping(f); | 136 if (stepping) %DebugPrepareStepInIfStepping(f); |
136 %_CallFunction(receiver, entry.value, entry.value, this, f); | 137 key = value_array[0]; |
| 138 %_CallFunction(receiver, key, key, this, f); |
137 } | 139 } |
138 } | 140 } |
139 | 141 |
140 | 142 |
141 // ------------------------------------------------------------------- | 143 // ------------------------------------------------------------------- |
142 | 144 |
143 function SetUpSet() { | 145 function SetUpSet() { |
144 %CheckIsBootstrapping(); | 146 %CheckIsBootstrapping(); |
145 | 147 |
146 %SetCode($Set, SetConstructor); | 148 %SetCode($Set, SetConstructor); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 if (!IS_MAP(this)) { | 259 if (!IS_MAP(this)) { |
258 throw MakeTypeError('incompatible_method_receiver', | 260 throw MakeTypeError('incompatible_method_receiver', |
259 ['Map.prototype.forEach', this]); | 261 ['Map.prototype.forEach', this]); |
260 } | 262 } |
261 | 263 |
262 if (!IS_SPEC_FUNCTION(f)) { | 264 if (!IS_SPEC_FUNCTION(f)) { |
263 throw MakeTypeError('called_non_callable', [f]); | 265 throw MakeTypeError('called_non_callable', [f]); |
264 } | 266 } |
265 | 267 |
266 var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES); | 268 var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES); |
267 var entry; | |
268 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 269 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
269 while (!(entry = %MapIteratorNext(iterator)).done) { | 270 var value_array = [UNDEFINED, UNDEFINED]; |
| 271 while (%MapIteratorNext(iterator, value_array)) { |
270 if (stepping) %DebugPrepareStepInIfStepping(f); | 272 if (stepping) %DebugPrepareStepInIfStepping(f); |
271 %_CallFunction(receiver, entry.value[1], entry.value[0], this, f); | 273 %_CallFunction(receiver, value_array[1], value_array[0], this, f); |
272 } | 274 } |
273 } | 275 } |
274 | 276 |
275 | 277 |
276 // ------------------------------------------------------------------- | 278 // ------------------------------------------------------------------- |
277 | 279 |
278 function SetUpMap() { | 280 function SetUpMap() { |
279 %CheckIsBootstrapping(); | 281 %CheckIsBootstrapping(); |
280 | 282 |
281 %SetCode($Map, MapConstructor); | 283 %SetCode($Map, MapConstructor); |
282 %FunctionSetPrototype($Map, new $Object()); | 284 %FunctionSetPrototype($Map, new $Object()); |
283 %SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM); | 285 %SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM); |
284 | 286 |
285 %FunctionSetLength(MapForEach, 1); | 287 %FunctionSetLength(MapForEach, 1); |
286 | 288 |
287 // Set up the non-enumerable functions on the Map prototype object. | 289 // Set up the non-enumerable functions on the Map prototype object. |
288 InstallGetter($Map.prototype, "size", MapGetSizeJS); | 290 InstallGetter($Map.prototype, "size", MapGetSizeJS); |
289 InstallFunctions($Map.prototype, DONT_ENUM, $Array( | 291 InstallFunctions($Map.prototype, DONT_ENUM, $Array( |
290 "get", MapGetJS, | 292 "get", MapGetJS, |
291 "set", MapSetJS, | 293 "set", MapSetJS, |
292 "has", MapHasJS, | 294 "has", MapHasJS, |
293 "delete", MapDeleteJS, | 295 "delete", MapDeleteJS, |
294 "clear", MapClearJS, | 296 "clear", MapClearJS, |
295 "forEach", MapForEach | 297 "forEach", MapForEach |
296 )); | 298 )); |
297 } | 299 } |
298 | 300 |
299 SetUpMap(); | 301 SetUpMap(); |
OLD | NEW |