1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-10 20:43:05 +00:00

Sourcemapping uses line, column instead of offsets.

This should be friendlier to most users. It does, however, mean
we lose range information. However, range information could be
recovered by re-parsing, as janet's grammar is simple enough to do this.
This commit is contained in:
Calvin Rose
2019-09-22 17:18:28 -05:00
parent 228d045a06
commit a8afc5b81f
13 changed files with 177 additions and 164 deletions

View File

@@ -258,9 +258,9 @@ static void marshal_one_def(MarshalState *st, JanetFuncDef *def, int flags) {
int32_t current = 0;
for (int32_t i = 0; i < def->bytecode_length; i++) {
JanetSourceMapping map = def->sourcemap[i];
pushint(st, map.start - current);
pushint(st, map.end - map.start);
current = map.end;
pushint(st, map.line - current);
pushint(st, map.column);
current = map.line;
}
}
}
@@ -827,9 +827,8 @@ static const uint8_t *unmarshal_one_def(
}
for (int32_t i = 0; i < bytecode_length; i++) {
current += readint(st, &data);
def->sourcemap[i].start = current;
current += readint(st, &data);
def->sourcemap[i].end = current;
def->sourcemap[i].line = current;
def->sourcemap[i].column = readint(st, &data);
}
} else {
def->sourcemap = NULL;