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 20 matching lines...) Expand all Loading... |
31 var InnerArrayIndexOf; | 31 var InnerArrayIndexOf; |
32 var InnerArrayJoin; | 32 var InnerArrayJoin; |
33 var InnerArrayLastIndexOf; | 33 var InnerArrayLastIndexOf; |
34 var InnerArrayReduce; | 34 var InnerArrayReduce; |
35 var InnerArrayReduceRight; | 35 var InnerArrayReduceRight; |
36 var InnerArraySome; | 36 var InnerArraySome; |
37 var InnerArraySort; | 37 var InnerArraySort; |
38 var InnerArrayToLocaleString; | 38 var InnerArrayToLocaleString; |
39 var InternalArray = utils.InternalArray; | 39 var InternalArray = utils.InternalArray; |
40 var IsNaN; | 40 var IsNaN; |
41 var MakeRangeError; | |
42 var MakeTypeError; | |
43 var MaxSimple; | 41 var MaxSimple; |
44 var MinSimple; | 42 var MinSimple; |
45 var PackedArrayReverse; | 43 var PackedArrayReverse; |
46 var SpeciesConstructor; | 44 var SpeciesConstructor; |
47 var ToPositiveInteger; | 45 var ToPositiveInteger; |
48 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 46 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
49 var speciesSymbol = utils.ImportNow("species_symbol"); | 47 var speciesSymbol = utils.ImportNow("species_symbol"); |
50 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 48 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
51 | 49 |
52 macro TYPED_ARRAYS(FUNCTION) | 50 macro TYPED_ARRAYS(FUNCTION) |
(...skipping 30 matching lines...) Expand all Loading... |
83 InnerArrayForEach = from.InnerArrayForEach; | 81 InnerArrayForEach = from.InnerArrayForEach; |
84 InnerArrayIndexOf = from.InnerArrayIndexOf; | 82 InnerArrayIndexOf = from.InnerArrayIndexOf; |
85 InnerArrayJoin = from.InnerArrayJoin; | 83 InnerArrayJoin = from.InnerArrayJoin; |
86 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf; | 84 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf; |
87 InnerArrayReduce = from.InnerArrayReduce; | 85 InnerArrayReduce = from.InnerArrayReduce; |
88 InnerArrayReduceRight = from.InnerArrayReduceRight; | 86 InnerArrayReduceRight = from.InnerArrayReduceRight; |
89 InnerArraySome = from.InnerArraySome; | 87 InnerArraySome = from.InnerArraySome; |
90 InnerArraySort = from.InnerArraySort; | 88 InnerArraySort = from.InnerArraySort; |
91 InnerArrayToLocaleString = from.InnerArrayToLocaleString; | 89 InnerArrayToLocaleString = from.InnerArrayToLocaleString; |
92 IsNaN = from.IsNaN; | 90 IsNaN = from.IsNaN; |
93 MakeRangeError = from.MakeRangeError; | |
94 MakeTypeError = from.MakeTypeError; | |
95 MaxSimple = from.MaxSimple; | 91 MaxSimple = from.MaxSimple; |
96 MinSimple = from.MinSimple; | 92 MinSimple = from.MinSimple; |
97 PackedArrayReverse = from.PackedArrayReverse; | 93 PackedArrayReverse = from.PackedArrayReverse; |
98 SpeciesConstructor = from.SpeciesConstructor; | 94 SpeciesConstructor = from.SpeciesConstructor; |
99 ToPositiveInteger = from.ToPositiveInteger; | 95 ToPositiveInteger = from.ToPositiveInteger; |
100 }); | 96 }); |
101 | 97 |
102 // --------------- Typed Arrays --------------------- | 98 // --------------- Typed Arrays --------------------- |
103 | 99 |
104 function TypedArrayDefaultConstructor(typedArray) { | 100 function TypedArrayDefaultConstructor(typedArray) { |
105 switch (%_ClassOf(typedArray)) { | 101 switch (%_ClassOf(typedArray)) { |
106 macro TYPED_ARRAY_CONSTRUCTOR_CASE(ARRAY_ID, NAME, ELEMENT_SIZE) | 102 macro TYPED_ARRAY_CONSTRUCTOR_CASE(ARRAY_ID, NAME, ELEMENT_SIZE) |
107 case "NAME": | 103 case "NAME": |
108 return GlobalNAME; | 104 return GlobalNAME; |
109 endmacro | 105 endmacro |
110 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR_CASE) | 106 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR_CASE) |
111 } | 107 } |
112 // The TypeError should not be generated since all callers should | 108 // The TypeError should not be generated since all callers should |
113 // have already called ValidateTypedArray. | 109 // have already called ValidateTypedArray. |
114 throw MakeTypeError(kIncompatibleMethodReceiver, | 110 throw %make_type_error(kIncompatibleMethodReceiver, |
115 "TypedArrayDefaultConstructor", this); | 111 "TypedArrayDefaultConstructor", this); |
116 } | 112 } |
117 | 113 |
118 function TypedArrayCreate(constructor, arg0, arg1, arg2) { | 114 function TypedArrayCreate(constructor, arg0, arg1, arg2) { |
119 if (IS_UNDEFINED(arg1)) { | 115 if (IS_UNDEFINED(arg1)) { |
120 var newTypedArray = new constructor(arg0); | 116 var newTypedArray = new constructor(arg0); |
121 } else { | 117 } else { |
122 var newTypedArray = new constructor(arg0, arg1, arg2); | 118 var newTypedArray = new constructor(arg0, arg1, arg2); |
123 } | 119 } |
124 if (!IS_TYPEDARRAY(newTypedArray)) throw MakeTypeError(kNotTypedArray); | 120 if (!IS_TYPEDARRAY(newTypedArray)) throw %make_type_error(kNotTypedArray); |
125 // TODO(littledan): Check for being detached, here and elsewhere | 121 // TODO(littledan): Check for being detached, here and elsewhere |
126 // All callers where the first argument is a Number have no additional | 122 // All callers where the first argument is a Number have no additional |
127 // arguments. | 123 // arguments. |
128 if (IS_NUMBER(arg0) && %_TypedArrayGetLength(newTypedArray) < arg0) { | 124 if (IS_NUMBER(arg0) && %_TypedArrayGetLength(newTypedArray) < arg0) { |
129 throw MakeTypeError(kTypedArrayTooShort); | 125 throw %make_type_error(kTypedArrayTooShort); |
130 } | 126 } |
131 return newTypedArray; | 127 return newTypedArray; |
132 } | 128 } |
133 | 129 |
134 function TypedArraySpeciesCreate(exemplar, arg0, arg1, arg2, conservative) { | 130 function TypedArraySpeciesCreate(exemplar, arg0, arg1, arg2, conservative) { |
135 var defaultConstructor = TypedArrayDefaultConstructor(exemplar); | 131 var defaultConstructor = TypedArrayDefaultConstructor(exemplar); |
136 var constructor = SpeciesConstructor(exemplar, defaultConstructor, | 132 var constructor = SpeciesConstructor(exemplar, defaultConstructor, |
137 conservative); | 133 conservative); |
138 return TypedArrayCreate(constructor, arg0, arg1, arg2); | 134 return TypedArrayCreate(constructor, arg0, arg1, arg2); |
139 } | 135 } |
140 | 136 |
141 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) | 137 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) |
142 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { | 138 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { |
143 if (!IS_UNDEFINED(byteOffset)) { | 139 if (!IS_UNDEFINED(byteOffset)) { |
144 byteOffset = ToPositiveInteger(byteOffset, kInvalidTypedArrayLength); | 140 byteOffset = ToPositiveInteger(byteOffset, kInvalidTypedArrayLength); |
145 } | 141 } |
146 if (!IS_UNDEFINED(length)) { | 142 if (!IS_UNDEFINED(length)) { |
147 length = ToPositiveInteger(length, kInvalidTypedArrayLength); | 143 length = ToPositiveInteger(length, kInvalidTypedArrayLength); |
148 } | 144 } |
149 | 145 |
150 var bufferByteLength = %_ArrayBufferGetByteLength(buffer); | 146 var bufferByteLength = %_ArrayBufferGetByteLength(buffer); |
151 var offset; | 147 var offset; |
152 if (IS_UNDEFINED(byteOffset)) { | 148 if (IS_UNDEFINED(byteOffset)) { |
153 offset = 0; | 149 offset = 0; |
154 } else { | 150 } else { |
155 offset = byteOffset; | 151 offset = byteOffset; |
156 | 152 |
157 if (offset % ELEMENT_SIZE !== 0) { | 153 if (offset % ELEMENT_SIZE !== 0) { |
158 throw MakeRangeError(kInvalidTypedArrayAlignment, | 154 throw %make_range_error(kInvalidTypedArrayAlignment, |
159 "start offset", "NAME", ELEMENT_SIZE); | 155 "start offset", "NAME", ELEMENT_SIZE); |
160 } | 156 } |
161 if (offset > bufferByteLength) { | 157 if (offset > bufferByteLength) { |
162 throw MakeRangeError(kInvalidTypedArrayOffset); | 158 throw %make_range_error(kInvalidTypedArrayOffset); |
163 } | 159 } |
164 } | 160 } |
165 | 161 |
166 var newByteLength; | 162 var newByteLength; |
167 var newLength; | 163 var newLength; |
168 if (IS_UNDEFINED(length)) { | 164 if (IS_UNDEFINED(length)) { |
169 if (bufferByteLength % ELEMENT_SIZE !== 0) { | 165 if (bufferByteLength % ELEMENT_SIZE !== 0) { |
170 throw MakeRangeError(kInvalidTypedArrayAlignment, | 166 throw %make_range_error(kInvalidTypedArrayAlignment, |
171 "byte length", "NAME", ELEMENT_SIZE); | 167 "byte length", "NAME", ELEMENT_SIZE); |
172 } | 168 } |
173 newByteLength = bufferByteLength - offset; | 169 newByteLength = bufferByteLength - offset; |
174 newLength = newByteLength / ELEMENT_SIZE; | 170 newLength = newByteLength / ELEMENT_SIZE; |
175 } else { | 171 } else { |
176 var newLength = length; | 172 var newLength = length; |
177 newByteLength = newLength * ELEMENT_SIZE; | 173 newByteLength = newLength * ELEMENT_SIZE; |
178 } | 174 } |
179 if ((offset + newByteLength > bufferByteLength) | 175 if ((offset + newByteLength > bufferByteLength) |
180 || (newLength > %_MaxSmi())) { | 176 || (newLength > %_MaxSmi())) { |
181 throw MakeRangeError(kInvalidTypedArrayLength); | 177 throw %make_range_error(kInvalidTypedArrayLength); |
182 } | 178 } |
183 %_TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength, true); | 179 %_TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength, true); |
184 } | 180 } |
185 | 181 |
186 function NAMEConstructByLength(obj, length) { | 182 function NAMEConstructByLength(obj, length) { |
187 var l = IS_UNDEFINED(length) ? | 183 var l = IS_UNDEFINED(length) ? |
188 0 : ToPositiveInteger(length, kInvalidTypedArrayLength); | 184 0 : ToPositiveInteger(length, kInvalidTypedArrayLength); |
189 if (l > %_MaxSmi()) { | 185 if (l > %_MaxSmi()) { |
190 throw MakeRangeError(kInvalidTypedArrayLength); | 186 throw %make_range_error(kInvalidTypedArrayLength); |
191 } | 187 } |
192 var byteLength = l * ELEMENT_SIZE; | 188 var byteLength = l * ELEMENT_SIZE; |
193 if (byteLength > %_TypedArrayMaxSizeInHeap()) { | 189 if (byteLength > %_TypedArrayMaxSizeInHeap()) { |
194 var buffer = new GlobalArrayBuffer(byteLength); | 190 var buffer = new GlobalArrayBuffer(byteLength); |
195 %_TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength, true); | 191 %_TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength, true); |
196 } else { | 192 } else { |
197 %_TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength, true); | 193 %_TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength, true); |
198 } | 194 } |
199 } | 195 } |
200 | 196 |
201 function NAMEConstructByArrayLike(obj, arrayLike, length) { | 197 function NAMEConstructByArrayLike(obj, arrayLike, length) { |
202 var l = ToPositiveInteger(length, kInvalidTypedArrayLength); | 198 var l = ToPositiveInteger(length, kInvalidTypedArrayLength); |
203 | 199 |
204 if (l > %_MaxSmi()) { | 200 if (l > %_MaxSmi()) { |
205 throw MakeRangeError(kInvalidTypedArrayLength); | 201 throw %make_range_error(kInvalidTypedArrayLength); |
206 } | 202 } |
207 var initialized = false; | 203 var initialized = false; |
208 var byteLength = l * ELEMENT_SIZE; | 204 var byteLength = l * ELEMENT_SIZE; |
209 if (byteLength <= %_TypedArrayMaxSizeInHeap()) { | 205 if (byteLength <= %_TypedArrayMaxSizeInHeap()) { |
210 %_TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength, false); | 206 %_TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength, false); |
211 } else { | 207 } else { |
212 initialized = | 208 initialized = |
213 %TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l); | 209 %TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l); |
214 } | 210 } |
215 if (!initialized) { | 211 if (!initialized) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 NAMEConstructByTypedArray(this, arg1); | 264 NAMEConstructByTypedArray(this, arg1); |
269 } else { | 265 } else { |
270 var iteratorFn = arg1[iteratorSymbol]; | 266 var iteratorFn = arg1[iteratorSymbol]; |
271 if (IS_UNDEFINED(iteratorFn) || iteratorFn === ArrayValues) { | 267 if (IS_UNDEFINED(iteratorFn) || iteratorFn === ArrayValues) { |
272 NAMEConstructByArrayLike(this, arg1, arg1.length); | 268 NAMEConstructByArrayLike(this, arg1, arg1.length); |
273 } else { | 269 } else { |
274 NAMEConstructByIterable(this, arg1, iteratorFn); | 270 NAMEConstructByIterable(this, arg1, iteratorFn); |
275 } | 271 } |
276 } | 272 } |
277 } else { | 273 } else { |
278 throw MakeTypeError(kConstructorNotFunction, "NAME") | 274 throw %make_type_error(kConstructorNotFunction, "NAME") |
279 } | 275 } |
280 } | 276 } |
281 | 277 |
282 function NAMESubArray(begin, end) { | 278 function NAMESubArray(begin, end) { |
283 var beginInt = TO_INTEGER(begin); | 279 var beginInt = TO_INTEGER(begin); |
284 if (!IS_UNDEFINED(end)) { | 280 if (!IS_UNDEFINED(end)) { |
285 var endInt = TO_INTEGER(end); | 281 var endInt = TO_INTEGER(end); |
286 var srcLength = %_TypedArrayGetLength(this); | 282 var srcLength = %_TypedArrayGetLength(this); |
287 } else { | 283 } else { |
288 var srcLength = %_TypedArrayGetLength(this); | 284 var srcLength = %_TypedArrayGetLength(this); |
(...skipping 29 matching lines...) Expand all Loading... |
318 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR) | 314 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR) |
319 | 315 |
320 function TypedArraySubArray(begin, end) { | 316 function TypedArraySubArray(begin, end) { |
321 switch (%_ClassOf(this)) { | 317 switch (%_ClassOf(this)) { |
322 macro TYPED_ARRAY_SUBARRAY_CASE(ARRAY_ID, NAME, ELEMENT_SIZE) | 318 macro TYPED_ARRAY_SUBARRAY_CASE(ARRAY_ID, NAME, ELEMENT_SIZE) |
323 case "NAME": | 319 case "NAME": |
324 return %_Call(NAMESubArray, this, begin, end); | 320 return %_Call(NAMESubArray, this, begin, end); |
325 endmacro | 321 endmacro |
326 TYPED_ARRAYS(TYPED_ARRAY_SUBARRAY_CASE) | 322 TYPED_ARRAYS(TYPED_ARRAY_SUBARRAY_CASE) |
327 } | 323 } |
328 throw MakeTypeError(kIncompatibleMethodReceiver, | 324 throw %make_type_error(kIncompatibleMethodReceiver, |
329 "get TypedArray.prototype.subarray", this); | 325 "get TypedArray.prototype.subarray", this); |
330 } | 326 } |
331 %SetForceInlineFlag(TypedArraySubArray); | 327 %SetForceInlineFlag(TypedArraySubArray); |
332 | 328 |
333 | 329 |
334 | 330 |
335 function TypedArraySetFromArrayLike(target, source, sourceLength, offset) { | 331 function TypedArraySetFromArrayLike(target, source, sourceLength, offset) { |
336 if (offset > 0) { | 332 if (offset > 0) { |
337 for (var i = 0; i < sourceLength; i++) { | 333 for (var i = 0; i < sourceLength; i++) { |
338 target[offset + i] = source[i]; | 334 target[offset + i] = source[i]; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 for (var i = leftIndex; i <= rightIndex; i++) { | 388 for (var i = leftIndex; i <= rightIndex; i++) { |
393 temp[i - leftIndex] = source[i]; | 389 temp[i - leftIndex] = source[i]; |
394 } | 390 } |
395 for (i = leftIndex; i <= rightIndex; i++) { | 391 for (i = leftIndex; i <= rightIndex; i++) { |
396 target[offset + i] = temp[i - leftIndex]; | 392 target[offset + i] = temp[i - leftIndex]; |
397 } | 393 } |
398 } | 394 } |
399 | 395 |
400 function TypedArraySet(obj, offset) { | 396 function TypedArraySet(obj, offset) { |
401 var intOffset = IS_UNDEFINED(offset) ? 0 : TO_INTEGER(offset); | 397 var intOffset = IS_UNDEFINED(offset) ? 0 : TO_INTEGER(offset); |
402 if (intOffset < 0) throw MakeTypeError(kTypedArraySetNegativeOffset); | 398 if (intOffset < 0) throw %make_type_error(kTypedArraySetNegativeOffset); |
403 | 399 |
404 if (intOffset > %_MaxSmi()) { | 400 if (intOffset > %_MaxSmi()) { |
405 throw MakeRangeError(kTypedArraySetSourceTooLarge); | 401 throw %make_range_error(kTypedArraySetSourceTooLarge); |
406 } | 402 } |
407 switch (%TypedArraySetFastCases(this, obj, intOffset)) { | 403 switch (%TypedArraySetFastCases(this, obj, intOffset)) { |
408 // These numbers should be synchronized with runtime.cc. | 404 // These numbers should be synchronized with runtime.cc. |
409 case 0: // TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE | 405 case 0: // TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE |
410 return; | 406 return; |
411 case 1: // TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING | 407 case 1: // TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING |
412 TypedArraySetFromOverlappingTypedArray(this, obj, intOffset); | 408 TypedArraySetFromOverlappingTypedArray(this, obj, intOffset); |
413 return; | 409 return; |
414 case 2: // TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING | 410 case 2: // TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING |
415 TypedArraySetFromArrayLike(this, | 411 TypedArraySetFromArrayLike(this, |
416 obj, %_TypedArrayGetLength(obj), intOffset); | 412 obj, %_TypedArrayGetLength(obj), intOffset); |
417 return; | 413 return; |
418 case 3: // TYPED_ARRAY_SET_NON_TYPED_ARRAY | 414 case 3: // TYPED_ARRAY_SET_NON_TYPED_ARRAY |
419 var l = obj.length; | 415 var l = obj.length; |
420 if (IS_UNDEFINED(l)) { | 416 if (IS_UNDEFINED(l)) { |
421 if (IS_NUMBER(obj)) { | 417 if (IS_NUMBER(obj)) { |
422 // For number as a first argument, throw TypeError | 418 // For number as a first argument, throw TypeError |
423 // instead of silently ignoring the call, so that | 419 // instead of silently ignoring the call, so that |
424 // the user knows (s)he did something wrong. | 420 // the user knows (s)he did something wrong. |
425 // (Consistent with Firefox and Blink/WebKit) | 421 // (Consistent with Firefox and Blink/WebKit) |
426 throw MakeTypeError(kInvalidArgument); | 422 throw %make_type_error(kInvalidArgument); |
427 } | 423 } |
428 return; | 424 return; |
429 } | 425 } |
430 l = TO_LENGTH(l); | 426 l = TO_LENGTH(l); |
431 if (intOffset + l > %_TypedArrayGetLength(this)) { | 427 if (intOffset + l > %_TypedArrayGetLength(this)) { |
432 throw MakeRangeError(kTypedArraySetSourceTooLarge); | 428 throw %make_range_error(kTypedArraySetSourceTooLarge); |
433 } | 429 } |
434 TypedArraySetFromArrayLike(this, obj, l, intOffset); | 430 TypedArraySetFromArrayLike(this, obj, l, intOffset); |
435 return; | 431 return; |
436 } | 432 } |
437 } | 433 } |
438 %FunctionSetLength(TypedArraySet, 1); | 434 %FunctionSetLength(TypedArraySet, 1); |
439 | 435 |
440 function TypedArrayGetToStringTag() { | 436 function TypedArrayGetToStringTag() { |
441 if (!IS_TYPEDARRAY(this)) return; | 437 if (!IS_TYPEDARRAY(this)) return; |
442 var name = %_ClassOf(this); | 438 var name = %_ClassOf(this); |
443 if (IS_UNDEFINED(name)) return; | 439 if (IS_UNDEFINED(name)) return; |
444 return name; | 440 return name; |
445 } | 441 } |
446 | 442 |
447 | 443 |
448 function TypedArrayCopyWithin(target, start, end) { | 444 function TypedArrayCopyWithin(target, start, end) { |
449 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 445 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
450 | 446 |
451 var length = %_TypedArrayGetLength(this); | 447 var length = %_TypedArrayGetLength(this); |
452 | 448 |
453 // TODO(littledan): Replace with a memcpy for better performance | 449 // TODO(littledan): Replace with a memcpy for better performance |
454 return InnerArrayCopyWithin(target, start, end, this, length); | 450 return InnerArrayCopyWithin(target, start, end, this, length); |
455 } | 451 } |
456 %FunctionSetLength(TypedArrayCopyWithin, 2); | 452 %FunctionSetLength(TypedArrayCopyWithin, 2); |
457 | 453 |
458 | 454 |
459 // ES6 draft 05-05-15, section 22.2.3.7 | 455 // ES6 draft 05-05-15, section 22.2.3.7 |
460 function TypedArrayEvery(f, receiver) { | 456 function TypedArrayEvery(f, receiver) { |
461 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 457 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
462 | 458 |
463 var length = %_TypedArrayGetLength(this); | 459 var length = %_TypedArrayGetLength(this); |
464 | 460 |
465 return InnerArrayEvery(f, receiver, this, length); | 461 return InnerArrayEvery(f, receiver, this, length); |
466 } | 462 } |
467 %FunctionSetLength(TypedArrayEvery, 1); | 463 %FunctionSetLength(TypedArrayEvery, 1); |
468 | 464 |
469 | 465 |
470 // ES6 draft 08-24-14, section 22.2.3.12 | 466 // ES6 draft 08-24-14, section 22.2.3.12 |
471 function TypedArrayForEach(f, receiver) { | 467 function TypedArrayForEach(f, receiver) { |
472 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 468 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
473 | 469 |
474 var length = %_TypedArrayGetLength(this); | 470 var length = %_TypedArrayGetLength(this); |
475 | 471 |
476 InnerArrayForEach(f, receiver, this, length); | 472 InnerArrayForEach(f, receiver, this, length); |
477 } | 473 } |
478 %FunctionSetLength(TypedArrayForEach, 1); | 474 %FunctionSetLength(TypedArrayForEach, 1); |
479 | 475 |
480 | 476 |
481 // ES6 draft 04-05-14 section 22.2.3.8 | 477 // ES6 draft 04-05-14 section 22.2.3.8 |
482 function TypedArrayFill(value, start, end) { | 478 function TypedArrayFill(value, start, end) { |
483 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 479 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
484 | 480 |
485 var length = %_TypedArrayGetLength(this); | 481 var length = %_TypedArrayGetLength(this); |
486 | 482 |
487 return InnerArrayFill(value, start, end, this, length); | 483 return InnerArrayFill(value, start, end, this, length); |
488 } | 484 } |
489 %FunctionSetLength(TypedArrayFill, 1); | 485 %FunctionSetLength(TypedArrayFill, 1); |
490 | 486 |
491 | 487 |
492 // ES6 draft 07-15-13, section 22.2.3.9 | 488 // ES6 draft 07-15-13, section 22.2.3.9 |
493 function TypedArrayFilter(f, thisArg) { | 489 function TypedArrayFilter(f, thisArg) { |
494 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 490 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
495 | 491 |
496 var length = %_TypedArrayGetLength(this); | 492 var length = %_TypedArrayGetLength(this); |
497 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); | 493 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f); |
498 var result = new InternalArray(); | 494 var result = new InternalArray(); |
499 InnerArrayFilter(f, thisArg, this, length, result); | 495 InnerArrayFilter(f, thisArg, this, length, result); |
500 var captured = result.length; | 496 var captured = result.length; |
501 var output = TypedArraySpeciesCreate(this, captured); | 497 var output = TypedArraySpeciesCreate(this, captured); |
502 for (var i = 0; i < captured; i++) { | 498 for (var i = 0; i < captured; i++) { |
503 output[i] = result[i]; | 499 output[i] = result[i]; |
504 } | 500 } |
505 return output; | 501 return output; |
506 } | 502 } |
507 %FunctionSetLength(TypedArrayFilter, 1); | 503 %FunctionSetLength(TypedArrayFilter, 1); |
508 | 504 |
509 | 505 |
510 // ES6 draft 07-15-13, section 22.2.3.10 | 506 // ES6 draft 07-15-13, section 22.2.3.10 |
511 function TypedArrayFind(predicate, thisArg) { | 507 function TypedArrayFind(predicate, thisArg) { |
512 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 508 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
513 | 509 |
514 var length = %_TypedArrayGetLength(this); | 510 var length = %_TypedArrayGetLength(this); |
515 | 511 |
516 return InnerArrayFind(predicate, thisArg, this, length); | 512 return InnerArrayFind(predicate, thisArg, this, length); |
517 } | 513 } |
518 %FunctionSetLength(TypedArrayFind, 1); | 514 %FunctionSetLength(TypedArrayFind, 1); |
519 | 515 |
520 | 516 |
521 // ES6 draft 07-15-13, section 22.2.3.11 | 517 // ES6 draft 07-15-13, section 22.2.3.11 |
522 function TypedArrayFindIndex(predicate, thisArg) { | 518 function TypedArrayFindIndex(predicate, thisArg) { |
523 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 519 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
524 | 520 |
525 var length = %_TypedArrayGetLength(this); | 521 var length = %_TypedArrayGetLength(this); |
526 | 522 |
527 return InnerArrayFindIndex(predicate, thisArg, this, length); | 523 return InnerArrayFindIndex(predicate, thisArg, this, length); |
528 } | 524 } |
529 %FunctionSetLength(TypedArrayFindIndex, 1); | 525 %FunctionSetLength(TypedArrayFindIndex, 1); |
530 | 526 |
531 | 527 |
532 // ES6 draft 05-18-15, section 22.2.3.21 | 528 // ES6 draft 05-18-15, section 22.2.3.21 |
533 function TypedArrayReverse() { | 529 function TypedArrayReverse() { |
534 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 530 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
535 | 531 |
536 var length = %_TypedArrayGetLength(this); | 532 var length = %_TypedArrayGetLength(this); |
537 | 533 |
538 return PackedArrayReverse(this, length); | 534 return PackedArrayReverse(this, length); |
539 } | 535 } |
540 | 536 |
541 | 537 |
542 function TypedArrayComparefn(x, y) { | 538 function TypedArrayComparefn(x, y) { |
543 if (x === 0 && x === y) { | 539 if (x === 0 && x === y) { |
544 x = 1 / x; | 540 x = 1 / x; |
545 y = 1 / y; | 541 y = 1 / y; |
546 } | 542 } |
547 if (x < y) { | 543 if (x < y) { |
548 return -1; | 544 return -1; |
549 } else if (x > y) { | 545 } else if (x > y) { |
550 return 1; | 546 return 1; |
551 } else if (IsNaN(x) && IsNaN(y)) { | 547 } else if (IsNaN(x) && IsNaN(y)) { |
552 return IsNaN(y) ? 0 : 1; | 548 return IsNaN(y) ? 0 : 1; |
553 } else if (IsNaN(x)) { | 549 } else if (IsNaN(x)) { |
554 return 1; | 550 return 1; |
555 } | 551 } |
556 return 0; | 552 return 0; |
557 } | 553 } |
558 | 554 |
559 | 555 |
560 // ES6 draft 05-18-15, section 22.2.3.25 | 556 // ES6 draft 05-18-15, section 22.2.3.25 |
561 function TypedArraySort(comparefn) { | 557 function TypedArraySort(comparefn) { |
562 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 558 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
563 | 559 |
564 var length = %_TypedArrayGetLength(this); | 560 var length = %_TypedArrayGetLength(this); |
565 | 561 |
566 if (IS_UNDEFINED(comparefn)) { | 562 if (IS_UNDEFINED(comparefn)) { |
567 comparefn = TypedArrayComparefn; | 563 comparefn = TypedArrayComparefn; |
568 } | 564 } |
569 | 565 |
570 return InnerArraySort(this, length, comparefn); | 566 return InnerArraySort(this, length, comparefn); |
571 } | 567 } |
572 | 568 |
573 | 569 |
574 // ES6 section 22.2.3.13 | 570 // ES6 section 22.2.3.13 |
575 function TypedArrayIndexOf(element, index) { | 571 function TypedArrayIndexOf(element, index) { |
576 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 572 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
577 | 573 |
578 var length = %_TypedArrayGetLength(this); | 574 var length = %_TypedArrayGetLength(this); |
579 return InnerArrayIndexOf(this, element, index, length); | 575 return InnerArrayIndexOf(this, element, index, length); |
580 } | 576 } |
581 %FunctionSetLength(TypedArrayIndexOf, 1); | 577 %FunctionSetLength(TypedArrayIndexOf, 1); |
582 | 578 |
583 | 579 |
584 // ES6 section 22.2.3.16 | 580 // ES6 section 22.2.3.16 |
585 function TypedArrayLastIndexOf(element, index) { | 581 function TypedArrayLastIndexOf(element, index) { |
586 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 582 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
587 | 583 |
588 var length = %_TypedArrayGetLength(this); | 584 var length = %_TypedArrayGetLength(this); |
589 | 585 |
590 return InnerArrayLastIndexOf(this, element, index, length, | 586 return InnerArrayLastIndexOf(this, element, index, length, |
591 arguments.length); | 587 arguments.length); |
592 } | 588 } |
593 %FunctionSetLength(TypedArrayLastIndexOf, 1); | 589 %FunctionSetLength(TypedArrayLastIndexOf, 1); |
594 | 590 |
595 | 591 |
596 // ES6 draft 07-15-13, section 22.2.3.18 | 592 // ES6 draft 07-15-13, section 22.2.3.18 |
597 function TypedArrayMap(f, thisArg) { | 593 function TypedArrayMap(f, thisArg) { |
598 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 594 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
599 | 595 |
600 var length = %_TypedArrayGetLength(this); | 596 var length = %_TypedArrayGetLength(this); |
601 var result = TypedArraySpeciesCreate(this, length); | 597 var result = TypedArraySpeciesCreate(this, length); |
602 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); | 598 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f); |
603 for (var i = 0; i < length; i++) { | 599 for (var i = 0; i < length; i++) { |
604 var element = this[i]; | 600 var element = this[i]; |
605 result[i] = %_Call(f, thisArg, element, i, this); | 601 result[i] = %_Call(f, thisArg, element, i, this); |
606 } | 602 } |
607 return result; | 603 return result; |
608 } | 604 } |
609 %FunctionSetLength(TypedArrayMap, 1); | 605 %FunctionSetLength(TypedArrayMap, 1); |
610 | 606 |
611 | 607 |
612 // ES6 draft 05-05-15, section 22.2.3.24 | 608 // ES6 draft 05-05-15, section 22.2.3.24 |
613 function TypedArraySome(f, receiver) { | 609 function TypedArraySome(f, receiver) { |
614 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 610 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
615 | 611 |
616 var length = %_TypedArrayGetLength(this); | 612 var length = %_TypedArrayGetLength(this); |
617 | 613 |
618 return InnerArraySome(f, receiver, this, length); | 614 return InnerArraySome(f, receiver, this, length); |
619 } | 615 } |
620 %FunctionSetLength(TypedArraySome, 1); | 616 %FunctionSetLength(TypedArraySome, 1); |
621 | 617 |
622 | 618 |
623 // ES6 section 22.2.3.27 | 619 // ES6 section 22.2.3.27 |
624 function TypedArrayToLocaleString() { | 620 function TypedArrayToLocaleString() { |
625 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 621 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
626 | 622 |
627 var length = %_TypedArrayGetLength(this); | 623 var length = %_TypedArrayGetLength(this); |
628 | 624 |
629 return InnerArrayToLocaleString(this, length); | 625 return InnerArrayToLocaleString(this, length); |
630 } | 626 } |
631 | 627 |
632 | 628 |
633 // ES6 section 22.2.3.14 | 629 // ES6 section 22.2.3.14 |
634 function TypedArrayJoin(separator) { | 630 function TypedArrayJoin(separator) { |
635 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 631 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
636 | 632 |
637 var length = %_TypedArrayGetLength(this); | 633 var length = %_TypedArrayGetLength(this); |
638 | 634 |
639 return InnerArrayJoin(separator, this, length); | 635 return InnerArrayJoin(separator, this, length); |
640 } | 636 } |
641 | 637 |
642 | 638 |
643 // ES6 draft 07-15-13, section 22.2.3.19 | 639 // ES6 draft 07-15-13, section 22.2.3.19 |
644 function TypedArrayReduce(callback, current) { | 640 function TypedArrayReduce(callback, current) { |
645 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 641 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
646 | 642 |
647 var length = %_TypedArrayGetLength(this); | 643 var length = %_TypedArrayGetLength(this); |
648 return InnerArrayReduce(callback, current, this, length, | 644 return InnerArrayReduce(callback, current, this, length, |
649 arguments.length); | 645 arguments.length); |
650 } | 646 } |
651 %FunctionSetLength(TypedArrayReduce, 1); | 647 %FunctionSetLength(TypedArrayReduce, 1); |
652 | 648 |
653 | 649 |
654 // ES6 draft 07-15-13, section 22.2.3.19 | 650 // ES6 draft 07-15-13, section 22.2.3.19 |
655 function TypedArrayReduceRight(callback, current) { | 651 function TypedArrayReduceRight(callback, current) { |
656 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 652 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
657 | 653 |
658 var length = %_TypedArrayGetLength(this); | 654 var length = %_TypedArrayGetLength(this); |
659 return InnerArrayReduceRight(callback, current, this, length, | 655 return InnerArrayReduceRight(callback, current, this, length, |
660 arguments.length); | 656 arguments.length); |
661 } | 657 } |
662 %FunctionSetLength(TypedArrayReduceRight, 1); | 658 %FunctionSetLength(TypedArrayReduceRight, 1); |
663 | 659 |
664 | 660 |
665 function TypedArraySlice(start, end) { | 661 function TypedArraySlice(start, end) { |
666 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 662 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
667 var len = %_TypedArrayGetLength(this); | 663 var len = %_TypedArrayGetLength(this); |
668 | 664 |
669 var relativeStart = TO_INTEGER(start); | 665 var relativeStart = TO_INTEGER(start); |
670 | 666 |
671 var k; | 667 var k; |
672 if (relativeStart < 0) { | 668 if (relativeStart < 0) { |
673 k = MaxSimple(len + relativeStart, 0); | 669 k = MaxSimple(len + relativeStart, 0); |
674 } else { | 670 } else { |
675 k = MinSimple(relativeStart, len); | 671 k = MinSimple(relativeStart, len); |
676 } | 672 } |
(...skipping 23 matching lines...) Expand all Loading... |
700 array[n] = kValue; | 696 array[n] = kValue; |
701 k++; | 697 k++; |
702 n++; | 698 n++; |
703 } | 699 } |
704 return array; | 700 return array; |
705 } | 701 } |
706 | 702 |
707 | 703 |
708 // ES2016 draft, section 22.2.3.14 | 704 // ES2016 draft, section 22.2.3.14 |
709 function TypedArrayIncludes(searchElement, fromIndex) { | 705 function TypedArrayIncludes(searchElement, fromIndex) { |
710 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 706 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
711 | 707 |
712 var length = %_TypedArrayGetLength(this); | 708 var length = %_TypedArrayGetLength(this); |
713 | 709 |
714 if (length === 0) return false; | 710 if (length === 0) return false; |
715 var n = TO_INTEGER(fromIndex); | 711 var n = TO_INTEGER(fromIndex); |
716 | 712 |
717 var k; | 713 var k; |
718 if (n >= 0) { | 714 if (n >= 0) { |
719 k = n; | 715 k = n; |
720 } else { | 716 } else { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 %MoveArrayContents(internal_array, array); | 760 %MoveArrayContents(internal_array, array); |
765 return array; | 761 return array; |
766 } | 762 } |
767 return TO_OBJECT(items); | 763 return TO_OBJECT(items); |
768 } | 764 } |
769 | 765 |
770 | 766 |
771 // ES#sec-%typedarray%.from | 767 // ES#sec-%typedarray%.from |
772 // %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) | 768 // %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) |
773 function TypedArrayFrom(source, mapfn, thisArg) { | 769 function TypedArrayFrom(source, mapfn, thisArg) { |
774 if (!%IsConstructor(this)) throw MakeTypeError(kNotConstructor, this); | 770 if (!%IsConstructor(this)) throw %make_type_error(kNotConstructor, this); |
775 var mapping; | 771 var mapping; |
776 if (!IS_UNDEFINED(mapfn)) { | 772 if (!IS_UNDEFINED(mapfn)) { |
777 if (!IS_CALLABLE(mapfn)) throw MakeTypeError(kCalledNonCallable, this); | 773 if (!IS_CALLABLE(mapfn)) throw %make_type_error(kCalledNonCallable, this); |
778 mapping = true; | 774 mapping = true; |
779 } else { | 775 } else { |
780 mapping = false; | 776 mapping = false; |
781 } | 777 } |
782 var arrayLike = IterableToArrayLike(source); | 778 var arrayLike = IterableToArrayLike(source); |
783 var length = TO_LENGTH(arrayLike.length); | 779 var length = TO_LENGTH(arrayLike.length); |
784 var targetObject = TypedArrayCreate(this, length); | 780 var targetObject = TypedArrayCreate(this, length); |
785 var value, mappedValue; | 781 var value, mappedValue; |
786 for (var i = 0; i < length; i++) { | 782 for (var i = 0; i < length; i++) { |
787 value = arrayLike[i]; | 783 value = arrayLike[i]; |
788 if (mapping) { | 784 if (mapping) { |
789 mappedValue = %_Call(mapfn, thisArg, value, i); | 785 mappedValue = %_Call(mapfn, thisArg, value, i); |
790 } else { | 786 } else { |
791 mappedValue = value; | 787 mappedValue = value; |
792 } | 788 } |
793 targetObject[i] = mappedValue; | 789 targetObject[i] = mappedValue; |
794 } | 790 } |
795 return targetObject; | 791 return targetObject; |
796 } | 792 } |
797 %FunctionSetLength(TypedArrayFrom, 1); | 793 %FunctionSetLength(TypedArrayFrom, 1); |
798 | 794 |
799 // TODO(bmeurer): Migrate this to a proper builtin. | 795 // TODO(bmeurer): Migrate this to a proper builtin. |
800 function TypedArrayConstructor() { | 796 function TypedArrayConstructor() { |
801 if (IS_UNDEFINED(new.target)) { | 797 if (IS_UNDEFINED(new.target)) { |
802 throw MakeTypeError(kConstructorNonCallable, "TypedArray"); | 798 throw %make_type_error(kConstructorNonCallable, "TypedArray"); |
803 } | 799 } |
804 if (new.target === GlobalTypedArray) { | 800 if (new.target === GlobalTypedArray) { |
805 throw MakeTypeError(kConstructAbstractClass, "TypedArray"); | 801 throw %make_type_error(kConstructAbstractClass, "TypedArray"); |
806 } | 802 } |
807 } | 803 } |
808 | 804 |
809 function TypedArraySpecies() { | 805 function TypedArraySpecies() { |
810 return this; | 806 return this; |
811 } | 807 } |
812 | 808 |
813 // ------------------------------------------------------------------- | 809 // ------------------------------------------------------------------- |
814 | 810 |
815 %SetCode(GlobalTypedArray, TypedArrayConstructor); | 811 %SetCode(GlobalTypedArray, TypedArrayConstructor); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 FUNCTION(Int32) | 872 FUNCTION(Int32) |
877 FUNCTION(Uint32) | 873 FUNCTION(Uint32) |
878 FUNCTION(Float32) | 874 FUNCTION(Float32) |
879 FUNCTION(Float64) | 875 FUNCTION(Float64) |
880 endmacro | 876 endmacro |
881 | 877 |
882 | 878 |
883 macro DATA_VIEW_GETTER_SETTER(TYPENAME) | 879 macro DATA_VIEW_GETTER_SETTER(TYPENAME) |
884 function DataViewGetTYPENAMEJS(offset, little_endian) { | 880 function DataViewGetTYPENAMEJS(offset, little_endian) { |
885 if (!IS_DATAVIEW(this)) { | 881 if (!IS_DATAVIEW(this)) { |
886 throw MakeTypeError(kIncompatibleMethodReceiver, | 882 throw %make_type_error(kIncompatibleMethodReceiver, |
887 'DataView.getTYPENAME', this); | 883 'DataView.getTYPENAME', this); |
888 } | 884 } |
889 if (arguments.length < 1) throw MakeTypeError(kInvalidArgument); | 885 if (arguments.length < 1) throw %make_type_error(kInvalidArgument); |
890 offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset); | 886 offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset); |
891 return %DataViewGetTYPENAME(this, offset, !!little_endian); | 887 return %DataViewGetTYPENAME(this, offset, !!little_endian); |
892 } | 888 } |
893 %FunctionSetLength(DataViewGetTYPENAMEJS, 1); | 889 %FunctionSetLength(DataViewGetTYPENAMEJS, 1); |
894 | 890 |
895 function DataViewSetTYPENAMEJS(offset, value, little_endian) { | 891 function DataViewSetTYPENAMEJS(offset, value, little_endian) { |
896 if (!IS_DATAVIEW(this)) { | 892 if (!IS_DATAVIEW(this)) { |
897 throw MakeTypeError(kIncompatibleMethodReceiver, | 893 throw %make_type_error(kIncompatibleMethodReceiver, |
898 'DataView.setTYPENAME', this); | 894 'DataView.setTYPENAME', this); |
899 } | 895 } |
900 if (arguments.length < 2) throw MakeTypeError(kInvalidArgument); | 896 if (arguments.length < 2) throw %make_type_error(kInvalidArgument); |
901 offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset); | 897 offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset); |
902 %DataViewSetTYPENAME(this, offset, TO_NUMBER(value), !!little_endian); | 898 %DataViewSetTYPENAME(this, offset, TO_NUMBER(value), !!little_endian); |
903 } | 899 } |
904 %FunctionSetLength(DataViewSetTYPENAMEJS, 2); | 900 %FunctionSetLength(DataViewSetTYPENAMEJS, 2); |
905 endmacro | 901 endmacro |
906 | 902 |
907 DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER) | 903 DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER) |
908 | 904 |
909 utils.InstallFunctions(GlobalDataView.prototype, DONT_ENUM, [ | 905 utils.InstallFunctions(GlobalDataView.prototype, DONT_ENUM, [ |
910 "getInt8", DataViewGetInt8JS, | 906 "getInt8", DataViewGetInt8JS, |
(...skipping 15 matching lines...) Expand all Loading... |
926 "setUint32", DataViewSetUint32JS, | 922 "setUint32", DataViewSetUint32JS, |
927 | 923 |
928 "getFloat32", DataViewGetFloat32JS, | 924 "getFloat32", DataViewGetFloat32JS, |
929 "setFloat32", DataViewSetFloat32JS, | 925 "setFloat32", DataViewSetFloat32JS, |
930 | 926 |
931 "getFloat64", DataViewGetFloat64JS, | 927 "getFloat64", DataViewGetFloat64JS, |
932 "setFloat64", DataViewSetFloat64JS | 928 "setFloat64", DataViewSetFloat64JS |
933 ]); | 929 ]); |
934 | 930 |
935 }) | 931 }) |
OLD | NEW |