if (args.length==3) { con = MethodHandles.dropArguments(con, 1, targetType.parameterType(1)); foldTargetType = foldTargetType.insertParameterTypes(0, targetType.parameterType(1));
private static MethodHandle buildGetter(Class arrayClass) { MethodHandle get = MethodHandles.arrayElementGetter(arrayClass); MethodHandle fallback = MethodHandles.explicitCastArguments(get, get.type().changeParameterType(0, Object.class)); fallback = MethodHandles.dropArguments(fallback, 2, int.class); MethodType reorderType = fallback.type(). insertParameterTypes(0, int.class). dropParameterTypes(2,3); fallback = MethodHandles.permuteArguments(fallback, reorderType, 1, 0, 0); fallback = MethodHandles.foldArguments(fallback, normalizeIndex); fallback = MethodHandles.explicitCastArguments(fallback, get.type()); MethodHandle guard = MethodHandles.dropArguments(notNegative, 0, arrayClass); MethodHandle handle = MethodHandles.guardWithTest(guard, get, fallback); return handle; }
private static MethodHandle buildSetter(Class arrayClass){ MethodHandle set = MethodHandles.arrayElementSetter(arrayClass); MethodHandle fallback = MethodHandles.explicitCastArguments(set, set.type().changeParameterType(0, Object.class)); fallback = MethodHandles.dropArguments(fallback, 3, int.class); MethodType reorderType = fallback.type(). insertParameterTypes(0, int.class). dropParameterTypes(4,5); fallback = MethodHandles.permuteArguments(fallback, reorderType, 1, 0, 3, 0); fallback = MethodHandles.foldArguments(fallback, normalizeIndex); fallback = MethodHandles.explicitCastArguments(fallback, set.type()); MethodHandle guard = MethodHandles.dropArguments(notNegative, 0, arrayClass); MethodHandle handle = MethodHandles.guardWithTest(guard, set, fallback); return handle; }
public MethodType down(MethodType type) { return type.insertParameterTypes(position, types); }
Binder(LinkerServices linkerServices, MethodType methodType, Object fixedKey) { this.linkerServices = linkerServices; this.methodType = fixedKey == null ? methodType : methodType.insertParameterTypes(1, fixedKey.getClass()); this.fixedKey = fixedKey; }
Binder(final LinkerServices linkerServices, final MethodType methodType, final Object fixedKey) { this.linkerServices = linkerServices; this.methodType = fixedKey == null ? methodType : methodType.insertParameterTypes(1, fixedKey.getClass()); this.fixedKey = fixedKey; }
private static MethodType getMethodType(AccessibleObject ao) { final boolean isMethod = ao instanceof Method; final Class<?> rtype = isMethod ? ((Method)ao).getReturnType() : ((Constructor<?>)ao).getDeclaringClass(); final Class<?>[] ptypes = isMethod ? ((Method)ao).getParameterTypes() : ((Constructor<?>)ao).getParameterTypes(); final MethodType type = MethodType.methodType(rtype, ptypes); final Member m = (Member)ao; return type.insertParameterTypes(0, isMethod ? Modifier.isStatic(m.getModifiers()) ? Object.class : m.getDeclaringClass() : StaticClass.class); }
private static MethodType getMethodType(final AccessibleObject ao) { final boolean isMethod = ao instanceof Method; final Class<?> rtype = isMethod ? ((Method)ao).getReturnType() : ((Constructor<?>)ao).getDeclaringClass(); final Class<?>[] ptypes = isMethod ? ((Method)ao).getParameterTypes() : ((Constructor<?>)ao).getParameterTypes(); final MethodType type = MethodType.methodType(rtype, ptypes); final Member m = (Member)ao; return type.insertParameterTypes(0, isMethod ? Modifier.isStatic(m.getModifiers()) ? Object.class : m.getDeclaringClass() : StaticClass.class); }
private VisitorType(AstNodes nodeTypes, MethodType wantedType, String adapter) { this.nodeTypes = nodeTypes; this.wantedType = wantedType; if (adapter != null) { try { this.adapter = MethodHandles.lookup().findStatic(getClass(), adapter, NODE_VISITOR_TYPE.insertParameterTypes(0, MethodHandle.class)); } catch (NoSuchMethodException | IllegalAccessException e) { throw new InternalError(e); } } }
/** * Returns a new call site descriptor that is identical to the passed one, except that it has additional parameter * types inserted into its method type. * @param desc the original call site descriptor * @param num index at which the new parameters are inserted * @param ptypesToInsert the new types to insert * @return a new call site descriptor with modified method type */ public static CallSiteDescriptor insertParameterTypes(CallSiteDescriptor desc, int num, Class<?>... ptypesToInsert) { return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert)); }
/** * Returns a new call site descriptor that is identical to the passed one, except that it has additional parameter * types inserted into its method type. * @param desc the original call site descriptor * @param num index at which the new parameters are inserted * @param ptypesToInsert the new types to insert * @return a new call site descriptor with modified method type */ public static CallSiteDescriptor insertParameterTypes(final CallSiteDescriptor desc, final int num, final Class<?>... ptypesToInsert) { return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert)); }
public MethodType down(MethodType type) { assertTypesAreCompatible(); return type .dropParameterTypes(index, index + count) .insertParameterTypes(index, arrayType); }
/** * Returns a new call site descriptor that is identical to the passed one, except that it has additional parameter * types inserted into its method type. * @param desc the original call site descriptor * @param num index at which the new parameters are inserted * @param ptypesToInsert the new types to insert * @return a new call site descriptor with modified method type */ public static CallSiteDescriptor insertParameterTypes(CallSiteDescriptor desc, int num, List<Class<?>> ptypesToInsert) { return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert)); } }
/** * Returns a new call site descriptor that is identical to the passed one, except that it has additional parameter * types inserted into its method type. * @param desc the original call site descriptor * @param num index at which the new parameters are inserted * @param ptypesToInsert the new types to insert * @return a new call site descriptor with modified method type */ public static CallSiteDescriptor insertParameterTypes(final CallSiteDescriptor desc, final int num, final List<Class<?>> ptypesToInsert) { return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert)); } }
public IsNilSite() { super(TYPE); setTarget(Binder.from(TYPE.insertParameterTypes(0, IsNilSite.class)).invokeVirtualQuiet(LOOKUP, "init").bindTo(this)); }
public IsNilSite() { super(TYPE); setTarget(Binder.from(TYPE.insertParameterTypes(0, IsNilSite.class)).invokeVirtualQuiet(LOOKUP, "init").bindTo(this)); }
public IsTrueSite() { super(TYPE); setTarget(Binder.from(TYPE.insertParameterTypes(0, IsTrueSite.class)).invokeVirtualQuiet(LOOKUP, "init").bindTo(this)); }
public static CallSite ivar(Lookup lookup, String name, MethodType type) throws Throwable { String[] names = name.split(":"); String operation = names[0]; String varName = names[1]; VariableSite site = new VariableSite(type, varName, "noname", 0); MethodHandle handle; handle = lookup.findStatic(Bootstrap.class, operation, type.insertParameterTypes(0, VariableSite.class)); handle = handle.bindTo(site); site.setTarget(handle.asType(site.type())); return site; }
public static CallSite ivar(Lookup lookup, String name, MethodType type) throws Throwable { String[] names = name.split(":"); String operation = names[0]; String varName = names[1]; VariableSite site = new VariableSite(type, varName, "noname", 0); MethodHandle handle; handle = lookup.findStatic(Bootstrap.class, operation, type.insertParameterTypes(0, VariableSite.class)); handle = handle.bindTo(site); site.setTarget(handle.asType(site.type())); return site; }
public IsTrueSite() { super(TYPE); setTarget(Binder.from(TYPE.insertParameterTypes(0, IsTrueSite.class)).invokeVirtualQuiet(LOOKUP, "init").bindTo(this)); }