public static TypedArray SpeciesCreate(TypedArray source, params EcmaValue[] args) { RuntimeObject constructor = RuntimeObject.GetSpeciesConstructor(source, TypedArrayInfo.GetDefaultConstructor(source.ArrayKind)); return(constructor.Construct(args).GetUnderlyingObject <TypedArray>()); }
public TypedArray(TypedArrayKind kind) : base(TypedArrayInfo.GetDefaultPrototype(kind)) { this.ArrayKind = kind; this.ElementSize = TypedArrayInfo.GetElementSize(kind); }
internal virtual void Init(ArrayBuffer buffer, long byteOffset, long byteLength) { Guard.ArgumentNotNull(buffer, "buffer"); long bytesPerElement = this.ElementSize; long count = byteLength / bytesPerElement; if ((byteOffset % bytesPerElement) != 0) { throw new EcmaRangeErrorException(InternalString.Error.TypedArrayInvalidOffset, TypedArrayInfo.GetTypedArrayName(this.ArrayKind), bytesPerElement); } if ((byteLength % bytesPerElement) != 0) { throw new EcmaRangeErrorException(InternalString.Error.TypedArrayInvalidByteLength, TypedArrayInfo.GetTypedArrayName(this.ArrayKind), bytesPerElement); } if (byteOffset < 0 || byteOffset > buffer.ByteLength) { throw new EcmaRangeErrorException(InternalString.Error.BufferOffsetOutOfBound, byteOffset); } if (byteLength + byteOffset > buffer.ByteLength || count > Int32.MaxValue) { throw new EcmaRangeErrorException(InternalString.Error.TypedArrayInvalidLength, count); } this.Buffer = buffer; this.ByteOffset = byteOffset; this.ByteLength = byteLength; this.Length = (int)count; }