Ejemplo n.º 1
0
 private IRubyObject offsetCommon(ThreadContext context, int i, boolean is_19) {
   check();
   Ruby runtime = context.getRuntime();
   if (i < 0 || (regs == null ? 1 : regs.numRegs) <= i)
     throw runtime.newIndexError("index " + i + " out of matches");
   int b, e;
   if (regs == null) {
     b = begin;
     e = end;
   } else {
     b = regs.beg[i];
     e = regs.end[i];
   }
   if (b < 0) return runtime.newArray(runtime.getNil(), runtime.getNil());
   if (is_19 && !str.singleByteOptimizable()) {
     updateCharOffset();
     b = charOffsets.beg[i];
     e = charOffsets.end[i];
   }
   return runtime.newArray(RubyFixnum.newFixnum(runtime, b), RubyFixnum.newFixnum(runtime, e));
 }
Ejemplo n.º 2
0
 private int endCommon(Ruby runtime, int i) {
   check();
   if (i < 0 || (regs == null ? 1 : regs.numRegs) <= i)
     throw runtime.newIndexError("index " + i + " out of matches");
   return regs == null ? end : regs.end[i];
 }