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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 53 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
54 for (var i = 0; i < length; i++) { | 54 for (var i = 0; i < length; i++) { |
55 var element = this[i]; | 55 var element = this[i]; |
56 // Prepare break slots for debugger step in. | 56 // Prepare break slots for debugger step in. |
57 if (stepping) %DebugPrepareStepInIfStepping(f); | 57 if (stepping) %DebugPrepareStepInIfStepping(f); |
58 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; | 58 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; |
59 %_CallFunction(new_receiver, TO_OBJECT_INLINE(element), i, this, f); | 59 %_CallFunction(new_receiver, TO_OBJECT_INLINE(element), i, this, f); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
| 63 // ES6 draft 05-05-15, section 22.2.3.12 |
| 64 function NAMEEvery(f /* thisArg */) { // length == 1 |
| 65 if (!%IsTypedArray(this)) { |
| 66 throw MakeTypeError('not_typed_array', []); |
| 67 } |
| 68 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 69 |
| 70 var length = %_TypedArrayGetLength(this); |
| 71 var receiver; |
| 72 |
| 73 if (%_ArgumentsLength() > 1) { |
| 74 receiver = %_Arguments(1); |
| 75 } |
| 76 |
| 77 var needs_wrapper = false; |
| 78 if (IS_NULL_OR_UNDEFINED(receiver)) { |
| 79 receiver = %GetDefaultReceiver(f) || receiver; |
| 80 } else { |
| 81 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
| 82 } |
| 83 |
| 84 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
| 85 for (var i = 0; i < length; i++) { |
| 86 var element = this[i]; |
| 87 // Prepare break slots for debugger step in. |
| 88 if (stepping) %DebugPrepareStepInIfStepping(f); |
| 89 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; |
| 90 if (!%_CallFunction(new_receiver, TO_OBJECT_INLINE(element), i, this, f)) { |
| 91 return false; |
| 92 } |
| 93 } |
| 94 return true; |
| 95 } |
| 96 |
63 // ES6 draft 08-24-14, section 22.2.2.2 | 97 // ES6 draft 08-24-14, section 22.2.2.2 |
64 function NAMEOf() { // length == 0 | 98 function NAMEOf() { // length == 0 |
65 var length = %_ArgumentsLength(); | 99 var length = %_ArgumentsLength(); |
66 var array = new this(length); | 100 var array = new this(length); |
67 for (var i = 0; i < length; i++) { | 101 for (var i = 0; i < length; i++) { |
68 array[i] = %_Arguments(i); | 102 array[i] = %_Arguments(i); |
69 } | 103 } |
70 return array; | 104 return array; |
71 } | 105 } |
72 | 106 |
73 endmacro | 107 endmacro |
74 | 108 |
75 TYPED_ARRAYS(TYPED_ARRAY_HARMONY_ADDITIONS) | 109 TYPED_ARRAYS(TYPED_ARRAY_HARMONY_ADDITIONS) |
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, [ |
86 "forEach", NAMEForEach | 120 "forEach", NAMEForEach, |
| 121 "every", NAMEEvery |
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 |