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


Java ScriptFunction.isStrict方法代码示例

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


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

示例1: allocate

import jdk.nashorn.internal.runtime.ScriptFunction; //导入方法依赖的package包/类
/**
 * Factory to create correct Arguments object based on strict mode.
 *
 * @param arguments the actual arguments array passed
 * @param callee the callee function that uses arguments object
 * @param numParams the number of declared (named) function parameters
 * @return Arguments Object
 */
public static ScriptObject allocate(final Object[] arguments, final ScriptFunction callee, final int numParams) {
    // Strict functions won't always have a callee for arguments, and will pass null instead.
    final boolean isStrict = callee == null || callee.isStrict();
    final Global global = Global.instance();
    final ScriptObject proto = global.getObjectPrototype();
    if (isStrict) {
        return new NativeStrictArguments(arguments, numParams, proto, NativeStrictArguments.getInitialMap());
    }
    return new NativeArguments(arguments, callee, numParams, proto, NativeArguments.getInitialMap());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:NativeArguments.java

示例2: sort

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

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

    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));
        }
    });

    return list.toArray(new Object[array.length]);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:NativeArray.java

示例3: getCallThis

import jdk.nashorn.internal.runtime.ScriptFunction; //导入方法依赖的package包/类
/**
 * Given a script function used as a delegate for a SAM adapter, figure out
 * the right object to use as its "this" when called.
 * @param delegate the delegate function
 * @param global the current global of the adapter
 * @return either the passed global, or UNDEFINED if the function is strict.
 */
public static Object getCallThis(final ScriptFunction delegate, final Object global) {
    return delegate.isStrict() ? ScriptRuntime.UNDEFINED : global;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:JavaAdapterServices.java


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