OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 if (mapping) { | 135 if (mapping) { |
136 if (!IS_SPEC_FUNCTION(mapfn)) { | 136 if (!IS_SPEC_FUNCTION(mapfn)) { |
137 throw MakeTypeError('called_non_callable', [ mapfn ]); | 137 throw MakeTypeError('called_non_callable', [ mapfn ]); |
138 } else if (IS_NULL_OR_UNDEFINED(receiver)) { | 138 } else if (IS_NULL_OR_UNDEFINED(receiver)) { |
139 receiver = %GetDefaultReceiver(mapfn) || receiver; | 139 receiver = %GetDefaultReceiver(mapfn) || receiver; |
140 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(mapfn)) { | 140 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(mapfn)) { |
141 receiver = ToObject(receiver); | 141 receiver = ToObject(receiver); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 var iterable = ToIterable(items); | 145 var iterable = GetMethod(items, symbolIterator); |
arv (Not doing code reviews)
2015/01/21 15:05:18
We now call items.[[Get]](symbolIterator) twice. T
caitp (gmail)
2015/01/21 17:21:49
hmm, well it's trivial to replace the for...of wit
| |
146 var k; | 146 var k; |
147 var result; | 147 var result; |
148 var mappedValue; | 148 var mappedValue; |
149 var nextValue; | 149 var nextValue; |
150 | 150 |
151 if (!IS_UNDEFINED(iterable)) { | 151 if (!IS_UNDEFINED(iterable)) { |
152 result = %IsConstructor(this) ? new this() : []; | 152 result = %IsConstructor(this) ? new this() : []; |
153 | 153 |
154 k = 0; | 154 k = 0; |
155 for (nextValue of items) { | 155 for (nextValue of items) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 | 215 |
216 // Set up the non-enumerable functions on the Array prototype object. | 216 // Set up the non-enumerable functions on the Array prototype object. |
217 InstallFunctions($Array.prototype, DONT_ENUM, $Array( | 217 InstallFunctions($Array.prototype, DONT_ENUM, $Array( |
218 "find", ArrayFind, | 218 "find", ArrayFind, |
219 "findIndex", ArrayFindIndex, | 219 "findIndex", ArrayFindIndex, |
220 "fill", ArrayFill | 220 "fill", ArrayFill |
221 )); | 221 )); |
222 } | 222 } |
223 | 223 |
224 HarmonyArrayExtendArrayPrototype(); | 224 HarmonyArrayExtendArrayPrototype(); |
OLD | NEW |