Java Code Examples for jdk.nashorn.internal.runtime.arrays.ContinuousArrayData#isEmpty()

The following examples show how to use jdk.nashorn.internal.runtime.arrays.ContinuousArrayData#isEmpty() . 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 TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param arg argument
 * @return resulting NativeArray
 */
@SpecializedFunction(linkLogic=ConcatLinkLogic.class)
public static NativeArray concat(final Object self, final Object arg) {
    //arg is [NativeArray] of same type.
    final ContinuousArrayData selfData = getContinuousArrayDataCCE(self);
    final ContinuousArrayData newData;

    if (arg instanceof NativeArray) {
        final ContinuousArrayData argData = (ContinuousArrayData)((NativeArray)arg).getArray();
        if (argData.isEmpty()) {
            newData = selfData.copy();
        } else if (selfData.isEmpty()) {
            newData = argData.copy();
        } else {
            final Class<?> widestElementType = selfData.widest(argData).getBoxedElementType();
            newData = ((ContinuousArrayData)selfData.convert(widestElementType)).fastConcat((ContinuousArrayData)argData.convert(widestElementType));
        }
    } else {
        newData = getContinuousArrayDataCCE(self, Object.class).copy();
        newData.fastPush(arg);
    }

    return new NativeArray(newData);
}
 
Example 2
Source File: NativeArray.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param arg argument
 * @return resulting NativeArray
 */
@SpecializedFunction(linkLogic=ConcatLinkLogic.class)
public static NativeArray concat(final Object self, final Object arg) {
    //arg is [NativeArray] of same type.
    final ContinuousArrayData selfData = getContinuousArrayDataCCE(self);
    final ContinuousArrayData newData;

    if (arg instanceof NativeArray) {
        final ContinuousArrayData argData = (ContinuousArrayData)((NativeArray)arg).getArray();
        if (argData.isEmpty()) {
            newData = selfData.copy();
        } else if (selfData.isEmpty()) {
            newData = argData.copy();
        } else {
            final Class<?> widestElementType = selfData.widest(argData).getBoxedElementType();
            newData = ((ContinuousArrayData)selfData.convert(widestElementType)).fastConcat((ContinuousArrayData)argData.convert(widestElementType));
        }
    } else {
        newData = getContinuousArrayDataCCE(self, Object.class).copy();
        newData.fastPush(arg);
    }

    return new NativeArray(newData);
}
 
Example 3
Source File: NativeArray.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param arg argument
 * @return resulting NativeArray
 */
@SpecializedFunction(linkLogic=ConcatLinkLogic.class)
public static NativeArray concat(final Object self, final Object arg) {
    //arg is [NativeArray] of same type.
    final ContinuousArrayData selfData = getContinuousArrayDataCCE(self);
    final ContinuousArrayData newData;

    if (arg instanceof NativeArray) {
        final ContinuousArrayData argData = (ContinuousArrayData)((NativeArray)arg).getArray();
        if (argData.isEmpty()) {
            newData = selfData.copy();
        } else if (selfData.isEmpty()) {
            newData = argData.copy();
        } else {
            final Class<?> widestElementType = selfData.widest(argData).getBoxedElementType();
            newData = ((ContinuousArrayData)selfData.convert(widestElementType)).fastConcat((ContinuousArrayData)argData.convert(widestElementType));
        }
    } else {
        newData = getContinuousArrayDataCCE(self, Object.class).copy();
        newData.fastPush(arg);
    }

    return new NativeArray(newData);
}
 
Example 4
Source File: NativeArray.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param arg argument
 * @return resulting NativeArray
 */
