예제 #1
0
  public static IRubyObject fallback(
      JRubyCallSite site,
      ThreadContext context,
      IRubyObject caller,
      IRubyObject self,
      String name,
      IRubyObject[] args,
      Block block) {
    RubyClass selfClass = pollAndGetClass(context, self);
    CacheEntry entry = selfClass.searchWithCache(name);

    try {
      if (methodMissing(entry, site.callType(), name, caller)) {
        return callMethodMissing(entry, site.callType(), context, self, name, args, block);
      }
      site.setTarget(createGWT(TEST_N_B, TARGET_N_B, FALLBACK_N_B, entry, site));
      return entry.method.call(context, self, selfClass, name, args, block);
    } catch (JumpException.BreakJump bj) {
      return handleBreakJump(context, bj);
    } catch (JumpException.RetryJump rj) {
      return retryJumpError(context);
    } finally {
      block.escape();
    }
  }
예제 #2
0
  public static IRubyObject fallback(
      JRubyCallSite site,
      ThreadContext context,
      IRubyObject caller,
      IRubyObject self,
      String name) {
    RubyClass selfClass = pollAndGetClass(context, self);
    CacheEntry entry = selfClass.searchWithCache(name);
    if (methodMissing(entry, site.callType(), name, caller)) {
      return callMethodMissing(entry, site.callType(), context, self, name);
    }
    site.setTarget(createGWT(TEST_0, TARGET_0, FALLBACK_0, entry, site));

    return entry.method.call(context, self, selfClass, name);
  }
예제 #3
0
  public static CallSite bootstrap(Class caller, String name, MethodType type) {
    JRubyCallSite site;

    if (name == "call") {
      site = new JRubyCallSite(caller, name, type, CallType.NORMAL);
    } else {
      site = new JRubyCallSite(caller, name, type, CallType.FUNCTIONAL);
    }

    MethodType fallbackType = type.insertParameterType(0, JRubyCallSite.class);
    MethodHandle myFallback =
        MethodHandles.insertArguments(
            MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "fallback", fallbackType),
            0,
            site);
    site.setTarget(myFallback);
    return site;
  }