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


Java GuardedInvocation类代码示例

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


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

示例1: getGuardedInvocation

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices)
        throws Exception {
    final LinkRequest ncrequest = request.withoutRuntimeContext();
    // BeansLinker already checked that the name is at least 2 elements long and the first element is "dyn".
    final CallSiteDescriptor callSiteDescriptor = ncrequest.getCallSiteDescriptor();
    final String op = callSiteDescriptor.getNameToken(CallSiteDescriptor.OPERATOR);
    // Either dyn:callMethod:name(this[,args]) or dyn:callMethod(this,name[,args]).
    if("callMethod" == op) {
        return getCallPropWithThis(callSiteDescriptor, linkerServices);
    }
    List<String> operations = CallSiteDescriptorFactory.tokenizeOperators(callSiteDescriptor);
    while(!operations.isEmpty()) {
        final GuardedInvocationComponent gic = getGuardedInvocationComponent(callSiteDescriptor, linkerServices,
                operations);
        if(gic != null) {
            return gic.getGuardedInvocation();
        }
        operations = pop(operations);
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:AbstractJavaLinker.java

示例2: findSetMethod

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
@Override
public GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final boolean isScope = NashornCallSiteDescriptor.isScope(desc);

    if (lexicalScope != null && isScope) {
        final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
        if (lexicalScope.hasOwnProperty(name)) {
            return lexicalScope.findSetMethod(desc, request);
        }
    }

    final GuardedInvocation invocation = super.findSetMethod(desc, request);

    if (isScope && context.getEnv()._es6) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:Global.java

示例3: getArrayConverter

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
/**
 * Returns a guarded invocation that converts from a source type that is NativeArray to a Java array or List or
 * Deque type.
 * @param sourceType the source type (presumably NativeArray a superclass of it)
 * @param targetType the target type (presumably an array type, or List or Deque)
 * @return a guarded invocation that converts from the source type to the target type. null is returned if
 * either the source type is neither NativeArray, nor a superclass of it, or if the target type is not an array
 * type, List, or Deque.
 */
private static GuardedInvocation getArrayConverter(final Class<?> sourceType, final Class<?> targetType) {
    final boolean isSourceTypeNativeArray = sourceType == NativeArray.class;
    // If source type is more generic than NativeArray class, we'll need to use a guard
    final boolean isSourceTypeGeneric = !isSourceTypeNativeArray && sourceType.isAssignableFrom(NativeArray.class);

    if (isSourceTypeNativeArray || isSourceTypeGeneric) {
        final MethodHandle guard = isSourceTypeGeneric ? IS_NATIVE_ARRAY : null;
        if(targetType.isArray()) {
            return new GuardedInvocation(ARRAY_CONVERTERS.get(targetType), guard);
        }
        if(targetType == List.class) {
            return new GuardedInvocation(JSType.TO_JAVA_LIST.methodHandle(), guard);
        }
        if(targetType == Deque.class) {
            return new GuardedInvocation(JSType.TO_JAVA_DEQUE.methodHandle(), guard);
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:NashornLinker.java

示例4: getGuardedInvocation

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception {
    final LinkRequest requestWithoutContext = request.withoutRuntimeContext(); // Nashorn has no runtime context
    final Object self = requestWithoutContext.getReceiver();
    final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();
    checkJSObjectClass();

    if (desc.getNameTokenCount() < 2 || !"dyn".equals(desc.getNameToken(CallSiteDescriptor.SCHEME))) {
        // We only support standard "dyn:*[:*]" operations
        return null;
    }

    final GuardedInvocation inv;
    if (jsObjectClass.isInstance(self)) {
        inv = lookup(desc, request, linkerServices);
    } else {
        throw new AssertionError(); // Should never reach here.
    }

    return Bootstrap.asTypeSafeReturn(inv, linkerServices, desc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:BrowserJSObjectLinker.java

示例5: lookup

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
private GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request, final LinkerServices linkerServices) throws Exception {
    final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0);
    final int c = desc.getNameTokenCount();

    switch (operator) {
        case "getProp":
        case "getElem":
        case "getMethod":
            if (c > 2) {
                return findGetMethod(desc);
            }
        // For indexed get, we want GuardedInvocation from beans linker and pass it.
        // BrowserJSObjectLinker.get uses this fallback getter for explicit signature method access.
        return findGetIndexMethod(nashornBeansLinker.getGuardedInvocation(request, linkerServices));
        case "setProp":
        case "setElem":
            return c > 2 ? findSetMethod(desc) : findSetIndexMethod();
        case "call":
            return findCallMethod(desc);
        default:
            return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:BrowserJSObjectLinker.java

示例6: getGuardedInvocation

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices)
        throws Exception {
    final GuardedInvocation gi = super.getGuardedInvocation(request, linkerServices);
    if(gi != null) {
        return gi;
    }
    final CallSiteDescriptor desc = request.getCallSiteDescriptor();
    final String op = desc.getNameToken(CallSiteDescriptor.OPERATOR);
    if("new" == op && constructor != null) {
        final MethodHandle ctorInvocation = constructor.getInvocation(desc, linkerServices);
        if(ctorInvocation != null) {
            return new GuardedInvocation(ctorInvocation, getClassGuard(desc.getMethodType()));
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:StaticClassLinker.java

示例7: lookup

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
private GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request, final LinkerServices linkerServices) throws Exception {
    final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0);
    final int c = desc.getNameTokenCount();

    switch (operator) {
        case "getProp":
        case "getElem":
        case "getMethod":
            if (c > 2) {
                return findGetMethod(desc);
            }
        // For indexed get, we want get GuardedInvocation beans linker and pass it.
        // JSObjectLinker.get uses this fallback getter for explicit signature method access.
        return findGetIndexMethod(nashornBeansLinker.getGuardedInvocation(request, linkerServices));
        case "setProp":
        case "setElem":
            return c > 2 ? findSetMethod(desc) : findSetIndexMethod();
        case "call":
            return findCallMethod(desc);
        case "new":
            return findNewMethod(desc);
        default:
            return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:JSObjectLinker.java

示例8: linkNull

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
private static GuardedInvocation linkNull(final LinkRequest linkRequest) {
    final NashornCallSiteDescriptor desc = (NashornCallSiteDescriptor)linkRequest.getCallSiteDescriptor();
    final String operator = desc.getFirstOperator();
    switch (operator) {
    case "new":
    case "call":
        throw typeError("not.a.function", "null");
    case "callMethod":
    case "getMethod":
        throw typeError("no.such.function", getArgument(linkRequest), "null");
    case "getProp":
    case "getElem":
        throw typeError("cant.get.property", getArgument(linkRequest), "null");
    case "setProp":
    case "setElem":
        throw typeError("cant.set.property", getArgument(linkRequest), "null");
    default:
        break;
    }
    throw new AssertionError("unknown call type " + desc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:NashornBottomLinker.java

示例9: findFastGetIndexMethod

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
/**
 * Return a fast linked array getter, or null if we have to dispatch to super class
 * @param desc     descriptor
 * @param request  link request
 * @return invocation or null if needs to be sent to slow relink
 */
@Override
public GuardedInvocation findFastGetIndexMethod(final Class<? extends ArrayData> clazz, final CallSiteDescriptor desc, final LinkRequest request) {
    final MethodType callType   = desc.getMethodType();
    final Class<?>   indexType  = callType.parameterType(1);
    final Class<?>   returnType = callType.returnType();

    if (ContinuousArrayData.class.isAssignableFrom(clazz) && indexType == int.class) {
        final Object[] args  = request.getArguments();
        final int      index = (int)args[args.length - 1];

        if (has(index)) {
            final MethodHandle getArray     = ScriptObject.GET_ARRAY.methodHandle();
            final int          programPoint = NashornCallSiteDescriptor.isOptimistic(desc) ? NashornCallSiteDescriptor.getProgramPoint(desc) : INVALID_PROGRAM_POINT;
            MethodHandle       getElement   = getElementGetter(returnType, programPoint);
            if (getElement != null) {
                getElement = MH.filterArguments(getElement, 0, MH.asType(getArray, getArray.type().changeReturnType(clazz)));
                final MethodHandle guard = MH.insertArguments(FAST_ACCESS_GUARD, 0, clazz);
                return new GuardedInvocation(getElement, guard, (SwitchPoint)null, ClassCastException.class);
            }
        }
    }

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

示例10: findFastSetIndexMethod

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
/**
 * Return a fast linked array setter, or null if we have to dispatch to super class
 * @param desc     descriptor
 * @param request  link request
 * @return invocation or null if needs to be sent to slow relink
 */
@Override
public GuardedInvocation findFastSetIndexMethod(final Class<? extends ArrayData> clazz, final CallSiteDescriptor desc, final LinkRequest request) { // array, index, value
    final MethodType callType    = desc.getMethodType();
    final Class<?>   indexType   = callType.parameterType(1);
    final Class<?>   elementType = callType.parameterType(2);

    if (ContinuousArrayData.class.isAssignableFrom(clazz) && indexType == int.class) {
        final Object[]        args  = request.getArguments();
        final int             index = (int)args[args.length - 2];

        if (hasRoomFor(index)) {
            MethodHandle setElement = getElementSetter(elementType); //Z(continuousarraydata, int, int), return true if successful
            if (setElement != null) {
                //else we are dealing with a wider type than supported by this callsite
                MethodHandle getArray = ScriptObject.GET_ARRAY.methodHandle();
                getArray   = MH.asType(getArray, getArray.type().changeReturnType(getClass()));
                setElement = MH.filterArguments(setElement, 0, getArray);
                final MethodHandle guard = MH.insertArguments(FAST_ACCESS_GUARD, 0, clazz);
                return new GuardedInvocation(setElement, guard, (SwitchPoint)null, ClassCastException.class); //CCE if not a scriptObject anymore
            }
        }
    }

    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:ContinuousArrayData.java

示例11: getGuardedInvocation

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices)
        throws Exception {
    final CallSiteDescriptor callSiteDescriptor = request.getCallSiteDescriptor();
    final int l = callSiteDescriptor.getNameTokenCount();
    // All names conforming to the dynalang MOP should have at least two tokens, the first one being "dyn"
    if(l < 2 || "dyn" != callSiteDescriptor.getNameToken(CallSiteDescriptor.SCHEME)) {
        return null;
    }

    final Object receiver = request.getReceiver();
    if(receiver == null) {
        // Can't operate on null
        return null;
    }
    return getLinkerForClass(receiver.getClass()).getGuardedInvocation(request, linkerServices);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:BeansLinker.java

示例12: createConverter

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
MethodHandle createConverter(final Class<?> sourceType, final Class<?> targetType) throws Exception {
    final MethodType type = MethodType.methodType(targetType, sourceType);
    final MethodHandle identity = IDENTITY_CONVERSION.asType(type);
    MethodHandle last = identity;
    boolean cacheable = true;
    for(int i = factories.length; i-- > 0;) {
        final GuardedTypeConversion next = factories[i].convertToType(sourceType, targetType);
        if(next != null) {
            cacheable = cacheable && next.isCacheable();
            final GuardedInvocation conversionInvocation = next.getConversionInvocation();
            conversionInvocation.assertType(type);
            last = conversionInvocation.compose(last);
        }
    }
    if(last == identity) {
        return IDENTITY_CONVERSION;
    }
    if(cacheable) {
        return last;
    }
    throw new NotCacheableConverter(last);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:TypeConverterFactory.java

示例13: findGetMethod

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
@Override
protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operator) {
    final String name = desc.getNameToken(2);

    // if str.length(), then let the bean linker handle it
    if ("length".equals(name) && "getMethod".equals(operator)) {
        return null;
    }

    return super.findGetMethod(desc, request, operator);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:NativeString.java

示例14: findGetIndexMethod

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
@Override
protected GuardedInvocation findGetIndexMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final GuardedInvocation inv = getArray().findFastGetIndexMethod(getArray().getClass(), desc, request);
    if (inv != null) {
        return inv;
    }
    return super.findGetIndexMethod(desc, request);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:ArrayBufferView.java

示例15: findSetIndexMethod

import jdk.internal.dynalink.linker.GuardedInvocation; //导入依赖的package包/类
@Override
protected GuardedInvocation findSetIndexMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final GuardedInvocation inv = getArray().findFastSetIndexMethod(getArray().getClass(), desc, request);
    if (inv != null) {
        return inv;
    }
    return super.findSetIndexMethod(desc, request);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:ArrayBufferView.java


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