コード例 #1
0
ファイル: InterpretedBlock.java プロジェクト: arkxu/jruby
  @Override
  public IRubyObject yield(
      ThreadContext context,
      IRubyObject[] args,
      IRubyObject self,
      RubyModule klass,
      Binding binding,
      Block.Type type,
      Block block) {
    if (klass == null) {
      self = prepareSelf(binding);
    }

    Visibility oldVis = binding.getFrame().getVisibility();
    Frame lastFrame = pre(context, klass, binding);
    Ruby runtime = context.runtime;

    try {
      if (!noargblock) {
        IRubyObject[] preppedArgs = RubyProc.prepareArgs(context, type, arity, args);
        RubyArray argArray = context.runtime.newArrayNoCopyLight(preppedArgs);
        IRubyObject value = assigner.convertIfAlreadyArray(runtime, argArray);

        assigner.assignArray(runtime, context, self, value, block);
      }

      // This while loop is for restarting the block call in case a 'redo' fires.
      return evalBlockBody(context, binding, self);
    } catch (JumpException.FlowControlException jump) {
      return Helpers.handleBlockJump(context, jump, type);
    } finally {
      post(context, binding, oldVis, lastFrame);
    }
  }
コード例 #2
0
ファイル: InterpretedBlock.java プロジェクト: arkxu/jruby
  @Override
  public IRubyObject yield(
      ThreadContext context, IRubyObject value, Binding binding, Block.Type type, Block block) {
    IRubyObject self = prepareSelf(binding);
    Visibility oldVis = binding.getFrame().getVisibility();
    Frame lastFrame = pre(context, null, binding);

    try {
      if (!noargblock) {
        assigner.assignArray(
            context.runtime, context, self, assigner.convertToArray(context.runtime, value), block);
      }

      return evalBlockBody(context, binding, self);
    } catch (JumpException.FlowControlException jump) {
      return Helpers.handleBlockJump(context, jump, type);
    } finally {
      post(context, binding, oldVis, lastFrame);
    }
  }