UNPKG

babel-core

Version:

A compiler for writing next generation JavaScript

60 lines (45 loc) 1.37 kB
"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"];