Class ScriptArray
java.lang.Object
com.oracle.truffle.js.runtime.array.ScriptArray
- Direct Known Subclasses:
DynamicArray,TypedArray
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprotected final classstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ScriptArrayaddRange(JSDynamicObject object, long offset, int size) abstract ScriptArrayaddRangeImpl(JSDynamicObject object, long offset, int size) This method grows the array by adding more elements of a given size.asIterable(JSDynamicObject object) final booleancanDeleteElement(JSDynamicObject object, long index, boolean strict) final ScriptArraycast(ScriptArray other) static AbstractConstantArraycreateConstantArray(Object[] elements) static AbstractConstantArrayfinal ScriptArraydeleteElement(JSDynamicObject object, long index, boolean strict) abstract ScriptArraydeleteElementImpl(JSDynamicObject object, long index, boolean strict) abstract longfirstElementIndex(JSDynamicObject object) First element index (inclusive).abstract ScriptArrayfreeze()abstract ObjectgetElement(JSDynamicObject object, long index) abstract ObjectgetElementInBounds(JSDynamicObject object, long index) abstract booleanhasElement(JSDynamicObject object, long index) abstract booleanhasHoles(JSDynamicObject object) Returns true when this array actually has holes betweenfirstElementIndex(com.oracle.truffle.js.runtime.objects.JSDynamicObject)andlastElementIndex(com.oracle.truffle.js.runtime.objects.JSDynamicObject).booleanhasHolesOrUnused(JSDynamicObject object) Returns true when this array has any hole or unused elements between 0 andlength(com.oracle.truffle.js.runtime.objects.JSDynamicObject).booleanbooleanisFrozen()booleanReturns true if this array type could have hole values in it.booleanisInBoundsFast(JSDynamicObject object, long index) Range check only, might be a hole depending on array type.final booleanisInstance(ScriptArray other) booleanbooleanisSealed()abstract longlastElementIndex(JSDynamicObject object) Last element index (inclusive).abstract longlength(JSDynamicObject object) abstract intlengthInt(JSDynamicObject object) makeMultiRangeList(int total, long[] ranges) makeRangeList(long rangeStart, long rangeEnd) abstract longnextElementIndex(JSDynamicObject object, long index) Returns the next index.protected static intnextPower(int length) ownPropertyKeys(JSDynamicObject object) ownPropertyKeysHoles(JSDynamicObject object) abstract ScriptArrayabstract longpreviousElementIndex(JSDynamicObject object, long index) Returns the previous index.final ScriptArrayremoveRange(JSDynamicObject object, long start, long end) final ScriptArrayremoveRange(JSDynamicObject object, long start, long end, com.oracle.truffle.api.profiles.BranchProfile errorBranch) abstract ScriptArrayremoveRangeImpl(JSDynamicObject object, long start, long end) This function deletes all elements in the range from [start..end[.abstract ScriptArrayseal()final ScriptArraysetElement(JSDynamicObject object, long index, Object value, boolean strict) abstract ScriptArraysetElementImpl(JSDynamicObject object, long index, Object value, boolean strict) final ScriptArraysetLength(JSDynamicObject object, long len, boolean strict) final ScriptArraysetLength(JSDynamicObject object, long len, boolean strict, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) abstract ScriptArraysetLengthImpl(JSDynamicObject object, long len, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) abstract ScriptArrayfinal ScriptArrayshiftRange(JSDynamicObject object, long from) shiftRangeImpl(JSDynamicObject object, long limit) This function shifts all elements in the range from [0..limit[.final Object[]toArray(JSDynamicObject thisObj) Creates an Object[] from this array, of size array.length.protected static final voidtraceArrayTransition(ScriptArray oldArray, ScriptArray newArray, long index, Object value) protected static final voidtraceWrite(String access, long index, Object value) static booleanvalueIsByte(int value)
-
Field Details
-
EMPTY_OBJECT_ARRAY
-
-
Constructor Details
-
ScriptArray
public ScriptArray()
-
-
Method Details
-
getElement
-
getElementInBounds
-
setElementImpl
public abstract ScriptArray setElementImpl(JSDynamicObject object, long index, Object value, boolean strict) -
setElement
public final ScriptArray setElement(JSDynamicObject object, long index, Object value, boolean strict) -
deleteElementImpl
-
deleteElement
-
canDeleteElement
-
hasElement
- Returns:
- true if array has an element (not a hole) at this index.
-
length
-
lengthInt
-
setLengthImpl
public abstract ScriptArray setLengthImpl(JSDynamicObject object, long len, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) -
setLength
public final ScriptArray setLength(JSDynamicObject object, long len, boolean strict, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) -
setLength
-
firstElementIndex
First element index (inclusive). -
lastElementIndex
Last element index (inclusive). -
nextElementIndex
Returns 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(). -
previousElementIndex
Returns the previous index. The index is guaranteed either to exist, or be smaller than firstElementIndex(). -
isInBoundsFast
Range check only, might be a hole depending on array type. -
asIterable
-
toArray
Creates an Object[] from this array, of size array.length. Does not check the prototype chain, i.e. result can be wrong. Use JSToObjectArrayNode for more correct results. This is mostly used in tests, but also in a few places in Node.js. -
createConstantEmptyArray
-
createConstantArray
-
valueIsByte
public static boolean valueIsByte(int value) -
traceArrayTransition
protected static final void traceArrayTransition(ScriptArray oldArray, ScriptArray newArray, long index, Object value) -
traceWrite
-
isHolesType
public boolean isHolesType()Returns true if this array type could have hole values in it. Doesn't tell whether it actually HAS holes. -
hasHoles
Returns true when this array actually has holes betweenfirstElementIndex(com.oracle.truffle.js.runtime.objects.JSDynamicObject)andlastElementIndex(com.oracle.truffle.js.runtime.objects.JSDynamicObject). ImpliesisHolesType().- See Also:
-
hasHolesOrUnused
Returns true when this array has any hole or unused elements between 0 andlength(com.oracle.truffle.js.runtime.objects.JSDynamicObject).- See Also:
-
removeRangeImpl
This 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; -
removeRange
-
removeRange
public final ScriptArray removeRange(JSDynamicObject object, long start, long end, com.oracle.truffle.api.profiles.BranchProfile errorBranch) -
shiftRangeImpl
This function shifts all elements in the range from [0..limit[. Depending on the underlying implementation, the shift operation might be zero-copy. Can be used by e.g. Array.prototype.shift; -
shiftRange
-
addRangeImpl
This 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.- Parameters:
offset- starting offset positionsize- size of the inserted empty array- Returns:
- a
ScriptArrayinstance with the new size
-
addRange
-
ownPropertyKeys
-
ownPropertyKeysContiguous
-
ownPropertyKeysHoles
-
makeRangeList
-
makeMultiRangeList
-
nextPower
protected static int nextPower(int length) -
isSealed
public boolean isSealed() -
isFrozen
public boolean isFrozen() -
isLengthNotWritable
public boolean isLengthNotWritable() -
isExtensible
public boolean isExtensible() -
seal
-
freeze
-
setLengthNotWritable
-
preventExtensions
-
isInstance
-
cast
-