private int nextValue() { return Base64VLQ.decode(content); } }
/** * Writes a VLQ encoded value to the provide appendable. * @throws IOException */ public static void encode(Appendable out, int value) throws IOException { value = toVLQSigned(value); do { int digit = value & VLQ_BASE_MASK; value >>>= VLQ_BASE_SHIFT; if (value > 0) { digit |= VLQ_CONTINUATION_BIT; } out.append(Base64.toBase64(digit)); } while (value > 0); }
/** * Decodes the next VLQValue from the provided CharIterator. */ public static int decode(CharIterator in) { int result = 0; boolean continuation; int shift = 0; do { char c = in.next(); int digit = Base64.fromBase64(c); continuation = (digit & VLQ_CONTINUATION_BIT) != 0; digit &= VLQ_BASE_MASK; result = result + (digit << shift); shift = shift + VLQ_BASE_SHIFT; } while (continuation); return fromVLQSigned(result); } }
/** * Writes an entry for the given column (of the generated text) and * associated mapping. * The values are stored as relative to the last seen values for each * field and encoded as Base64VLQs. */ void writeEntry(Mapping m, int column) throws IOException { // The relative generated column number Base64VLQ.encode(out, column - previousColumn); previousColumn = column; if (m != null) { // The relative source file id int sourceId = getSourceId(m.sourceFile); Base64VLQ.encode(out, sourceId - previousSourceFileId); previousSourceFileId = sourceId; // The relative source file line and column int srcline = m.originalPosition.getLine(); int srcColumn = m.originalPosition.getColumn(); Base64VLQ.encode(out, srcline - previousSourceLine); previousSourceLine = srcline; Base64VLQ.encode(out, srcColumn - previousSourceColumn); previousSourceColumn = srcColumn; if (m.originalName != null) { // The relative id for the associated symbol name int nameId = getNameId(m.originalName); Base64VLQ.encode(out, (nameId - previousNameId)); previousNameId = nameId; } } }
/** * Writes a VLQ encoded value to the provide appendable. * @throws IOException */ public static void encode(Appendable out, int value) throws IOException { value = toVLQSigned(value); do { int digit = value & VLQ_BASE_MASK; value >>>= VLQ_BASE_SHIFT; if (value > 0) { digit |= VLQ_CONTINUATION_BIT; } out.append(Base64.toBase64(digit)); } while (value > 0); }
/** * Decodes the next VLQValue from the provided CharIterator. */ public static int decode(CharIterator in) { int result = 0; boolean continuation; int shift = 0; do { char c = in.next(); int digit = Base64.fromBase64(c); continuation = (digit & VLQ_CONTINUATION_BIT) != 0; digit &= VLQ_BASE_MASK; result = result + (digit << shift); shift = shift + VLQ_BASE_SHIFT; } while (continuation); return fromVLQSigned(result); } }
/** * Writes an entry for the given column (of the generated text) and * associated mapping. * The values are stored as relative to the last seen values for each * field and encoded as Base64VLQs. */ void writeEntry(Mapping m, int column) throws IOException { // The relative generated column number Base64VLQ.encode(out, column - previousColumn); previousColumn = column; if (m != null) { // The relative source file id int sourceId = getSourceId(m.sourceFile); Base64VLQ.encode(out, sourceId - previousSourceFileId); previousSourceFileId = sourceId; // The relative source file line and column int srcline = m.originalPosition.getLine(); int srcColumn = m.originalPosition.getColumn(); Base64VLQ.encode(out, srcline - previousSourceLine); previousSourceLine = srcline; Base64VLQ.encode(out, srcColumn - previousSourceColumn); previousSourceColumn = srcColumn; if (m.originalName != null) { // The relative id for the associated symbol name int nameId = getNameId(m.originalName); Base64VLQ.encode(out, (nameId - previousNameId)); previousNameId = nameId; } } }
private int nextValue() { return Base64VLQ.decode(content); } }