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

Side by Side Diff: src/weak_collection.js

Issue 464093002: ES6: Make Map/Set constructors support iterable values (Closed) Base URL: https://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 | « src/ic.cc ('k') | test/mjsunit/es6/collections.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 $WeakMap = global.WeakMap; 11 var $WeakMap = global.WeakMap;
12 var $WeakSet = global.WeakSet; 12 var $WeakSet = global.WeakSet;
13 13
14 14
15 // ------------------------------------------------------------------- 15 // -------------------------------------------------------------------
16 // Harmony WeakMap 16 // Harmony WeakMap
17 17
18 function WeakMapConstructor(iterable) { 18 function WeakMapConstructor(iterable) {
19 if (!%_IsConstructCall()) { 19 if (!%_IsConstructCall()) {
20 throw MakeTypeError('constructor_not_function', ['WeakMap']); 20 throw MakeTypeError('constructor_not_function', ['WeakMap']);
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.set; 27 adder = this.set;
28 if (!IS_SPEC_FUNCTION(adder)) { 28 if (!IS_SPEC_FUNCTION(adder)) {
29 throw MakeTypeError('property_not_function', ['set', this]); 29 throw MakeTypeError('property_not_function', ['set', this]);
30 } 30 }
31 } 31 }
32 32
33 %WeakCollectionInitialize(this); 33 %WeakCollectionInitialize(this);
34 34
35 if (IS_UNDEFINED(iter)) return; 35 if (IS_UNDEFINED(iter)) return;
36 36
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Harmony WeakSet 132 // Harmony WeakSet
133 133
134 function WeakSetConstructor(iterable) { 134 function WeakSetConstructor(iterable) {
135 if (!%_IsConstructCall()) { 135 if (!%_IsConstructCall()) {
136 throw MakeTypeError('constructor_not_function', ['WeakSet']); 136 throw MakeTypeError('constructor_not_function', ['WeakSet']);
137 } 137 }
138 138
139 var iter, adder; 139 var iter, adder;
140 140
141 if (!IS_NULL_OR_UNDEFINED(iterable)) { 141 if (!IS_NULL_OR_UNDEFINED(iterable)) {
142 iter = GetIterator(iterable); 142 iter = GetIterator(ToObject(iterable));
143 adder = this.add; 143 adder = this.add;
144 if (!IS_SPEC_FUNCTION(adder)) { 144 if (!IS_SPEC_FUNCTION(adder)) {
145 throw MakeTypeError('property_not_function', ['add', this]); 145 throw MakeTypeError('property_not_function', ['add', this]);
146 } 146 }
147 } 147 }
148 148
149 %WeakCollectionInitialize(this); 149 %WeakCollectionInitialize(this);
150 150
151 if (IS_UNDEFINED(iter)) return; 151 if (IS_UNDEFINED(iter)) return;
152 152
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // Set up the non-enumerable functions on the WeakSet prototype object. 218 // Set up the non-enumerable functions on the WeakSet prototype object.
219 InstallFunctions($WeakSet.prototype, DONT_ENUM, $Array( 219 InstallFunctions($WeakSet.prototype, DONT_ENUM, $Array(
220 "add", WeakSetAdd, 220 "add", WeakSetAdd,
221 "has", WeakSetHas, 221 "has", WeakSetHas,
222 "delete", WeakSetDelete, 222 "delete", WeakSetDelete,
223 "clear", WeakSetClear 223 "clear", WeakSetClear
224 )); 224 ));
225 } 225 }
226 226
227 SetUpWeakSet(); 227 SetUpWeakSet();
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | test/mjsunit/es6/collections.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698