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

Side by Side Diff: src/weak-collection.js

Issue 1316933002: [es6] Initial steps towards a correct implementation of IsCallable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase again. Created 5 years, 3 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
« no previous file with comments | « src/v8natives.js ('k') | src/x64/lithium-codegen-x64.cc » ('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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 var GlobalObject = global.Object; 11 var GlobalObject = global.Object;
12 var GlobalWeakMap = global.WeakMap; 12 var GlobalWeakMap = global.WeakMap;
13 var GlobalWeakSet = global.WeakSet; 13 var GlobalWeakSet = global.WeakSet;
14 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); 14 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
15 15
16 // ------------------------------------------------------------------- 16 // -------------------------------------------------------------------
17 // Harmony WeakMap 17 // Harmony WeakMap
18 18
19 function WeakMapConstructor(iterable) { 19 function WeakMapConstructor(iterable) {
20 if (!%_IsConstructCall()) { 20 if (!%_IsConstructCall()) {
21 throw MakeTypeError(kConstructorNotFunction, "WeakMap"); 21 throw MakeTypeError(kConstructorNotFunction, "WeakMap");
22 } 22 }
23 23
24 %WeakCollectionInitialize(this); 24 %WeakCollectionInitialize(this);
25 25
26 if (!IS_NULL_OR_UNDEFINED(iterable)) { 26 if (!IS_NULL_OR_UNDEFINED(iterable)) {
27 var adder = this.set; 27 var adder = this.set;
28 if (!IS_SPEC_FUNCTION(adder)) { 28 if (!IS_CALLABLE(adder)) {
29 throw MakeTypeError(kPropertyNotFunction, 'set', this); 29 throw MakeTypeError(kPropertyNotFunction, 'set', this);
30 } 30 }
31 for (var nextItem of iterable) { 31 for (var nextItem of iterable) {
32 if (!IS_SPEC_OBJECT(nextItem)) { 32 if (!IS_SPEC_OBJECT(nextItem)) {
33 throw MakeTypeError(kIteratorValueNotAnObject, nextItem); 33 throw MakeTypeError(kIteratorValueNotAnObject, nextItem);
34 } 34 }
35 %_CallFunction(this, nextItem[0], nextItem[1], adder); 35 %_CallFunction(this, nextItem[0], nextItem[1], adder);
36 } 36 }
37 } 37 }
38 } 38 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 function WeakSetConstructor(iterable) { 108 function WeakSetConstructor(iterable) {
109 if (!%_IsConstructCall()) { 109 if (!%_IsConstructCall()) {
110 throw MakeTypeError(kConstructorNotFunction, "WeakSet"); 110 throw MakeTypeError(kConstructorNotFunction, "WeakSet");
111 } 111 }
112 112
113 %WeakCollectionInitialize(this); 113 %WeakCollectionInitialize(this);
114 114
115 if (!IS_NULL_OR_UNDEFINED(iterable)) { 115 if (!IS_NULL_OR_UNDEFINED(iterable)) {
116 var adder = this.add; 116 var adder = this.add;
117 if (!IS_SPEC_FUNCTION(adder)) { 117 if (!IS_CALLABLE(adder)) {
118 throw MakeTypeError(kPropertyNotFunction, 'add', this); 118 throw MakeTypeError(kPropertyNotFunction, 'add', this);
119 } 119 }
120 for (var value of iterable) { 120 for (var value of iterable) {
121 %_CallFunction(this, value, adder); 121 %_CallFunction(this, value, adder);
122 } 122 }
123 } 123 }
124 } 124 }
125 125
126 126
127 function WeakSetAdd(value) { 127 function WeakSetAdd(value) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 DONT_ENUM | READ_ONLY); 169 DONT_ENUM | READ_ONLY);
170 170
171 // Set up the non-enumerable functions on the WeakSet prototype object. 171 // Set up the non-enumerable functions on the WeakSet prototype object.
172 utils.InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ 172 utils.InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [
173 "add", WeakSetAdd, 173 "add", WeakSetAdd,
174 "has", WeakSetHas, 174 "has", WeakSetHas,
175 "delete", WeakSetDelete 175 "delete", WeakSetDelete
176 ]); 176 ]);
177 177
178 }) 178 })
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698