private int[] readRle(int size) throws IOException { int[] array = new int[size]; for (int i = 0; i < size;) { int count = readUnsignedNumber(); boolean repeat = (count & 1) != 0; count >>>= 1; if (!repeat) { while (count-- > 0) { array[i++] = readUnsignedNumber(); } } else { int n = readUnsignedNumber(); while (count-- > 0) { array[i++] = n; } } } return array; }
private RecordArray[] readVariableMappings(int count) throws IOException { RecordArray[] mappings = new RecordArray[count]; int varCount = readUnsignedNumber(); int lastVar = 0; while (varCount-- > 0) { lastVar += readUnsignedNumber(); mappings[lastVar] = readMultiMapping(); } return mappings; }
private String readNullableString() throws IOException { int size = readUnsignedNumber(); return size > 0 ? readStringChars(size - 1) : null; }
private String[] readStrings() throws IOException { String[] array = new String[readUnsignedNumber()]; for (int i = 0; i < array.length; ++i) { array[i] = readString(); } return array; }
private int readNumber() throws IOException { return processSign(readUnsignedNumber()); }
private String readString() throws IOException { return readStringChars(readUnsignedNumber()); }
private List<DebugInformation.ClassMetadata> readClassesMetadata(int count) throws IOException { List<DebugInformation.ClassMetadata> classes = new ArrayList<>(count); for (int i = 0; i < count; ++i) { DebugInformation.ClassMetadata cls = new DebugInformation.ClassMetadata(); classes.add(cls); cls.id = i; cls.jsName = readNullableString(); cls.parentId = readUnsignedNumber() - 1; if (cls.parentId.equals(-1)) { cls.parentId = null; } int entryCount = readUnsignedNumber(); resetRelativeNumber(); for (int j = 0; j < entryCount; ++j) { int key = readRelativeNumber(); int value = readUnsignedNumber(); cls.fieldMap.put(key, value); } } return classes; }
private long[] readExactMethods() throws IOException { long[] result = new long[readUnsignedNumber()]; int lastClass = 0; int lastMethod = 0; for (int i = 0; i < result.length; ++i) { lastClass += readNumber(); lastMethod += readNumber(); result[i] = ((long) lastClass << 32) | lastMethod; } return result; }
private RecordArray readMultiMapping() throws IOException { RecordArrayBuilder builder = readLinesAndColumns(2, 1); for (int i = 0; i < builder.size(); ++i) { int count = readUnsignedNumber(); RecordArrayBuilder.SubArray array = builder.get(i).getArray(0); int last = 0; for (int j = 0; j < count; ++j) { last += readNumber(); array.add(last); } } return builder.build(); }
private RecordArrayBuilder readLinesAndColumns(int fields, int arrays) throws IOException { RecordArrayBuilder builder = new RecordArrayBuilder(fields, arrays); int size = readUnsignedNumber(); for (int i = 0; i < size; ++i) { builder.add(); } int[] lines = extractLines(readRle(builder.size())); int[] columns = extractColumns(readRle(builder.size()), lines); for (int i = 0; i < builder.size(); ++i) { RecordArrayBuilder.Record record = builder.get(i); record.set(0, lines[i]); record.set(1, columns[i]); } return builder; }
private RecordArray readCFG() throws IOException { RecordArrayBuilder builder = new RecordArrayBuilder(1, 1); int size = readUnsignedNumber(); for (int i = 0; i < size; ++i) { builder.add();
private int[] readRle(int size) throws IOException { int[] array = new int[size]; for (int i = 0; i < size;) { int count = readUnsignedNumber(); boolean repeat = (count & 1) != 0; count >>>= 1; if (!repeat) { while (count-- > 0) { array[i++] = readUnsignedNumber(); } } else { int n = readUnsignedNumber(); while (count-- > 0) { array[i++] = n; } } } return array; }
private RecordArray[] readVariableMappings(int count) throws IOException { RecordArray[] mappings = new RecordArray[count]; int varCount = readUnsignedNumber(); int lastVar = 0; while (varCount-- > 0) { lastVar += readUnsignedNumber(); mappings[lastVar] = readMultiMapping(); } return mappings; }
private String readString() throws IOException { byte[] bytes = new byte[readUnsignedNumber()]; int pos = 0; while (pos < bytes.length) { int read = input.read(bytes, pos, bytes.length - pos); if (read == -1) { throw new EOFException(); } pos += read; } return new String(bytes, "UTF-8"); } }
private String[] readStrings() throws IOException { String[] array = new String[readUnsignedNumber()]; for (int i = 0; i < array.length; ++i) { array[i] = readString(); } return array; }
private int readNumber() throws IOException { return processSign(readUnsignedNumber()); }
private List<DebugInformation.ClassMetadata> readClassesMetadata(int count) throws IOException { List<DebugInformation.ClassMetadata> classes = new ArrayList<>(count); for (int i = 0; i < count; ++i) { DebugInformation.ClassMetadata cls = new DebugInformation.ClassMetadata(); classes.add(cls); cls.parentId = readUnsignedNumber() - 1; if (cls.parentId.equals(-1)) { cls.parentId = null; } int entryCount = readUnsignedNumber(); resetRelativeNumber(); for (int j = 0; j < entryCount; ++j) { int key = readRelativeNumber(); int value = readUnsignedNumber(); cls.fieldMap.put(key, value); } } return classes; }
private long[] readExactMethods() throws IOException { long[] result = new long[readUnsignedNumber()]; int lastClass = 0; int lastMethod = 0; for (int i = 0; i < result.length; ++i) { lastClass += readNumber(); lastMethod += readNumber(); result[i] = ((long) lastClass << 32) | lastMethod; } return result; }
private RecordArray readMultiMapping() throws IOException { RecordArrayBuilder builder = readLinesAndColumns(2, 1); for (int i = 0; i < builder.size(); ++i) { int count = readUnsignedNumber(); RecordArrayBuilder.SubArray array = builder.get(i).getArray(0); int last = 0; for (int j = 0; j < count; ++j) { last += readNumber(); array.add(last); } } return builder.build(); }
private RecordArrayBuilder readLinesAndColumns(int fields, int arrays) throws IOException { RecordArrayBuilder builder = new RecordArrayBuilder(fields, arrays); int size = readUnsignedNumber(); for (int i = 0; i < size; ++i) { builder.add(); } int[] lines = extractLines(readRle(builder.size())); int[] columns = extractColumns(readRle(builder.size()), lines); for (int i = 0; i < builder.size(); ++i) { RecordArrayBuilder.Record record = builder.get(i); record.set(0, lines[i]); record.set(1, columns[i]); } return builder; }