/** * Insert an argument (name + type) into the signature. * * @param index the index at which to insert * @param name the name of the new argument * @param type the type of the new argument * @return a new signature with the added arguments */ public Signature insertArg(int index, String name, Class<?> type) { return insertArgs(index, new String[]{name}, new Class<?>[]{type}); }
/** * Insert arguments (names + types) into the signature before the argument * with the given name. * * @param beforeName the name of the argument before which to insert * @param names the names of the new arguments * @param types the types of the new arguments * @return a new Signature with the added arguments */ public Signature insertArgs(String beforeName, String[] names, Class<?>... types) { return insertArgs(argOffset(beforeName), names, types); }
/** * Insert an argument (name + type) into the signature before the argument * with the given name. * * @param beforeName the name of the argument before which to insert * @param name the name of the new argument * @param type the type of the new argument * @return a new signature with the added arguments */ public Signature insertArg(String beforeName, String name, Class<?> type) { return insertArgs(argOffset(beforeName), new String[]{name}, new Class<?>[]{type}); }
/** * Insert arguments into the argument list at the given index with the * given names and values. * * @param index the index at which to insert the arguments * @param names the names of the new arguments * @param types the types of the new arguments * @param values the values of the new arguments * @return a new SmartBinder with the insert applied */ public SmartBinder insert(int index, String[] names, Class<?>[] types, Object... values) { return new SmartBinder(this, signature().insertArgs(index, names, types), binder.insert(index, types, values)); }
protected static final Signature signatureFor(IRScope method, boolean aritySplit) { if (aritySplit) { StaticScope argScope = method.getStaticScope(); if (argScope.isArgumentScope() && argScope.getSignature().isFixed() && !argScope.getSignature().hasKwargs()) { // we have only required arguments...emit a signature appropriate to that arity String[] args = new String[argScope.getSignature().required()]; Class[] types = new Class[args.length]; // Class... for (int i = 0; i < args.length; i++) { args[i] = "arg" + i; types[i] = IRubyObject.class; } return METHOD_SIGNATURE_BASE.insertArgs(BLOCK_ARG_NAME, args, types); } // we can't do an specific-arity signature return null; } // normal boxed arg list signature return METHOD_SIGNATURE_BASE.insertArgs(BLOCK_ARG_NAME, new String[]{"args"}, IRubyObject[].class); }
protected static final Signature signatureFor(IRScope method, boolean aritySplit) { if (aritySplit) { StaticScope argScope = method.getStaticScope(); if (argScope.isArgumentScope() && argScope.getSignature().isFixed() && !argScope.getSignature().hasKwargs()) { // we have only required arguments...emit a signature appropriate to that arity String[] args = new String[argScope.getSignature().required()]; Class[] types = new Class[args.length]; // Class... for (int i = 0; i < args.length; i++) { args[i] = "arg" + i; types[i] = IRubyObject.class; } return METHOD_SIGNATURE_BASE.insertArgs(BLOCK_ARG_NAME, args, types); } // we can't do an specific-arity signature return null; } // normal boxed arg list signature return METHOD_SIGNATURE_BASE.insertArgs(BLOCK_ARG_NAME, new String[]{"args"}, IRubyObject[].class); }
static MethodHandle buildIndyHandle(InvokeSite site, DynamicMethod method, RubyModule implClass) { MethodHandle mh = null; Signature siteToDyncall = site.signature.insertArgs(3, arrayOf("class", "name"), arrayOf(RubyModule.class, String.class));
static MethodHandle buildIndyHandle(InvokeSite site, DynamicMethod method, RubyModule implClass) { MethodHandle mh = null; Signature siteToDyncall = site.signature.insertArgs(3, arrayOf("class", "name"), arrayOf(RubyModule.class, String.class));