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 var $getHash; | 5 var $getHash; |
6 var $getExistingHash; | 6 var $getExistingHash; |
7 | 7 |
8 (function(global, utils) { | 8 (function(global, utils) { |
9 "use strict"; | 9 "use strict"; |
10 | 10 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 function SetConstructor(iterable) { | 128 function SetConstructor(iterable) { |
129 if (!%_IsConstructCall()) { | 129 if (!%_IsConstructCall()) { |
130 throw MakeTypeError(kConstructorNotFunction, "Set"); | 130 throw MakeTypeError(kConstructorNotFunction, "Set"); |
131 } | 131 } |
132 | 132 |
133 %_SetInitialize(this); | 133 %_SetInitialize(this); |
134 | 134 |
135 if (!IS_NULL_OR_UNDEFINED(iterable)) { | 135 if (!IS_NULL_OR_UNDEFINED(iterable)) { |
136 var adder = this.add; | 136 var adder = this.add; |
137 if (!IS_SPEC_FUNCTION(adder)) { | 137 if (!IS_CALLABLE(adder)) { |
138 throw MakeTypeError(kPropertyNotFunction, 'add', this); | 138 throw MakeTypeError(kPropertyNotFunction, 'add', this); |
139 } | 139 } |
140 | 140 |
141 for (var value of iterable) { | 141 for (var value of iterable) { |
142 %_CallFunction(this, value, adder); | 142 %_CallFunction(this, value, adder); |
143 } | 143 } |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 | 147 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 %_SetClear(this); | 238 %_SetClear(this); |
239 } | 239 } |
240 | 240 |
241 | 241 |
242 function SetForEach(f, receiver) { | 242 function SetForEach(f, receiver) { |
243 if (!IS_SET(this)) { | 243 if (!IS_SET(this)) { |
244 throw MakeTypeError(kIncompatibleMethodReceiver, | 244 throw MakeTypeError(kIncompatibleMethodReceiver, |
245 'Set.prototype.forEach', this); | 245 'Set.prototype.forEach', this); |
246 } | 246 } |
247 | 247 |
248 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 248 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); |
249 var needs_wrapper = false; | 249 var needs_wrapper = false; |
250 if (IS_NULL(receiver)) { | 250 if (IS_NULL(receiver)) { |
251 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; | 251 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
252 } else if (!IS_UNDEFINED(receiver)) { | 252 } else if (!IS_UNDEFINED(receiver)) { |
253 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 253 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
254 } | 254 } |
255 | 255 |
256 var iterator = new SetIterator(this, ITERATOR_KIND_VALUES); | 256 var iterator = new SetIterator(this, ITERATOR_KIND_VALUES); |
257 var key; | 257 var key; |
258 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 258 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 292 |
293 function MapConstructor(iterable) { | 293 function MapConstructor(iterable) { |
294 if (!%_IsConstructCall()) { | 294 if (!%_IsConstructCall()) { |
295 throw MakeTypeError(kConstructorNotFunction, "Map"); | 295 throw MakeTypeError(kConstructorNotFunction, "Map"); |
296 } | 296 } |
297 | 297 |
298 %_MapInitialize(this); | 298 %_MapInitialize(this); |
299 | 299 |
300 if (!IS_NULL_OR_UNDEFINED(iterable)) { | 300 if (!IS_NULL_OR_UNDEFINED(iterable)) { |
301 var adder = this.set; | 301 var adder = this.set; |
302 if (!IS_SPEC_FUNCTION(adder)) { | 302 if (!IS_CALLABLE(adder)) { |
303 throw MakeTypeError(kPropertyNotFunction, 'set', this); | 303 throw MakeTypeError(kPropertyNotFunction, 'set', this); |
304 } | 304 } |
305 | 305 |
306 for (var nextItem of iterable) { | 306 for (var nextItem of iterable) { |
307 if (!IS_SPEC_OBJECT(nextItem)) { | 307 if (!IS_SPEC_OBJECT(nextItem)) { |
308 throw MakeTypeError(kIteratorValueNotAnObject, nextItem); | 308 throw MakeTypeError(kIteratorValueNotAnObject, nextItem); |
309 } | 309 } |
310 %_CallFunction(this, nextItem[0], nextItem[1], adder); | 310 %_CallFunction(this, nextItem[0], nextItem[1], adder); |
311 } | 311 } |
312 } | 312 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 %_MapClear(this); | 429 %_MapClear(this); |
430 } | 430 } |
431 | 431 |
432 | 432 |
433 function MapForEach(f, receiver) { | 433 function MapForEach(f, receiver) { |
434 if (!IS_MAP(this)) { | 434 if (!IS_MAP(this)) { |
435 throw MakeTypeError(kIncompatibleMethodReceiver, | 435 throw MakeTypeError(kIncompatibleMethodReceiver, |
436 'Map.prototype.forEach', this); | 436 'Map.prototype.forEach', this); |
437 } | 437 } |
438 | 438 |
439 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 439 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); |
440 var needs_wrapper = false; | 440 var needs_wrapper = false; |
441 if (IS_NULL(receiver)) { | 441 if (IS_NULL(receiver)) { |
442 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; | 442 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
443 } else if (!IS_UNDEFINED(receiver)) { | 443 } else if (!IS_UNDEFINED(receiver)) { |
444 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 444 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
445 } | 445 } |
446 | 446 |
447 var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES); | 447 var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES); |
448 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 448 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
449 var value_array = [UNDEFINED, UNDEFINED]; | 449 var value_array = [UNDEFINED, UNDEFINED]; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 "map_has", MapHas, | 509 "map_has", MapHas, |
510 "map_delete", MapDelete, | 510 "map_delete", MapDelete, |
511 "set_add", SetAdd, | 511 "set_add", SetAdd, |
512 "set_has", SetHas, | 512 "set_has", SetHas, |
513 "set_delete", SetDelete, | 513 "set_delete", SetDelete, |
514 "map_from_array", MapFromArray, | 514 "map_from_array", MapFromArray, |
515 "set_from_array",SetFromArray, | 515 "set_from_array",SetFromArray, |
516 ]); | 516 ]); |
517 | 517 |
518 }) | 518 }) |
OLD | NEW |