本文整理了Java中org.jruby.ir.targets.YieldSite
类的一些代码示例,展示了YieldSite
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YieldSite
类的具体详情如下:
包路径:org.jruby.ir.targets.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);
}
内容来源于网络,如有侵权,请联系作者删除!