org.jruby.runtime.Block.yieldArray()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(122)

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

Block.yieldArray介绍

暂无

代码示例

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

@Override
  public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyObject value, int index, Block block) {
    block.yieldArray(context, context.runtime.newArray(key, value), null);
  }
};

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

@Override
  public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyObject value, int index, Block block) {
    block.yieldArray(context, context.runtime.newArray(key, value), null);
  }
};

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

public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
    IRubyObject larg = packEnumValues(ctx, largs);
    checkContext(context, ctx, "inject");
    result[0] = result[0] == null ?
        larg : block.yieldArray(ctx, runtime.newArray(result[0], larg), null);
    return ctx.nil;
  }
});

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

public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
    IRubyObject larg = packEnumValues(ctx, largs);
    IRubyObject val = block.yieldArray(ctx, larg, null);
    result[0] = sumAdd(ctx, result[0], val, memo);
    return ctx.nil;
  }
});

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

public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
    IRubyObject larg = packEnumValues(ctx, largs);
    checkContext(context, ctx, "inject");
    result[0] = result[0] == null ?
        larg : block.yieldArray(ctx, runtime.newArray(result[0], larg), null);
    return ctx.nil;
  }
});

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

@Override
  public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyObject value, int index, Block block) {
    if (block.yieldArray(context, context.runtime.newArray(key, value), null).isTrue()) {
      result.fastASet(key, value);
    }
  }
}

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

@Override
  public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyObject value, int index, Block block) {
    if (block.yieldArray(context, RubyArray.newArray(context.runtime, key, value), null).isTrue()) {
      self.delete(context, key, Block.NULL_BLOCK);
    }
  }
};

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

@Override
  public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyObject value, int index, Block block) {
    if (!block.yieldArray(context, context.runtime.newArray(key, value), null).isTrue()) {
      modified = true;
      self.remove(key);
    }
  }
}

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

public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
    final IRubyObject larg; boolean ary = false;
    switch (largs.length) {
      case 0:  larg = ctx.nil; break;
      case 1:  larg = largs[0]; break;
      default: larg = RubyArray.newArrayMayCopy(ctx.runtime, largs); ary = true;
    }
    IRubyObject val = ary ? block.yieldArray(ctx, larg, null) : block.yield(ctx, larg);
    synchronized (result) { result.append(val); }
    return ctx.nil;
  }
});

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

@Override
  public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyObject value, int index, Block block) {
    if (!block.yieldArray(context, RubyArray.newArray(context.runtime, key, value), null).isTrue()) {
      result.fastASet(key, value);
    }
  }
}

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

@Override
  public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyObject value, int index, Block block) {
    if (block.yieldArray(context, context.runtime.newArray(key, value), null).isTrue()) {
      result.fastASet(key, value);
    }
  }
}

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

public void visit(IRubyObject key, IRubyObject value) {
    if (block.yieldArray(context, runtime.newArray(key, value), null, null).isTrue()) {
      result.fastASet(key, value);
    }
  }
});

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

private IRubyObject any_p_i_fast(ThreadContext context, Block block) {
  iteratorEntry();
  try {
    for (RubyHashEntry entry = head.nextAdded; entry != head; entry = entry.nextAdded) {
      if (block.yieldArray(context, context.runtime.newArray(entry.key, entry.value), null).isTrue())
        return context.tru;
    }
    return context.fals;
  } finally {
    iteratorExit();
  }
}

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

private RubyBoolean any_p_i_fast(ThreadContext context, Block block) {
  final Ruby runtime = context.runtime;
  for ( Map.Entry entry : entrySet() ) {
    final IRubyObject key = JavaUtil.convertJavaToUsableRubyObject(runtime, entry.getKey());
    final IRubyObject val = JavaUtil.convertJavaToUsableRubyObject(runtime, entry.getValue());
    if ( block.yieldArray(context, runtime.newArray(key, val), null).isTrue() ) {
      return runtime.getTrue();
    }
  }
  return runtime.getFalse();
}

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

public void visit(IRubyObject key, IRubyObject value) {
    if (block.yieldArray(context, runtime.newArray(key, value), null, null).isTrue()) {
      result.append(runtime.newArray(key, value));
    }
  }
});

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

private IRubyObject any_p_i_fast(ThreadContext context, Block block) {
  iteratorEntry();
  try {
    for (RubyHashEntry entry = head.nextAdded; entry != head; entry = entry.nextAdded) {
      if (block.yieldArray(context, context.runtime.newArray(entry.key, entry.value), null).isTrue())
        return context.tru;
    }
    return context.fals;
  } finally {
    iteratorExit();
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
    IRubyObject larg = packEnumValues(runtime, largs);
    checkContext(localContext, ctx, "max{}");
    if (result[0] == null || RubyComparable.cmpint(ctx, block.yieldArray(ctx,
                                       runtime.newArray(larg, result[0]), null, null), larg, result[0]) > 0) {
      result[0] = larg;
    }
    return runtime.getNil();
  }
});

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

@Override
protected IRubyObject sortInternal(ThreadContext context, Block block) {
  if (!packed()) return super.sortInternal(context, block);
  IRubyObject ret = block.yieldArray(context, newArray(context.runtime, car, cdr), null);
  //TODO: ary_sort_check should be done here
  int compare = RubyComparable.cmpint(context, ret, car, cdr);
  if (compare > 0) reverse_bang();
  return this;
}

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

@Override
protected IRubyObject sortInternal(ThreadContext context, Block block) {
  if (!packed()) return super.sortInternal(context, block);
  IRubyObject ret = block.yieldArray(context, newArray(context.runtime, car, cdr), null);
  //TODO: ary_sort_check should be done here
  int compare = RubyComparable.cmpint(context, ret, car, cdr);
  if (compare > 0) reverse_bang();
  return this;
}

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

@Override
public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
  IRubyObject argsResult = argsNode.interpret(runtime, context, self, aBlock);
  
  if (expandedArguments) {
    if (argsNode instanceof Splat19Node) argsResult = Helpers.unsplatValue19(argsResult);
    return context.getCurrentFrame().getBlock().yieldArray(context, argsResult, null, null);
  } 
  return context.getCurrentFrame().getBlock().yield(context, argsResult);
}

相关文章