mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-17 00:41:32 +00:00
Wire assertions to global abort, see #8
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user