hermes-parser 0.4.6 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ * @format
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ import type {HermesNode} from './HermesAST';
14
+ import type {ParserOptions} from './ParserOptions';
15
+
16
+ import HermesParserDeserializer from './HermesParserDeserializer';
17
+ import HermesParserWASM from './HermesParserWASM';
18
+
19
+ const hermesParse = HermesParserWASM.cwrap('hermesParse', 'number', [
20
+ 'number',
21
+ 'number',
22
+ 'number',
23
+ 'number',
24
+ 'number',
25
+ ]);
26
+
27
+ const hermesParseResult_free = HermesParserWASM.cwrap(
28
+ 'hermesParseResult_free',
29
+ 'void',
30
+ ['number'],
31
+ );
32
+
33
+ const hermesParseResult_getError = HermesParserWASM.cwrap(
34
+ 'hermesParseResult_getError',
35
+ 'string',
36
+ ['number'],
37
+ );
38
+
39
+ const hermesParseResult_getErrorLine = HermesParserWASM.cwrap(
40
+ 'hermesParseResult_getErrorLine',
41
+ 'number',
42
+ ['number'],
43
+ );
44
+
45
+ const hermesParseResult_getErrorColumn = HermesParserWASM.cwrap(
46
+ 'hermesParseResult_getErrorColumn',
47
+ 'number',
48
+ ['number'],
49
+ );
50
+
51
+ const hermesParseResult_getProgramBuffer = HermesParserWASM.cwrap(
52
+ 'hermesParseResult_getProgramBuffer',
53
+ 'number',
54
+ ['number'],
55
+ );
56
+
57
+ const hermesParseResult_getPositionBuffer = HermesParserWASM.cwrap(
58
+ 'hermesParseResult_getPositionBuffer',
59
+ 'number',
60
+ ['number'],
61
+ );
62
+
63
+ const hermesParseResult_getPositionBufferSize = HermesParserWASM.cwrap(
64
+ 'hermesParseResult_getPositionBufferSize',
65
+ 'number',
66
+ ['number'],
67
+ );
68
+
69
+ // Copy a string into the WASM heap and null-terminate
70
+ function copyToHeap(buffer, addr) {
71
+ HermesParserWASM.HEAP8.set(buffer, addr);
72
+ HermesParserWASM.HEAP8[addr + buffer.length] = 0;
73
+ }
74
+
75
+ export function parse(source: string, options: ParserOptions): HermesNode {
76
+ // Allocate space on heap for source text
77
+ const sourceBuffer = Buffer.from(source, 'utf8');
78
+ const sourceAddr = HermesParserWASM._malloc(sourceBuffer.length + 1);
79
+ if (!sourceAddr) {
80
+ throw new Error('Parser out of memory');
81
+ }
82
+
83
+ try {
84
+ // Copy source text onto WASM heap
85
+ copyToHeap(sourceBuffer, sourceAddr);
86
+
87
+ const parseResult = hermesParse(
88
+ sourceAddr,
89
+ sourceBuffer.length + 1,
90
+ options.flow === 'detect',
91
+ options.tokens,
92
+ options.allowReturnOutsideFunction,
93
+ );
94
+
95
+ try {
96
+ // Extract and throw error from parse result if parsing failed
97
+ const err = hermesParseResult_getError(parseResult);
98
+ if (err) {
99
+ const syntaxError = new SyntaxError(err);
100
+ // $FlowExpectedError[prop-missing]
101
+ syntaxError.loc = {
102
+ line: hermesParseResult_getErrorLine(parseResult),
103
+ column: hermesParseResult_getErrorColumn(parseResult),
104
+ };
105
+
106
+ throw syntaxError;
107
+ }
108
+
109
+ const deserializer = new HermesParserDeserializer(
110
+ hermesParseResult_getProgramBuffer(parseResult),
111
+ hermesParseResult_getPositionBuffer(parseResult),
112
+ hermesParseResult_getPositionBufferSize(parseResult),
113
+ HermesParserWASM,
114
+ options,
115
+ );
116
+ return deserializer.deserialize();
117
+ } finally {
118
+ hermesParseResult_free(parseResult);
119
+ }
120
+ } finally {
121
+ HermesParserWASM._free(sourceAddr);
122
+ }
123
+ }
@@ -1,9 +1,10 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
+ *
7
8
  * @format
