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 (function(global, utils) { | 5 (function(global, utils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 } | 123 } |
124 if (!initialized) { | 124 if (!initialized) { |
125 for (var i = 0; i < l; i++) { | 125 for (var i = 0; i < l; i++) { |
126 // It is crucial that we let any execptions from arrayLike[i] | 126 // It is crucial that we let any execptions from arrayLike[i] |
127 // propagate outside the function. | 127 // propagate outside the function. |
128 obj[i] = arrayLike[i]; | 128 obj[i] = arrayLike[i]; |
129 } | 129 } |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 function NAMEConstructByIterable(obj, iterable) { | |
134 var list = new InternalArray(); | |
135 for (var element of iterable) { | |
136 list.push(element); | |
137 } | |
138 return NAMEConstructByArrayLike(obj, list); | |
139 } | |
140 | |
133 function NAMEConstructor(arg1, arg2, arg3) { | 141 function NAMEConstructor(arg1, arg2, arg3) { |
134 if (%_IsConstructCall()) { | 142 if (%_IsConstructCall()) { |
135 if (IS_ARRAYBUFFER(arg1) || IS_SHAREDARRAYBUFFER(arg1)) { | 143 if (IS_ARRAYBUFFER(arg1) || IS_SHAREDARRAYBUFFER(arg1)) { |
136 NAMEConstructByArrayBuffer(this, arg1, arg2, arg3); | 144 NAMEConstructByArrayBuffer(this, arg1, arg2, arg3); |
137 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) || | 145 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) || |
138 IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) { | 146 IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) { |
139 NAMEConstructByLength(this, arg1); | 147 NAMEConstructByLength(this, arg1); |
140 } else { | 148 } else { |
141 NAMEConstructByArrayLike(this, arg1); | 149 var iteratorFn = arg1[Symbol.iterator]; |
150 if (IS_UNDEFINED(iteratorFn) || iteratorFn === $arrayValues) { | |
151 NAMEConstructByArrayLike(this, arg1); | |
152 } else { | |
153 // TODO(littledan): The code here is lazy and looks up @@iterator | |
154 // twice. Currently, that's fine, but it'll be observable with proxies. | |
adamk
2015/06/12 00:57:08
Proxies aren't required, a getter for @@iterator i
caitp (gmail)
2015/06/12 01:11:33
I think the only way to really fix that currently
Dan Ehrenberg
2015/06/12 02:42:22
Well, you can use for-of on most of the builtin it
| |
155 NAMEConstructByIterable(this, arg1); | |
156 } | |
142 } | 157 } |
143 } else { | 158 } else { |
144 throw MakeTypeError(kConstructorNotFunction, "NAME") | 159 throw MakeTypeError(kConstructorNotFunction, "NAME") |
145 } | 160 } |
146 } | 161 } |
147 | 162 |
148 function NAME_GetBuffer() { | 163 function NAME_GetBuffer() { |
149 if (!(%_ClassOf(this) === 'NAME')) { | 164 if (!(%_ClassOf(this) === 'NAME')) { |
150 throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.buffer", this); | 165 throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.buffer", this); |
151 } | 166 } |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 "setUint32", DataViewSetUint32JS, | 488 "setUint32", DataViewSetUint32JS, |
474 | 489 |
475 "getFloat32", DataViewGetFloat32JS, | 490 "getFloat32", DataViewGetFloat32JS, |
476 "setFloat32", DataViewSetFloat32JS, | 491 "setFloat32", DataViewSetFloat32JS, |
477 | 492 |
478 "getFloat64", DataViewGetFloat64JS, | 493 "getFloat64", DataViewGetFloat64JS, |
479 "setFloat64", DataViewSetFloat64JS | 494 "setFloat64", DataViewSetFloat64JS |
480 ]); | 495 ]); |
481 | 496 |
482 }) | 497 }) |
OLD | NEW |