Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: src/collection.js

Issue 259883002: ES6: Add support for Map and Set Iterator (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code review changes Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/bootstrapper.cc ('k') | src/collection-iterator.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 function SetForEach(f, receiver) { 72 function SetForEach(f, receiver) {
73 if (!IS_SET(this)) { 73 if (!IS_SET(this)) {
74 throw MakeTypeError('incompatible_method_receiver', 74 throw MakeTypeError('incompatible_method_receiver',
75 ['Set.prototype.forEach', this]); 75 ['Set.prototype.forEach', this]);
76 } 76 }
77 77
78 if (!IS_SPEC_FUNCTION(f)) { 78 if (!IS_SPEC_FUNCTION(f)) {
79 throw MakeTypeError('called_non_callable', [f]); 79 throw MakeTypeError('called_non_callable', [f]);
80 } 80 }
81 81
82 var iterator = %SetCreateIterator(this, ITERATOR_KIND_VALUES); 82 var iterator = new SetIterator(this, ITERATOR_KIND_VALUES);
83 var entry; 83 var entry;
84 var stepping = %_DebugCallbackSupportsStepping(f); 84 var stepping = %_DebugCallbackSupportsStepping(f);
85 while (!(entry = %SetIteratorNext(iterator)).done) { 85 while (!(entry = %SetIteratorNext(iterator)).done) {
86 if (stepping) %DebugPrepareStepInIfStepping(f); 86 if (stepping) %DebugPrepareStepInIfStepping(f);
87 %_CallFunction(receiver, entry.value, entry.value, this, f); 87 %_CallFunction(receiver, entry.value, entry.value, this, f);
88 } 88 }
89 } 89 }
90 90
91 91
92 // ------------------------------------------------------------------- 92 // -------------------------------------------------------------------
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 function MapForEach(f, receiver) { 183 function MapForEach(f, receiver) {
184 if (!IS_MAP(this)) { 184 if (!IS_MAP(this)) {
185 throw MakeTypeError('incompatible_method_receiver', 185 throw MakeTypeError('incompatible_method_receiver',
186 ['Map.prototype.forEach', this]); 186 ['Map.prototype.forEach', this]);
187 } 187 }
188 188
189 if (!IS_SPEC_FUNCTION(f)) { 189 if (!IS_SPEC_FUNCTION(f)) {
190 throw MakeTypeError('called_non_callable', [f]); 190 throw MakeTypeError('called_non_callable', [f]);
191 } 191 }
192 192
193 var iterator = %MapCreateIterator(this, ITERATOR_KIND_ENTRIES); 193 var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES);
194 var entry; 194 var entry;
195 var stepping = %_DebugCallbackSupportsStepping(f); 195 var stepping = %_DebugCallbackSupportsStepping(f);
196 while (!(entry = %MapIteratorNext(iterator)).done) { 196 while (!(entry = %MapIteratorNext(iterator)).done) {
197 if (stepping) %DebugPrepareStepInIfStepping(f); 197 if (stepping) %DebugPrepareStepInIfStepping(f);
198 %_CallFunction(receiver, entry.value[1], entry.value[0], this, f); 198 %_CallFunction(receiver, entry.value[1], entry.value[0], this, f);
199 } 199 }
200 } 200 }
201 201
202 202
203 // ------------------------------------------------------------------- 203 // -------------------------------------------------------------------
(...skipping 13 matching lines...) Expand all
217 "get", MapGetJS, 217 "get", MapGetJS,
218 "set", MapSetJS, 218 "set", MapSetJS,
219 "has", MapHasJS, 219 "has", MapHasJS,
220 "delete", MapDeleteJS, 220 "delete", MapDeleteJS,
221 "clear", MapClearJS, 221 "clear", MapClearJS,
222 "forEach", MapForEach 222 "forEach", MapForEach
223 )); 223 ));
224 } 224 }
225 225
226 SetUpMap(); 226 SetUpMap();
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/collection-iterator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698