state.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _location = require("../util/location");
  7. var _context = require("./context");
  8. var _types = require("./types");
  9. class State {
  10. constructor() {
  11. this.strict = void 0;
  12. this.curLine = void 0;
  13. this.lineStart = void 0;
  14. this.startLoc = void 0;
  15. this.endLoc = void 0;
  16. this.errors = [];
  17. this.potentialArrowAt = -1;
  18. this.noArrowAt = [];
  19. this.noArrowParamsConversionAt = [];
  20. this.maybeInArrowParameters = false;
  21. this.inType = false;
  22. this.noAnonFunctionType = false;
  23. this.hasFlowComment = false;
  24. this.isAmbientContext = false;
  25. this.inAbstractClass = false;
  26. this.inDisallowConditionalTypesContext = false;
  27. this.topicContext = {
  28. maxNumOfResolvableTopics: 0,
  29. maxTopicIndex: null
  30. };
  31. this.soloAwait = false;
  32. this.inFSharpPipelineDirectBody = false;
  33. this.labels = [];
  34. this.comments = [];
  35. this.commentStack = [];
  36. this.pos = 0;
  37. this.type = 137;
  38. this.value = null;
  39. this.start = 0;
  40. this.end = 0;
  41. this.lastTokEndLoc = null;
  42. this.lastTokStartLoc = null;
  43. this.lastTokStart = 0;
  44. this.context = [_context.types.brace];
  45. this.canStartJSXElement = true;
  46. this.containsEsc = false;
  47. this.firstInvalidTemplateEscapePos = null;
  48. this.strictErrors = new Map();
  49. this.tokensLength = 0;
  50. }
  51. init({
  52. strictMode,
  53. sourceType,
  54. startLine,
  55. startColumn
  56. }) {
  57. this.strict = strictMode === false ? false : strictMode === true ? true : sourceType === "module";
  58. this.curLine = startLine;
  59. this.lineStart = -startColumn;
  60. this.startLoc = this.endLoc = new _location.Position(startLine, startColumn, 0);
  61. }
  62. curPosition() {
  63. return new _location.Position(this.curLine, this.pos - this.lineStart, this.pos);
  64. }
  65. clone(skipArrays) {
  66. const state = new State();
  67. const keys = Object.keys(this);
  68. for (let i = 0, length = keys.length; i < length; i++) {
  69. const key = keys[i];
  70. let val = this[key];
  71. if (!skipArrays && Array.isArray(val)) {
  72. val = val.slice();
  73. }
  74. state[key] = val;
  75. }
  76. return state;
  77. }
  78. }
  79. exports.default = State;
  80. //# sourceMappingURL=state.js.map