private int subpatSetCheck(Ruby runtime, int nth, Region regs) { int numRegs = regs == null ? 1 : regs.numRegs; if (nth < numRegs) { if (nth < 0) { if (-nth < numRegs) return nth + numRegs; } else { return nth; } } throw runtime.newIndexError("index " + nth + " out of regexp"); }
private int subpatSetCheck(Ruby runtime, int nth, Region regs) { int numRegs = regs == null ? 1 : regs.numRegs; if (nth < numRegs) { if (nth < 0) { if (-nth < numRegs) return nth + numRegs; } else { return nth; } } throw runtime.newIndexError("index " + nth + " out of regexp"); }
public static final void checkBounds(Ruby runtime, long size, long off, long len) { if ((off | len | (off + len) | (size - (off + len))) < 0) { throw runtime.newIndexError("Memory access offset=" + off + " size=" + len + " is out of bounds"); } }
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]; }
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]; }
final IRubyObject aref(int idx) { int newIdx = idx < 0 ? values.length + idx : idx; if (newIdx < 0) { throw getRuntime().newIndexError("offset " + idx + " too small for struct(size:" + values.length + ")"); } if (newIdx >= values.length) { throw getRuntime().newIndexError("offset " + idx + " too large for struct(size:" + values.length + ")"); } return values[newIdx]; }
private IRubyObject aset(int idx, IRubyObject value) { int newIdx = idx < 0 ? values.length + idx : idx; if (newIdx < 0) { throw getRuntime().newIndexError("offset " + idx + " too small for struct(size:" + values.length + ")"); } else if (newIdx >= values.length) { throw getRuntime().newIndexError("offset " + idx + " too large for struct(size:" + values.length + ")"); } modify(); return values[newIdx] = value; }
private IRubyObject aset(int idx, IRubyObject value) { int newIdx = idx < 0 ? values.length + idx : idx; if (newIdx < 0) { throw getRuntime().newIndexError("offset " + idx + " too small for struct(size:" + values.length + ")"); } else if (newIdx >= values.length) { throw getRuntime().newIndexError("offset " + idx + " too large for struct(size:" + values.length + ")"); } modify(); return values[newIdx] = value; }
private void insert(long pos, IRubyObject val) { if (pos == -1) pos = realLength; else if (pos < 0) { long minpos = -realLength - 1; if (pos < minpos) { throw getRuntime().newIndexError("index " + pos + " too small for array; minimum: " + minpos); } pos++; } spliceOne(pos, val); // rb_ary_new4 }
@JRubyMethod(name = "[]") public final IRubyObject aref(ThreadContext context, IRubyObject indexArg) { final int index = RubyNumeric.num2int(indexArg); final int offset = index * typeSize; if (offset >= size) { throw context.runtime.newIndexError(String.format("Index %d out of range", index)); } return slice(context.runtime, offset); }
@JRubyMethod(name = "[]") public final IRubyObject aref(ThreadContext context, IRubyObject indexArg) { final int index = RubyNumeric.num2int(indexArg); final int offset = index * typeSize; if (offset >= size) { throw context.runtime.newIndexError(String.format("Index %d out of range", index)); } return slice(context.runtime, offset); }
@JRubyMethod(name = "[]") public final IRubyObject aref(ThreadContext context, IRubyObject indexArg) { final int index = RubyNumeric.num2int(indexArg); final int offset = index * typeSize; if (offset >= size) { throw context.runtime.newIndexError(String.format("Index %d out of range", index)); } return slice(context.runtime, offset); }
public int getNameToBackrefNumber(String name) { try { byte[] bytes = name.getBytes(); return getPattern().nameToBackrefNumber(bytes, 0, bytes.length, regs); } catch (JOniException je) { throw getRuntime().newIndexError(je.getMessage()); } }
public int getNameToBackrefNumber(String name) { try { byte[] bytes = name.getBytes(); return getPattern().nameToBackrefNumber(bytes, 0, bytes.length, regs); } catch (JOniException je) { throw getRuntime().newIndexError(je.getMessage()); } }
private static int nameToBackrefNumber(Ruby runtime, Regex pattern, Region regs, ByteListHolder str) { if (pattern == null) { throw runtime.newIndexError("undefined group name reference: " + str); } ByteList value = str.getByteList(); try { return pattern.nameToBackrefNumber(value.getUnsafeBytes(), value.getBegin(), value.getBegin() + value.getRealSize(), regs); } catch (JOniException je) { throw runtime.newIndexError(je.getMessage()); } }
private static int nameToBackrefNumber(Ruby runtime, Regex pattern, Region regs, ByteListHolder str) { if (pattern == null) { throw runtime.newIndexError("undefined group name reference: " + str); } ByteList value = str.getByteList(); try { return pattern.nameToBackrefNumber(value.getUnsafeBytes(), value.getBegin(), value.getBegin() + value.getRealSize(), regs); } catch (JOniException je) { throw runtime.newIndexError(je.getMessage()); } }
private long getOffset(int index) { if (index < 0 || (index >= arrayType.length() && arrayType.length() > 0)) { throw getRuntime().newIndexError("index " + index + " out of bounds"); } return index * (long) arrayType.getComponentType().getNativeSize(); }
private final long getOffset(int index) { if (index < 0 || (index >= arrayType.length() && arrayType.length() > 0)) { throw getRuntime().newIndexError("index " + index + " out of bounds"); } return (long) (index * arrayType.getComponentType().getNativeSize()); }
private final long getOffset(int index) { if (index < 0 || (index >= arrayType.length() && arrayType.length() > 0)) { throw getRuntime().newIndexError("index " + index + " out of bounds"); } return (long) (index * arrayType.getComponentType().getNativeSize()); }
private int nameToBackrefNumber(RubyString str) { ByteList value = str.getByteList(); try { return pattern.nameToBackrefNumber(value.getUnsafeBytes(), value.getBegin(), value.getBegin() + value.getRealSize(), regs); } catch (JOniException je) { throw getRuntime().newIndexError(je.getMessage()); } }