Daniel Lo Nigro 0076204f80 Fix Flow.
Removed `@flow` annotation from files that don't actually pass Flow check at the moment. These will be added back file by file once the files are properly converted to use Flow.

Closes #3064
2015-11-15 21:30:22 -08:00

45 lines
782 B
JavaScript

/* @flow */
/**
* Track current position in code generation.
*/
export default class Position {
column: number;
line: number;
constructor() {
this.line = 1;
this.column = 0;
}
/**
* Push a string to the current position, mantaining the current line and column.
*/
push(str: string): void {
for (let i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line++;
this.column = 0;
} else {
this.column++;
}
}
}
/**
* Unshift a string from the current position, mantaining the current line and column.
*/
unshift(str: string): void {
for (let i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line--;
} else {
this.column--;
}
}
}
}