package goja

import (
	
	
	
	
	
	

	
)

type typedArraySortCtx struct {
	ta           *typedArrayObject
	compare      func(FunctionCall) Value
	needValidate bool
	detached     bool
}

func ( *typedArraySortCtx) () int {
	return .ta.length
}

func ( *typedArraySortCtx) () {
	if !.detached && .needValidate {
		.detached = !.ta.viewedArrayBuf.ensureNotDetached(false)
		.needValidate = false
	}
}

func ( *typedArraySortCtx) (,  int) bool {
	.checkDetached()
	if .detached {
		return false
	}
	 := .ta.offset
	if .compare != nil {
		 := .ta.typedArray.get( + )
		 := .ta.typedArray.get( + )
		 := .compare(FunctionCall{
			This:      _undefined,
			Arguments: []Value{, },
		}).ToNumber()
		.needValidate = true
		if ,  := .(valueInt);  {
			return  < 0
		}
		 := .ToFloat()
		if  < 0 {
			return true
		}
		if  > 0 {
			return false
		}
		if math.Signbit() {
			return true
		}
		return false
	}

	return .ta.typedArray.less(+, +)
}

func ( *typedArraySortCtx) (,  int) {
	.checkDetached()
	if .detached {
		return
	}
	 := .ta.offset
	.ta.typedArray.swap(+, +)
}

func allocByteSlice( int) ( []byte) {
	defer func() {
		if  := recover();  != nil {
			panic(rangeError(fmt.Sprintf("Buffer size is too large: %d", )))
		}
	}()
	if  < 0 {
		panic(rangeError(fmt.Sprintf("Invalid buffer size: %d", )))
	}
	 = make([]byte, )
	return
}

func ( *Runtime) ( []Value,  *Object) *Object {
	if  == nil {
		panic(.needNew("ArrayBuffer"))
	}
	 := ._newArrayBuffer(.getPrototypeFromCtor(, .getArrayBuffer(), .getArrayBufferPrototype()), nil)
	if len() > 0 {
		.data = allocByteSlice(.toIndex([0]))
	}
	return .val
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.This)
	if ,  := .self.(*arrayBufferObject);  {
		if .ensureNotDetached(false) {
			return intToValue(int64(len(.data)))
		}
		return intToValue(0)
	}
	panic(.NewTypeError("Object is not ArrayBuffer: %s", ))
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.This)
	if ,  := .self.(*arrayBufferObject);  {
		 := int64(len(.data))
		 := relToIdx(.Argument(0).ToInteger(), )
		var  int64
		if  := .Argument(1);  != _undefined {
			 = .ToInteger()
		} else {
			 = 
		}
		 = relToIdx(, )
		 := max(-, 0)
		 := .speciesConstructor(, .getArrayBuffer())([]Value{intToValue()}, nil)
		if ,  := .self.(*arrayBufferObject);  {
			if  > 0 {
				.ensureNotDetached(true)
				if  ==  {
					panic(.NewTypeError("Species constructor returned the same ArrayBuffer"))
				}
				if int64(len(.data)) <  {
					panic(.NewTypeError("Species constructor returned an ArrayBuffer that is too small: %d", len(.data)))
				}
				.ensureNotDetached(true)
				copy(.data, .data[:])
			}
			return 
		}
		panic(.NewTypeError("Species constructor did not return an ArrayBuffer: %s", .String()))
	}
	panic(.NewTypeError("Object is not ArrayBuffer: %s", ))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .Argument(0).(*Object);  {
		if ,  := .self.(*dataViewObject);  {
			return valueTrue
		}
		if ,  := .self.(*typedArrayObject);  {
			return valueTrue
		}
	}
	return valueFalse
}

