public void write(OutputStream output) throws IOException { DebugInformationWriter writer = new DebugInformationWriter(new DataOutputStream(output)); writer.write(this); }
private void writeNumber(int number) throws IOException { writeUnsignedNumber(convertToSigned(number)); }
private void writeVariableMappings(DebugInformation debugInfo) throws IOException { int lastVar = 0; writeUnsignedNumber(nonNullVariableMappings(debugInfo)); for (int i = 0; i < debugInfo.variableMappings.length; ++i) { RecordArray mapping = debugInfo.variableMappings[i]; if (mapping == null) { continue; } writeUnsignedNumber(i - lastVar); lastVar = i; writeMultiMapping(mapping); } }
private void writeMapping(RecordArray mapping) throws IOException { writeLinesAndColumns(mapping); writeRle(packValues(mapping)); }
private void writeCallSiteMapping(RecordArray mapping) throws IOException { writeLinesAndColumns(mapping); writeRle(packValues(mapping)); writeRle(packCallSites(mapping)); }
private void writeLinesAndColumns(RecordArray mapping) throws IOException { writeUnsignedNumber(mapping.size()); writeRle(packLines(mapping)); writeRle(packColumns(mapping)); }
private void writeClassMetadata(List<ClassMetadata> classes) throws IOException { for (int i = 0; i < classes.size(); ++i) { ClassMetadata cls = classes.get(i); writeNullableString(cls.jsName); writeUnsignedNumber(cls.parentId != null ? cls.parentId + 1 : 0); writeUnsignedNumber(cls.fieldMap.size()); List<Integer> keys = new ArrayList<>(cls.fieldMap.keySet()); Collections.sort(keys); resetRelativeNumber(); for (int key : keys) { writeRelativeNumber(key); writeUnsignedNumber(cls.fieldMap.get(key)); } } }
private void writeCFG(RecordArray mapping) throws IOException { writeUnsignedNumber(mapping.size()); writeRle(mapping.cut(0)); IntegerArray sizes = new IntegerArray(1); IntegerArray files = new IntegerArray(1); IntegerArray lines = new IntegerArray(1); int lastFile = 0; int lastLine = 0; for (int i = 0; i < mapping.size(); ++i) { int type = mapping.get(i).get(0); if (type == 0) { continue; } int[] data = mapping.get(i).getArray(0); sizes.add(data.length / 2); for (int j = 0; j < data.length; j += 2) { int file = data[j]; int line = data[j + 1]; files.add(convertToSigned(file - lastFile)); lines.add(convertToSigned(line - lastLine)); lastFile = file; lastLine = line; } } writeRle(sizes.getAll()); writeRle(files.getAll()); writeRle(lines.getAll()); }
private void writeClassMetadata(List<ClassMetadata> classes) throws IOException { for (int i = 0; i < classes.size(); ++i) { ClassMetadata cls = classes.get(i); writeUnsignedNumber(cls.parentId != null ? cls.parentId + 1 : 0); writeUnsignedNumber(cls.fieldMap.size()); List<Integer> keys = new ArrayList<>(cls.fieldMap.keySet()); Collections.sort(keys); resetRelativeNumber(); for (int key : keys) { writeRelativeNumber(key); writeUnsignedNumber(cls.fieldMap.get(key)); } } }
private int[] packValues(RecordArray mapping) { int[] values = mapping.cut(2); int last = 0; for (int i = 0; i < values.length; ++i) { int value = values[i]; if (value == -1) { values[i] = 0; } else { values[i] = 1 + convertToSigned(value - last); last = value; } } return values; }
private void writeCFGs(DebugInformation debugInfo) throws IOException { for (int i = 0; i < debugInfo.controlFlowGraphs.length; ++i) { writeCFG(debugInfo.controlFlowGraphs[i]); } }
private void writeLinesAndColumns(RecordArray mapping) throws IOException { writeUnsignedNumber(mapping.size()); writeRle(packLines(mapping)); writeRle(packColumns(mapping)); }
private void writeCallSiteMapping(RecordArray mapping) throws IOException { writeLinesAndColumns(mapping); writeRle(packValues(mapping)); writeRle(packCallSites(mapping)); }
private void writeMapping(RecordArray mapping) throws IOException { writeLinesAndColumns(mapping); writeRle(packValues(mapping)); }
private void writeCFG(RecordArray mapping) throws IOException { writeUnsignedNumber(mapping.size()); writeRle(mapping.cut(0)); IntegerArray sizes = new IntegerArray(1); IntegerArray files = new IntegerArray(1); IntegerArray lines = new IntegerArray(1); int lastFile = 0; int lastLine = 0; for (int i = 0; i < mapping.size(); ++i) { int type = mapping.get(i).get(0); if (type == 0) { continue; } int[] data = mapping.get(i).getArray(0); sizes.add(data.length / 2); for (int j = 0; j < data.length; j += 2) { int file = data[j]; int line = data[j + 1]; files.add(convertToSigned(file - lastFile)); lines.add(convertToSigned(line - lastLine)); lastFile = file; lastLine = line; } } writeRle(sizes.getAll()); writeRle(files.getAll()); writeRle(lines.getAll()); }
private int[] packCallSites(RecordArray mapping) { int[] callSites = mapping.cut(3); int last = 0; int j = 0; for (int i = 0; i < callSites.length; ++i) { int type = mapping.get(i).get(2); if (type != 0) { int callSite = callSites[i]; callSites[j++] = convertToSigned(callSite - last); last = callSite; } } return Arrays.copyOf(callSites, j); }
private void writeCFGs(DebugInformation debugInfo) throws IOException { for (int i = 0; i < debugInfo.controlFlowGraphs.length; ++i) { writeCFG(debugInfo.controlFlowGraphs[i]); } }
private void writeVariableMappings(DebugInformation debugInfo) throws IOException { int lastVar = 0; writeUnsignedNumber(nonNullVariableMappings(debugInfo)); for (int i = 0; i < debugInfo.variableMappings.length; ++i) { RecordArray mapping = debugInfo.variableMappings[i]; if (mapping == null) { continue; } writeUnsignedNumber(i - lastVar); lastVar = i; writeMultiMapping(mapping); } }
public void write(OutputStream output) throws IOException { DebugInformationWriter writer = new DebugInformationWriter(new DataOutputStream(output)); writer.write(this); }
private void writeNumber(int number) throws IOException { writeUnsignedNumber(convertToSigned(number)); }