@SpecializedFunction(linkLogic=ConcatLinkLogic.class)
public static NativeArray concat(final Object self, final Object arg) {
    //arg is [NativeArray] of same type.
    final ContinuousArrayData selfData = getContinuousArrayDataCCE(self);
    final ContinuousArrayData newData;

    if (arg instanceof NativeArray) {
        final ContinuousArrayData argData = (ContinuousArrayData)((NativeArray)arg).getArray();
        if (argData.isEmpty()) {
            newData = selfData.copy();
        } else if (selfData.isEmpty()) {
            newData = argData.copy();
        } else {
            final Class<?> widestElementType = selfData.widest(argData).getBoxedElementType();
            newData = ((ContinuousArrayData)selfData.convert(widestElementType)).fastConcat((ContinuousArrayData)argData.convert(widestElementType));
        }
    } else {
        newData = getContinuousArrayDataCCE(self, Object.class).copy();
        newData.fastPush(arg);
    }

    return new NativeArray(newData);
}
 
Example 5
Source File: NativeArray.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param arg argument
 * @return resulting NativeArray
 */
@SpecializedFunction(linkLogic=ConcatLinkLogic.class)
public static NativeArray concat(final Object self, final Object arg) {
    //arg is [NativeArray] of same type.
    final ContinuousArrayData selfData = getContinuousArrayDataCCE(self);
    final ContinuousArrayData newData;

    if (arg instanceof NativeArray) {
        final ContinuousArrayData argData = (ContinuousArrayData)((NativeArray)arg).getArray();
        if (argData.isEmpty()) {
            newData = selfData.copy();
        } else if (selfData.isEmpty()) {
            newData = argData.copy();
        } else {
            final Class<?> widestElementType = selfData.widest(argData).getBoxedElementType();
            newData = ((ContinuousArrayData)selfData.convert(widestElementType)).fastConcat((ContinuousArrayData)argData.convert(widestElementType));
        }
    } else {
        newData = getContinuousArrayDataCCE(self, Object.class).copy();
        newData.fastPush(arg);
    }

    return new NativeArray(newData);
}
 
Example 6
Source File: NativeArray.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param arg argument
 * @return resulting NativeArray
 */
@SpecializedFunction(linkLogic=ConcatLinkLogic.class)
public static NativeArray concat(final Object self, final Object arg) {
    //arg is [NativeArray] of same type.
    final ContinuousArrayData selfData = getContinuousArrayDataCCE(self);
    final ContinuousArrayData newData;

    if (arg instanceof NativeArray) {
        final ContinuousArrayData argData = (ContinuousArrayData)((NativeArray)arg).getArray();
        if (argData.isEmpty()) {
            newData = selfData.copy();
        } else if (selfData.isEmpty()) {
            newData = argData.copy();
        } else {
            final Class<?> widestElementType = selfData.widest(argData).getBoxedElementType();
            newData = ((ContinuousArrayData)selfData.convert(widestElementType)).fastConcat((ContinuousArrayData)argData.convert(widestElementType));
        }
    } else {
        newData = getContinuousArrayDataCCE(self, Object.class).copy();
        newData.fastPush(arg);
    }

    return new NativeArray(newData);
}
 
Example 7
Source File: NativeArray.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param arg argument
 * @return resulting NativeArray
 */
@SpecializedFunction(linkLogic=ConcatLinkLogic.class)
public static NativeArray concat(final Object self, final Object arg) {
    //arg is [NativeArray] of same type.
    final ContinuousArrayData selfData = getContinuousArrayDataCCE(self);
    final ContinuousArrayData newData;

    if (arg instanceof NativeArray) {
        final ContinuousArrayData argData = (ContinuousArrayData)((NativeArray)arg).getArray();
        if (argData.isEmpty()) {
            newData = selfData.copy();
        } else if (selfData.isEmpty()) {
            newData = argData.copy();
        } else {
            final Class<?> widestElementType = selfData.widest(argData).getBoxedElementType();
            newData = ((ContinuousArrayData)selfData.convert(widestElementType)).fastConcat((ContinuousArrayData)argData.convert(widestElementType));
        }
    } else {
        newData = getContinuousArrayDataCCE(self, Object.class).copy();
        newData.fastPush(arg);
    }

    return new NativeArray(newData);
}