make SourceLocation fields readonly (#1637)

This commit is contained in:
Kevin Barabash
2018-08-19 10:44:11 -04:00
committed by ylemkimon
parent aee4a86a67
commit ead04e5a29

View File

@@ -6,16 +6,15 @@ import type {LexerInterface} from "./Token";
* This object is immutable.
*/
export default class SourceLocation {
lexer: LexerInterface; // Lexer holding the input string.
start: number; // Start offset, zero-based inclusive.
end: number; // End offset, zero-based exclusive.
// The + prefix indicates that these fields aren't writeable
+lexer: LexerInterface; // Lexer holding the input string.
+start: number; // Start offset, zero-based inclusive.
+end: number; // End offset, zero-based exclusive.
constructor(lexer: LexerInterface, start: number, end: number) {
this.lexer = lexer;
this.start = start;
this.end = end;
// $FlowFixMe, do not polyfill
Object["freeze"](this); // Immutable to allow sharing in range().
}
/**