Class SparseArray
java.lang.Object
com.oracle.truffle.js.runtime.array.ScriptArray
com.oracle.truffle.js.runtime.array.DynamicArray
com.oracle.truffle.js.runtime.array.SparseArray
Array that stores its elements in a HashMap-like structure, e.g. in a TreeMap.
-
Nested Class Summary
Nested classes/interfaces inherited from class DynamicArray
DynamicArray.DynamicArrayCacheNested classes/interfaces inherited from class ScriptArray
ScriptArray.CreateWritableProfileAccess, ScriptArray.DefaultIterator, ScriptArray.SetLengthProfileAccess -
Field Summary
Fields inherited from class DynamicArray
cache, INTEGRITY_LEVEL_FROZEN, INTEGRITY_LEVEL_FROZEN_LENGTH_READONLY, INTEGRITY_LEVEL_MASK, INTEGRITY_LEVEL_NONE, INTEGRITY_LEVEL_NONE_LENGTH_READONLY, INTEGRITY_LEVEL_NOT_EXTENSIBLE, INTEGRITY_LEVEL_NOT_EXTENSIBLE_LENGTH_READONLY, INTEGRITY_LEVEL_SEALED, INTEGRITY_LEVEL_SEALED_LENGTH_READONLY, INTEGRITY_LEVELS, integrityLevel, LENGTH_NOT_WRITABLE, LENGTH_WRITABLE_MASKFields inherited from class ScriptArray
EMPTY_OBJECT_ARRAY -
Method Summary
Modifier and TypeMethodDescriptionaddRangeImpl(JSDynamicObject object, long offset, int size) Shift elements starting from offset by size.cloneArray(JSDynamicObject object) protected static voidcopyArrayToMap(JSDynamicObject object, ScriptArray fromArray, Map<Long, Object> toMap) static SparseArraydeleteElementImpl(JSDynamicObject object, long index, boolean strict) longfirstElementIndex(JSDynamicObject object) First element index (inclusive).getElement(JSDynamicObject object, long index) getElementInBounds(JSDynamicObject object, long index) booleanhasElement(JSDynamicObject object, long index) booleanhasHoles(JSDynamicObject object) Returns true when this array actually has holes betweenScriptArray.firstElementIndex(JSDynamicObject)andScriptArray.lastElementIndex(JSDynamicObject).booleanReturns true if this array type could have hole values in it.longlastElementIndex(JSDynamicObject object) Last element index (inclusive).longlength(JSDynamicObject object) intlengthInt(JSDynamicObject object) static SparseArraymakeSparseArray(JSDynamicObject object, ScriptArray fromArray) longnextElementIndex(JSDynamicObject object, long index) Returns the next index.ownPropertyKeys(JSDynamicObject object) longpreviousElementIndex(JSDynamicObject object, long index) Returns the previous index.removeRangeImpl(JSDynamicObject object, long start, long end) Removes elements from start (inclusive) to end (exclusive), shifting succeeding elements.setElementImpl(JSDynamicObject object, long index, Object value, boolean strict) setLengthImpl(JSDynamicObject object, long len, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) protected DynamicArraywithIntegrityLevel(int newIntegrityLevel) Methods inherited from class DynamicArray
createCache, freeze, isExtensible, isFrozen, isLengthNotWritable, isSealed, maybePreinitializeCache, preventExtensions, seal, setIntegrityLevel, setLengthNotWritable, toStringMethods inherited from class ScriptArray
addRange, asIterable, canDeleteElement, cast, createConstantArray, createConstantEmptyArray, deleteElement, hasHolesOrUnused, isInBoundsFast, isInstance, makeMultiRangeList, makeRangeList, nextPower, ownPropertyKeysContiguous, ownPropertyKeysHoles, removeRange, removeRange, setElement, setLength, setLength, shiftRange, shiftRangeImpl, toArray, traceArrayTransition, traceWrite, valueIsByte
-
Method Details
-
createSparseArray
-
makeSparseArray
-
createArrayMap
-
copyArrayToMap
protected static void copyArrayToMap(JSDynamicObject object, ScriptArray fromArray, Map<Long, Object> toMap) -
getElement
- Specified by:
getElementin classScriptArray
-
getElementInBounds
- Specified by:
getElementInBoundsin classScriptArray
-
setElementImpl
- Specified by:
setElementImplin classScriptArray
-
length
- Specified by:
lengthin classScriptArray
-
lengthInt
- Specified by:
lengthIntin classScriptArray
-
setLengthImpl
public SparseArray 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
-
cloneArray
- Specified by:
cloneArrayin classDynamicArray
-
deleteElementImpl
- Specified by:
deleteElementImplin classScriptArray
-
hasElement
- Specified by:
hasElementin classScriptArray- Returns:
- true if array has an element (not a hole) at this index.
-
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(JSDynamicObject)andScriptArray.lastElementIndex(JSDynamicObject). ImpliesScriptArray.isHolesType().- Specified by:
hasHolesin classScriptArray- See Also:
-
removeRangeImpl
Removes elements from start (inclusive) to end (exclusive), shifting succeeding elements.- Specified by:
removeRangeImplin classScriptArray
-
addRangeImpl
Shift elements starting from offset by size.- Specified by:
addRangeImplin classScriptArray- Parameters:
offset- starting offset positionsize- size of the inserted empty array- Returns:
- a
ScriptArrayinstance with the new size
-
ownPropertyKeys
- Overrides:
ownPropertyKeysin classScriptArray
-
withIntegrityLevel
- Specified by:
withIntegrityLevelin classDynamicArray
-