Exemplo n.º 1
0
    @Specialization
    public RubyString toS(VirtualFrame frame, RubyRange.ObjectRange range) {
      notDesignedForCompilation();

      // TODO(CS): cast?
      final RubyString begin = (RubyString) toS.call(frame, range.getBegin(), "to_s", null);
      final RubyString end = (RubyString) toS.call(frame, range.getBegin(), "to_s", null);

      return getContext().makeString(begin + (range.doesExcludeEnd() ? "..." : "..") + end);
    }
Exemplo n.º 2
0
    @Specialization
    public boolean include(VirtualFrame frame, RubyRange.ObjectRange range, Object value) {
      notDesignedForCompilation();

      if (callLess.callBoolean(frame, value, "<", null, range.getBegin())) {
        return false;
      }

      if (range.doesExcludeEnd()) {
        if (callGreaterEqual.callBoolean(frame, value, ">=", null, range.getEnd())) {
          return false;
        }
      } else {
        if (callGreater.callBoolean(frame, value, ">", null, range.getEnd())) {
          return false;
        }
      }

      return true;
    }
Exemplo n.º 3
0
    @Specialization
    public boolean equal(VirtualFrame frame, RubyRange.ObjectRange a, RubyRange.ObjectRange b) {
      notDesignedForCompilation();

      return a.doesExcludeEnd() == b.doesExcludeEnd()
          && equal(frame, a.getBegin(), b.getBegin())
          && equal(frame, a.getEnd(), b.getEnd());
    }
Exemplo n.º 4
0
 @Specialization
 public Object last(RubyRange.ObjectRange range) {
   return range.getEnd();
 }
Exemplo n.º 5
0
 @Specialization
 public RubyRange.ObjectRange initialize(
     RubyRange.ObjectRange range, Object begin, Object end, boolean excludeEnd) {
   range.initialize(begin, end, excludeEnd);
   return range;
 }
Exemplo n.º 6
0
 @Specialization
 public Object each(RubyRange.ObjectRange range) {
   return range.getBegin();
 }