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 (function() { | 5 (function() { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 macro DECLARE_GLOBALS(INDEX, NAME, SIZE) | 24 macro DECLARE_GLOBALS(INDEX, NAME, SIZE) |
25 var GlobalNAME = global.NAME; | 25 var GlobalNAME = global.NAME; |
26 endmacro | 26 endmacro |
27 | 27 |
28 TYPED_ARRAYS(DECLARE_GLOBALS) | 28 TYPED_ARRAYS(DECLARE_GLOBALS) |
29 | 29 |
30 // ------------------------------------------------------------------- | 30 // ------------------------------------------------------------------- |
31 | 31 |
32 macro TYPED_ARRAY_HARMONY_ADDITIONS(ARRAY_ID, NAME, ELEMENT_SIZE) | 32 macro TYPED_ARRAY_HARMONY_ADDITIONS(ARRAY_ID, NAME, ELEMENT_SIZE) |
33 | 33 |
| 34 // ES6 draft 05-05-15, section 22.2.3.7 |
| 35 function NAMEEvery(f /* thisArg */) { // length == 1 |
| 36 if (!%IsTypedArray(this)) { |
| 37 throw MakeTypeError('not_typed_array', []); |
| 38 } |
| 39 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 40 |
| 41 var length = %_TypedArrayGetLength(this); |
| 42 var receiver; |
| 43 |
| 44 if (%_ArgumentsLength() > 1) { |
| 45 receiver = %_Arguments(1); |
| 46 } |
| 47 |
| 48 var needs_wrapper = false; |
| 49 if (IS_NULL(receiver)) { |
| 50 if (%IsSloppyModeFunction(mapfn)) receiver = UNDEFINED; |
| 51 } else if (!IS_UNDEFINED(receiver)) { |
| 52 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
| 53 } |
| 54 |
| 55 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
| 56 for (var i = 0; i < length; i++) { |
| 57 var element = this[i]; |
| 58 // Prepare break slots for debugger step in. |
| 59 if (stepping) %DebugPrepareStepInIfStepping(f); |
| 60 var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; |
| 61 if (!%_CallFunction(new_receiver, TO_OBJECT_INLINE(element), i, this, f)) { |
| 62 return false; |
| 63 } |
| 64 } |
| 65 return true; |
| 66 } |
| 67 |
34 // ES6 draft 08-24-14, section 22.2.3.12 | 68 // ES6 draft 08-24-14, section 22.2.3.12 |
35 function NAMEForEach(f /* thisArg */) { // length == 1 | 69 function NAMEForEach(f /* thisArg */) { // length == 1 |
36 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); | 70 if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); |
37 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 71 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
38 | 72 |
39 var length = %_TypedArrayGetLength(this); | 73 var length = %_TypedArrayGetLength(this); |
40 var receiver; | 74 var receiver; |
41 | 75 |
42 if (%_ArgumentsLength() > 1) { | 76 if (%_ArgumentsLength() > 1) { |
43 receiver = %_Arguments(1); | 77 receiver = %_Arguments(1); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 110 |
77 | 111 |
78 macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) | 112 macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) |
79 // Set up non-enumerable functions on the object. | 113 // Set up non-enumerable functions on the object. |
80 $installFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [ | 114 $installFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [ |
81 "of", NAMEOf | 115 "of", NAMEOf |
82 ]); | 116 ]); |
83 | 117 |
84 // Set up non-enumerable functions on the prototype object. | 118 // Set up non-enumerable functions on the prototype object. |
85 $installFunctions(GlobalNAME.prototype, DONT_ENUM, [ | 119 $installFunctions(GlobalNAME.prototype, DONT_ENUM, [ |
| 120 "every", NAMEEvery, |
86 "forEach", NAMEForEach | 121 "forEach", NAMEForEach |
87 ]); | 122 ]); |
88 endmacro | 123 endmacro |
89 | 124 |
90 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) | 125 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) |
91 | 126 |
92 })(); | 127 })(); |
OLD | NEW |