0
0
mirror of https://github.com/Doodle3D/Doodle3D-API synced 2024-06-02 21:54:33 +02:00
Doodle3D-API/jspm_packages/npm/babel-core@5.6.20/lib/babel/generation/position.js
2015-07-15 15:06:18 +02:00

62 lines
1.4 KiB
JavaScript

/* */
"format cjs";
"use strict";
var _toolsProtectJs2 = require("./../tools/protect.js");
var _toolsProtectJs3 = _interopRequireDefault(_toolsProtectJs2);
exports.__esModule = true;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
_toolsProtectJs3["default"](module);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/**
* Track current position in code generation.
*/
var Position = (function () {
function Position() {
_classCallCheck(this, Position);
this.line = 1;
this.column = 0;
}
/**
* Push a string to the current position, mantaining the current line and column.
*/
Position.prototype.push = function push(str) {
for (var 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.
*/
Position.prototype.unshift = function unshift(str) {
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line--;
} else {
this.column--;
}
}
};
return Position;
})();
exports["default"] = Position;
module.exports = exports["default"];