gpt4 book ai didi

org.jruby.ir.instructions.YieldInstr类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 09:07:31 26 4
gpt4 key购买 nike

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

YieldInstr介绍

暂无

代码示例

代码示例来源: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

public Operand getBlockArg() {
  return getOperand1();
}

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

public Operand getYieldArg() {
  return getOperand2();
}

代码示例来源: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

@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.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: com.ning.billing/killbill-osgi-bundles-jruby

@Override
public Instr cloneForInlining(InlinerInfo ii) {
  return new YieldInstr(ii.getRenamedVariable(result), blockArg.cloneForInlining(ii), yieldArg.cloneForInlining(ii), unwrapArray);
}

代码示例来源: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

case UNDEF_METHOD: return UndefMethodInstr.decode(this);
case UNRESOLVED_SUPER: return UnresolvedSuperInstr.decode(this);
case YIELD: return YieldInstr.decode(this);
case ZSUPER: return ZSuperInstr.decode(this);

代码示例来源: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.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-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.jruby/jruby-complete

@Override
public void encode(IRWriterEncoder e) {
  super.encode(e);
  e.encode(getBlockArg());
  e.encode(getYieldArg());
  e.encode(isUnwrapArray());
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@Override
public Instr cloneForInlining(InlinerInfo ii) {
  return new YieldInstr(ii.getRenamedVariable(result), blockArg.cloneForInlining(ii), yieldArg.cloneForInlining(ii), 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-core

case UNDEF_METHOD: return UndefMethodInstr.decode(this);
case UNRESOLVED_SUPER: return UnresolvedSuperInstr.decode(this);
case YIELD: return YieldInstr.decode(this);
case ZSUPER: return ZSuperInstr.decode(this);

代码示例来源: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: 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();
}

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

public static YieldInstr decode(IRReaderDecoder d) {
  return new YieldInstr(d.decodeVariable(), d.decodeOperand(), d.decodeOperand(), d.decodeBoolean());
}

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