protected final MethodHandle newIdTest() { return Binder.from(boolean.class, ThreadContext.class, IRubyObject.class) .insert(2, id) .invoke(testModuleMatch); }
public static CallSite string(Lookup lookup, String name, MethodType type, String value, int encoding) { MethodHandle handle = Binder .from(IRubyObject.class, ThreadContext.class) .insert(0, new Class[]{String.class, int.class}, value, encoding) .invokeStaticQuiet(MethodHandles.lookup(), Bootstrap.class, "string"); CallSite site = new ConstantCallSite(handle); return site; }
public static CallSite searchConst(Lookup lookup, String name, MethodType type) { MutableCallSite site = new MutableCallSite(type); String[] bits = name.split(":"); String constName = bits[1]; MethodHandle handle = Binder .from(type) .insert(0, site, constName) .invokeStaticQuiet(MethodHandles.lookup(), Bootstrap.class, "searchConst"); site.setTarget(handle); return site; }
private MethodHandle noCacheSMFC() { if (_noCacheSMFC != null) return _noCacheSMFC; return _noCacheSMFC = Binder.from(type()) .insert(0, this) .invokeVirtualQuiet(Bootstrap.LOOKUP, "noCacheSearchModuleForConst"); }
public CallSite bootstrap(MethodHandles.Lookup lookup) { MethodHandle handle = prepareBinder() .insert(0, this) .invokeVirtualQuiet(lookup, "construct"); setTarget(handle); return this; }
private MethodHandle SMFC() { if (_SMFC != null) return _SMFC; return _SMFC = Binder.from(type()) .insert(0, this) .invokeVirtualQuiet(Bootstrap.LOOKUP, "searchModuleForConst"); }
private MethodHandle ISC() { if (_ISC != null) return _ISC; return _ISC = Binder.from(type()) .insert(0, this) .invokeVirtualQuiet(Bootstrap.LOOKUP, "inheritanceSearchConst"); }
private MethodHandle noCacheSMFC() { if (_noCacheSMFC != null) return _noCacheSMFC; return _noCacheSMFC = Binder.from(type()) .insert(0, this) .invokeVirtualQuiet(Bootstrap.LOOKUP, "noCacheSearchModuleForConst"); }
/** * Insert an argument into the argument list at the given index with the * given name and value. * * @param index the index at which to insert the argument * @param name the name of the new argument * @param value the value of the new argument * @return a new SmartBinder with the insert applied */ public SmartBinder insert(int index, String name, boolean value) { return new SmartBinder(this, signature().insertArg(index, name, boolean.class), binder.insert(index, value)); }
private MethodHandle ISC() { if (_ISC != null) return _ISC; return _ISC = Binder.from(type()) .insert(0, this) .invokeVirtualQuiet(Bootstrap.LOOKUP, "inheritanceSearchConst"); }
public CallSite bootstrap(MethodHandles.Lookup lookup) { MethodHandle handle = prepareBinder() .insert(0, this) .invokeVirtualQuiet(lookup, "construct"); setTarget(handle); return this; }
public boolean init(IRubyObject obj) { Ruby runtime = obj.getRuntime(); IRubyObject nil = runtime.getNil(); IRubyObject fals = runtime.getFalse(); setTarget( Binder.from(type()) .insert(0, RubyBoolean.False.class, fals) .insert(0, RubyNil.class, nil) .invokeStaticQuiet(LOOKUP, IsTrueSite.class, "isTruthy") ); return nil != obj && fals != obj; }
public static CallSite constLookup(MethodHandles.Lookup lookup, String searchType, MethodType type, String constName, int publicOnly, int callConstMissing) { ConstantLookupSite site = new ConstantLookupSite(type, constName, publicOnly == 0 ? false : true, callConstMissing == 0 ? false : true); MethodHandle handle = Binder .from(lookup, type) .insert(0, site) .invokeVirtualQuiet(lookup, searchType); site.setTarget(handle); return site; }
public static CallSite constLookup(MethodHandles.Lookup lookup, String searchType, MethodType type, String constName, int publicOnly, int callConstMissing) { ConstantLookupSite site = new ConstantLookupSite(type, constName, publicOnly == 0 ? false : true, callConstMissing == 0 ? false : true); MethodHandle handle = Binder .from(lookup, type) .insert(0, site) .invokeVirtualQuiet(lookup, searchType); site.setTarget(handle); return site; }
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 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 boolean init(IRubyObject obj) { IRubyObject nil = obj.getRuntime().getNil(); setTarget( Binder.from(type()) .insert(0, RubyNil.class, nil) .invokeStaticQuiet(LOOKUP, IsNilSite.class, "isNil") ); return nil == obj; }
public static CallSite string(Lookup lookup, String name, MethodType type, String value, String encodingName, int cr) { MutableCallSite site = new MutableCallSite(type); Binder binder = Binder .from(RubyString.class, ThreadContext.class) .insert(0, arrayOf(MutableCallSite.class, ByteList.class, int.class), site, bytelist(value, encodingName), cr); site.setTarget(binder.invokeStaticQuiet(lookup, Bootstrap.class, "string")); return site; }