public static CallSite globalBootstrap(Lookup lookup, String name, MethodType type, String file, int line) throws Throwable { String[] names = name.split(":"); String operation = names[0]; String varName = JavaNameMangler.demangleMethodName(names[1]); GlobalSite site = new GlobalSite(type, varName, file, line); MethodHandle handle; if (operation.equals("get")) { handle = lookup.findStatic(InvokeDynamicSupport.class, "getGlobalFallback", methodType(IRubyObject.class, GlobalSite.class, ThreadContext.class)); } else { throw new RuntimeException("invalid variable access type"); } handle = handle.bindTo(site); site.setTarget(handle); return site; }
public static CallSite globalBootstrap(Lookup lookup, String name, MethodType type, String file, int line) throws Throwable { String[] names = name.split(":"); String operation = names[0]; String varName = JavaNameMangler.demangleMethodName(names[1]); GlobalSite site = new GlobalSite(type, varName, file, line); MethodHandle handle; if (operation.equals("get")) { handle = lookup.findStatic(InvokeDynamicSupport.class, "getGlobalFallback", methodType(IRubyObject.class, GlobalSite.class, ThreadContext.class)); } else { throw new RuntimeException("invalid variable access type"); } handle = handle.bindTo(site); site.setTarget(handle); return site; }
public static CallSite globalBooleanBootstrap(Lookup lookup, String name, MethodType type, String file, int line) throws Throwable { String[] names = name.split(":"); String operation = names[0]; String varName = JavaNameMangler.demangleMethodName(names[1]); GlobalSite site = new GlobalSite(type, varName, file, line); MethodHandle handle; if (operation.equals("getBoolean")) { handle = lookup.findStatic(InvokeDynamicSupport.class, "getGlobalBooleanFallback", methodType(boolean.class, GlobalSite.class, ThreadContext.class)); } else { throw new RuntimeException("invalid variable access type"); } handle = handle.bindTo(site); site.setTarget(handle); return site; }
public static CallSite globalBooleanBootstrap(Lookup lookup, String name, MethodType type, String file, int line) throws Throwable { String[] names = name.split(":"); String operation = names[0]; String varName = JavaNameMangler.demangleMethodName(names[1]); GlobalSite site = new GlobalSite(type, varName, file, line); MethodHandle handle; if (operation.equals("getBoolean")) { handle = lookup.findStatic(InvokeDynamicSupport.class, "getGlobalBooleanFallback", methodType(boolean.class, GlobalSite.class, ThreadContext.class)); } else { throw new RuntimeException("invalid variable access type"); } handle = handle.bindTo(site); site.setTarget(handle); return site; }
public static CallSite globalBootstrap(Lookup lookup, String name, MethodType type, String file, int line) throws Throwable { String[] names = name.split(":"); String operation = names[0]; String varName = JavaNameMangler.demangleMethodName(names[1]); GlobalSite site = new GlobalSite(type, varName, file, line); MethodHandle handle; if (operation.equals("get")) { handle = lookup.findStatic(Bootstrap.class, "getGlobalFallback", methodType(IRubyObject.class, GlobalSite.class, ThreadContext.class)); } else { handle = lookup.findStatic(Bootstrap.class, "setGlobalFallback", methodType(void.class, GlobalSite.class, IRubyObject.class, ThreadContext.class)); } handle = handle.bindTo(site); site.setTarget(handle); return site; }
public static CallSite globalBootstrap(Lookup lookup, String name, MethodType type, String file, int line) throws Throwable { String[] names = name.split(":"); String operation = names[0]; String varName = JavaNameMangler.demangleMethodName(names[1]); GlobalSite site = new GlobalSite(type, varName, file, line); MethodHandle handle; if (operation.equals("get")) { handle = lookup.findStatic(Bootstrap.class, "getGlobalFallback", methodType(IRubyObject.class, GlobalSite.class, ThreadContext.class)); } else { handle = lookup.findStatic(Bootstrap.class, "setGlobalFallback", methodType(void.class, GlobalSite.class, IRubyObject.class, ThreadContext.class)); } handle = handle.bindTo(site); site.setTarget(handle); return site; }
public static void setGlobalFallback(GlobalSite site, IRubyObject value, ThreadContext context) throws Throwable { Ruby runtime = context.runtime; GlobalVariable variable = runtime.getGlobalVariables().getVariable(site.name()); MethodHandle uncached = lookup().findStatic(Bootstrap.class, "setGlobalUncached", methodType(void.class, GlobalVariable.class, IRubyObject.class)); uncached = uncached.bindTo(variable); uncached = dropArguments(uncached, 1, ThreadContext.class); site.setTarget(uncached); uncached.invokeWithArguments(value, context); }
public static void setGlobalFallback(GlobalSite site, IRubyObject value, ThreadContext context) throws Throwable { Ruby runtime = context.runtime; GlobalVariable variable = runtime.getGlobalVariables().getVariable(site.name()); MethodHandle uncached = lookup().findStatic(Bootstrap.class, "setGlobalUncached", methodType(void.class, GlobalVariable.class, IRubyObject.class)); uncached = uncached.bindTo(variable); uncached = dropArguments(uncached, 1, ThreadContext.class); site.setTarget(uncached); uncached.invokeWithArguments(value, context); }