Class TypedArray
java.lang.Object
com.oracle.truffle.js.runtime.array.ScriptArray
com.oracle.truffle.js.runtime.array.TypedArray
- Direct Known Subclasses:
TypedArray.TypedBigIntArray,TypedArray.TypedFloatArray,TypedArray.TypedIntArray
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic enumstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic classstatic classstatic final classstatic final classstatic final classstatic final classstatic classstatic final classstatic classstatic classstatic classstatic final classstatic final classstatic final classstatic final classstatic classstatic classstatic classstatic final classstatic final classstatic final classstatic final classNested classes/interfaces inherited from class com.oracle.truffle.js.runtime.array.ScriptArray
ScriptArray.CreateWritableProfileAccess, ScriptArray.DefaultIterator, ScriptArray.SetLengthProfileAccess -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final bytestatic final bytestatic final bytestatic final byteFields inherited from class com.oracle.truffle.js.runtime.array.ScriptArray
EMPTY_OBJECT_ARRAY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTypedArray(TypedArrayFactory factory, boolean offset, boolean fixedLength, byte bufferType) -
Method Summary
Modifier and TypeMethodDescriptionaddRangeImpl(JSDynamicObject object, long atOffset, int size) This method grows the array by adding more elements of a given size.final intfinal bytefinal ScriptArraydeleteElementImpl(JSDynamicObject object, long index, boolean strict) static TypedArrayFactory[]static TypedArrayFactory[]final longfirstElementIndex(JSDynamicObject object) First element index (inclusive).freeze()abstract ObjectgetBufferElement(JSArrayBufferObject buffer, int index, boolean littleEndian, com.oracle.truffle.api.interop.InteropLibrary interop) static JSArrayBufferObjectgetBufferFromTypedArray(JSDynamicObject typedArray) Get ArrayBuffer from TypedArray.protected static byte[]getByteArray(JSArrayBufferObject buffer) Get byte[] from ArrayBuffer.protected static ByteBufferGet ByteBuffer from ArrayBuffer with unspecified byte order.abstract TypedArray.ElementTypefinal TypedArrayFactoryfinal com.oracle.truffle.api.strings.TruffleStringgetName()final intgetOffset(JSDynamicObject object) final booleanhasElement(JSDynamicObject object, long index) booleanhasHoles(JSDynamicObject object) Returns true when this array actually has holes betweenScriptArray.firstElementIndex(com.oracle.truffle.js.runtime.objects.JSDynamicObject)andScriptArray.lastElementIndex(com.oracle.truffle.js.runtime.objects.JSDynamicObject).final booleanfinal booleanisDirect()booleanisFrozen()booleanReturns true if this array type could have hole values in it.final booleanbooleanbooleanisSealed()final longlastElementIndex(JSDynamicObject object) Last element index (inclusive).final longlength(JSDynamicObject object) final intlengthInt(JSDynamicObject object) final longnextElementIndex(JSDynamicObject object, long index) Returns the next index.final longpreviousElementIndex(JSDynamicObject object, long index) Returns the previous index.removeRangeImpl(JSDynamicObject object, long start, long end) This function deletes all elements in the range from [start..end[.seal()abstract voidsetBufferElement(JSArrayBufferObject buffer, int index, boolean littleEndian, Object value, com.oracle.truffle.api.interop.InteropLibrary interop) final TypedArraysetLengthImpl(JSDynamicObject object, long len, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) protected static JSExceptionunsupportedBufferAccess(Object buffer, com.oracle.truffle.api.interop.UnsupportedMessageException e) Methods inherited from class com.oracle.truffle.js.runtime.array.ScriptArray
addRange, asIterable, canDeleteElement, cast, createConstantArray, createConstantEmptyArray, deleteElement, getElement, getElementInBounds, hasHolesOrUnused, isExtensible, isInBoundsFast, isInstance, makeMultiRangeList, makeRangeList, nextPower, ownPropertyKeys, ownPropertyKeysContiguous, ownPropertyKeysHoles, removeRange, removeRange, setElement, setElementImpl, setLength, setLength, shiftRange, shiftRangeImpl, toArray, traceArrayTransition, traceWrite, valueIsByte
-
Field Details
-
BUFFER_TYPE_ARRAY
public static final byte BUFFER_TYPE_ARRAY- See Also:
-
BUFFER_TYPE_DIRECT
public static final byte BUFFER_TYPE_DIRECT- See Also:
-
BUFFER_TYPE_SHARED
public static final byte BUFFER_TYPE_SHARED- See Also:
-
BUFFER_TYPE_INTEROP
public static final byte BUFFER_TYPE_INTEROP- See Also:
-
-
Constructor Details
-
TypedArray
protected TypedArray(TypedArrayFactory factory, boolean offset, boolean fixedLength, byte bufferType)
-
-
Method Details
-
length
- Specified by:
lengthin classScriptArray
-
lengthInt
- Specified by:
lengthIntin classScriptArray
-
setLengthImpl
public final TypedArray setLengthImpl(JSDynamicObject object, long len, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) - Specified by:
setLengthImplin classScriptArray
-
firstElementIndex
Description copied from class:ScriptArrayFirst element index (inclusive).- Specified by:
firstElementIndexin classScriptArray
-
lastElementIndex
Description copied from class:ScriptArrayLast element index (inclusive).- Specified by:
lastElementIndexin classScriptArray
-
nextElementIndex
Description copied from class:ScriptArrayReturns the next index. The index is guaranteed either to exist, or be MAX_SAFE_INTEGER. Reason for MAX_SAFE_INTEGER is: this array could be the prototype of another one; returning the length() of this array would be wrong, if the inheriting array is longer, but has a hole at length().- Specified by:
nextElementIndexin classScriptArray
-
previousElementIndex
Description copied from class:ScriptArrayReturns the previous index. The index is guaranteed either to exist, or be smaller than firstElementIndex().- Specified by:
previousElementIndexin classScriptArray
-
deleteElementImpl
- Specified by:
deleteElementImplin classScriptArray
-
hasElement
- Specified by:
hasElementin classScriptArray- Returns:
- true if array has an element (not a hole) at this index.
-
getDirectByteBuffer
Get ByteBuffer from ArrayBuffer with unspecified byte order. -
getByteArray
Get byte[] from ArrayBuffer. -
getBufferFromTypedArray
Get ArrayBuffer from TypedArray. -
getOffset
-
getFactory
-
bytesPerElement
public final int bytesPerElement() -
bytesPerElementShift
public final byte bytesPerElementShift() -
getName
public final com.oracle.truffle.api.strings.TruffleString getName() -
isHolesType
public boolean isHolesType()Description copied from class:ScriptArrayReturns true if this array type could have hole values in it. Doesn't tell whether it actually HAS holes.- Overrides:
isHolesTypein classScriptArray
-
hasHoles
Description copied from class:ScriptArrayReturns true when this array actually has holes betweenScriptArray.firstElementIndex(com.oracle.truffle.js.runtime.objects.JSDynamicObject)andScriptArray.lastElementIndex(com.oracle.truffle.js.runtime.objects.JSDynamicObject). ImpliesScriptArray.isHolesType().- Specified by:
hasHolesin classScriptArray- See Also:
-
removeRangeImpl
Description copied from class:ScriptArrayThis function deletes all elements in the range from [start..end[. This is equivalent to shifting the whole array, starting with element index end, by end-start positions to the left. Can be used by e.g. Array.prototype.splice;- Specified by:
removeRangeImplin classScriptArray
-
addRangeImpl
Description copied from class:ScriptArrayThis method grows the array by adding more elements of a given size. An offset parameter can be used to specify where the new elements have to be added (starting from zero). The operation is equivalent to shifting (right) the whole array or its part as defined by the offset parameter.- Specified by:
addRangeImplin classScriptArray- Parameters:
atOffset- starting offset positionsize- size of the inserted empty array- Returns:
- a
ScriptArrayinstance with the new size
-
isSealed
public boolean isSealed()- Overrides:
isSealedin classScriptArray
-
isFrozen
public boolean isFrozen()- Overrides:
isFrozenin classScriptArray
-
isLengthNotWritable
public boolean isLengthNotWritable()- Overrides:
isLengthNotWritablein classScriptArray
-
seal
- Specified by:
sealin classScriptArray
-
freeze
- Specified by:
freezein classScriptArray
-
setLengthNotWritable
- Specified by:
setLengthNotWritablein classScriptArray
-
preventExtensions
- Specified by:
preventExtensionsin classScriptArray
-
isDirect
public final boolean isDirect() -
isInterop
public final boolean isInterop() -
hasOffset
public final boolean hasOffset() -
getElementType
-
getBufferElement
public abstract Object getBufferElement(JSArrayBufferObject buffer, int index, boolean littleEndian, com.oracle.truffle.api.interop.InteropLibrary interop) -
setBufferElement
public abstract void setBufferElement(JSArrayBufferObject buffer, int index, boolean littleEndian, Object value, com.oracle.truffle.api.interop.InteropLibrary interop) -
factories
-
factories
-
unsupportedBufferAccess
protected static JSException unsupportedBufferAccess(Object buffer, com.oracle.truffle.api.interop.UnsupportedMessageException e)
-