public GuardBuilder filter(int index, MethodHandle... functions) { binder = binder.filter(index, functions); return this; }
.filter(0, parameterFilters) .filterReturn(resultFilter) .invoke(nativeInvoker);
/** * Filter incoming arguments, from the given index, replacing each with the * result of calling the associated function in the given list. This version * guarantees left-to-right evaluation of filter functions, potentially at * the cost of a more complex handle tree. * * @param index the index of the first argument to filter * @param functions the array of functions to transform the arguments * @return a new Binder */ public Binder filterForward(int index, MethodHandle... functions) { Binder filtered = this; for (int i = 0; i < functions.length; i++) { filtered = filtered.filter(index + i, functions[i]); } return filtered; }
.filter(0, parameterFilters) .filterReturn(resultFilter) .invoke(nativeInvoker);
public GuardBuilder filter(int index, Filter filter) throws Exception { MethodHandle methodHandle = filter.methodHandle( methodType(binder.type().parameterType(index), binder.type().parameterType(index)) ); binder = binder.filter(index, methodHandle ); return this; }
public MethodHandle getNormalYieldUnwrapHandle() { MethodHandle normalYieldUnwrapHandle = this.normalYieldUnwrapHandle; if (normalYieldUnwrapHandle != null) return normalYieldUnwrapHandle; return this.normalYieldUnwrapHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class) .filter(2, VALUE_TO_ARRAY) .insert(2, new Class[] {StaticScope.class, IRubyObject.class}, getStaticScope(), null) .append(Block.class, Block.NULL_BLOCK) .invoke(handle); } //
public MethodHandle getNormalYieldHandle() { MethodHandle normalYieldHandle = this.normalYieldHandle; if (normalYieldHandle != null) return normalYieldHandle; return this.normalYieldHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class) .filter(2, WRAP_VALUE) .insert(2, new Class[]{StaticScope.class, IRubyObject.class}, getStaticScope(), null) .append(Block.class, Block.NULL_BLOCK) .invoke(handle); }
public MethodHandle getNormalYieldUnwrapHandle() { MethodHandle normalYieldUnwrapHandle = this.normalYieldUnwrapHandle; if (normalYieldUnwrapHandle != null) return normalYieldUnwrapHandle; return this.normalYieldUnwrapHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class) .filter(2, VALUE_TO_ARRAY) .insert(2, new Class[] {StaticScope.class, IRubyObject.class}, getStaticScope(), null) .append(Block.class, Block.NULL_BLOCK) .invoke(handle); } //
public MethodHandle getNormalYieldHandle() { MethodHandle normalYieldHandle = this.normalYieldHandle; if (normalYieldHandle != null) return normalYieldHandle; return this.normalYieldHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class) .filter(2, WRAP_VALUE) .insert(2, new Class[]{StaticScope.class, IRubyObject.class}, getStaticScope(), null) .append(Block.class, Block.NULL_BLOCK) .invoke(handle); }
/** * Filter the arguments matching the given pattern using the given filter function. * * @param pattern the regular expression pattern to match arguments * @param filter the MethodHandle to use to filter the arguments * @return a new SmartBinder with the filter applied */ public SmartBinder filter(String pattern, MethodHandle filter) { String[] argNames = signature().argNames(); Pattern pat = Pattern.compile(pattern); Binder newBinder = binder(); Signature newSig = signature(); for (int i = 0; i < argNames.length; i++) { if (pat.matcher(argNames[i]).matches()) { newBinder = newBinder.filter(i, filter); newSig = newSig.argType(i, filter.type().returnType()); } } return new SmartBinder(newSig, newBinder); }
.filter(0, guards) .invoke(isTrue);
.filter(0, guards) .invoke(isTrue);