Wire assertions to global abort, see #8

This commit is contained in:
dcodeIO
2018-01-27 16:23:00 +01:00
parent de066fc128
commit 5d76ba9437
6 changed files with 161 additions and 66 deletions

View File

@ -293,6 +293,27 @@ export class Range {
get atStart(): Range { return new Range(this.source, this.start, this.start); }
get atEnd(): Range { return new Range(this.source, this.end, this.end); }
get line(): i32 {
var text = this.source.text;
var pos = this.start;
var line = 1;
while (pos-- > 0)
if (text.charCodeAt(pos) == CharCode.LINEFEED)
line++;
return line;
}
get column(): i32 {
var text = this.source.text;
var pos = this.start;
var column = 1;
while (pos-- > 0)
if (text.charCodeAt(pos) == CharCode.LINEFEED)
break;
column++;
return column;
}
toString(): string {
return this.source.text.substring(this.start, this.end);
}