Esempio n. 1
0
  @Override
  public IRubyObject interpret(
      Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
    Block block =
        SharedScopeBlock.newInterpretedSharedScopeClosure(
            context, this, context.getCurrentScope(), self);

    try {
      while (true) {
        try {
          String savedFile = context.getFile();
          int savedLine = context.getLine();

          IRubyObject recv = null;
          try {
            recv = iterNode.interpret(runtime, context, self, aBlock);
          } finally {
            context.setFileAndLine(savedFile, savedLine);
          }

          return callAdapter.call(context, self, recv, block);
        } catch (JumpException.RetryJump rj) {
          // do nothing, allow loop to retry
        }
      }
    } catch (JumpException.BreakJump bj) {
      return (IRubyObject) bj.getValue();
    }
  }
Esempio n. 2
0
  @Override
  public Object interpret(
      ThreadContext context,
      DynamicScope dynamicScope,
      IRubyObject self,
      Object[] temp,
      Block block) {
    IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp);
    IRubyObject[] values = prepareArguments(context, self, arguments, dynamicScope, temp);
    Block preparedBlock = prepareBlock(context, self, dynamicScope, temp);

    return callSite.call(context, self, object, values, preparedBlock);
  }