Java Code Examples for jdk.nashorn.internal.runtime.arrays.ArrayData#has()

The following examples show how to use jdk.nashorn.internal.runtime.arrays.ArrayData#has() . 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 jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void set(final long key, final long value, final int callSiteFlags) {
    final int index = getArrayIndex(key);

    if (isValidArrayIndex(index)) {
        final ArrayData data = getArray();
        if (data.has(index)) {
            setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
        } else {
            doesNotHave(index, value, callSiteFlags);
        }

        return;
    }

    final String propName = JSType.toString(key);
    setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
}
 
Example 2
Source File: ScriptObject.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void set(final double key, final double value, final int callSiteFlags) {
    final int index = getArrayIndex(key);

    if (isValidArrayIndex(index)) {
        final ArrayData data = getArray();
        if (data.has(index)) {
            setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
        } else {
            doesNotHave(index, value, callSiteFlags);
        }

        return;
    }

    final String propName = JSType.toString(key);
    setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
}
 
Example 3
Source File: ScriptObject.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void set(final Object key, final double value, final int callSiteFlags) {
    final Object primitiveKey = JSType.toPrimitive(key, String.class);
    final int    index        = getArrayIndex(primitiveKey);

    if (isValidArrayIndex(index)) {
        final ArrayData data = getArray();
        if (data.has(index)) {
            setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
        } else {
            doesNotHave(index, value, callSiteFlags);
        }

        return;
    }

    final String propName = JSType.toString(primitiveKey);
    setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
}
 
Example 4
Source File: ScriptObject.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@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 5
Source File: ScriptObject.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void set(final Object key, final Object value, final int callSiteFlags) {
    final Object primitiveKey = JSType.toPrimitive(key, String.class);
    final int    index        = getArrayIndex(primitiveKey);

    if (isValidArrayIndex(index)) {
        final ArrayData data = getArray();
        if (data.has(index)) {
            setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
        } else {
            doesNotHave(index, value, callSiteFlags);
        }

        return;
    }

    final String propName = JSType.toString(primitiveKey);
    setObject(findProperty(propName, true), callSiteFlags, propName, value);
}
 
Example 6
Source File: ScriptObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void set(final double key, final int value, final int callSiteFlags) {
    final int index = getArrayIndex(key);

    if (isValidArrayIndex(index)) {
        final ArrayData data = getArray();
        if (data.has(index)) {
            setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
        } else {
            doesNotHave(index, value, callSiteFlags);
        }

        return;
    }

    final String propName = JSType.toString(key);
    setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
}
 
Example 7
Source File: ScriptObject.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object get(final int key) {
    final int index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getObject(index);
    }

    return get(index, JSType.toString(key));
}
 
Example 8
Source File: ScriptObject.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public double getDouble(final double key, final int programPoint) {
    final int       index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return isValid(programPoint) ? array.getDoubleOptimistic(index, programPoint) : array.getDouble(index);
    }

    return getDouble(index, JSType.toString(key), programPoint);
}
 
Example 9
Source File: ScriptObject.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getInt(final long key, final int programPoint) {
    final int       index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return isValid(programPoint) ? array.getIntOptimistic(index, programPoint) : array.getInt(index);
    }

    return getInt(index, JSType.toString(key), programPoint);
}
 
Example 10
Source File: ScriptObject.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object get(final double key) {
    final int index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getObject(index);
    }

    return get(index, JSType.toString(key));
}
 
Example 11
Source File: ScriptObject.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object get(final double key) {
    final int index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getObject(index);
    }

    return get(index, JSType.toString(key));
}
 
Example 12
Source File: ScriptObject.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object get(final int key) {
    final int index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getObject(index);
    }

    return get(index, JSType.toString(key));
}
 
Example 13
Source File: ScriptObject.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public double getDouble(final Object key) {
    final Object primitiveKey = JSType.toPrimitive(key, String.class);
    final int index = getArrayIndex(primitiveKey);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getDouble(index);
    }

    return getDouble(index, JSType.toString(primitiveKey));
}
 
Example 14
Source File: ScriptObject.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getInt(final Object key, final int programPoint) {
    final Object    primitiveKey = JSType.toPrimitive(key, String.class);
    final int       index        = getArrayIndex(primitiveKey);
    final ArrayData array        = getArray();

    if (array.has(index)) {
        return isValid(programPoint) ? array.getIntOptimistic(index, programPoint) : array.getInt(index);
    }

    return getInt(index, JSType.toPropertyKey(primitiveKey), programPoint);
}
 
Example 15
Source File: ScriptObject.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getInt(final double key, final int programPoint) {
    final int       index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return isValid(programPoint) ? array.getIntOptimistic(index, programPoint) : array.getInt(index);
    }

    return getInt(index, JSType.toString(key), programPoint);
}
 
Example 16
Source File: ScriptObject.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getInt(final long key) {
    final int index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getInt(index);
    }

    return getInt(index, JSType.toString(key));
}
 
Example 17
Source File: ScriptObject.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object get(final double key) {
    final int index = ArrayIndex.getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getObject(index);
    }

    return get(index, JSType.toString(key));
}
 
Example 18
Source File: ScriptObject.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getInt(final long key) {
    final int index = ArrayIndex.getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getInt(index);
    }

    return getInt(index, JSType.toString(key));
}
 
Example 19
Source File: ScriptObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getInt(final double key, final int programPoint) {
    final int       index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return isValid(programPoint) ? array.getIntOptimistic(index, programPoint) : array.getInt(index);
    }

    return getInt(index, JSType.toString(key), programPoint);
}
 
Example 20
Source File: ScriptObject.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object get(final Object key) {
    final Object    primitiveKey = JSType.toPrimitive(key, String.class);
    final int       index        = getArrayIndex(primitiveKey);
    final ArrayData array        = getArray();

    if (array.has(index)) {
        return array.getObject(index);
    }

    return get(index, JSType.toPropertyKey(primitiveKey));
}