func ( *Runtime) ( []Value,  *Object) *Object {
	if  == nil {
		panic(.needNew("DataView"))
	}
	var  Value
	if len() > 0 {
		 = [0]
	}
	var  *arrayBufferObject
	if ,  := .(*Object);  {
		if ,  := .self.(*arrayBufferObject);  {
			 = 
		}
	}
	if  == nil {
		panic(.NewTypeError("First argument to DataView constructor must be an ArrayBuffer"))
	}
	var ,  int
	if len() > 1 {
		 := nilSafe([1])
		 = .toIndex()
		.ensureNotDetached(true)
		if  > len(.data) {
			panic(.newError(.getRangeError(), "Start offset %s is outside the bounds of the buffer", .String()))
		}
	}
	if len() > 2 && [2] != nil && [2] != _undefined {
		 = .toIndex([2])
		if + > len(.data) {
			panic(.newError(.getRangeError(), "Invalid DataView length %d", ))
		}
	} else {
		 = len(.data) - 
	}
	 := .getPrototypeFromCtor(, .getDataView(), .getDataViewPrototype())
	.ensureNotDetached(true)
	if  > len(.data) {
		panic(.newError(.getRangeError(), "Start offset %d is outside the bounds of the buffer", ))
	}
	if + > len(.data) {
		panic(.newError(.getRangeError(), "Invalid DataView length %d", ))
	}
	 := &Object{runtime: }
	 := &dataViewObject{
		baseObject: baseObject{
			class:      classObject,
			val:        ,
			prototype:  ,
			extensible: true,
		},
		viewedArrayBuf: ,
		byteOffset:     ,
		byteLen:        ,
	}
	.self = 
	.init()
	return 
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		return .viewedArrayBuf.val
	}
	panic(.NewTypeError("Method get DataView.prototype.buffer called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		return intToValue(int64(.byteLen))
	}
	panic(.NewTypeError("Method get DataView.prototype.byteLength called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		return intToValue(int64(.byteOffset))
	}
	panic(.NewTypeError("Method get DataView.prototype.byteOffset called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		return floatToValue(float64(.viewedArrayBuf.getFloat32(.getIdxAndByteOrder(.toIndex(.Argument(0)), .Argument(1), 4))))
	}
	panic(.NewTypeError("Method DataView.prototype.getFloat32 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		return floatToValue(.viewedArrayBuf.getFloat64(.getIdxAndByteOrder(.toIndex(.Argument(0)), .Argument(1), 8)))
	}
	panic(.NewTypeError("Method DataView.prototype.getFloat64 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		,  := .getIdxAndByteOrder(.toIndex(.Argument(0)), .Argument(1), 1)
		return intToValue(int64(.viewedArrayBuf.getInt8()))
	}
	panic(.NewTypeError("Method DataView.prototype.getInt8 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		return intToValue(int64(.viewedArrayBuf.getInt16(.getIdxAndByteOrder(.toIndex(.Argument(0)), .Argument(1), 2))))
	}
	panic(.NewTypeError("Method DataView.prototype.getInt16 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		return intToValue(int64(.viewedArrayBuf.getInt32(.getIdxAndByteOrder(.toIndex(.Argument(0)), .Argument(1), 4))))
	}
	panic(.NewTypeError("Method DataView.prototype.getInt32 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		,  := .getIdxAndByteOrder(.toIndex(.Argument(0)), .Argument(1), 1)
		return intToValue(int64(.viewedArrayBuf.getUint8()))
	}
	panic(.NewTypeError("Method DataView.prototype.getUint8 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		return intToValue(int64(.viewedArrayBuf.getUint16(.getIdxAndByteOrder(.toIndex(.Argument(0)), .Argument(1), 2))))
	}
	panic(.NewTypeError("Method DataView.prototype.getUint16 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		return intToValue(int64(.viewedArrayBuf.getUint32(.getIdxAndByteOrder(.toIndex(.Argument(0)), .Argument(1), 4))))
	}
	panic(.NewTypeError("Method DataView.prototype.getUint32 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		return (*valueBigInt)(.viewedArrayBuf.getBigInt64(.getIdxAndByteOrder(.toIndex(.Argument(0).ToNumber()), .Argument(1), 8)))
	}
	panic(.NewTypeError("Method DataView.prototype.getBigInt64 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		return (*valueBigInt)(.viewedArrayBuf.getBigUint64(.getIdxAndByteOrder(.toIndex(.Argument(0).ToNumber()), .Argument(1), 8)))
	}
	panic(.NewTypeError("Method DataView.prototype.getBigUint64 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		 := .toIndex(.Argument(0))
		 := toFloat32(.Argument(1))
		,  := .getIdxAndByteOrder(, .Argument(2), 4)
		.viewedArrayBuf.setFloat32(, , )
		return _undefined
	}
	panic(.NewTypeError("Method DataView.prototype.setFloat32 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		 := .toIndex(.Argument(0))
		 := .Argument(1).ToFloat()
		,  := .getIdxAndByteOrder(, .Argument(2), 8)
		.viewedArrayBuf.setFloat64(, , )
		return _undefined
	}
	panic(.NewTypeError("Method DataView.prototype.setFloat64 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		 := .toIndex(.Argument(0))
		 := toInt8(.Argument(1))
		,  := .getIdxAndByteOrder(, .Argument(2), 1)
		.viewedArrayBuf.setInt8(, )
		return _undefined
	}
	panic(.NewTypeError("Method DataView.prototype.setInt8 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		 := .toIndex(.Argument(0))
		 := toInt16(.Argument(1))
		,  := .getIdxAndByteOrder(, .Argument(2), 2)
		.viewedArrayBuf.setInt16(, , )
		return _undefined
	}
	panic(.NewTypeError("Method DataView.prototype.setInt16 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		 := .toIndex(.Argument(0))
		 := toInt32(.Argument(1))
		,  := .getIdxAndByteOrder(, .Argument(2), 4)
		.viewedArrayBuf.setInt32(, , )
		return _undefined
	}
	panic(.NewTypeError("Method DataView.prototype.setInt32 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		 := .toIndex(.Argument(0))
		 := toUint8(.Argument(1))
		,  := .getIdxAndByteOrder(, .Argument(2), 1)
		.viewedArrayBuf.setUint8(, )
		return _undefined
	}
	panic(.NewTypeError("Method DataView.prototype.setUint8 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		 := .toIndex(.Argument(0))
		 := toUint16(.Argument(1))
		,  := .getIdxAndByteOrder(, .Argument(2), 2)
		.viewedArrayBuf.setUint16(, , )
		return _undefined
	}
	panic(.NewTypeError("Method DataView.prototype.setUint16 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		 := .toIndex(.Argument(0))
		 := toUint32(.Argument(1))
		,  := .getIdxAndByteOrder(, .Argument(2), 4)
		.viewedArrayBuf.setUint32(, , )
		return _undefined
	}
	panic(.NewTypeError("Method DataView.prototype.setUint32 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		 := .toIndex(.Argument(0))
		 := toBigInt64(.Argument(1))
		,  := .getIdxAndByteOrder(, .Argument(2), 8)
		.viewedArrayBuf.setBigInt64(, , )
		return _undefined
	}
	panic(.NewTypeError("Method DataView.prototype.setBigInt64 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*dataViewObject);  {
		 := .toIndex(.Argument(0))
		 := toBigUint64(.Argument(1))
		,  := .getIdxAndByteOrder(, .Argument(2), 8)
		.viewedArrayBuf.setBigUint64(, , )
		return _undefined
	}
	panic(.NewTypeError("Method DataView.prototype.setBigUint64 called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		return .viewedArrayBuf.val
	}
	panic(.NewTypeError("Method get TypedArray.prototype.buffer called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		if .viewedArrayBuf.data == nil {
			return _positiveZero
		}
		return intToValue(int64(.length) * int64(.elemSize))
	}
	panic(.NewTypeError("Method get TypedArray.prototype.byteLength called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		if .viewedArrayBuf.data == nil {
			return _positiveZero
		}
		return intToValue(int64(.length))
	}
	panic(.NewTypeError("Method get TypedArray.prototype.length called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		if .viewedArrayBuf.data == nil {
			return _positiveZero
		}
		return intToValue(int64(.offset) * int64(.elemSize))
	}
	panic(.NewTypeError("Method get TypedArray.prototype.byteOffset called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := int64(.length)
		var  int64
		 := toIntStrict(relToIdx(.Argument(0).ToInteger(), ))
		 := toIntStrict(relToIdx(.Argument(1).ToInteger(), ))
		if  := .Argument(2);  != _undefined {
			 = .ToInteger()
		} else {
			 = 
		}
		 := toIntStrict(relToIdx(, ))
		 := .viewedArrayBuf.data
		 := .offset
		 := .elemSize
		if  >  {
			.viewedArrayBuf.ensureNotDetached(true)
			copy([(+)*:], [(+)*:(+)*])
		}
		return .This
	}
	panic(.NewTypeError("Method TypedArray.prototype.copyWithin called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		return .createArrayIterator(.val, iterationKindKeyValue)
	}
	panic(.NewTypeError("Method TypedArray.prototype.entries called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .toCallable(.Argument(0))
		 := FunctionCall{
			This:      .Argument(1),
			Arguments: []Value{nil, nil, .This},
		}
		for  := 0;  < .length; ++ {
			if .isValidIntegerIndex() {
				.Arguments[0] = .typedArray.get(.offset + )
			} else {
				.Arguments[0] = _undefined
			}
			.Arguments[1] = intToValue(int64())
			if !().ToBoolean() {
				return valueFalse
			}
		}
		return valueTrue

	}
	panic(.NewTypeError("Method TypedArray.prototype.every called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := int64(.length)
		 := toIntStrict(relToIdx(.Argument(1).ToInteger(), ))
		var  int64
		if  := .Argument(2);  != _undefined {
			 = .ToInteger()
		} else {
			 = 
		}
		 := toIntStrict(relToIdx(, ))
		 := .typedArray.toRaw(.Argument(0))
		.viewedArrayBuf.ensureNotDetached(true)
		for ;  < ; ++ {
			.typedArray.setRaw(.offset+, )
		}
		return .This
	}
	panic(.NewTypeError("Method TypedArray.prototype.fill called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.This)
	if ,  := .self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .toCallable(.Argument(0))
		 := FunctionCall{
			This:      .Argument(1),
			Arguments: []Value{nil, nil, .This},
		}
		 := make([]byte, 0, .length*.elemSize)
		 := 0
		 := make([]byte, .elemSize)
		for  := 0;  < .length; ++ {
			if .isValidIntegerIndex() {
				.Arguments[0] = .typedArray.get(.offset + )
				 := (.offset + ) * .elemSize
				copy(, .viewedArrayBuf.data[:])
			} else {
				.Arguments[0] = _undefined
				for  := range  {
					[] = 0
				}
			}
			.Arguments[1] = intToValue(int64())
			if ().ToBoolean() {
				 = append(, ...)
				++
			}
		}
		 := .speciesConstructorObj(, .defaultCtor)
		 := ._newArrayBuffer(.getArrayBufferPrototype(), nil)
		.data = 
		 := .toConstructor(.defaultCtor)([]Value{.val}, .defaultCtor)
		if  == .defaultCtor {
			return 
		} else {
			 := .typedArrayCreate(, intToValue(int64()))
			 := .self.(*typedArrayObject)
			for  := 0;  < ; ++ {
				.typedArray.set(, .typedArray.get(.offset+))
			}
			return .val
		}
	}
	panic(.NewTypeError("Method TypedArray.prototype.filter called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .toCallable(.Argument(0))
		 := FunctionCall{
			This:      .Argument(1),
			Arguments: []Value{nil, nil, .This},
		}
		for  := 0;  < .length; ++ {
			var  Value
			if .isValidIntegerIndex() {
				 = .typedArray.get(.offset + )
			}
			.Arguments[0] = 
			.Arguments[1] = intToValue(int64())
			if ().ToBoolean() {
				return 
			}
		}
		return _undefined
	}
	panic(.NewTypeError("Method TypedArray.prototype.find called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .toCallable(.Argument(0))
		 := FunctionCall{
			This:      .Argument(1),
			Arguments: []Value{nil, nil, .This},
		}
		for  := 0;  < .length; ++ {
			if .isValidIntegerIndex() {
				.Arguments[0] = .typedArray.get(.offset + )
			} else {
				.Arguments[0] = _undefined
			}
			.Arguments[1] = intToValue(int64())
			if ().ToBoolean() {
				return .Arguments[1]
			}
		}
		return intToValue(-1)
	}
	panic(.NewTypeError("Method TypedArray.prototype.findIndex called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .toCallable(.Argument(0))
		 := FunctionCall{
			This:      .Argument(1),
			Arguments: []Value{nil, nil, .This},
		}
		for  := .length - 1;  >= 0; -- {
			var  Value
			if .isValidIntegerIndex() {
				 = .typedArray.get(.offset + )
			}
			.Arguments[0] = 
			.Arguments[1] = intToValue(int64())
			if ().ToBoolean() {
				return 
			}
		}
		return _undefined
	}
	panic(.NewTypeError("Method TypedArray.prototype.findLast called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .toCallable(.Argument(0))
		 := FunctionCall{
			This:      .Argument(1),
			Arguments: []Value{nil, nil, .This},
		}
		for  := .length - 1;  >= 0; -- {
			if .isValidIntegerIndex() {
				.Arguments[0] = .typedArray.get(.offset + )
			} else {
				.Arguments[0] = _undefined
			}
			.Arguments[1] = intToValue(int64())
			if ().ToBoolean() {
				return .Arguments[1]
			}
		}
		return intToValue(-1)
	}
	panic(.NewTypeError("Method TypedArray.prototype.findLastIndex called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .toCallable(.Argument(0))
		 := FunctionCall{
			This:      .Argument(1),
			Arguments: []Value{nil, nil, .This},
		}
		for  := 0;  < .length; ++ {
			var  Value
			if .isValidIntegerIndex() {
				 = .typedArray.get(.offset + )
			}
			.Arguments[0] = 
			.Arguments[1] = intToValue(int64())
			()
		}
		return _undefined
	}
	panic(.NewTypeError("Method TypedArray.prototype.forEach called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := int64(.length)
		if  == 0 {
			return valueFalse
		}

		 := .Argument(1).ToInteger()
		if  >=  {
			return valueFalse
		}

		if  < 0 {
			 = max(+, 0)
		}

		 := .Argument(0)
		if  == _negativeZero {
			 = _positiveZero
		}
		 := toIntStrict()
		if !.viewedArrayBuf.ensureNotDetached(false) {
			if  == _undefined &&  < .length {
				return valueTrue
			}
			return valueFalse
		}
		if .typedArray.typeMatch() {
			 := .typedArray.toRaw()
			for  := ;  < .length; ++ {
				if .typedArray.getRaw(.offset+) ==  {
					return valueTrue
				}
			}
		}
		return valueFalse
	}
	panic(.NewTypeError("Method TypedArray.prototype.includes called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .Argument(0).ToInteger()
		 := int64(.length)
		if  < 0 {
			 =  + 
		}
		if  >=  ||  < 0 {
			return _undefined
		}
		if .viewedArrayBuf.ensureNotDetached(false) {
			return .typedArray.get(.offset + int())
		}
		return _undefined
	}
	panic(.NewTypeError("Method TypedArray.prototype.at called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := int64(.length)
		if  == 0 {
			return intToValue(-1)
		}

		 := .Argument(1).ToInteger()
		if  >=  {
			return intToValue(-1)
		}

		if  < 0 {
			 = max(+, 0)
		}

		if .viewedArrayBuf.ensureNotDetached(false) {
			 := .Argument(0)
			if  == _negativeZero {
				 = _positiveZero
			}
			if !IsNaN() && .typedArray.typeMatch() {
				 := .typedArray.toRaw()
				for  := toIntStrict();  < .length; ++ {
					if .typedArray.getRaw(.offset+) ==  {
						return intToValue(int64())
					}
				}
			}
		}
		return intToValue(-1)
	}
	panic(.NewTypeError("Method TypedArray.prototype.indexOf called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .Argument(0)
		var  String
		if  != _undefined {
			 = .toString()
		} else {
			 = asciiString(",")
		}
		 := .length
		if  == 0 {
			return stringEmpty
		}

		var  StringBuilder

		var  Value
		if .isValidIntegerIndex(0) {
			 = .typedArray.get(.offset + 0)
		}
		if  != nil &&  != _undefined &&  != _null {
			.WriteString(.toString())
		}

		for  := 1;  < ; ++ {
			.WriteString()
			if .isValidIntegerIndex() {
				 := .typedArray.get(.offset + )
				if  != nil &&  != _undefined &&  != _null {
					.WriteString(.toString())
				}
			}
		}

		return .String()
	}
	panic(.NewTypeError("Method TypedArray.prototype.join called on incompatible receiver"))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		return .createArrayIterator(.val, iterationKindKey)
	}
	panic(.NewTypeError("Method TypedArray.prototype.keys called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := int64(.length)
		if  == 0 {
			return intToValue(-1)
		}

		var  int64

		if len(.Arguments) < 2 {
			 =  - 1
		} else {
			 = .Argument(1).ToInteger()
			if  >= 0 {
				 = min(, -1)
			} else {
				 += 
				if  < 0 {
					 = -1 // prevent underflow in toIntStrict() on 32-bit platforms
				}
			}
		}

		if .viewedArrayBuf.ensureNotDetached(false) {
			 := .Argument(0)
			if  == _negativeZero {
				 = _positiveZero
			}
			if !IsNaN() && .typedArray.typeMatch() {
				 := .typedArray.toRaw()
				for  := toIntStrict();  >= 0; -- {
					if .typedArray.getRaw(.offset+) ==  {
						return intToValue(int64())
					}
				}
			}
		}

		return intToValue(-1)
	}
	panic(.NewTypeError("Method TypedArray.prototype.lastIndexOf called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .toCallable(.Argument(0))
		 := FunctionCall{
			This:      .Argument(1),
			Arguments: []Value{nil, nil, .This},
		}
		 := .typedArraySpeciesCreate(, []Value{intToValue(int64(.length))})
		for  := 0;  < .length; ++ {
			if .isValidIntegerIndex() {
				.Arguments[0] = .typedArray.get(.offset + )
			} else {
				.Arguments[0] = _undefined
			}
			.Arguments[1] = intToValue(int64())
			.typedArray.set(, ())
		}
		return .val
	}
	panic(.NewTypeError("Method TypedArray.prototype.map called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .toCallable(.Argument(0))
		 := FunctionCall{
			This:      _undefined,
			Arguments: []Value{nil, nil, nil, .This},
		}
		 := 0
		if len(.Arguments) >= 2 {
			.Arguments[0] = .Argument(1)
		} else {
			if .length > 0 {
				.Arguments[0] = .typedArray.get(.offset + 0)
				 = 1
			}
		}
		if .Arguments[0] == nil {
			panic(.NewTypeError("Reduce of empty array with no initial value"))
		}
		for ;  < .length; ++ {
			if .isValidIntegerIndex() {
				.Arguments[1] = .typedArray.get(.offset + )
			} else {
				.Arguments[1] = _undefined
			}
			 := valueInt()
			.Arguments[2] = 
			.Arguments[0] = ()
		}
		return .Arguments[0]
	}
	panic(.NewTypeError("Method TypedArray.prototype.reduce called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .toCallable(.Argument(0))
		 := FunctionCall{
			This:      _undefined,
			Arguments: []Value{nil, nil, nil, .This},
		}
		 := .length - 1
		if len(.Arguments) >= 2 {
			.Arguments[0] = .Argument(1)
		} else {
			if  >= 0 {
				.Arguments[0] = .typedArray.get(.offset + )
				--
			}
		}
		if .Arguments[0] == nil {
			panic(.NewTypeError("Reduce of empty array with no initial value"))
		}
		for ;  >= 0; -- {
			if .isValidIntegerIndex() {
				.Arguments[1] = .typedArray.get(.offset + )
			} else {
				.Arguments[1] = _undefined
			}
			 := valueInt()
			.Arguments[2] = 
			.Arguments[0] = ()
		}
		return .Arguments[0]
	}
	panic(.NewTypeError("Method TypedArray.prototype.reduceRight called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .length
		 :=  / 2
		for  := 0;  != ; ++ {
			 :=  -  - 1
			.typedArray.swap(.offset+, .offset+)
		}

		return .This
	}
	panic(.NewTypeError("Method TypedArray.prototype.reverse called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		 := .Argument(0).ToObject()
		 := toIntStrict(.Argument(1).ToInteger())
		if  < 0 {
			panic(.newError(.getRangeError(), "offset should be >= 0"))
		}
		.viewedArrayBuf.ensureNotDetached(true)
		 := .length
		if ,  := .self.(*typedArrayObject);  {
			.viewedArrayBuf.ensureNotDetached(true)
			 := .length
			if  :=  + ;  < 0 ||  >  {
				panic(.newError(.getRangeError(), "Source is too large"))
			}
			if .defaultCtor == .defaultCtor {
				copy(.viewedArrayBuf.data[(.offset+)*.elemSize:],
					.viewedArrayBuf.data[.offset*.elemSize:(.offset+)*.elemSize])
			} else {
				checkTypedArrayMixBigInt(.defaultCtor, .defaultCtor)
				 := uintptr(unsafe.Pointer(&.viewedArrayBuf.data[.offset*.elemSize]))
				 :=  + uintptr(*.elemSize)
				 := uintptr(unsafe.Pointer(&.viewedArrayBuf.data[(.offset+)*.elemSize]))
				 := .offset + 
				 := .offset
				if .elemSize == .elemSize {
					if  <=  ||  >=  {
						for  := 0;  < ; ++ {
							.typedArray.set(+, .typedArray.get(+))
						}
					} else {
						for  :=  - 1;  >= 0; -- {
							.typedArray.set(+, .typedArray.get(+))
						}
					}
				} else {
					 := int(-) / (.elemSize - .elemSize)
					if  < 0 {
						 = 0
					} else if  >  {
						 = 
					}
					if .elemSize < .elemSize {
						for  := ;  < ; ++ {
							.typedArray.set(+, .typedArray.get(+))
						}
						for  :=  - 1;  >= 0; -- {
							.typedArray.set(+, .typedArray.get(+))
						}
					} else {
						for  := 0;  < ; ++ {
							.typedArray.set(+, .typedArray.get(+))
						}
						for  :=  - 1;  >= ; -- {
							.typedArray.set(+, .typedArray.get(+))
						}
					}
				}
			}
		} else {
			 := .length
			 := toIntStrict(toLength(.self.getStr("length", nil)))
			if  :=  + ;  < 0 ||  >  {
				panic(.newError(.getRangeError(), "Source is too large"))
			}
			for  := 0;  < ; ++ {
				 := nilSafe(.self.getIdx(valueInt(), nil))
				if .isValidIntegerIndex() {
					.typedArray.set(+, )
				}
			}
		}
		return _undefined
	}
	panic(.NewTypeError("Method TypedArray.prototype.set called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := int64(.length)
		 := toIntStrict(relToIdx(.Argument(0).ToInteger(), ))
		var  int64
		if  := .Argument(1);  != _undefined {
			 = .ToInteger()
		} else {
			 = 
		}
		 := toIntStrict(relToIdx(, ))

		 :=  - 
		if  < 0 {
			 = 0
		}
		 := .typedArraySpeciesCreate(, []Value{intToValue(int64())})
		if .defaultCtor == .defaultCtor {
			if  > 0 {
				.viewedArrayBuf.ensureNotDetached(true)
				 := .offset
				 := .elemSize
				copy(.viewedArrayBuf.data, .viewedArrayBuf.data[(+)*:(++)*])
			}
		} else {
			for  := 0;  < ; ++ {
				.viewedArrayBuf.ensureNotDetached(true)
				.typedArray.set(, .typedArray.get(.offset++))
			}
		}
		return .val
	}
	panic(.NewTypeError("Method TypedArray.prototype.slice called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		 := .toCallable(.Argument(0))
		 := FunctionCall{
			This:      .Argument(1),
			Arguments: []Value{nil, nil, .This},
		}
		for  := 0;  < .length; ++ {
			if .isValidIntegerIndex() {
				.Arguments[0] = .typedArray.get(.offset + )
			} else {
				.Arguments[0] = _undefined
			}
			.Arguments[1] = intToValue(int64())
			if ().ToBoolean() {
				return valueTrue
			}
		}
		return valueFalse
	}
	panic(.NewTypeError("Method TypedArray.prototype.some called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		var  func(FunctionCall) Value

		if  := .Argument(0);  != _undefined {
			 = .toCallable()
		}

		 := typedArraySortCtx{
			ta:      ,
			compare: ,
		}

		sort.Stable(&)
		return .This
	}
	panic(.NewTypeError("Method TypedArray.prototype.sort called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		 := int64(.length)
		 := relToIdx(.Argument(0).ToInteger(), )
		var  int64
		if  := .Argument(1);  != _undefined {
			 = .ToInteger()
		} else {
			 = 
		}
		 := relToIdx(, )
		 := max(-, 0)
		return .typedArraySpeciesCreate(, []Value{.viewedArrayBuf.val,
			intToValue((int64(.offset) + ) * int64(.elemSize)),
			intToValue(),
		}).val
	}
	panic(.NewTypeError("Method TypedArray.prototype.subarray called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		 := .length
		var  StringBuilder
		for  := 0;  < ; ++ {
			.viewedArrayBuf.ensureNotDetached(true)
			if  > 0 {
				.WriteRune(',')
			}
			 := .typedArray.get(.offset + )
			.writeItemLocaleString(, &)
		}
		return .String()
	}
	panic(.NewTypeError("Method TypedArray.prototype.toLocaleString called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .toObject(.This).self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		return .createArrayIterator(.val, iterationKindValue)
	}
	panic(.NewTypeError("Method TypedArray.prototype.values called on incompatible receiver %s", .objectproto_toString(FunctionCall{This: .This})))
}

func ( *Runtime) ( FunctionCall) Value {
	if ,  := .This.(*Object);  {
		if ,  := .self.(*typedArrayObject);  {
			return nilSafe(.defaultCtor.self.getStr("name", nil))
		}
	}

	return _undefined
}

func ( *Runtime) ( FunctionCall) Value {
	 := .This.ToObject()
	,  := .self.(*typedArrayObject)
	if ! {
		panic(.NewTypeError("%s is not a valid TypedArray", .objectproto_toString(FunctionCall{This: .This})))
	}
	.viewedArrayBuf.ensureNotDetached(true)
	 := .length
	 := .Argument(0).ToInteger()
	var  int

	if  >= 0 {
		 = toIntStrict()
	} else {
		 = toIntStrict(int64() + )
	}
	if !.isValidIntegerIndex() {
		panic(.newError(.getRangeError(), "Invalid typed array index"))
	}

	var  Value
	switch .typedArray.(type) {
	case *bigInt64Array, *bigUint64Array:
		 = toBigInt(.Argument(1))
	default:
		 = .Argument(1).ToNumber()
	}

	 := .typedArrayCreate(.defaultCtor, intToValue(int64()))
	for  := 0;  < ; ++ {
		var  Value
		if  ==  {
			 = 
		} else {
			 = .typedArray.get(.offset + )
		}
		.typedArray.set(.offset+, )
	}
	return .val
}

func ( *Runtime) ( FunctionCall) Value {
	 := .This.ToObject()
	,  := .self.(*typedArrayObject)
	if ! {
		panic(.NewTypeError("%s is not a valid TypedArray", .objectproto_toString(FunctionCall{This: .This})))
	}
	.viewedArrayBuf.ensureNotDetached(true)
	 := .length

	 := .typedArrayCreate(.defaultCtor, intToValue(int64()))

	for  := 0;  < ; ++ {
		 :=  -  - 1
		 := .typedArray.get(.offset + )
		.typedArray.set(.offset+, )
	}

	return .val
}

func ( *Runtime) ( FunctionCall) Value {
	 := .This.ToObject()
	,  := .self.(*typedArrayObject)
	if ! {
		panic(.NewTypeError("%s is not a valid TypedArray", .objectproto_toString(FunctionCall{This: .This})))
	}
	.viewedArrayBuf.ensureNotDetached(true)

	var  func(FunctionCall) Value
	 := .Argument(0)
	if  != _undefined {
		if ,  := .(*Object);  {
			, _ = .self.assertCallable()
		}
		if  == nil {
			panic(.NewTypeError("The comparison function must be either a function or undefined"))
		}
	}

	 := .length

	 := .typedArrayCreate(.defaultCtor, intToValue(int64()))
	copy(.viewedArrayBuf.data, .viewedArrayBuf.data)

	 := typedArraySortCtx{
		ta:      ,
		compare: ,
	}

	sort.Stable(&)

	return .val
}

func ( *Runtime) ([]Value, *Object) *Object {
	panic(.NewTypeError("Abstract class TypedArray not directly constructable"))
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.This)
	var  func( FunctionCall) Value
	 := .Argument(2)
	if  := .Argument(1);  != _undefined {
		 = .toCallable()
	}
	 := .toObject(.Argument(0))
	 := toMethod(.self.getSym(SymIterator, nil))
	if  != nil {
		 := .iterableToList(, )
		 := .typedArrayCreate(, intToValue(int64(len())))
		if  == nil {
			for ,  := range  {
				.typedArray.set(, )
			}
		} else {
			 := FunctionCall{
				This:      ,
				Arguments: []Value{nil, nil},
			}
			for ,  := range  {
				.Arguments[0], .Arguments[1] = , intToValue(int64())
				 = ()
				._putIdx(, )
			}
		}
		return .val
	}
	 := toIntStrict(toLength(.self.getStr("length", nil)))
	 := .typedArrayCreate(, intToValue(int64()))
	if  == nil {
		for  := 0;  < ; ++ {
			.typedArray.set(, nilSafe(.self.getIdx(valueInt(), nil)))
		}
	} else {
		 := FunctionCall{
			This:      ,
			Arguments: []Value{nil, nil},
		}
		for  := 0;  < ; ++ {
			 := valueInt()
			.Arguments[0], .Arguments[1] = .self.getIdx(, nil), 
			.typedArray.set(, ())
		}
	}
	return .val
}

func ( *Runtime) ( FunctionCall) Value {
	 := .typedArrayCreate(.toObject(.This), intToValue(int64(len(.Arguments))))
	for ,  := range .Arguments {
		.typedArray.set(, )
	}
	return .val
}

func ( *Runtime) ( *Object,  int,  typedArrayObjectCtor,  *Object) *typedArrayObject {
	 := ._newArrayBuffer(.getArrayBufferPrototype(), nil)
	 := (, 0, , .getPrototypeFromCtor(, nil, ))
	if  > 0 {
		.data = allocByteSlice( * .elemSize)
	}
	return 
}

func ( *Runtime) ( *typedArrayObject,  []Value) *typedArrayObject {
	return .typedArrayCreate(.speciesConstructorObj(.val, .defaultCtor), ...)
}

func ( *Runtime) ( *Object,  ...Value) *typedArrayObject {
	 := .toConstructor()(, )
	if ,  := .self.(*typedArrayObject);  {
		.viewedArrayBuf.ensureNotDetached(true)
		if len() == 1 {
			if ,  := [0].(valueInt);  {
				if .length < int() {
					panic(.NewTypeError("Derived TypedArray constructor created an array which was too small"))
				}
			}
		}
		return 
	}
	panic(.NewTypeError("Invalid TypedArray: %s", ))
}

func ( *Runtime) (,  *Object, ,  Value,  typedArrayObjectCtor,  *Object) *Object {
	var  func( FunctionCall) Value
	if  != nil {
		 = .toCallable()
		if  == nil {
			 = _undefined
		}
	}
	 := toMethod(.self.getSym(SymIterator, nil))
	if  != nil {
		 := .iterableToList(, )
		 := .allocateTypedArray(, len(), , )
		if  == nil {
			for ,  := range  {
				.typedArray.set(, )
			}
		} else {
			 := FunctionCall{
				This:      ,
				Arguments: []Value{nil, nil},
			}
			for ,  := range  {
				.Arguments[0], .Arguments[1] = , intToValue(int64())
				 = ()
				.typedArray.set(, )
			}
		}
		return .val
	}
	 := toIntStrict(toLength(.self.getStr("length", nil)))
	 := .allocateTypedArray(, , , )
	if  == nil {
		for  := 0;  < ; ++ {
			.typedArray.set(, nilSafe(.self.getIdx(valueInt(), nil)))
		}
	} else {
		 := FunctionCall{
			This:      ,
			Arguments: []Value{nil, nil},
		}
		for  := 0;  < ; ++ {
			 := valueInt()
			.Arguments[0], .Arguments[1] = .self.getIdx(, nil), 
			.typedArray.set(, ())
		}
	}
	return .val
}

func ( *Runtime) ( *arrayBufferObject,  []Value,  *Object,  typedArrayObjectCtor,  *Object) *Object {
	 := (, 0, 0, .getPrototypeFromCtor(, nil, ))
	var  int
	if len() > 1 && [1] != nil && [1] != _undefined {
		 = .toIndex([1])
		if %.elemSize != 0 {
			panic(.newError(.getRangeError(), "Start offset of %s should be a multiple of %d", .self.getStr("name", nil), .elemSize))
		}
	}
	var  int
	if len() > 2 && [2] != nil && [2] != _undefined {
		 = .toIndex([2])
		.ensureNotDetached(true)
		if +*.elemSize > len(.data) {
			panic(.newError(.getRangeError(), "Invalid typed array length: %d", ))
		}
	} else {
		.ensureNotDetached(true)
		if len(.data)%.elemSize != 0 {
			panic(.newError(.getRangeError(), "Byte length of %s should be a multiple of %d", .self.getStr("name", nil), .elemSize))
		}
		 = (len(.data) - ) / .elemSize
		if  < 0 {
			panic(.newError(.getRangeError(), "Start offset %d is outside the bounds of the buffer", ))
		}
	}
	.offset =  / .elemSize
	.length = 
	return .val
}

func checkTypedArrayMixBigInt(,  *Object) {
	 := .self.getStr("name", nil).String()
	if strings.HasPrefix(, "Big") {
		if !strings.HasPrefix(.self.getStr("name", nil).String(), "Big") {
			panic(errMixBigIntType)
		}
	}
}

func ( *Runtime) ( *typedArrayObject,  *Object,  typedArrayObjectCtor,  *Object) *Object {
	 := .allocateTypedArray(, 0, , )
	.viewedArrayBuf.ensureNotDetached(true)
	 := .length

	.viewedArrayBuf.data = allocByteSlice(toIntStrict(int64() * int64(.elemSize)))
	.viewedArrayBuf.ensureNotDetached(true)
	if .defaultCtor == .defaultCtor {
		copy(.viewedArrayBuf.data, .viewedArrayBuf.data[.offset*.elemSize:])
		.length = .length
		return .val
	} else {
		checkTypedArrayMixBigInt(.defaultCtor, )
	}
	.length = 
	for  := 0;  < ; ++ {
		.typedArray.set(, .typedArray.get(.offset+))
	}
	return .val
}

func ( *Runtime) ( []Value,  *Object,  typedArrayObjectCtor,  *Object) *Object {
	if  == nil {
		panic(.needNew("TypedArray"))
	}
	if len() > 0 {
		if ,  := [0].(*Object);  {
			switch o := .self.(type) {
			case *arrayBufferObject:
				return ._newTypedArrayFromArrayBuffer(, , , , )
			case *typedArrayObject:
				return ._newTypedArrayFromTypedArray(, , , )
			default:
				return .typedArrayFrom(, , nil, nil, , )
			}
		}
	}
	var  int
	if len() > 0 {
		if  := [0];  != nil {
			 = .toIndex()
		}
	}
	return .allocateTypedArray(, , , ).val
}

func ( *Runtime) ( []Value, ,  *Object) *Object {
	return ._newTypedArray(, , .newUint8ArrayObject, )
}

func ( *Runtime) ( []Value, ,  *Object) *Object {
	return ._newTypedArray(, , .newUint8ClampedArrayObject, )
}

func ( *Runtime) ( []Value, ,  *Object) *Object {
	return ._newTypedArray(, , .newInt8ArrayObject, )
}

func ( *Runtime) ( []Value, ,  *Object) *Object {
	return ._newTypedArray(, , .newUint16ArrayObject, )
}

func ( *Runtime) ( []Value, ,  *Object) *Object {
	return ._newTypedArray(, , .newInt16ArrayObject, )
}

func ( *Runtime) ( []Value, ,  *Object) *Object {
	return ._newTypedArray(, , .newUint32ArrayObject, )
}

func ( *Runtime) ( []Value, ,  *Object) *Object {
	return ._newTypedArray(, , .newInt32ArrayObject, )
}

func ( *Runtime) ( []Value, ,  *Object) *Object {
	return ._newTypedArray(, , .newFloat32ArrayObject, )
}

func ( *Runtime) ( []Value, ,  *Object) *Object {
	return ._newTypedArray(, , .newFloat64ArrayObject, )
}

func ( *Runtime) ( []Value, ,  *Object) *Object {
	return ._newTypedArray(, , .newBigInt64ArrayObject, )
}

func ( *Runtime) ( []Value, ,  *Object) *Object {
	return ._newTypedArray(, , .newBigUint64ArrayObject, )
}

func ( *Runtime) ( *Object) objectImpl {
	 := newBaseObjectObj(, .global.ObjectPrototype, classObject)
	 := &valueProperty{
		accessor:     true,
		configurable: true,
		getterFunc:   .newNativeFunc(.arrayBufferProto_getByteLength, "get byteLength", 0),
	}
	._put("byteLength", )
	._putProp("constructor", .getArrayBuffer(), true, false, true)
	._putProp("slice", .newNativeFunc(.arrayBufferProto_slice, "slice", 2), true, false, true)
	._putSym(SymToStringTag, valueProp(asciiString("ArrayBuffer"), false, false, true))
	return 
}

func ( *Runtime) ( *Object) objectImpl {
	 := .newNativeConstructOnly(, .builtin_newArrayBuffer, .getArrayBufferPrototype(), "ArrayBuffer", 1)
	._putProp("isView", .newNativeFunc(.arrayBuffer_isView, "isView", 1), true, false, true)
	.putSpeciesReturnThis()

	return 
}

func ( *Runtime) ( *Object) objectImpl {
	 := .newNativeConstructOnly(, .newDataView, .getDataViewPrototype(), "DataView", 1)
	return 
}

func ( *Runtime) ( *Object) objectImpl {
	 := .newNativeConstructOnly(, .newTypedArray, .getTypedArrayPrototype(), "TypedArray", 0)
	._putProp("from", .newNativeFunc(.typedArray_from, "from", 1), true, false, true)
	._putProp("of", .newNativeFunc(.typedArray_of, "of", 0), true, false, true)
	.putSpeciesReturnThis()

	return 
}

func ( *Runtime) () *Object {
	 := .global.TypedArray
	if  == nil {
		 = &Object{runtime: }
		.global.TypedArray = 
		.createTypedArray()
	}
	return 
}

func ( *Runtime) ( *Object,  func( []Value, ,  *Object) *Object,  unistring.String,  int) {
	 := .newBaseObject(.getTypedArrayPrototype(), classObject)
	 := .newNativeConstructOnly(, func( []Value,  *Object) *Object {
		return (, , .val)
	}, .val, , 3)

	._putProp("constructor", .val, true, false, true)

	.prototype = .getTypedArray()
	 := intToValue(int64())
	._putProp("BYTES_PER_ELEMENT", , false, false, false)
	._putProp("BYTES_PER_ELEMENT", , false, false, false)
}

func addTypedArrays( *objectTemplate) {
	.putStr("ArrayBuffer", func( *Runtime) Value { return valueProp(.getArrayBuffer(), true, false, true) })
	.putStr("DataView", func( *Runtime) Value { return valueProp(.getDataView(), true, false, true) })
	.putStr("Uint8Array", func( *Runtime) Value { return valueProp(.getUint8Array(), true, false, true) })
	.putStr("Uint8ClampedArray", func( *Runtime) Value { return valueProp(.getUint8ClampedArray(), true, false, true) })
	.putStr("Int8Array", func( *Runtime) Value { return valueProp(.getInt8Array(), true, false, true) })
	.putStr("Uint16Array", func( *Runtime) Value { return valueProp(.getUint16Array(), true, false, true) })
	.putStr("Int16Array", func( *Runtime) Value { return valueProp(.getInt16Array(), true, false, true) })
	.putStr("Uint32Array", func( *Runtime) Value { return valueProp(.getUint32Array(), true, false, true) })
	.putStr("Int32Array", func( *Runtime) Value { return valueProp(.getInt32Array(), true, false, true) })
	.putStr("Float32Array", func( *Runtime) Value { return valueProp(.getFloat32Array(), true, false, true) })
	.putStr("Float64Array", func( *Runtime) Value { return valueProp(.getFloat64Array(), true, false, true) })
	.putStr("BigInt64Array", func( *Runtime) Value { return valueProp(.getBigInt64Array(), true, false, true) })
	.putStr("BigUint64Array", func( *Runtime) Value { return valueProp(.getBigUint64Array(), true, false, true) })
}

func createTypedArrayProtoTemplate() *objectTemplate {
	 := newObjectTemplate()
	.protoFactory = func( *Runtime) *Object {
		return .global.ObjectPrototype
	}

	.putStr("buffer", func( *Runtime) Value {
		return &valueProperty{
			accessor:     true,
			configurable: true,
			getterFunc:   .newNativeFunc(.typedArrayProto_getBuffer, "get buffer", 0),
		}
	})

	.putStr("byteLength", func( *Runtime) Value {
		return &valueProperty{
			accessor:     true,
			configurable: true,
			getterFunc:   .newNativeFunc(.typedArrayProto_getByteLen, "get byteLength", 0),
		}
	})

	.putStr("byteOffset", func( *Runtime) Value {
		return &valueProperty{
			accessor:     true,
			configurable: true,
			getterFunc:   .newNativeFunc(.typedArrayProto_getByteOffset, "get byteOffset", 0),
		}
	})

	.putStr("at", func( *Runtime) Value { return .methodProp(.typedArrayProto_at, "at", 1) })
	.putStr("constructor", func( *Runtime) Value { return valueProp(.getTypedArray(), true, false, true) })
	.putStr("copyWithin", func( *Runtime) Value { return .methodProp(.typedArrayProto_copyWithin, "copyWithin", 2) })
	.putStr("entries", func( *Runtime) Value { return .methodProp(.typedArrayProto_entries, "entries", 0) })
	.putStr("every", func( *Runtime) Value { return .methodProp(.typedArrayProto_every, "every", 1) })
	.putStr("fill", func( *Runtime) Value { return .methodProp(.typedArrayProto_fill, "fill", 1) })
	.putStr("filter", func( *Runtime) Value { return .methodProp(.typedArrayProto_filter, "filter", 1) })
	.putStr("find", func( *Runtime) Value { return .methodProp(.typedArrayProto_find, "find", 1) })
	.putStr("findIndex", func( *Runtime) Value { return .methodProp(.typedArrayProto_findIndex, "findIndex", 1) })
	.putStr("findLast", func( *Runtime) Value { return .methodProp(.typedArrayProto_findLast, "findLast", 1) })
	.putStr("findLastIndex", func( *Runtime) Value { return .methodProp(.typedArrayProto_findLastIndex, "findLastIndex", 1) })
	.putStr("forEach", func( *Runtime) Value { return .methodProp(.typedArrayProto_forEach, "forEach", 1) })
	.putStr("includes", func( *Runtime) Value { return .methodProp(.typedArrayProto_includes, "includes", 1) })
	.putStr("indexOf", func( *Runtime) Value { return .methodProp(.typedArrayProto_indexOf, "indexOf", 1) })
	.putStr("join", func( *Runtime) Value { return .methodProp(.typedArrayProto_join, "join", 1) })
	.putStr("keys", func( *Runtime) Value { return .methodProp(.typedArrayProto_keys, "keys", 0) })
	.putStr("lastIndexOf", func( *Runtime) Value { return .methodProp(.typedArrayProto_lastIndexOf, "lastIndexOf", 1) })
	.putStr("length", func( *Runtime) Value {
		return &valueProperty{
			accessor:     true,
			configurable: true,
			getterFunc:   .newNativeFunc(.typedArrayProto_getLength, "get length", 0),
		}
	})
	.putStr("map", func( *Runtime) Value { return .methodProp(.typedArrayProto_map, "map", 1) })
	.putStr("reduce", func( *Runtime) Value { return .methodProp(.typedArrayProto_reduce, "reduce", 1) })
	.putStr("reduceRight", func( *Runtime) Value { return .methodProp(.typedArrayProto_reduceRight, "reduceRight", 1) })
	.putStr("reverse", func( *Runtime) Value { return .methodProp(.typedArrayProto_reverse, "reverse", 0) })
	.putStr("set", func( *Runtime) Value { return .methodProp(.typedArrayProto_set, "set", 1) })
	.putStr("slice", func( *Runtime) Value { return .methodProp(.typedArrayProto_slice, "slice", 2) })
	.putStr("some", func( *Runtime) Value { return .methodProp(.typedArrayProto_some, "some", 1) })
	.putStr("sort", func( *Runtime) Value { return .methodProp(.typedArrayProto_sort, "sort", 1) })
	.putStr("subarray", func( *Runtime) Value { return .methodProp(.typedArrayProto_subarray, "subarray", 2) })
	.putStr("toLocaleString", func( *Runtime) Value { return .methodProp(.typedArrayProto_toLocaleString, "toLocaleString", 0) })
	.putStr("with", func( *Runtime) Value { return .methodProp(.typedArrayProto_with, "with", 2) })
	.putStr("toReversed", func( *Runtime) Value { return .methodProp(.typedArrayProto_toReversed, "toReversed", 0) })
	.putStr("toSorted", func( *Runtime) Value { return .methodProp(.typedArrayProto_toSorted, "toSorted", 1) })
	.putStr("toString", func( *Runtime) Value { return valueProp(.getArrayToString(), true, false, true) })
	.putStr("values", func( *Runtime) Value { return valueProp(.getTypedArrayValues(), true, false, true) })

	.putSym(SymIterator, func( *Runtime) Value { return valueProp(.getTypedArrayValues(), true, false, true) })
	.putSym(SymToStringTag, func( *Runtime) Value {
		return &valueProperty{
			getterFunc:   .newNativeFunc(.typedArrayProto_toStringTag, "get [Symbol.toStringTag]", 0),
			accessor:     true,
			configurable: true,
		}
	})

	return 
}

func ( *Runtime) () *Object {
	 := .global.typedArrayValues
	if  == nil {
		 = .newNativeFunc(.typedArrayProto_values, "values", 0)
		.global.typedArrayValues = 
	}
	return 
}

var typedArrayProtoTemplate *objectTemplate
var typedArrayProtoTemplateOnce sync.Once

func getTypedArrayProtoTemplate() *objectTemplate {
	typedArrayProtoTemplateOnce.Do(func() {
		typedArrayProtoTemplate = createTypedArrayProtoTemplate()
	})
	return typedArrayProtoTemplate
}

func ( *Runtime) () *Object {
	 := .global.TypedArrayPrototype
	if  == nil {
		 = &Object{runtime: }
		.global.TypedArrayPrototype = 
		.newTemplatedObject(getTypedArrayProtoTemplate(), )
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.Uint8Array
	if  == nil {
		 = &Object{runtime: }
		.global.Uint8Array = 
		.createTypedArrayCtor(, .newUint8Array, "Uint8Array", 1)
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.Uint8ClampedArray
	if  == nil {
		 = &Object{runtime: }
		.global.Uint8ClampedArray = 
		.createTypedArrayCtor(, .newUint8ClampedArray, "Uint8ClampedArray", 1)
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.Int8Array
	if  == nil {
		 = &Object{runtime: }
		.global.Int8Array = 
		.createTypedArrayCtor(, .newInt8Array, "Int8Array", 1)
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.Uint16Array
	if  == nil {
		 = &Object{runtime: }
		.global.Uint16Array = 
		.createTypedArrayCtor(, .newUint16Array, "Uint16Array", 2)
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.Int16Array
	if  == nil {
		 = &Object{runtime: }
		.global.Int16Array = 
		.createTypedArrayCtor(, .newInt16Array, "Int16Array", 2)
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.Uint32Array
	if  == nil {
		 = &Object{runtime: }
		.global.Uint32Array = 
		.createTypedArrayCtor(, .newUint32Array, "Uint32Array", 4)
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.Int32Array
	if  == nil {
		 = &Object{runtime: }
		.global.Int32Array = 
		.createTypedArrayCtor(, .newInt32Array, "Int32Array", 4)
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.Float32Array
	if  == nil {
		 = &Object{runtime: }
		.global.Float32Array = 
		.createTypedArrayCtor(, .newFloat32Array, "Float32Array", 4)
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.Float64Array
	if  == nil {
		 = &Object{runtime: }
		.global.Float64Array = 
		.createTypedArrayCtor(, .newFloat64Array, "Float64Array", 8)
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.BigInt64Array
	if  == nil {
		 = &Object{runtime: }
		.global.BigInt64Array = 
		.createTypedArrayCtor(, .newBigInt64Array, "BigInt64Array", 8)
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.BigUint64Array
	if  == nil {
		 = &Object{runtime: }
		.global.BigUint64Array = 
		.createTypedArrayCtor(, .newBigUint64Array, "BigUint64Array", 8)
	}
	return 
}

func createDataViewProtoTemplate() *objectTemplate {
	 := newObjectTemplate()
	.protoFactory = func( *Runtime) *Object {
		return .global.ObjectPrototype
	}

	.putStr("buffer", func( *Runtime) Value {
		return &valueProperty{
			accessor:     true,
			configurable: true,
			getterFunc:   .newNativeFunc(.dataViewProto_getBuffer, "get buffer", 0),
		}
	})
	.putStr("byteLength", func( *Runtime) Value {
		return &valueProperty{
			accessor:     true,
			configurable: true,
			getterFunc:   .newNativeFunc(.dataViewProto_getByteLen, "get byteLength", 0),
		}
	})
	.putStr("byteOffset", func( *Runtime) Value {
		return &valueProperty{
			accessor:     true,
			configurable: true,
			getterFunc:   .newNativeFunc(.dataViewProto_getByteOffset, "get byteOffset", 0),
		}
	})

	.putStr("constructor", func( *Runtime) Value { return valueProp(.getDataView(), true, false, true) })

	.putStr("getFloat32", func( *Runtime) Value { return .methodProp(.dataViewProto_getFloat32, "getFloat32", 1) })
	.putStr("getFloat64", func( *Runtime) Value { return .methodProp(.dataViewProto_getFloat64, "getFloat64", 1) })
	.putStr("getInt8", func( *Runtime) Value { return .methodProp(.dataViewProto_getInt8, "getInt8", 1) })
	.putStr("getInt16", func( *Runtime) Value { return .methodProp(.dataViewProto_getInt16, "getInt16", 1) })
	.putStr("getInt32", func( *Runtime) Value { return .methodProp(.dataViewProto_getInt32, "getInt32", 1) })
	.putStr("getUint8", func( *Runtime) Value { return .methodProp(.dataViewProto_getUint8, "getUint8", 1) })
	.putStr("getUint16", func( *Runtime) Value { return .methodProp(.dataViewProto_getUint16, "getUint16", 1) })
	.putStr("getUint32", func( *Runtime) Value { return .methodProp(.dataViewProto_getUint32, "getUint32", 1) })
	.putStr("getBigInt64", func( *Runtime) Value { return .methodProp(.dataViewProto_getBigInt64, "getBigInt64", 1) })
	.putStr("getBigUint64", func( *Runtime) Value { return .methodProp(.dataViewProto_getBigUint64, "getBigUint64", 1) })
	.putStr("setFloat32", func( *Runtime) Value { return .methodProp(.dataViewProto_setFloat32, "setFloat32", 2) })
	.putStr("setFloat64", func( *Runtime) Value { return .methodProp(.dataViewProto_setFloat64, "setFloat64", 2) })
	.putStr("setInt8", func( *Runtime) Value { return .methodProp(.dataViewProto_setInt8, "setInt8", 2) })
	.putStr("setInt16", func( *Runtime) Value { return .methodProp(.dataViewProto_setInt16, "setInt16", 2) })
	.putStr("setInt32", func( *Runtime) Value { return .methodProp(.dataViewProto_setInt32, "setInt32", 2) })
	.putStr("setUint8", func( *Runtime) Value { return .methodProp(.dataViewProto_setUint8, "setUint8", 2) })
	.putStr("setUint16", func( *Runtime) Value { return .methodProp(.dataViewProto_setUint16, "setUint16", 2) })
	.putStr("setUint32", func( *Runtime) Value { return .methodProp(.dataViewProto_setUint32, "setUint32", 2) })
	.putStr("setBigInt64", func( *Runtime) Value { return .methodProp(.dataViewProto_setBigInt64, "setBigInt64", 2) })
	.putStr("setBigUint64", func( *Runtime) Value { return .methodProp(.dataViewProto_setBigUint64, "setBigUint64", 2) })

	.putSym(SymToStringTag, func( *Runtime) Value { return valueProp(asciiString("DataView"), false, false, true) })

	return 
}

var dataViewProtoTemplate *objectTemplate
var dataViewProtoTemplateOnce sync.Once

func getDataViewProtoTemplate() *objectTemplate {
	dataViewProtoTemplateOnce.Do(func() {
		dataViewProtoTemplate = createDataViewProtoTemplate()
	})
	return dataViewProtoTemplate
}

func ( *Runtime) () *Object {
	 := .global.DataViewPrototype
	if  == nil {
		 = &Object{runtime: }
		.global.DataViewPrototype = 
		.newTemplatedObject(getDataViewProtoTemplate(), )
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.DataView
	if  == nil {
		 = &Object{runtime: }
		.global.DataView = 
		.self = .createDataView()
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.ArrayBufferPrototype
	if  == nil {
		 = &Object{runtime: }
		.global.ArrayBufferPrototype = 
		.self = .createArrayBufferProto()
	}
	return 
}

func ( *Runtime) () *Object {
	 := .global.ArrayBuffer
	if  == nil {
		 = &Object{runtime: }
		.global.ArrayBuffer = 
		.self = .createArrayBuffer()
	}
	return 
}