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

Side by Side Diff: src/collection.js

Issue 466003002: ES6: Make Map/Set constructors support iterable values (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | « no previous file | src/weak_collection.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
11 var $Set = global.Set; 11 var $Set = global.Set;
12 var $Map = global.Map; 12 var $Map = global.Map;
13 13
14 14
15 // ------------------------------------------------------------------- 15 // -------------------------------------------------------------------
16 // Harmony Set 16 // Harmony Set
17 17
18 function SetConstructor(iterable) { 18 function SetConstructor(iterable) {
19 if (!%_IsConstructCall()) { 19 if (!%_IsConstructCall()) {
20 throw MakeTypeError('constructor_not_function', ['Set']); 20 throw MakeTypeError('constructor_not_function', ['Set']);
21 } 21 }
22 22
23 var iter, adder; 23 var iter, adder;
24 24
25 if (!IS_NULL_OR_UNDEFINED(iterable)) { 25 if (!IS_NULL_OR_UNDEFINED(iterable)) {
26 iter = GetIterator(iterable); 26 iter = GetIterator(ToObject(iterable));
27 adder = this.add; 27 adder = this.add;
28 if (!IS_SPEC_FUNCTION(adder)) { 28 if (!IS_SPEC_FUNCTION(adder)) {
29 throw MakeTypeError('property_not_function', ['add', this]); 29 throw MakeTypeError('property_not_function', ['add', this]);
30 } 30 }
31 } 31 }
32 32
33 %SetInitialize(this); 33 %SetInitialize(this);
34 34
35 if (IS_UNDEFINED(iter)) return; 35 if (IS_UNDEFINED(iter)) return;
36 36
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // Harmony Map 140 // Harmony Map
141 141
142 function MapConstructor(iterable) { 142 function MapConstructor(iterable) {
143 if (!%_IsConstructCall()) { 143 if (!%_IsConstructCall()) {
144 throw MakeTypeError('constructor_not_function', ['Map']); 144 throw MakeTypeError('constructor_not_function', ['Map']);
145 } 145 }
146 146
147 var iter, adder; 147 var iter, adder;
148 148
149 if (!IS_NULL_OR_UNDEFINED(iterable)) { 149 if (!IS_NULL_OR_UNDEFINED(iterable)) {
150 iter = GetIterator(iterable); 150 iter = GetIterator(ToObject(iterable));
151 adder = this.set; 151 adder = this.set;
152 if (!IS_SPEC_FUNCTION(adder)) { 152 if (!IS_SPEC_FUNCTION(adder)) {
153 throw MakeTypeError('property_not_function', ['set', this]); 153 throw MakeTypeError('property_not_function', ['set', this]);
154 } 154 }
155 } 155 }
156 156
157 %MapInitialize(this); 157 %MapInitialize(this);
158 158
159 if (IS_UNDEFINED(iter)) return; 159 if (IS_UNDEFINED(iter)) return;
160 160
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 "get", MapGetJS, 263 "get", MapGetJS,
264 "set", MapSetJS, 264 "set", MapSetJS,
265 "has", MapHasJS, 265 "has", MapHasJS,
266 "delete", MapDeleteJS, 266 "delete", MapDeleteJS,
267 "clear", MapClearJS, 267 "clear", MapClearJS,
268 "forEach", MapForEach 268 "forEach", MapForEach
269 )); 269 ));
270 } 270 }
271 271
272 SetUpMap(); 272 SetUpMap();
OLDNEW
« no previous file with comments | « no previous file | src/weak_collection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698