gpt4 book ai didi

org.jruby.ir.targets.YieldSite类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 13:17:56 28 4
gpt4 key购买 nike

本文整理了Java中org.jruby.ir.targets.YieldSite类的一些代码示例,展示了YieldSite类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YieldSite类的具体详情如下:
包路径:org.jruby.ir.targets.YieldSite
类名称:YieldSite

YieldSite介绍

[英]Created by headius on 1/8/16.
[中]海德乌斯于2016年1月8日创作。

代码示例

代码示例来源:origin: org.jruby/jruby-complete

public static CallSite bootstrap(MethodHandles.Lookup lookup, String name, MethodType type, int unwrap) throws Throwable {
  YieldSite site = new YieldSite(type, unwrap == 1 ? true : false);
  MethodHandle handle;
  switch (name) {
    case "yield":
    case "yieldSpecific":
      handle = Binder.from(type)
          .prepend(YieldSite.class, site)
          .invokeVirtual(lookup, name);
      break;
    case "yieldValues":
      handle = Binder.from(type)
          .collect(2, IRubyObject[].class)
          .prepend(YieldSite.class, site)
          .invokeVirtual(lookup, name);
      break;
    default:
      throw new RuntimeException("invalid yield type: " + name);
  }
  site.setTarget(handle);
  return site;
}

代码示例来源:origin: org.jruby/jruby-complete

public IRubyObject yieldSpecific(ThreadContext context, Block block) throws Throwable {
  if (Options.INVOKEDYNAMIC_YIELD.load()) {
    BlockBody body = block.getBody();
    MethodHandle target;
    if (block.getBody() instanceof CompiledIRBlockBody) {
      CompiledIRBlockBody compiledBody = (CompiledIRBlockBody) block.getBody();
      if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
        LOG.info("yield \tbound directly as yieldSpecific:" + Bootstrap.logBlock(block));
      }
      target = compiledBody.getNormalYieldSpecificHandle();
    } else {
      if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
        LOG.info("yield \tbound indirectly as yieldSpecific:" + Bootstrap.logBlock(block));
      }
      target = Binder.from(type())
          .permute(1, 0)
          .invokeVirtualQuiet(MethodHandles.lookup(), "yieldSpecific");
    }
    MethodHandle fallback = getTarget();
    MethodHandle test = body.getTestBlockBody();
    MethodHandle guard = MethodHandles.guardWithTest(test, target, fallback);
    setTarget(guard);
    return (IRubyObject) target.invokeExact(context, block);
  }
  return block.yieldSpecific(context);
}

代码示例来源:origin: org.jruby/jruby-core

public IRubyObject yield(ThreadContext context, Block block, IRubyObject arg) throws Throwable {
  if (Options.INVOKEDYNAMIC_YIELD.load()) {
    BlockBody body = block.getBody();
    MethodHandle target;
    if (block.getBody() instanceof CompiledIRBlockBody) {
      CompiledIRBlockBody compiledBody = (CompiledIRBlockBody) block.getBody();
      if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
        LOG.info("yield \tbound directly as yield:" + Bootstrap.logBlock(block));
      }
      target = unwrap ? compiledBody.getNormalYieldUnwrapHandle() : compiledBody.getNormalYieldHandle();
    } else {
      if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
        LOG.info("yield \tbound indirectly as yield:" + Bootstrap.logBlock(block));
      }
      target = Binder.from(type())
          .append(unwrap)
          .invokeStaticQuiet(MethodHandles.lookup(), IRRuntimeHelpers.class, "yield");
    }
    MethodHandle fallback = getTarget();
    MethodHandle test = body.getTestBlockBody();
    MethodHandle guard = MethodHandles.guardWithTest(test, target, fallback);
    setTarget(guard);
    return (IRubyObject) target.invokeExact(context, block, arg);
  }
  return IRRuntimeHelpers.yield(context, block, arg, unwrap);
}

代码示例来源:origin: org.jruby/jruby-core

public IRubyObject yieldSpecific(ThreadContext context, Block block) throws Throwable {
  if (Options.INVOKEDYNAMIC_YIELD.load()) {
    BlockBody body = block.getBody();
    MethodHandle target;
    if (block.getBody() instanceof CompiledIRBlockBody) {
      CompiledIRBlockBody compiledBody = (CompiledIRBlockBody) block.getBody();
      if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
        LOG.info("yield \tbound directly as yieldSpecific:" + Bootstrap.logBlock(block));
      }
      target = compiledBody.getNormalYieldSpecificHandle();
    } else {
      if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
        LOG.info("yield \tbound indirectly as yieldSpecific:" + Bootstrap.logBlock(block));
      }
      target = Binder.from(type())
          .permute(1, 0)
          .invokeVirtualQuiet(MethodHandles.lookup(), "yieldSpecific");
    }
    MethodHandle fallback = getTarget();
    MethodHandle test = body.getTestBlockBody();
    MethodHandle guard = MethodHandles.guardWithTest(test, target, fallback);
    setTarget(guard);
    return (IRubyObject) target.invokeExact(context, block);
  }
  return block.yieldSpecific(context);
}

代码示例来源:origin: org.jruby/jruby-core

public static CallSite bootstrap(MethodHandles.Lookup lookup, String name, MethodType type, int unwrap) throws Throwable {
  YieldSite site = new YieldSite(type, unwrap == 1 ? true : false);
  MethodHandle handle;
  switch (name) {
    case "yield":
    case "yieldSpecific":
      handle = Binder.from(type)
          .prepend(YieldSite.class, site)
          .invokeVirtual(lookup, name);
      break;
    case "yieldValues":
      handle = Binder.from(type)
          .collect(2, IRubyObject[].class)
          .prepend(YieldSite.class, site)
          .invokeVirtual(lookup, name);
      break;
    default:
      throw new RuntimeException("invalid yield type: " + name);
  }
  site.setTarget(handle);
  return site;
}

代码示例来源:origin: org.jruby/jruby-complete

public IRubyObject yield(ThreadContext context, Block block, IRubyObject arg) throws Throwable {
  if (Options.INVOKEDYNAMIC_YIELD.load()) {
    BlockBody body = block.getBody();
    MethodHandle target;
    if (block.getBody() instanceof CompiledIRBlockBody) {
      CompiledIRBlockBody compiledBody = (CompiledIRBlockBody) block.getBody();
      if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
        LOG.info("yield \tbound directly as yield:" + Bootstrap.logBlock(block));
      }
      target = unwrap ? compiledBody.getNormalYieldUnwrapHandle() : compiledBody.getNormalYieldHandle();
    } else {
      if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
        LOG.info("yield \tbound indirectly as yield:" + Bootstrap.logBlock(block));
      }
      target = Binder.from(type())
          .append(unwrap)
          .invokeStaticQuiet(MethodHandles.lookup(), IRRuntimeHelpers.class, "yield");
    }
    MethodHandle fallback = getTarget();
    MethodHandle test = body.getTestBlockBody();
    MethodHandle guard = MethodHandles.guardWithTest(test, target, fallback);
    setTarget(guard);
    return (IRubyObject) target.invokeExact(context, block, arg);
  }
  return IRRuntimeHelpers.yield(context, block, arg, unwrap);
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com