line_loc type for v8 perf

This commit is contained in:
Alistair Braidwood 2012-12-21 08:29:44 +00:00 committed by Marijn Haverbeke
parent c8eb50fabe
commit 3d0f85d616

View File

@ -394,13 +394,18 @@
return match ? match.index + match[0].length : input.length + 1; return match ? match.index + match[0].length : input.length + 1;
} }
var line_loc_t = function() {
this.line = tokCurLine;
this.column = tokPos - tokLineStart;
}
function curLineLoc() { function curLineLoc() {
while (tokLineStartNext <= tokPos) { while (tokLineStartNext <= tokPos) {
++tokCurLine; ++tokCurLine;
tokLineStart = tokLineStartNext; tokLineStart = tokLineStartNext;
tokLineStartNext = nextLineStart(); tokLineStartNext = nextLineStart();
} }
return {line: tokCurLine, column: tokPos - tokLineStart}; return new line_loc_t();
} }
// Reset the token state. Used at the start of a parse. // Reset the token state. Used at the start of a parse.
@ -920,7 +925,7 @@
} }
if (options.locations) { if (options.locations) {
node.loc = new node_loc_t(); node.loc = new node_loc_t();
node.loc.start = other.loc.start;//{start: other.loc.start, end: null, source: other.loc.source}; node.loc.start = other.loc.start;
} }
if (options.ranges) if (options.ranges)
node.range = [other.range[0], 0]; node.range = [other.range[0], 0];