public RubyRegexp loadPattern(Ruby runtime) { // FIXME: 1.9 should care about internal or external encoding and not kcode. if (pattern == null || runtime.getKCode() != pattern.getKCode()) { setPattern(RubyRegexp.newRegexp(runtime, value, options)); } return pattern; }
public final RubyRegexp cacheRegexp(int index, RubyString pattern, int options) { RubyRegexp regexp = regexps[index]; Ruby runtime = pattern.getRuntime(); if (regexp == null || runtime.getKCode() != regexp.getKCode()) { regexp = RubyRegexp.newRegexp(runtime, pattern.getByteList(), options); regexps[index] = regexp; } return regexp; }
public final RubyRegexp getRegexp(Ruby runtime, int index, String pattern, int options) { RubyRegexp regexp = regexps[index]; if (regexp == null || runtime.getKCode() != regexp.getKCode()) { regexp = RubyRegexp.newRegexp(runtime, pattern, options); regexp.setLiteral(); regexps[index] = regexp; } return regexp; }
@Override public IRubyObject each_charInternal(final ThreadContext context, final Block block) { checkReadable(); Ruby runtime = context.runtime; ByteList bytes = data.internal.getByteList(); int len = bytes.getRealSize(); int end = bytes.getBegin() + len; Encoding enc = runtime.is1_9() ? bytes.getEncoding() : runtime.getKCode().getEncoding(); while (data.pos < len) { int pos = (int) data.pos; int n = StringSupport.length(enc, bytes.getUnsafeBytes(), pos, end); if (len < pos + n) n = len - pos; data.pos += n; block.yield(context, data.internal.makeShared19(runtime, pos, n)); } return this; }