stage2 .debug_line stepping with gdb is working

This commit is contained in:
Andrew Kelley
2020-08-03 21:01:06 -07:00
parent ac10841fa9
commit d624bf8059
4 changed files with 100 additions and 44 deletions

View File

@@ -43,12 +43,19 @@ pub fn findLineColumn(source: []const u8, byte_offset: usize) struct { line: usi
return .{ .line = line, .column = column };
}
pub fn lineDelta(source: []const u8, start: usize, end: usize) usize {
var line: usize = 0;
for (source[start..end]) |byte| switch (byte) {
'\n' => line += 1,
else => continue,
};
pub fn lineDelta(source: []const u8, start: usize, end: usize) isize {
var line: isize = 0;
if (end >= start) {
for (source[start..end]) |byte| switch (byte) {
'\n' => line += 1,
else => continue,
};
} else {
for (source[end..start]) |byte| switch (byte) {
'\n' => line -= 1,
else => continue,
};
}
return line;
}