/** * Drop a single argument at the given index. * * @param index the index at which to drop an argument * @return a new Binder */ public Binder drop(int index) { return drop(index, 1); }
public GuardBuilder drop(int index) { binder = binder.drop(index); return this; }
/** * Drop all arguments from this handle chain * * @return a new Binder */ public Binder dropAll() { return drop(0, type().parameterCount()); }
/** * Drop from the end of the argument list a number of arguments. * * @param count the number of arguments to drop * @return a new Binder */ public Binder dropFirst(int count) { assert count <= type().parameterCount(); return drop(0, count); }
public MethodHandle getTestBlockBody() { final MethodHandle testBlockBody = this.testBlockBody; if (testBlockBody != null) return testBlockBody; return this.testBlockBody = Binder.from(boolean.class, ThreadContext.class, Block.class).drop(0).append(this).invoke(TEST_BLOCK_BODY); }
@Override public MethodHandle guardMethodHandle(MethodType inputType) throws Exception { Binder binder = Binder.from(inputType); return binder.drop(0, inputType.parameterCount()) .constant(false); } }
protected MethodHandle selfFilter(Class<?> selfType) throws NoSuchMethodException, IllegalAccessException { return Binder.from(MethodType.methodType(selfType, Object.class)) .drop(0) .insert(0, this.self) .invoke(MethodHandles.identity(Object.class)); }
public MethodHandle getTestBlockBody() { final MethodHandle testBlockBody = this.testBlockBody; if (testBlockBody != null) return testBlockBody; return this.testBlockBody = Binder.from(boolean.class, ThreadContext.class, Block.class).drop(0).append(this).invoke(TEST_BLOCK_BODY); }
@Override public MethodHandle guardMethodHandle(MethodType inputType) throws Exception { Binder binder = Binder.from(inputType); return binder.drop(0, inputType.parameterCount()) .constant(true); } }
public static IRubyObject symbol(MutableCallSite site, String name, ThreadContext context) { RubySymbol symbol = RubySymbol.newSymbol(context.runtime, name); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(symbol) ); return symbol; }
public static IRubyObject fixnum(MutableCallSite site, long value, ThreadContext context) { RubyFixnum fixnum = RubyFixnum.newFixnum(context.runtime, value); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(fixnum) ); return fixnum; }
/** * Drop from the end of the argument list a number of arguments. * * @param count the number of arguments to drop * @return a new Binder */ public Binder dropLast(int count) { assert count <= type().parameterCount(); return drop(type().parameterCount() - count, count); }
public static IRubyObject fixnum(MutableCallSite site, long value, ThreadContext context) { RubyFixnum fixnum = RubyFixnum.newFixnum(context.runtime, value); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(fixnum) ); return fixnum; }
public static IRubyObject flote(MutableCallSite site, double value, ThreadContext context) { RubyFloat flote = RubyFloat.newFloat(context.runtime, value); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(flote) ); return flote; } }
public static IRubyObject flote(MutableCallSite site, double value, ThreadContext context) { RubyFloat flote = RubyFloat.newFloat(context.runtime, value); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(flote) ); return flote; } }
public static IRubyObject symbol(MutableCallSite site, String name, ThreadContext context) { RubySymbol symbol = RubySymbol.newSymbol(context.runtime, name); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(symbol) ); return symbol; }
/** * Drop the argument with the given name. * * @param name the name of the argument to drop * @return a new SmartBinder with the drop applied */ public SmartBinder drop(String name) { int index = signature().argOffset(name); return new SmartBinder(this, signature().dropArg(index), binder.drop(index)); }
private void bind(Ruby runtime, RubyModule module, IRubyObject constant, MethodHandle cachingFallback) { MethodHandle target = Binder.from(type()) .drop(0, 2) .constant(constant); // Get appropriate fallback given state of site MethodHandle fallback = getFallback(module, cachingFallback); // Test that module is same as before target = guardWithTest(module.getIdTest(), target, fallback); // Global invalidation SwitchPoint switchPoint = (SwitchPoint) runtime.getConstantInvalidator(name).getData(); target = switchPoint.guardWithTest(target, fallback); setTarget(target); }