Java Code Examples for jdk.nashorn.internal.runtime.ScriptRuntime#EMPTY

The following examples show how to use jdk.nashorn.internal.runtime.ScriptRuntime#EMPTY . 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: NativeArray.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
NativeArray(final Object[] array) {
    this(ArrayData.allocate(array.length));

    ArrayData arrayData = this.getArray();

    for (int index = 0; index < array.length; index++) {
        final Object value = array[index];

        if (value == ScriptRuntime.EMPTY) {
            arrayData = arrayData.delete(index);
        } else {
            arrayData = arrayData.set(index, value, false);
        }
    }

    this.setArray(arrayData);
}
 
Example 2
Source File: NativeArray.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
NativeArray(final Object[] array) {
    this(ArrayData.allocate(array.length));

    ArrayData arrayData = this.getArray();
    arrayData.ensure(array.length - 1);

    for (int index = 0; index < array.length; index++) {
        final Object value = array[index];

        if (value == ScriptRuntime.EMPTY) {
            arrayData = arrayData.delete(index);
        } else {
            arrayData = arrayData.set(index, value, false);
        }
    }

    this.setArray(arrayData);
}
 
Example 3
Source File: NativeArray.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
NativeArray(final Object[] array) {
    this(ArrayData.allocate(array.length));

    ArrayData arrayData = this.getArray();

    for (int index = 0; index < array.length; index++) {
        final Object value = array[index];

        if (value == ScriptRuntime.EMPTY) {
            arrayData = arrayData.delete(index);
        } else {
            arrayData = arrayData.set(index, value, false);
        }
    }

    this.setArray(arrayData);
}
 
Example 4
Source File: NativeArray.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
NativeArray(final Object[] array) {
    this(ArrayData.allocate(array.length));

    ArrayData arrayData = this.getArray();

    for (int index = 0; index < array.length; index++) {
        final Object value = array[index];

        if (value == ScriptRuntime.EMPTY) {
            arrayData = arrayData.delete(index);
        } else {
            arrayData = arrayData.set(index, value, false);
        }
    }

    this.setArray(arrayData);
}
 
Example 5
Source File: NativeArray.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
NativeArray(final Object[] array) {
    this(ArrayData.allocate(array.length));

    ArrayData arrayData = this.getArray();

    for (int index = 0; index < array.length; index++) {
        final Object value = array[index];

        if (value == ScriptRuntime.EMPTY) {
            arrayData = arrayData.delete(index);
        } else {
            arrayData = arrayData.set(index, value, false);
        }
    }

    this.setArray(arrayData);
}
 
Example 6
Source File: ObjectArrayData.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object fastPopObject() {
    if (length() == 0) {
        return ScriptRuntime.UNDEFINED;
    }
    final int newLength = (int)decreaseLength();
    final Object elem = array[newLength];
    array[newLength] = ScriptRuntime.EMPTY;
    return elem;
}
 
Example 7
Source File: Global.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Allocate a new object array.
 *
 * @param initial object values.
 * @return the new array
 */
public static NativeArray allocate(final Object[] initial) {
    ArrayData arrayData = ArrayData.allocate(initial);

    for (int index = 0; index < initial.length; index++) {
        final Object value = initial[index];

        if (value == ScriptRuntime.EMPTY) {
            arrayData = arrayData.delete(index);
        }
    }

    return new NativeArray(arrayData);
}
 
Example 8
Source File: ObjectArrayData.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object fastPopObject() {
    if (length() == 0) {
        return ScriptRuntime.UNDEFINED;
    }
    final int newLength = (int)decreaseLength();
    final Object elem = array[newLength];
    array[newLength] = ScriptRuntime.EMPTY;
    return elem;
}
 
Example 9
Source File: ObjectArrayData.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object fastPopObject() {
    if (length() == 0) {
        return ScriptRuntime.UNDEFINED;
    }
    final int newLength = (int)decreaseLength();
    final Object elem = array[newLength];
    array[newLength] = ScriptRuntime.EMPTY;
    return elem;
}
 
Example 10
Source File: Global.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Allocate a new object array.
 *
 * @param initial object values.
 * @return the new array
 */
public static NativeArray allocate(final Object[] initial) {
    ArrayData arrayData = ArrayData.allocate(initial);

    for (int index = 0; index < initial.length; index++) {
        final Object value = initial[index];

        if (value == ScriptRuntime.EMPTY) {
            arrayData = arrayData.delete(index);
        }
    }

    return new NativeArray(arrayData);
}
 
Example 11
Source File: ObjectArrayData.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object fastPopObject() {
    if (length() == 0) {
        return ScriptRuntime.UNDEFINED;
    }
    final int newLength = (int)decreaseLength();
    final Object elem = array[newLength];
    array[newLength] = ScriptRuntime.EMPTY;
    return elem;
}
 
Example 12
Source File: Global.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Allocate a new object array.
 *
 * @param initial object values.
 * @return the new array
 */
public static NativeArray allocate(final Object[] initial) {
    ArrayData arrayData = ArrayData.allocate(initial);

    for (int index = 0; index < initial.length; index++) {
        final Object value = initial[index];

        if (value == ScriptRuntime.EMPTY) {
            arrayData = arrayData.delete(index);
        }
    }

    return new NativeArray(arrayData);
}
 
Example 13
Source File: Global.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Allocate a new object array.
 *
 * @param initial object values.
 * @return the new array
 */
public static NativeArray allocate(final Object[] initial) {
    ArrayData arrayData = ArrayData.allocate(initial);

    for (int index = 0; index < initial.length; index++) {
        final Object value = initial[index];

        if (value == ScriptRuntime.EMPTY) {
            arrayData = arrayData.delete(index);
        }
    }

    return new NativeArray(arrayData);
}
 
Example 14
Source File: ObjectArrayData.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object fastPopObject() {
    if (length() == 0) {
        return ScriptRuntime.UNDEFINED;
    }
    final int newLength = (int)decreaseLength();
    final Object elem = array[newLength];
    array[newLength] = ScriptRuntime.EMPTY;
    return elem;
}
 
Example 15
Source File: ObjectArrayData.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ArrayData setEmpty(final int index) {
    array[index] = ScriptRuntime.EMPTY;
    return this;
}
 
Example 16
Source File: ObjectArrayData.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ArrayData setEmpty(final int index) {
    array[index] = ScriptRuntime.EMPTY;
    return this;
}
 
Example 17
Source File: ObjectArrayData.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ArrayData setEmpty(final int index) {
    array[index] = ScriptRuntime.EMPTY;
    return this;
}
 
Example 18
Source File: ObjectArrayData.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ArrayData setEmpty(final int index) {
    array[index] = ScriptRuntime.EMPTY;
    return this;
}
 
Example 19
Source File: ObjectArrayData.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ArrayData setEmpty(final int index) {
    array[index] = ScriptRuntime.EMPTY;
    return this;
}
 
Example 20
Source File: ObjectArrayData.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ArrayData setEmpty(final int index) {
    array[index] = ScriptRuntime.EMPTY;
    return this;
}