8
9
  */
9
10
  'use strict';
@@ -16,13 +17,19 @@
16
17
  * this is technically invalid UTF-8 that UTF8ToString would convert to 0xfffd.
17
18
  */
18
19
 
19
- function HermesParserDecodeUTF8String(ptr, length, heap) {
20
- var endPtr = ptr + length;
21
- var str = '';
20
+ Object.defineProperty(exports, "__esModule", {
21
+ value: true
22
+ });
23
+ exports.default = HermesParserDecodeUTF8String;
24
+
25
+ function HermesParserDecodeUTF8String(ptrIn, length, heap) {
26
+ let ptr = ptrIn;
27
+ const endPtr = ptr + length;
28
+ let str = '';
22
29
 
23
30
  while (ptr < endPtr) {
24
31
  // ASCII characters fit in single byte code point
25
- var u0 = heap[ptr++];
32
+ let u0 = heap[ptr++];
26
33
 
27
34
  if (!(u0 & 0x80)) {
28
35
  str += String.fromCharCode(u0);
@@ -30,16 +37,16 @@ function HermesParserDecodeUTF8String(ptr, length, heap) {
30
37
  } // Two byte code point
31
38
 
32
39
 
33
- var u1 = heap[ptr++] & 0x3f;
40
+ const u1 = heap[ptr++] & 0x3f;
34
41
 
35
- if ((u0 & 0xe0) == 0xc0) {
42
+ if ((u0 & 0xe0) === 0xc0) {
36
43
  str += String.fromCharCode((u0 & 0x1f) << 6 | u1);
37
44
  continue;
38
45
  }
39
46
 
40
- var u2 = heap[ptr++] & 0x3f;
47
+ const u2 = heap[ptr++] & 0x3f;
41
48
 
42
- if ((u0 & 0xf0) == 0xe0) {
49
+ if ((u0 & 0xf0) === 0xe0) {
43
50
  // Three byte code point
44
51
  u0 = (u0 & 0x0f) << 12 | u1 << 6 | u2;
45
52
  } else {
@@ -58,6 +65,4 @@ function HermesParserDecodeUTF8String(ptr, length, heap) {
58
65
  }
59
66
 
60
67
  return str;
61
- }
62
-
63
- module.exports = HermesParserDecodeUTF8String;
68
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ * @format
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ /**
14
+ * Decode a UTF-8 encoded string from Hermes with a known length.
15
+ * Based on Emscripten's UTF8ToString with the following differences:
16
+ * - Always reads all bytes up to the given length, including null bytes. This
17
+ * means that we can decode strings that contain null bytes in the middle.
18
+ * - Allow UTF-8 encoded code points that are part of a surrogate pair, even though
19
+ * this is technically invalid UTF-8 that UTF8ToString would convert to 0xfffd.
20
+ */
21
+ export default function HermesParserDecodeUTF8String(
22
+ ptrIn: number,
23
+ length: number,
24
+ heap: Uint8Array,
25
+ ): string {
26
+ let ptr = ptrIn;
27
+ const endPtr = ptr + length;
28
+ let str = '';
29
+
30
+ while (ptr < endPtr) {
31
+ // ASCII characters fit in single byte code point
32
+ let u0 = heap[ptr++];
33
+ if (!(u0 & 0x80)) {
34
+ str += String.fromCharCode(u0);
35
+ continue;
36
+ }
37
+
38
+ // Two byte code point
39
+ const u1 = heap[ptr++] & 0x3f;
40
+ if ((u0 & 0xe0) === 0xc0) {
41
+ str += String.fromCharCode(((u0 & 0x1f) << 6) | u1);
42
+ continue;
43
+ }
44
+
45
+ const u2 = heap[ptr++] & 0x3f;
46
+ if ((u0 & 0xf0) === 0xe0) {
47
+ // Three byte code point
48
+ u0 = ((u0 & 0x0f) << 12) | (u1 << 6) | u2;
49
+ } else {
50
+ // Four byte code point
51
+ u0 = ((u0 & 0x07) << 18) | (u1 << 12) | (u2 << 6) | (heap[ptr++] & 0x3f);
52
+ }
53
+
54
+ if (u0 < 0x10000) {
55
+ // Code point fits into a single UTF-16 code unit
56
+ str += String.fromCharCode(u0);
57
+ } else {
58
+ // Code point does not fit into single UTF-16 code unit so convert to surrogate pair
59
+ u0 -= 0x10000;
60
+ str += String.fromCharCode(0xd800 | (u0 >> 10), 0xdc00 | (u0 & 0x3ff));
61
+ }
62
+ }
63
+
64
+ return str;
65
+ }
@@ -1,33 +1,39 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
+ *
7
8
  * @format
8
9
  */
9
10
  'use strict';
10
11
 
11
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
-
13
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14
-
15
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
16
-
17
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
-
19
- var HermesParserDecodeUTF8String = require('./HermesParserDecodeUTF8String');
20
-
21
- var NODE_DESERIALIZERS = require('./HermesParserNodeDeserializers');
22
-
23
- var HermesParserDeserializer = /*#__PURE__*/function () {
24
- function HermesParserDeserializer(programBuffer, positionBuffer, positionBufferSize, wasmParser, options) {
25
- _classCallCheck(this, HermesParserDeserializer);
26
-
27
- _defineProperty(this, "commentTypes", ['CommentLine', 'CommentBlock', 'InterpreterDirective']);
28
-
29
- _defineProperty(this, "tokenTypes", ['Boolean', 'Identifier', 'Keyword', 'Null', 'Numeric', 'Punctuator', 'String', 'RegularExpression', 'Template', 'JSXText']);
30
-
12
+ Object.defineProperty(exports, "__esModule", {
13
+ value: true
14
+ });
15
+ exports.default = void 0;
16
+
17
+ var _HermesParserDecodeUTF8String = _interopRequireDefault(require("./HermesParserDecodeUTF8String"));
18
+
19
+ var _HermesParserNodeDeserializers = _interopRequireDefault(require("./HermesParserNodeDeserializers"));
20
+
21
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
+
23
+ class HermesParserDeserializer {
24
+ // Matches StoredComment::Kind enum in JSLexer.h
25
+ // Matches TokenType enum in HermesParserJSSerializer.h
26
+ constructor(programBuffer, positionBuffer, positionBufferSize, wasmParser, options) {
27
+ this.programBufferIdx = void 0;
28
+ this.positionBufferIdx = void 0;
29
+ this.positionBufferSize = void 0;
30
+ this.locMap = void 0;
31
+ this.HEAPU8 = void 0;
32
+ this.HEAPU32 = void 0;
33
+ this.HEAPF64 = void 0;
34
+ this.options = void 0;
35
+ this.commentTypes = ['CommentLine', 'CommentBlock', 'InterpreterDirective'];
36
+ this.tokenTypes = ['Boolean', 'Identifier', 'Keyword', 'Null', 'Numeric', 'BigInt', 'Punctuator', 'String', 'RegularExpression', 'Template', 'JSXText'];
31
37
  // Program and position buffer are memory addresses, so we must convert
32
38
  // into indices into HEAPU32 (an array of 4-byte integers).
33
39
  this.programBufferIdx = programBuffer / 4;
@@ -44,207 +50,194 @@ var HermesParserDeserializer = /*#__PURE__*/function () {
44
50
  */
45
51
 
46
52
 
47
- _createClass(HermesParserDeserializer, [{
48
- key: "next",
49
- value: function next() {
50
- var num = this.HEAPU32[this.programBufferIdx++];
51
- return num;
52
- }
53
- }, {
54
- key: "deserialize",
55
- value: function deserialize() {
56
- var program = {
57
- type: 'Program',
58
- loc: this.addEmptyLoc(),
59
- body: this.deserializeNodeList(),
60
- comments: this.deserializeComments()
61
- };
62
-
63
- if (this.options.tokens) {
64
- program.tokens = this.deserializeTokens();
65
- }
53
+ next() {
54
+ const num = this.HEAPU32[this.programBufferIdx++];
55
+ return num;
56
+ }
66
57
 
67
- this.fillLocs();
68
- return program;
69
- }
70
- /**
71
- * Booleans are serialized as a single 4-byte integer.
72
- */
73
-
74
- }, {
75
- key: "deserializeBoolean",
76
- value: function deserializeBoolean() {
77
- return Boolean(this.next());
58
+ deserialize() {
59
+ const program = {
60
+ type: 'Program',
61
+ loc: this.addEmptyLoc(),
62
+ body: this.deserializeNodeList(),
63
+ comments: this.deserializeComments()
64
+ };
65
+
66
+ if (this.options.tokens === true) {
67
+ program.tokens = this.deserializeTokens();
78
68
  }
79
- /**
80
- * Numbers are serialized directly into program buffer, taking up 8 bytes
81
- * preceded by 4 bytes of alignment padding if necessary.
82
- */
83
-
84
- }, {
85
- key: "deserializeNumber",
86
- value: function deserializeNumber() {
87
- var floatIdx; // Numbers are aligned on 8-byte boundaries, so skip padding if we are at
88
- // an odd index into the 4-byte aligned program buffer.
89
-
90
- if (this.programBufferIdx % 2 === 0) {
91
- floatIdx = this.programBufferIdx / 2;
92
- this.programBufferIdx += 2;
93
- } else {
94
- floatIdx = (this.programBufferIdx + 1) / 2;
95
- this.programBufferIdx += 3;
96
- }
97
69
 
98
- return this.HEAPF64[floatIdx];
70
+ this.fillLocs();
71
+ return program;
72
+ }
73
+ /**
74
+ * Booleans are serialized as a single 4-byte integer.
75
+ */
76
+
77
+
78
+ deserializeBoolean() {
79
+ return Boolean(this.next());
80
+ }
81
+ /**
82
+ * Numbers are serialized directly into program buffer, taking up 8 bytes
83
+ * preceded by 4 bytes of alignment padding if necessary.
84
+ */
85
+
86
+
87
+ deserializeNumber() {
88
+ let floatIdx; // Numbers are aligned on 8-byte boundaries, so skip padding if we are at
89
+ // an odd index into the 4-byte aligned program buffer.
90
+
91
+ if (this.programBufferIdx % 2 === 0) {
92
+ floatIdx = this.programBufferIdx / 2;
93
+ this.programBufferIdx += 2;
94
+ } else {
95
+ floatIdx = (this.programBufferIdx + 1) / 2;
96
+ this.programBufferIdx += 3;
99
97
  }
100
- /**
101
- * Strings are serialized as a 4-byte pointer into the heap, followed
102
- * by their size as a 4-byte integer. The size is only present if the
103
- * pointer is non-null.
104
- */
105
-
106
- }, {
107
- key: "deserializeString",
108
- value: function deserializeString() {
109
- var ptr = this.next();
110
-
111
- if (ptr === 0) {
112
- return null;
113
- }
114
98
 
115
- var size = this.next();
116
- return HermesParserDecodeUTF8String(ptr, size, this.HEAPU8);
99
+ return this.HEAPF64[floatIdx];
100
+ }
101
+ /**
102
+ * Strings are serialized as a 4-byte pointer into the heap, followed
103
+ * by their size as a 4-byte integer. The size is only present if the
104
+ * pointer is non-null.
105
+ */
106
+
107
+
108
+ deserializeString() {
109
+ const ptr = this.next();
110
+
111
+ if (ptr === 0) {
112
+ return null;
117
113
  }
118
- /**
119
- * Nodes are serialized as a 4-byte integer denoting their node kind,
120
- * followed by a 4-byte loc ID, followed by serialized node properties.
121
- *
122
- * If the node kind is 0 the node is null, otherwise the node kind - 1 is an
123
- * index into the array of node deserialization functions.
124
- */
125
-
126
- }, {
127
- key: "deserializeNode",
128
- value: function deserializeNode() {
129
- var nodeType = this.next();
130
-
131
- if (nodeType === 0) {
132
- return null;
133
- }
134
114
 
135
- var nodeDeserializer = NODE_DESERIALIZERS[nodeType - 1].bind(this);
136
- return nodeDeserializer();
115
+ const size = this.next();
116
+ return (0, _HermesParserDecodeUTF8String.default)(ptr, size, this.HEAPU8);
117
+ }
118
+ /**
119
+ * Nodes are serialized as a 4-byte integer denoting their node kind,
120
+ * followed by a 4-byte loc ID, followed by serialized node properties.
121
+ *
122
+ * If the node kind is 0 the node is null, otherwise the node kind - 1 is an
123
+ * index into the array of node deserialization functions.
124
+ */
125
+
126
+
127
+ deserializeNode() {
128
+ const nodeType = this.next();
129
+
130
+ if (nodeType === 0) {
131
+ return null;
137
132
  }
138
- /**
139
- * Node lists are serialized as a 4-byte integer denoting the number of
140
- * elements in the list, followed by the serialized elements.
141
- */
142
-
143
- }, {
144
- key: "deserializeNodeList",
145
- value: function deserializeNodeList() {
146
- var size = this.next();
147
- var nodeList = [];
148
-
149
- for (var i = 0; i < size; i++) {
150
- nodeList.push(this.deserializeNode());
151
- }
152
133
 
153
- return nodeList;
154
- } // Matches StoredComment::Kind enum in JSLexer.h
155
-
156
- }, {
157
- key: "deserializeComments",
158
-
159
- /**
160
- * Comments are serialized as a node list, where each comment is serialized
161
- * as a 4-byte integer denoting comment type, followed by a 4-byte value
162
- * denoting the loc ID, followed by a serialized string for the comment value.
163
- */
164
- value: function deserializeComments() {
165
- var size = this.next();
166
- var comments = [];
167
-
168
- for (var i = 0; i < size; i++) {
169
- var commentType = this.commentTypes[this.next()];
170
- var loc = this.addEmptyLoc();
171
- var value = this.deserializeString();
172
- comments.push({
173
- type: commentType,
174
- loc: loc,
175
- value: value
176
- });
177
- }
134
+ const nodeDeserializer = _HermesParserNodeDeserializers.default[nodeType - 1].bind(this);
135
+
136
+ return nodeDeserializer();
137
+ }
138
+ /**
139
+ * Node lists are serialized as a 4-byte integer denoting the number of
140
+ * elements in the list, followed by the serialized elements.
141
+ */
142
+
178
143
 
179
- return comments;
144
+ deserializeNodeList() {
145
+ const size = this.next();
146
+ const nodeList = [];
147
+
148
+ for (let i = 0; i < size; i++) {
149
+ nodeList.push(this.deserializeNode());
180
150
  }
181
- }, {
182
- key: "deserializeTokens",
183
- value: function deserializeTokens() {
184
- var size = this.next();
185
- var tokens = [];
186
-
187
- for (var i = 0; i < size; i++) {
188
- var tokenType = this.tokenTypes[this.next()];
189
- var loc = this.addEmptyLoc();
190
- var value = this.deserializeString();
191
- tokens.push({
192
- type: tokenType,
193
- loc: loc,
194
- value: value
195
- });
196
- }
197
151
 
198
- return tokens;
152
+ return nodeList;
153
+ }
154
+ /**
155
+ * Comments are serialized as a node list, where each comment is serialized
156
+ * as a 4-byte integer denoting comment type, followed by a 4-byte value
157
+ * denoting the loc ID, followed by a serialized string for the comment value.
158
+ */
159
+
160
+
161
+ deserializeComments() {
162
+ const size = this.next();
163
+ const comments = [];
164
+
165
+ for (let i = 0; i < size; i++) {
166
+ const commentType = this.commentTypes[this.next()];
167
+ const loc = this.addEmptyLoc();
168
+ const value = this.deserializeString();
169
+ comments.push({
170
+ type: commentType,
171
+ loc,
172
+ value
173
+ });
199
174
  }
200
- /**
201
- * While deserializing the AST locations are represented by
202
- * a 4-byte loc ID. This is used to create a map of loc IDs to empty loc
203
- * objects that are filled after the AST has been deserialized.
204
- */
205
-
206
- }, {
207
- key: "addEmptyLoc",
208
- value: function addEmptyLoc() {
209
- var loc = {};
210
- this.locMap[this.next()] = loc;
211
- return loc;
175
+
176
+ return comments;
177
+ }
178
+
179
+ deserializeTokens() {
180
+ const size = this.next();
181
+ const tokens = [];
182
+
183
+ for (let i = 0; i < size; i++) {
184
+ const tokenType = this.tokenTypes[this.next()];
185
+ const loc = this.addEmptyLoc();
186
+ const value = this.deserializeString();
187
+ tokens.push({
188
+ type: tokenType,
189
+ loc,
190
+ value
191
+ });
212
192
  }
213
- /**
214
- * Positions are serialized as a loc ID which denotes which loc it is associated with,
215
- * followed by kind which denotes whether it is a start or end position,
216
- * followed by line, column, and offset (4-bytes each).
217
- */
218
-
219
- }, {
220
- key: "fillLocs",
221
- value: function fillLocs() {
222
- for (var i = 0; i < this.positionBufferSize; i++) {
223
- var locId = this.HEAPU32[this.positionBufferIdx++];
224
- var kind = this.HEAPU32[this.positionBufferIdx++];
225
- var line = this.HEAPU32[this.positionBufferIdx++];
226
- var column = this.HEAPU32[this.positionBufferIdx++];
227
- var offset = this.HEAPU32[this.positionBufferIdx++];
228
- var loc = this.locMap[locId];
229
-
230
- if (kind === 0) {
231
- loc.start = {
232
- line: line,
233
- column: column
234
- };
235
- loc.rangeStart = offset;
236
- } else {
237
- loc.end = {
238
- line: line,
239
- column: column
240
- };
241
- loc.rangeEnd = offset;
242
- }
193
+
194
+ return tokens;
195
+ }
196
+ /**
197
+ * While deserializing the AST locations are represented by
198
+ * a 4-byte loc ID. This is used to create a map of loc IDs to empty loc
199
+ * objects that are filled after the AST has been deserialized.
200
+ */
201
+
202
+
203
+ addEmptyLoc() {
204
+ // $FlowExpectedError
205
+ const loc = {};
206
+ this.locMap[this.next()] = loc;
207
+ return loc;
208
+ }
209
+ /**
210
+ * Positions are serialized as a loc ID which denotes which loc it is associated with,
211
+ * followed by kind which denotes whether it is a start or end position,
212
+ * followed by line, column, and offset (4-bytes each).
213
+ */
214
+
215
+
216
+ fillLocs() {
217
+ for (let i = 0; i < this.positionBufferSize; i++) {
218
+ const locId = this.HEAPU32[this.positionBufferIdx++];
219
+ const kind = this.HEAPU32[this.positionBufferIdx++];
220
+ const line = this.HEAPU32[this.positionBufferIdx++];
221
+ const column = this.HEAPU32[this.positionBufferIdx++];
222
+ const offset = this.HEAPU32[this.positionBufferIdx++];
223
+ const loc = this.locMap[locId];
224
+
225
+ if (kind === 0) {
226
+ loc.start = {
227
+ line,
228
+ column
229
+ };
230
+ loc.rangeStart = offset;
231
+ } else {
232
+ loc.end = {
233
+ line,
234
+ column
235
+ };
236
+ loc.rangeEnd = offset;
243
237
  }
244
238
  }
245
- }]);
239
+ }
246
240
 
247
- return HermesParserDeserializer;
248
- }();
241
+ }
249
242
 
250
- module.exports = HermesParserDeserializer;
243
+ exports.default = HermesParserDeserializer;