Java Code Examples for jdk.nashorn.internal.runtime.arrays.ArrayData#canDelete()
The following examples show how to use
jdk.nashorn.internal.runtime.arrays.ArrayData#canDelete() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScriptObject.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public boolean delete(final Object key, final boolean strict) { final Object primitiveKey = JSType.toPrimitive(key, String.class); final int index = getArrayIndex(primitiveKey); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(primitiveKey, strict); }
Example 2
Source File: ScriptObject.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public boolean delete(final Object key, final boolean strict) { final Object primitiveKey = JSType.toPrimitive(key, String.class); final int index = getArrayIndex(primitiveKey); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(primitiveKey, strict); }
Example 3
Source File: ScriptObject.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public boolean delete(final Object key, final boolean strict) { final Object primitiveKey = JSType.toPrimitive(key, String.class); final int index = getArrayIndex(primitiveKey); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(primitiveKey, strict); }
Example 4
Source File: ScriptObject.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final double key, final boolean strict) { final int index = getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 5
Source File: ScriptObject.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final double key, final boolean strict) { final int index = getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 6
Source File: ScriptObject.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final int key, final boolean strict) { final int index = getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 7
Source File: ScriptObject.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final double key, final boolean strict) { final int index = getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 8
Source File: ScriptObject.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final long key, final boolean strict) { final int index = getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 9
Source File: ScriptObject.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final double key, final boolean strict) { final int index = getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 10
Source File: ScriptObject.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final int key, final boolean strict) { final int index = getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 11
Source File: ScriptObject.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final double key, final boolean strict) { final int index = getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 12
Source File: ScriptObject.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final int key, final boolean strict) { final int index = getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 13
Source File: ScriptObject.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final int key, final boolean strict) { final int index = getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 14
Source File: ScriptObject.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final int key, final boolean strict) { final int index = getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 15
Source File: ScriptObject.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final int key, final boolean strict) { final int index = getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 16
Source File: ScriptObject.java From nashorn with GNU General Public License v2.0 | 5 votes |
@Override public boolean delete(final long key, final boolean strict) { final int index = ArrayIndex.getArrayIndex(key); final ArrayData array = getArray(); if (array.has(index)) { if (array.canDelete(index, strict)) { setArray(array.delete(index)); return true; } return false; } return deleteObject(JSType.toObject(key), strict); }
Example 17
Source File: ScriptObject.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Handle when an array doesn't have a slot - possibly grow and/or convert array. * * @param index key as index * @param value element value * @param strict are we in strict mode */ private void doesNotHave(final int index, final Object value, final boolean strict) { final long oldLength = getArray().length(); final long longIndex = ArrayIndex.toLongIndex(index); if (getMap().containsArrayKeys()) { final String key = JSType.toString(longIndex); final FindProperty find = findProperty(key, true); if (find != null) { setObject(find, strict, key, value); return; } } if (longIndex >= oldLength) { if (!isExtensible()) { if (strict) { throw typeError("object.non.extensible", JSType.toString(index), ScriptRuntime.safeToString(this)); } return; } setArray(getArray().ensure(longIndex)); } if (value instanceof Integer) { setArray(getArray().set(index, (int)value, strict)); } else if (value instanceof Long) { setArray(getArray().set(index, (long)value, strict)); } else if (value instanceof Double) { setArray(getArray().set(index, (double)value, strict)); } else { setArray(getArray().set(index, value, strict)); } if (longIndex > oldLength) { ArrayData array = getArray(); if (array.canDelete(oldLength, (longIndex - 1), strict)) { array = array.delete(oldLength, (longIndex - 1)); } setArray(array); } }
Example 18
Source File: ScriptObject.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Handle when an array doesn't have a slot - possibly grow and/or convert array. * * @param index key as index * @param value element value * @param strict are we in strict mode */ private void doesNotHave(final int index, final Object value, final boolean strict) { final long oldLength = getArray().length(); final long longIndex = ArrayIndex.toLongIndex(index); if (getMap().containsArrayKeys()) { final String key = JSType.toString(longIndex); final FindProperty find = findProperty(key, true); if (find != null) { setObject(find, strict, key, value); return; } } if (longIndex >= oldLength) { if (!isExtensible()) { if (strict) { throw typeError("object.non.extensible", JSType.toString(index), ScriptRuntime.safeToString(this)); } return; } setArray(getArray().ensure(longIndex)); } if (value instanceof Integer) { setArray(getArray().set(index, (int)value, strict)); } else if (value instanceof Long) { setArray(getArray().set(index, (long)value, strict)); } else if (value instanceof Double) { setArray(getArray().set(index, (double)value, strict)); } else { setArray(getArray().set(index, value, strict)); } if (longIndex > oldLength) { ArrayData array = getArray(); if (array.canDelete(oldLength, (longIndex - 1), strict)) { array = array.delete(oldLength, (longIndex - 1)); } setArray(array); } }
Example 19
Source File: ScriptObject.java From nashorn with GNU General Public License v2.0 | 4 votes |
/** * Handle when an array doesn't have a slot - possibly grow and/or convert array. * * @param index key as index * @param value element value * @param strict are we in strict mode */ private void doesNotHave(final int index, final Object value, final boolean strict) { final long oldLength = getArray().length(); final long longIndex = index & JSType.MAX_UINT; if (!getArray().has(index)) { final String key = JSType.toString(longIndex); final FindProperty find = findProperty(key, true); if (find != null) { setObject(find, strict, key, value); return; } } if (longIndex >= oldLength) { if (!isExtensible()) { if (strict) { throw typeError("object.non.extensible", JSType.toString(index), ScriptRuntime.safeToString(this)); } return; } setArray(getArray().ensure(longIndex)); } if (value instanceof Integer) { setArray(getArray().set(index, (int)value, strict)); } else if (value instanceof Long) { setArray(getArray().set(index, (long)value, strict)); } else if (value instanceof Double) { setArray(getArray().set(index, (double)value, strict)); } else { setArray(getArray().set(index, value, strict)); } if (longIndex > oldLength) { ArrayData array = getArray(); if (array.canDelete(oldLength, (longIndex - 1), strict)) { array = array.delete(oldLength, (longIndex - 1)); } setArray(array); } }
Example 20
Source File: ScriptObject.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Numeric length setter for length property * * @param newLength new length to set */ public final void setLength(final long newLength) { ArrayData data = getArray(); final long arrayLength = data.length(); if (newLength == arrayLength) { return; } if (newLength > arrayLength) { data = data.ensure(newLength - 1); if (data.canDelete(arrayLength, newLength - 1, false)) { data = data.delete(arrayLength, newLength - 1); } setArray(data); return; } if (newLength < arrayLength) { long actualLength = newLength; // Check for numeric keys in property map and delete them or adjust length, depending on whether // they're defined as configurable. See ES5 #15.4.5.2 if (getMap().containsArrayKeys()) { for (long l = arrayLength - 1; l >= newLength; l--) { final FindProperty find = findProperty(JSType.toString(l), false); if (find != null) { if (find.getProperty().isConfigurable()) { deleteOwnProperty(find.getProperty()); } else { actualLength = l + 1; break; } } } } setArray(data.shrink(actualLength)); data.setLength(actualLength); } }