本文整理了Java中org.jruby.ir.instructions.YieldInstr.getYieldArg()
方法的一些代码示例,展示了YieldInstr.getYieldArg()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YieldInstr.getYieldArg()
方法的具体详情如下:
包路径:org.jruby.ir.instructions.YieldInstr
类名称:YieldInstr
方法名:getYieldArg
暂无
代码示例来源:origin: org.jruby/jruby-complete
@Override
public Instr clone(CloneInfo ii) {
// FIXME: Is it necessary to clone a yield instruction in a method
// that is being inlined, i.e. in METHOD_INLINE clone mode?
// Fix BasicBlock.java:clone!!
return new YieldInstr(ii.getRenamedVariable(result), getBlockArg().cloneForInlining(ii),
getYieldArg().cloneForInlining(ii), unwrapArray);
}
代码示例来源:origin: org.jruby/jruby-core
@Override
public Instr clone(CloneInfo ii) {
// FIXME: Is it necessary to clone a yield instruction in a method
// that is being inlined, i.e. in METHOD_INLINE clone mode?
// Fix BasicBlock.java:clone!!
return new YieldInstr(ii.getRenamedVariable(result), getBlockArg().cloneForInlining(ii),
getYieldArg().cloneForInlining(ii), unwrapArray);
}
代码示例来源:origin: org.jruby/jruby-core
@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getBlockArg());
e.encode(getYieldArg());
e.encode(isUnwrapArray());
}
代码示例来源:origin: org.jruby/jruby-core
@Interp
@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Block blk = (Block)getBlockArg().retrieve(context, self, currScope, currDynScope, temp);
if (getYieldArg() == UndefinedValue.UNDEFINED) {
return IRRuntimeHelpers.yieldSpecific(context, blk);
} else {
Operand yieldOp = getYieldArg();
if (unwrapArray && yieldOp instanceof Array && ((Array)yieldOp).size() > 1) {
// Special case this path!
// Don't build a RubyArray.
return blk.yieldValues(context, ((Array)yieldOp).retrieveArrayElts(context, self, currScope, currDynScope, temp));
} else {
IRubyObject yieldVal = (IRubyObject) yieldOp.retrieve(context, self, currScope, currDynScope, temp);
return IRRuntimeHelpers.yield(context, blk, yieldVal, unwrapArray);
}
}
}
代码示例来源:origin: org.jruby/jruby-complete
@Interp
@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Block blk = (Block)getBlockArg().retrieve(context, self, currScope, currDynScope, temp);
if (getYieldArg() == UndefinedValue.UNDEFINED) {
return IRRuntimeHelpers.yieldSpecific(context, blk);
} else {
Operand yieldOp = getYieldArg();
if (unwrapArray && yieldOp instanceof Array && ((Array)yieldOp).size() > 1) {
// Special case this path!
// Don't build a RubyArray.
return blk.yieldValues(context, ((Array)yieldOp).retrieveArrayElts(context, self, currScope, currDynScope, temp));
} else {
IRubyObject yieldVal = (IRubyObject) yieldOp.retrieve(context, self, currScope, currDynScope, temp);
return IRRuntimeHelpers.yield(context, blk, yieldVal, unwrapArray);
}
}
}
代码示例来源:origin: org.jruby/jruby-complete
@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getBlockArg());
e.encode(getYieldArg());
e.encode(isUnwrapArray());
}
代码示例来源:origin: org.jruby/jruby-complete
@Override
public void YieldInstr(YieldInstr yieldinstr) {
jvmMethod().loadContext();
visit(yieldinstr.getBlockArg());
if (yieldinstr.getYieldArg() == UndefinedValue.UNDEFINED) {
jvmMethod().yieldSpecific();
} else {
Operand yieldOp = yieldinstr.getYieldArg();
if (yieldinstr.isUnwrapArray() && yieldOp instanceof Array && ((Array) yieldOp).size() > 1) {
Array yieldValues = (Array) yieldOp;
for (Operand yieldValue : yieldValues) {
visit(yieldValue);
}
jvmMethod().yieldValues(yieldValues.size());
} else {
visit(yieldinstr.getYieldArg());
jvmMethod().yield(yieldinstr.isUnwrapArray());
}
}
jvmStoreLocal(yieldinstr.getResult());
}
代码示例来源:origin: org.jruby/jruby-core
@Override
public void YieldInstr(YieldInstr yieldinstr) {
jvmMethod().loadContext();
visit(yieldinstr.getBlockArg());
if (yieldinstr.getYieldArg() == UndefinedValue.UNDEFINED) {
jvmMethod().yieldSpecific();
} else {
Operand yieldOp = yieldinstr.getYieldArg();
if (yieldinstr.isUnwrapArray() && yieldOp instanceof Array && ((Array) yieldOp).size() > 1) {
Array yieldValues = (Array) yieldOp;
for (Operand yieldValue : yieldValues) {
visit(yieldValue);
}
jvmMethod().yieldValues(yieldValues.size());
} else {
visit(yieldinstr.getYieldArg());
jvmMethod().yield(yieldinstr.isUnwrapArray());
}
}
jvmStoreLocal(yieldinstr.getResult());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@Override
public void YieldInstr(YieldInstr yieldinstr) {
visit(yieldinstr.getBlockArg());
// TODO: proc, nil block logic
jvm.method().loadLocal(0);
if (yieldinstr.getYieldArg() == UndefinedValue.UNDEFINED) {
jvm.method().adapter.invokevirtual(p(Block.class), "yieldSpecific", sig(IRubyObject.class, ThreadContext.class));
} else {
visit(yieldinstr.getYieldArg());
// TODO: if yielding array, call yieldArray
jvm.method().adapter.invokevirtual(p(Block.class), "yield", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class));
}
jvmStoreLocal(yieldinstr.getResult());
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@Override
public void YieldInstr(YieldInstr yieldinstr) {
visit(yieldinstr.getBlockArg());
// TODO: proc, nil block logic
jvm.method().loadLocal(0);
if (yieldinstr.getYieldArg() == UndefinedValue.UNDEFINED) {
jvm.method().adapter.invokevirtual(p(Block.class), "yieldSpecific", sig(IRubyObject.class, ThreadContext.class));
} else {
visit(yieldinstr.getYieldArg());
// TODO: if yielding array, call yieldArray
jvm.method().adapter.invokevirtual(p(Block.class), "yield", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class));
}
jvmStoreLocal(yieldinstr.getResult());
}
代码示例来源:origin: org.jruby/jruby-complete
public void setupYieldArgsAndYieldResult(YieldInstr yi, BasicBlock yieldBB, int blockArityValue) {
Operand yieldInstrArg = yi.getYieldArg();
if ((yieldInstrArg == UndefinedValue.UNDEFINED) || blockArityValue == 0) {
yieldArg = new Array(); // Zero-elt array
} else if (yieldInstrArg instanceof Array) {
yieldArg = yieldInstrArg;
// 1:1 arg match
if (((Array) yieldInstrArg).size() == blockArityValue) canMapArgsStatically = true;
} else if (blockArityValue == 1 && yi.unwrapArray == false) {
yieldArg = yieldInstrArg;
canMapArgsStatically = true;
} else {
// SSS FIXME: The code below is not entirely correct. We have to process 'yi.getYieldArg()' similar
// to how InterpretedIRBlockBody (1.8 and 1.9 modes) processes it. We may need a special instruction
// that takes care of aligning the stars and bringing good fortune to arg yielder and arg receiver.
IRScope callerScope = getHostScope();
Variable yieldArgArray = callerScope.createTemporaryVariable();
yieldBB.addInstr(new ToAryInstr(yieldArgArray, yieldInstrArg));
yieldArg = yieldArgArray;
}
yieldResult = yi.getResult();
}
代码示例来源:origin: org.jruby/jruby-core
public void setupYieldArgsAndYieldResult(YieldInstr yi, BasicBlock yieldBB, int blockArityValue) {
Operand yieldInstrArg = yi.getYieldArg();
if ((yieldInstrArg == UndefinedValue.UNDEFINED) || blockArityValue == 0) {
yieldArg = new Array(); // Zero-elt array
} else if (yieldInstrArg instanceof Array) {
yieldArg = yieldInstrArg;
// 1:1 arg match
if (((Array) yieldInstrArg).size() == blockArityValue) canMapArgsStatically = true;
} else if (blockArityValue == 1 && yi.unwrapArray == false) {
yieldArg = yieldInstrArg;
canMapArgsStatically = true;
} else {
// SSS FIXME: The code below is not entirely correct. We have to process 'yi.getYieldArg()' similar
// to how InterpretedIRBlockBody (1.8 and 1.9 modes) processes it. We may need a special instruction
// that takes care of aligning the stars and bringing good fortune to arg yielder and arg receiver.
IRScope callerScope = getHostScope();
Variable yieldArgArray = callerScope.createTemporaryVariable();
yieldBB.addInstr(new ToAryInstr(yieldArgArray, yieldInstrArg));
yieldArg = yieldArgArray;
}
yieldResult = yi.getResult();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public void setupYieldArgsAndYieldResult(YieldInstr yi, BasicBlock yieldBB, Arity blockArity) {
int blockArityValue = blockArity.getValue();
Operand yieldInstrArg = yi.getYieldArg();
if ((yieldInstrArg == UndefinedValue.UNDEFINED) || (blockArityValue == 0)) {
this.yieldArg = new Array(); // Zero-elt array
} else if (yieldInstrArg instanceof Array) {
this.yieldArg = yieldInstrArg;
// 1:1 arg match
if (((Array)yieldInstrArg).size() == blockArityValue) canMapArgsStatically = true;
} else {
// SSS FIXME: The code below is not entirely correct. We have to process 'yi.getYieldArg()' similar
// to how InterpretedIRBlockBody (1.8 and 1.9 modes) processes it. We may need a special instruction
// that takes care of aligning the stars and bringing good fortune to arg yielder and arg receiver.
IRScope callerScope = getInlineHostScope();
boolean needSpecialProcessing = (blockArityValue != -1) && (blockArityValue != 1);
Variable yieldArgArray = callerScope.getNewTemporaryVariable();
yieldBB.addInstr(new ToAryInstr(yieldArgArray, yieldInstrArg, callerScope.getManager().getTrue()));
this.yieldArg = yieldArgArray;
}
this.yieldResult = yi.getResult();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public void setupYieldArgsAndYieldResult(YieldInstr yi, BasicBlock yieldBB, Arity blockArity) {
int blockArityValue = blockArity.getValue();
Operand yieldInstrArg = yi.getYieldArg();
if ((yieldInstrArg == UndefinedValue.UNDEFINED) || (blockArityValue == 0)) {
this.yieldArg = new Array(); // Zero-elt array
} else if (yieldInstrArg instanceof Array) {
this.yieldArg = yieldInstrArg;
// 1:1 arg match
if (((Array)yieldInstrArg).size() == blockArityValue) canMapArgsStatically = true;
} else {
// SSS FIXME: The code below is not entirely correct. We have to process 'yi.getYieldArg()' similar
// to how InterpretedIRBlockBody (1.8 and 1.9 modes) processes it. We may need a special instruction
// that takes care of aligning the stars and bringing good fortune to arg yielder and arg receiver.
IRScope callerScope = getInlineHostScope();
boolean needSpecialProcessing = (blockArityValue != -1) && (blockArityValue != 1);
Variable yieldArgArray = callerScope.getNewTemporaryVariable();
yieldBB.addInstr(new ToAryInstr(yieldArgArray, yieldInstrArg, callerScope.getManager().getTrue()));
this.yieldArg = yieldArgArray;
}
this.yieldResult = yi.getResult();
}
内容来源于网络,如有侵权,请联系作者删除!