1 |
|
2 |
|
3 | "use strict";
|
4 |
|
5 | var _classCallCheck = require("babel-runtime/helpers/class-call-check")["default"];
|
6 |
|
7 | exports.__esModule = true;
|
8 |
|
9 | var _utilLocation = require("../util/location");
|
10 |
|
11 | var _context = require("./context");
|
12 |
|
13 | var _types = require("./types");
|
14 |
|
15 |
|
16 |
|
17 | var State = (function () {
|
18 | function State() {
|
19 | _classCallCheck(this, State);
|
20 | }
|
21 |
|
22 | State.prototype.init = function init(options /*: Object*/, input /*: string*/) {
|
23 | this.strict = options.strictMode === false ? false : options.sourceType === "module";
|
24 |
|
25 | this.input = input;
|
26 |
|
27 | this.potentialArrowAt = -1;
|
28 |
|
29 | this.inMethod = this.inFunction = this.inGenerator = this.inAsync = false;
|
30 |
|
31 | this.labels = [];
|
32 |
|
33 | this.decorators = [];
|
34 |
|
35 | this.tokens = [];
|
36 |
|
37 | this.comments = [];
|
38 |
|
39 | this.trailingComments = [];
|
40 | this.leadingComments = [];
|
41 | this.commentStack = [];
|
42 |
|
43 | this.pos = this.lineStart = 0;
|
44 | this.curLine = 1;
|
45 |
|
46 | this.type = _types.types.eof;
|
47 | this.value = null;
|
48 | this.start = this.end = this.pos;
|
49 | this.startLoc = this.endLoc = this.curPosition();
|
50 |
|
51 | this.lastTokEndLoc = this.lastTokStartLoc = null;
|
52 | this.lastTokStart = this.lastTokEnd = this.pos;
|
53 |
|
54 | this.context = [_context.types.b_stat];
|
55 | this.exprAllowed = true;
|
56 |
|
57 | this.containsEsc = this.containsOctal = false;
|
58 | this.octalPosition = null;
|
59 |
|
60 | return this;
|
61 | };
|
62 |
|
63 |
|
64 |
|
65 | State.prototype.curPosition = function curPosition() {
|
66 | return new _utilLocation.Position(this.curLine, this.pos - this.lineStart);
|
67 | };
|
68 |
|
69 | State.prototype.clone = function clone(skipArrays /*:: ?*/) {
|
70 | var state = new State();
|
71 | for (var key in this) {
|
72 | var val = this[key];
|
73 |
|
74 | if ((!skipArrays || key === "context") && Array.isArray(val)) {
|
75 | val = val.slice();
|
76 | }
|
77 |
|
78 | state[key] = val;
|
79 | }
|
80 | return state;
|
81 | };
|
82 |
|
83 | return State;
|
84 | })();
|
85 |
|
86 | exports["default"] = State;
|
87 | module.exports = exports["default"];
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
\ | No newline at end of file |