OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 13 matching lines...) Expand all Loading... |
24 endmacro | 24 endmacro |
25 | 25 |
26 | 26 |
27 macro TYPED_ARRAY_HARMONY_ADDITIONS(ARRAY_ID, NAME, ELEMENT_SIZE) | 27 macro TYPED_ARRAY_HARMONY_ADDITIONS(ARRAY_ID, NAME, ELEMENT_SIZE) |
28 | 28 |
29 // ES6 draft 08-24-14, section 22.2.3.12 | 29 // ES6 draft 08-24-14, section 22.2.3.12 |
30 function NAMEForEach(f /* thisArg */) { // length == 1 | 30 function NAMEForEach(f /* thisArg */) { // length == 1 |
31 if (!%IsTypedArray(this)) { | 31 if (!%IsTypedArray(this)) { |
32 throw MakeTypeError('not_typed_array', []); | 32 throw MakeTypeError('not_typed_array', []); |
33 } | 33 } |
34 if (!IS_SPEC_FUNCTION(f)) { | 34 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
35 throw MakeTypeError('called_non_callable', [ f ]); | |
36 } | |
37 | 35 |
38 var length = %_TypedArrayGetLength(this); | 36 var length = %_TypedArrayGetLength(this); |
39 var receiver; | 37 var receiver; |
40 | 38 |
41 if (%_ArgumentsLength() > 1) { | 39 if (%_ArgumentsLength() > 1) { |
42 receiver = %_Arguments(1); | 40 receiver = %_Arguments(1); |
43 } | 41 } |
44 | 42 |
45 var needs_wrapper = false; | 43 var needs_wrapper = false; |
46 if (IS_NULL_OR_UNDEFINED(receiver)) { | 44 if (IS_NULL_OR_UNDEFINED(receiver)) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // Set up non-enumerable functions on the prototype object. | 84 // Set up non-enumerable functions on the prototype object. |
87 InstallFunctions(global.NAME.prototype, DONT_ENUM, [ | 85 InstallFunctions(global.NAME.prototype, DONT_ENUM, [ |
88 "forEach", NAMEForEach | 86 "forEach", NAMEForEach |
89 ]); | 87 ]); |
90 endmacro | 88 endmacro |
91 | 89 |
92 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) | 90 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) |
93 } | 91 } |
94 | 92 |
95 HarmonyTypedArrayExtendPrototypes(); | 93 HarmonyTypedArrayExtendPrototypes(); |
OLD | NEW |