public CodeRangeBuffer clone() { return new CodeRangeBuffer(this); }
void addAllMultiByteRange(ScanEnvironment env) { mbuf = CodeRangeBuffer.addAllMultiByteRange(env, mbuf); }
public static CodeRangeBuffer addCodeRange(CodeRangeBuffer pbuf, ScanEnvironment env, int from, int to) { return addCodeRange(pbuf, env, from, to, true); }
protected static CodeRangeBuffer setAllMultiByteRange(ScanEnvironment env, CodeRangeBuffer pbuf) { return addCodeRangeToBuff(pbuf, env, mbcodeStartPosition(env.enc), LAST_CODE_POINT); }
public static CodeRangeBuffer notCodeRangeBuff(ScanEnvironment env, CodeRangeBuffer bbuf) { CodeRangeBuffer pbuf = null; if (bbuf == null) return setAllMultiByteRange(env, pbuf); int[]p = bbuf.p; int n = p[0]; if (n <= 0) return setAllMultiByteRange(env, pbuf); int pre = mbcodeStartPosition(env.enc); int from; int to = 0; for (int i=0; i<n; i++) { from = p[i * 2 + 1]; to = p[i * 2 + 2]; if (pre <= from - 1) { pbuf = addCodeRangeToBuff(pbuf, env, pre, from - 1); } if (to == LAST_CODE_POINT) break; pre = to + 1; } if (to < LAST_CODE_POINT) pbuf = addCodeRangeToBuff(pbuf, env, to + 1, LAST_CODE_POINT); return pbuf; }
if (not1 && bbuf2 != null) return bbuf2.clone(); /* not1 != 0 -> not2 == 0 */ return null; } else if (bbuf2 == null) { if (not2) return bbuf1.clone(); return null; int from = from1 > from2 ? from1 : from2; int to = to1 < to2 ? to1 : to2; pbuf = addCodeRangeToBuff(pbuf, env, from, to); int from1 = p1[i * 2 + 1]; int to1 = p1[i * 2 + 2]; pbuf = andCodeRange1(pbuf, env, from1, to1, p2, n2);
pbuf = CodeRangeBuffer.orCodeRangeBuff(env, buf1, false, buf2, false); } else { pbuf = CodeRangeBuffer.andCodeRangeBuff(buf1, not1, buf2, not2, env); pbuf = CodeRangeBuffer.notCodeRangeBuff(env, pbuf);
return setAllMultiByteRange(env, pbuf); return setAllMultiByteRange(env, pbuf); } else { if (!not2) { return bbuf2.clone(); } else { return notCodeRangeBuff(env, bbuf2); pbuf = bbuf2.clone(); } else if (!not1) { /* 1 OR (not 2) */ pbuf = notCodeRangeBuff(env, bbuf2); int from = p1[i * 2 + 1]; int to = p1[i * 2 + 2]; pbuf = addCodeRangeToBuff(pbuf, env, from, to);
if (pbuf == null) pbuf = new CodeRangeBuffer(); // move to CClassNode if (high < n) { int size = (n - high) * 2; pbuf.moveRight(fromPos, toPos, size); pbuf.moveLeftAndReduce(fromPos, toPos); pbuf.writeCodePoint(pos, from); pbuf.writeCodePoint(pos + 1, to); n += incN; pbuf.writeCodePoint(0, n);
cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_Control), true, false, env, this); if (enc.minLength() > 1) { CodeRangeBuffer buff = new CodeRangeBuffer(); buff = CodeRangeBuffer.addCodeRange(buff, env, 0x0a, 0x0a); buff = CodeRangeBuffer.addCodeRange(buff, env, 0x0d, 0x0d); cc.mbuf = CodeRangeBuffer.andCodeRangeBuff(cc.mbuf, false, buff, true, env); } else { cc.bs.clear(0x0a);
public static CodeRangeBuffer addCodeRangeToBuff(CodeRangeBuffer pbuf, ScanEnvironment env, int from, int to) { return addCodeRangeToBuff(pbuf, env, from, to, true); }
private void addMultiByteCClass(CodeRangeBuffer mbuf) { addLength(mbuf.getUsed()); addInts(mbuf.getCodeRange(), mbuf.getUsed()); }
public void writeCodePoint(int pos, int b) { int u = pos + 1; if (p.length < u) expand(u); p[pos] = b; if (used < u) used = u; }
public int isOneChar() { if (isNot()) return -1; int c = -1; if (mbuf != null) { int[]range = mbuf.getCodeRange(); c = range[1]; if (range[0] == 1 && c == range[2]) { if (c < BitSet.SINGLE_BYTE_SIZE && bs.at(c)) { c = -1; } } else { return -1; } } for (int i = 0; i < BitSet.BITSET_SIZE; i++) { int b1 = bs.bits[i]; if (b1 != 0) { if ((b1 & (b1 - 1)) == 0 && c == -1) { c = BitSet.BITS_IN_ROOM * i + Integer.bitCount(b1 - 1); } else { return -1; } } } return c; }
private int compileLengthCClassNode(CClassNode cc) { int len; if (cc.mbuf == null) { len = OPSize.OPCODE + BitSet.BITSET_SIZE; } else { if (enc.minLength() > 1 || cc.bs.isEmpty()) { len = OPSize.OPCODE; } else { len = OPSize.OPCODE + BitSet.BITSET_SIZE; } len += OPSize.LENGTH + cc.mbuf.getUsed(); } return len; }
CodeRangeBuffer pbuf = null; if (not1 && not2) { pbuf = CodeRangeBuffer.andCodeRangeBuff(buf1, false, buf2, false, env); } else { pbuf = CodeRangeBuffer.orCodeRangeBuff(env, buf1, not1, buf2, not2); if (not1) { pbuf = CodeRangeBuffer.notCodeRangeBuff(env, pbuf);
return setAllMultiByteRange(env, pbuf); return setAllMultiByteRange(env, pbuf); } else { if (!not2) { return bbuf2.clone(); } else { return notCodeRangeBuff(env, bbuf2); pbuf = bbuf2.clone(); } else if (!not1) { /* 1 OR (not 2) */ pbuf = notCodeRangeBuff(env, bbuf2); int from = p1[i * 2 + 1]; int to = p1[i * 2 + 2]; pbuf = addCodeRangeToBuff(pbuf, env, from, to);
if (pbuf == null) pbuf = new CodeRangeBuffer(); // move to CClassNode if (high < n) { int size = (n - high) * 2; pbuf.moveRight(fromPos, toPos, size); pbuf.moveLeftAndReduce(fromPos, toPos); pbuf.writeCodePoint(pos, from); pbuf.writeCodePoint(pos + 1, to); n += incN; pbuf.writeCodePoint(0, n);
public static CodeRangeBuffer notCodeRangeBuff(ScanEnvironment env, CodeRangeBuffer bbuf) { CodeRangeBuffer pbuf = null; if (bbuf == null) return setAllMultiByteRange(env, pbuf); int[]p = bbuf.p; int n = p[0]; if (n <= 0) return setAllMultiByteRange(env, pbuf); int pre = mbcodeStartPosition(env.enc); int from; int to = 0; for (int i=0; i<n; i++) { from = p[i * 2 + 1]; to = p[i * 2 + 2]; if (pre <= from - 1) { pbuf = addCodeRangeToBuff(pbuf, env, pre, from - 1); } if (to == LAST_CODE_POINT) break; pre = to + 1; } if (to < LAST_CODE_POINT) pbuf = addCodeRangeToBuff(pbuf, env, to + 1, LAST_CODE_POINT); return pbuf; }
if (not1 && bbuf2 != null) return bbuf2.clone(); /* not1 != 0 -> not2 == 0 */ return null; } else if (bbuf2 == null) { if (not2) return bbuf1.clone(); return null; int from = from1 > from2 ? from1 : from2; int to = to1 < to2 ? to1 : to2; pbuf = addCodeRangeToBuff(pbuf, env, from, to); int from1 = p1[i * 2 + 1]; int to1 = p1[i * 2 + 2]; pbuf = andCodeRange1(pbuf, env, from1, to1, p2, n2);