当前位置: 首页>>代码示例>>Java>>正文


Java SpecializedFunction类代码示例

本文整理汇总了Java中jdk.nashorn.internal.objects.annotations.SpecializedFunction的典型用法代码示例。如果您正苦于以下问题:Java SpecializedFunction类的具体用法?Java SpecializedFunction怎么用?Java SpecializedFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SpecializedFunction类属于jdk.nashorn.internal.objects.annotations包,在下文中一共展示了SpecializedFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toFixed

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * ECMA 15.7.4.5 Number.prototype.toFixed (fractionDigits) specialized for int fractionDigits
 *
 * @param self           self reference
 * @param fractionDigits how many digits should be after the decimal point, 0 if undefined
 *
 * @return number in decimal fixed point notation
 */
@SpecializedFunction
public static String toFixed(final Object self, final int fractionDigits) {
    if (fractionDigits < 0 || fractionDigits > 20) {
        throw rangeError("invalid.fraction.digits", "toFixed");
    }

    final double x = getNumberValue(self);
    if (Double.isNaN(x)) {
        return "NaN";
    }

    if (Math.abs(x) >= 1e21) {
        return JSType.toString(x);
    }

    final NumberFormat format = NumberFormat.getNumberInstance(Locale.US);
    format.setMinimumFractionDigits(fractionDigits);
    format.setMaximumFractionDigits(fractionDigits);
    format.setGroupingUsed(false);

    return format.format(x);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:NativeNumber.java

示例2: concat

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:NativeArray.java

示例3: toFixed

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * ECMA 15.7.4.5 Number.prototype.toFixed (fractionDigits) specialized for int fractionDigits
 *
 * @param self           self reference
 * @param fractionDigits how many digits should be after the decimal point, 0 if undefined
 *
 * @return number in decimal fixed point notation
 */
@SpecializedFunction
public static String toFixed(final Object self, final int fractionDigits) {
    if (fractionDigits < 0 || fractionDigits > 20) {
        throw rangeError("invalid.fraction.digits", "toFixed");
    }

    final double x = getNumberValue(self);
    if (Double.isNaN(x)) {
        return "NaN";
    }

    if (Math.abs(x) >= 1e21) {
        return JSType.toString(x);
    }

    return DoubleConversion.toFixed(x, fractionDigits);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:NativeNumber.java

示例4: fromCharCode

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * ECMA 15.5.3.2 - specialization for one char
 * @param self  self reference
 * @param value one argument to be interpreted as char
 * @return string with one charcode
 */
@SpecializedFunction
public static Object fromCharCode(final Object self, final Object value) {
    if (value instanceof Integer) {
        return fromCharCode(self, (int)value);
    }
    return Character.toString((char)JSType.toUint16(value));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:NativeString.java

示例5: getInt32

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * Get 32-bit signed int from given byteOffset
 *
 * @param self DataView object
 * @param byteOffset byte offset to read from
 * @return 32-bit signed int value at the byteOffset
 */
@SpecializedFunction
public static int getInt32(final Object self, final int byteOffset) {
    try {
        return getBuffer(self, false).getInt(byteOffset);
    } catch (final IllegalArgumentException iae) {
        throw rangeError(iae, "dataview.offset");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:NativeDataView.java

示例6: slice

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * ECMA 15.5.4.13 String.prototype.slice (start, end) specialized for single int parameter
 *
 * @param self  self reference
 * @param start start position for slice
 * @return sliced out substring
 */
@SpecializedFunction
public static String slice(final Object self, final int start) {
    final String str = checkObjectToString(self);
    final int from = start < 0 ? Math.max(str.length() + start, 0) : Math.min(start, str.length());

    return str.substring(from);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:NativeString.java

示例7: substring

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * ECMA 15.5.4.15 String.prototype.substring (start, end) specialized for int start parameter
 *
 * @param self  self reference
 * @param start start position of substring
 * @return substring given start and end indexes
 */
@SpecializedFunction
public static String substring(final Object self, final int start) {
    final String str = checkObjectToString(self);
    if (start < 0) {
        return str;
    } else if (start >= str.length()) {
        return "";
    } else {
        return str.substring(start);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:NativeString.java

示例8: setInt16

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * Set 16-bit signed int at the given byteOffset
 *
 * @param self DataView object
 * @param byteOffset byte offset to write at
 * @param value short value to set
 * @param littleEndian (optional) flag indicating whether to write in little endian order
 * @return undefined
 */
@SpecializedFunction
public static Object setInt16(final Object self, final int byteOffset, final int value, final boolean littleEndian) {
    try {
        getBuffer(self, littleEndian).putShort(byteOffset, (short)value);
        return UNDEFINED;
    } catch (final IllegalArgumentException iae) {
        throw rangeError(iae, "dataview.offset");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:NativeDataView.java

示例9: getFloat32

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * Get 32-bit float value from given byteOffset
 *
 * @param self DataView object
 * @param byteOffset byte offset to read from
 * @return 32-bit float value at the byteOffset
 */
@SpecializedFunction
public static double getFloat32(final Object self, final int byteOffset) {
    try {
        return getBuffer(self, false).getFloat(byteOffset);
    } catch (final IllegalArgumentException iae) {
        throw rangeError(iae, "dataview.offset");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:NativeDataView.java

示例10: construct

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * ECMA 15.4.2.2 new Array (len)
 *
 * Specialized constructor for one double argument (length)
 *
 * @param newObj was the new operator used to instantiate this array
 * @param self   self reference
 * @param length array length
 * @return the new NativeArray
 */
@SpecializedFunction(isConstructor=true)
public static NativeArray construct(final boolean newObj, final Object self, final double length) {
    final long uint32length = JSType.toUint32(length);

    if (uint32length == length) {
        return new NativeArray(uint32length);
    }

    return construct(newObj, self, new Object[]{length});
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:NativeArray.java

示例11: setFloat32

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * Set 32-bit float at the given byteOffset
 *
 * @param self DataView object
 * @param byteOffset byte offset to write at
 * @param value float value to set
 * @param littleEndian (optional) flag indicating whether to write in little endian order
 * @return undefined
 */
@SpecializedFunction
public static Object setFloat32(final Object self, final int byteOffset, final double value, final boolean littleEndian) {
    try {
        getBuffer(self, littleEndian).putFloat(byteOffset, (float)value);
        return UNDEFINED;
    } catch (final IllegalArgumentException iae) {
        throw rangeError(iae, "dataview.offset");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:NativeDataView.java

示例12: setUint32

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * Set 32-bit unsigned int at the given byteOffset
 *
 * @param self DataView object
 * @param byteOffset byte offset to write at
 * @param value int value to set
 * @return undefined
 */
@SpecializedFunction
public static Object setUint32(final Object self, final int byteOffset, final double value) {
    try {
        getBuffer(self, false).putInt(byteOffset, (int) JSType.toUint32(value));
        return UNDEFINED;
    } catch (final IllegalArgumentException iae) {
        throw rangeError(iae, "dataview.offset");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:NativeDataView.java

示例13: getFloat64

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * Get 64-bit float value from given byteOffset
 *
 * @param self DataView object
 * @param byteOffset byte offset to read from
 * @return 64-bit float value at the byteOffset
 */
@SpecializedFunction
public static double getFloat64(final Object self, final int byteOffset) {
    try {
        return getBuffer(self, false).getDouble(byteOffset);
    } catch (final IllegalArgumentException iae) {
        throw rangeError(iae, "dataview.offset");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:NativeDataView.java

示例14: getInt8

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
/**
 * Get 8-bit signed int from given byteOffset
 *
 * @param self DataView object
 * @param byteOffset byte offset to read from
 * @return 8-bit signed int value at the byteOffset
 */
@SpecializedFunction
public static int getInt8(final Object self, final int byteOffset) {
    try {
        return getBuffer(self).get(byteOffset);
    } catch (final IllegalArgumentException iae) {
        throw rangeError(iae, "dataview.offset");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:NativeDataView.java

示例15: getLinkLogic

import jdk.nashorn.internal.objects.annotations.SpecializedFunction; //导入依赖的package包/类
@Override
public SpecializedFunction.LinkLogic getLinkLogic(final Class<? extends LinkLogic> clazz) {
    if (clazz == PushLinkLogic.class) {
        return PushLinkLogic.INSTANCE;
    } else if (clazz == PopLinkLogic.class) {
        return PopLinkLogic.INSTANCE;
    } else if (clazz == ConcatLinkLogic.class) {
        return ConcatLinkLogic.INSTANCE;
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:NativeArray.java


注:本文中的jdk.nashorn.internal.objects.annotations.SpecializedFunction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。