main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $RangeError = require('es-errors/range');
|
---|
| 4 | var $TypeError = require('es-errors/type');
|
---|
| 5 |
|
---|
| 6 | var ToIndex = require('./ToIndex');
|
---|
| 7 | var TypedArrayElementSize = require('./TypedArrayElementSize');
|
---|
| 8 | var TypedArrayLength = require('./TypedArrayLength');
|
---|
| 9 |
|
---|
| 10 | var isTypedArrayWithBufferWitnessRecord = require('../helpers/records/typed-array-with-buffer-witness-record');
|
---|
| 11 |
|
---|
| 12 | var typedArrayByteOffset = require('typed-array-byte-offset');
|
---|
| 13 |
|
---|
| 14 | // https://262.ecma-international.org/15.0/#sec-validateatomicaccess
|
---|
| 15 |
|
---|
| 16 | module.exports = function ValidateAtomicAccess(taRecord, requestIndex) {
|
---|
| 17 | if (!isTypedArrayWithBufferWitnessRecord(taRecord)) {
|
---|
| 18 | throw new $TypeError('Assertion failed: `taRecord` must be a TypedArray With Buffer Witness Record');
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | var length = TypedArrayLength(taRecord); // step 1
|
---|
| 22 |
|
---|
| 23 | var accessIndex = ToIndex(requestIndex); // step 2
|
---|
| 24 |
|
---|
| 25 | /*
|
---|
| 26 | // this assertion can never be reached
|
---|
| 27 | if (!(accessIndex >= 0)) {
|
---|
| 28 | throw new $TypeError('Assertion failed: accessIndex >= 0'); // step 4
|
---|
| 29 | }
|
---|
| 30 | */
|
---|
| 31 |
|
---|
| 32 | if (accessIndex >= length) {
|
---|
| 33 | throw new $RangeError('index out of range'); // step 4
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | var typedArray = taRecord['[[Object]]']; // step 5
|
---|
| 37 |
|
---|
| 38 | var elementSize = TypedArrayElementSize(typedArray); // step 6
|
---|
| 39 |
|
---|
| 40 | var offset = typedArrayByteOffset(typedArray); // step 7
|
---|
| 41 |
|
---|
| 42 | return (accessIndex * elementSize) + offset; // step 8
|
---|
| 43 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.