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


Java Bootstrap.isStrictCallable方法代码示例

本文整理汇总了Java中jdk.nashorn.internal.runtime.linker.Bootstrap.isStrictCallable方法的典型用法代码示例。如果您正苦于以下问题:Java Bootstrap.isStrictCallable方法的具体用法?Java Bootstrap.isStrictCallable怎么用?Java Bootstrap.isStrictCallable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.nashorn.internal.runtime.linker.Bootstrap的用法示例。


在下文中一共展示了Bootstrap.isStrictCallable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import jdk.nashorn.internal.runtime.linker.Bootstrap; //导入方法依赖的package包/类
/**
 * Apply action main loop.
 * @return result of apply
 */
public final T apply() {
    final boolean strict = Bootstrap.isStrictCallable(callbackfn);

    // for non-strict callback, need to translate undefined thisArg to be global object
    thisArg = (thisArg == ScriptRuntime.UNDEFINED && !strict)? Context.getGlobal() : thisArg;

    applyLoopBegin(iter);
    final boolean reverse = iter.isReverse();
    while (iter.hasNext()) {

        final Object val = iter.next();
        index = iter.nextIndex() + (reverse ? 1 : -1);

        try {
            if (!forEach(val, index)) {
                return result;
            }
        } catch (final RuntimeException | Error e) {
            throw e;
        } catch (final Throwable t) {
            throw new RuntimeException(t);
        }
    }

    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:IteratorAction.java

示例2: sort

import jdk.nashorn.internal.runtime.linker.Bootstrap; //导入方法依赖的package包/类
private static Object[] sort(final Object[] array, final Object comparefn) {
    final Object cmp = compareFunction(comparefn);

    final List<Object> list = Arrays.asList(array);
    final Object cmpThis = cmp == null || Bootstrap.isStrictCallable(cmp) ? ScriptRuntime.UNDEFINED : Global.instance();

    try {
        Collections.sort(list, new Comparator<Object>() {
            private final MethodHandle call_cmp = getCALL_CMP();
            @Override
            public int compare(final Object x, final Object y) {
                if (x == ScriptRuntime.UNDEFINED && y == ScriptRuntime.UNDEFINED) {
                    return 0;
                } else if (x == ScriptRuntime.UNDEFINED) {
                    return 1;
                } else if (y == ScriptRuntime.UNDEFINED) {
                    return -1;
                }

                if (cmp != null) {
                    try {
                        return (int)Math.signum((double)call_cmp.invokeExact(cmp, cmpThis, x, y));
                    } catch (final RuntimeException | Error e) {
                        throw e;
                    } catch (final Throwable t) {
                        throw new RuntimeException(t);
                    }
                }

                return JSType.toString(x).compareTo(JSType.toString(y));
            }
        });
    } catch (final IllegalArgumentException iae) {
        // Collections.sort throws IllegalArgumentException when
        // Comparison method violates its general contract

        // See ECMA spec 15.4.4.11 Array.prototype.sort (comparefn).
        // If "comparefn" is not undefined and is not a consistent
        // comparison function for the elements of this array, the
        // behaviour of sort is implementation-defined.
    }

    return list.toArray(new Object[0]);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:45,代码来源:NativeArray.java

示例3: sort

import jdk.nashorn.internal.runtime.linker.Bootstrap; //导入方法依赖的package包/类
private static Object[] sort(final Object[] array, final Object comparefn) {
    final Object cmp = compareFunction(comparefn);

    final List<Object> list = Arrays.asList(array);
    final Object cmpThis = cmp == null || Bootstrap.isStrictCallable(cmp) ? ScriptRuntime.UNDEFINED : Global.instance();

    try {
        Collections.sort(list, new Comparator<Object>() {
            private final MethodHandle call_cmp = getCALL_CMP();
            @Override
            public int compare(final Object x, final Object y) {
                if (x == ScriptRuntime.UNDEFINED && y == ScriptRuntime.UNDEFINED) {
                    return 0;
                } else if (x == ScriptRuntime.UNDEFINED) {
                    return 1;
                } else if (y == ScriptRuntime.UNDEFINED) {
                    return -1;
                }

                if (cmp != null) {
                    try {
                        return (int)Math.signum((double)call_cmp.invokeExact(cmp, cmpThis, x, y));
                    } catch (final RuntimeException | Error e) {
                        throw e;
                    } catch (final Throwable t) {
                        throw new RuntimeException(t);
                    }
                }

                return JSType.toString(x).compareTo(JSType.toString(y));
            }
        });
    } catch (final IllegalArgumentException iae) {
        // Collections.sort throws IllegalArgumentException when
        // Comparison method violates its general contract

        // See ECMA spec 15.4.4.11 Array.prototype.sort (comparefn).
        // If "comparefn" is not undefined and is not a consistent
        // comparison function for the elements of this array, the
        // behaviour of sort is implementation-defined.
    }

    return list.toArray(new Object[array.length]);
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:45,代码来源:NativeArray.java


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