Ejemplo n.º 1
0
    @Specialization
    public Object step(
        VirtualFrame frame, RubyRange.IntegerFixnumRange range, int step, RubyProc block) {
      int count = 0;

      try {
        outer:
        for (int n = range.getBegin(); n < range.getExclusiveEnd(); n += step) {
          while (true) {
            if (CompilerDirectives.inInterpreter()) {
              count++;
            }

            try {
              yield(frame, block, n);
              continue outer;
            } catch (BreakException e) {
              breakProfile.enter();
              return e.getResult();
            } catch (NextException e) {
              nextProfile.enter();
              continue outer;
            } catch (RedoException e) {
              redoProfile.enter();
            }
          }
        }
      } finally {
        if (CompilerDirectives.inInterpreter()) {
          getRootNode().reportLoopCount(count);
        }
      }

      return range;
    }
Ejemplo n.º 2
0
  @Override
  public Object execute(VirtualFrame frame) {
    try {
      return body.execute(frame);
    } catch (BreakException e) {
      breakProfile.enter();

      if (matchingBreakProfile.profile(e.getBreakID() == breakID)) {
        return e.getResult();
      } else {
        throw e;
      }
    }
  }